方法一: dpkg命令打包
创建一个打包的目录,类似rpmbuild,这里创建了目录deb_build
mkdir deb_build
目标
我有一个hello的二进制文件hello和源码hello.c, 准备安装到/opt/helloworld目录中
步骤
- 在deb_build目录创建一个文件夹用于存放我的安装文件
mkdir helloworld
- 在helloworld文件里创建DEBIAN文件夹和opt文件夹
- 在DEBIAN文件夹创建一个文件control
- 在opt文件夹新建一个helloworld文件夹,存放上hello和hello.c,如下
$ tree helloworld/
helloworld/
├── DEBIAN
│ └── control
└── opt
└── helloworld
├── hello
└── hello.c
3 directories, 3 files
control文件类似rpm的spec文件,包含deb的包信息
只要把想安装的文件写到对应目录就可以安装到对应的系统目录
这里描述一个最简易的control文件
Package: helloworld Description: my deb test Maintainer: username <[email protected]> Version: 0.1 Architecture: all
- 回到deb_build目录,执行
dpkg -b helloworld
即可在当前目录生成deb包
$ dpkg -b helloworld
dpkg-deb: building package 'hello' in 'helloworld.deb'.
也可以指定
dpkg -b hellorld hellorld-0.1-all.deb
$ dpkg -b helloworld helloworld-0.1-all.deb dpkg-deb: building package 'helloworld' in 'helloworld-0.1-all.deb'.
- 安装打好的deb包
$ sudo dpkg -i helloworld-0.1-all.deb
Selecting previously unselected package helloworld.
(Reading database ... 208913 files and directories currently installed.)
Preparing to unpack helloworld-0.1-all.deb ...
Unpacking helloworld (0.1) ...
Setting up helloworld (0.1) ...
此时/opt/helloworld/hello和hello.c 就安装在/opt/helloworld目录下了
检测安装效果
- 查看包安装
$ dpkg -l helloworld
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=======================-================-================-===================================================
ii helloworld 0.1 all my deb test
- 检测/opt/helloworld目录
$ ls /opt/helloworld/
hello hello.c
$ sudo /opt/helloworld/hello
hello world
标签:opt,0.1,helloworld,打包,deb,hello,dpkg
From: https://www.cnblogs.com/ishmaelwanglin/p/17044160.html