简单构建Deb包

有时候将某些脚本或者项目打包成deb可以很方便的进行项目的安装。 项目结构简单如下:

├── app
│   └── dps
├── dps
│   └── DEBIAN
│       └── control
└── Makefile

简单说下结构

app目录:用于存放相关的文件,这里的dps是一个可执行的shell脚本。

#!/bin/bash
docker ps -a

dps/DEBIAN目录,用于存放控制信息,与DEBIAN同级的目录会默认安装到系统的根目录下. control文件

Package:dps
Version:0.0.1
Architecture:amd64
Maintainer:ysicing
Description:docker ps -a

Makefile文件

version = 0.0.1
deb_dir = dps

all: builddir createdeb clean
	echo "ok"

builddir:
	mkdir -p ${deb_dir}/usr/local/bin/
	cp -rf app/* $(deb_dir)/usr/local/bin/

createdeb:
	dpkg-deb -b $(deb_dir) dps_$(version)_amd64.deb

clean:
	rm -rf $(deb_dir)/usr/local/bin/*

在执行make以后会

├── app
│   └── dps
├── dps
│   ├── DEBIAN
│   │   └── control
│   └── usr
│       └── local
│           └── bin
├── dps_0.0.1_amd64.deb
└── Makefile

手动dpkg -i dps_0.0.1_amd64.deb

[email protected]:~/demo# dpkg -l | grep dps
ii  dps                           0.0.1                          amd64        docker ps -a
[email protected]:~/demo# dps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
*****
Written by ysicing on 29 June 2017