launchpad(零)ubuntu下制作最小deb包

1.安装环境

sudo apt update
sudo apt install dh-make
sudo apt install devscripts
sudo apt install build-essential

2.创建一个二级目录

mkdir ~/test/hello-1.0 -p
cd ~/test/hello-1.0

3.创建文件
hello.c 文件内容

//cat hello.c
#include <stdio.h>

int main(void)
{
        printf("%s\n","Hello");
        return 0;
}

Makefile 文件内容

# cat Makefile
hello:hello.o
	gcc -o hello hello.o
hello.o:hello.c
	gcc -o hello.o -c hello.c
.PHONY:rebuild clean
rebuild:clean hello
clean:
	rm -f hello hello.o

4.⽣成debian⽬录

dh_make --createorig -e liruijian@kylinos.cn

5.在debian目录下创建install文件

vi debian/install

install 文件内容

hello /bin

6.编译

debuild

7.查看deb包

ls ..

可以看到编译生成的deb包

cd ..
dpkg -x hello_1.0-1_amd64.deb hello

jian@ubuntu:~/test$ tree hello
hello
├── bin
│   └── hello
└── usr
    └── share
        └── doc
            └── hello
                ├── changelog.Debian.gz
                ├── copyright
                └── README.Debian

5 directories, 4 files

可以看到hello这个程序放在/bin目录下
8.安装deb包

dpkg -i hello_1.0-1_amd64.deb

9.检验

hello

可以看到hello命令可以执行,说明我们编译的hello可执行程序已经安装到/bin目录下了
10.可能出现的错误的处理方法
a.把debian/source/format文件删除
b.没有gpg key,这个不用处理,这个是在需要把整个包推到launchpad外网或者内网才需要的,本机编译即使报这个错误也会成功编译deb包。

11.备注
以上仅仅适用于本地编译,如果需要在launchpad线上编译,需要修改debian目录下的一些文件才可以成功推送到线上编译。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小坚学Linux

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值