首页 > 学院 > 开发设计 > 正文

UBUNTU制作安装包

2019-11-06 08:44:43
字体:
来源:转载
供稿:网友

1.常用的dpkg命令

dpkg -i xxx.deb 安装deb包,若提示错误,可以加参数—force-all强制安装,但不推荐这样做dpkg -r debname 移除deb包dpkg -S filepath 查看某个文件属于哪个deb包dpkg -X xxx.deb dirname 释放安装内容到dirname目录中dpkg -e xxx.deb 释放控制信息到当前目录下的DEBIAN子目录中dpkg -b xxx xxx.deb 将目录xxx打包为xxx.deb

2.使用dpkg制作包

解压一个deb安装包后,发现包含control.tar.gz和data.tar.xz两个包。其实control.tar.gz是压缩DEBIAN文件目录,data.tar.xz则是压缩除DEBIAN文件目录以外的其他目录,且这些目录必须按系统文件的规则进行存放(如/usr/local/bin/mscore)

2.1.DEBIAN文件目录

DEBIAN目录中一般有5个文件:控制文件 描述control 用了记录软件标识,版本号,平台,依赖信息等数据PReinst 在解包data.tar.gz前运行的脚本postinst 在解包数据后运行的脚本prerm 卸载时,在删除文件之前运行的脚本postrm 在删除文件之后运行的脚本其中control, 编码为utf-8, 内容如下所示: Package:mscore Version:1.0.12 Section:gnome Priority:extra Maintainer:su.gao<sugao_cn@163.com> Homepage:http://127.0.0.1/mscore/wikis/home Architecture:amd64 Depends: Description:jsut for test

2.2.其他文件目录

其他目录按文件系统规则存放,安装时将这些文件复制到对应的系统文件目录中,卸载时将这些文件从对应的系统文件目录删除。

2.3.例

在/home目录中创建文件目录mscore_deb; 在/home/mscore_deb目录中创建DEBIAN目录;在/home/mscore_deb/DEBIAN目录中创建control,preinst,postinst,prerm,postrm五个文件,并编辑control文件; 创建/home/mscore_deb/tmp目录;创建/home/mscore_deb/mscorek文件;打deb包: cd /home && dpkg -b mscore_deb mscore_amd64_1.0.12.deb安装deb包:cd /home && dpkg -i mscore_amd64_1.0.12.deb查看deb包信息:dpkg -s mscore

卸载deb包:dpkg -r mscore

3.制作启动图标

在/home/mscore_deb中创建usr/share/applications/mscore.desktop

mscore.desktop内容如下:

mscore.desktop[Desktop Entry]Version=1.0.12Name=mscoreExec=/usr/local/bin/mscoreTerminal=falseIcon=/etc/mscore/mscore_logo.pngType=ApplicationCategories=Application;
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表