闫刚 ubuntu下如何创建deb包

生成debhelloworld-1.0_amd64.deb的软件包

  1. 创建debhelloworld文件
vi debhelloworld.c 
#include <stdio.h>
int main(int argc, char *argv)
{
    printf("hello world\r\n");
    return 0;
}
  1. 编译c文件,生成可执行文件
gcc debhelloworld.c -o debhelloworld_bin 
mkdir debhelloworld
cd debhelloworld
mkdir -p usr/bin/
cp ../debhelloworld_bin usr/bin/debhelloworld

  1. 写1个control文件到debian下
mkdir DEBIAN
vi DEBIAN/control

下面注意,Package的值一定要写成可执行文件的命令

Package: debhelloworld
Version: 1.0
Section: custom
Priority: optional
Architecture: all
Essential: no
Installed-Size: 1024
Maintainer: helloworld.org
Description: Print helloworld.org on the screen
  1. 生成debhelloworld-1.0_amd64.deb文件
dpkg-deb --build debhelloworld
mv debhelloworld.deb debhelloworld-1.0_amd64.deb
  1. 验证debhelloworld-1.0_amd64.deb是否成功
yangang@ubuntu:~/work/tools$ sudo dpkg -i debhelloworld-1.0_amd64.deb
Selecting previously unselected package debhelloworld.
(Reading database ... 244879 files and directories currently installed.)
Preparing to unpack debhelloworld-1.0_amd64.deb ...
Unpacking debhelloworld (1.0) ...
Setting up debhelloworld (1.0) ...
  1. 执行测试
yangang@ubuntu:~/work/tools$ debhelloworld
hello world
  1. 卸载debhelloworld
yangang@ubuntu:~/work/tools$ sudo apt-get remove debhelloworld
[sudo] password for yangang:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  debhelloworld
0 upgraded, 0 newly installed, 1 to remove and 11 not upgraded.
After this operation, 1,049 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 244879 files and directories currently installed.)
Removing debhelloworld (1.0) ...
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值