英文:
Add postinst script to hello-traditional Debian package
问题
我试图添加到标准:hello-traditional Debian package
我下载并解压缩了它,然后将postinst脚本添加到debian文件夹。
这是一个非常基本的脚本,只是回显一个字符串。
#!/bin/sh
# This `DEBIAN/postinst` script is run post-installation
set -e
echo "Prova..............."
exit 0
我在本地重新构建了软件包:
dpkg-buildpackage -uc -us
或者
debuild -us -uc
但是当我测试它时,postinst脚本没有被调用:我看不到回显的字符串。
编辑
下面是rules文件(实际上是软件包中的原始文件):
#!/usr/bin/make -f
# Sample debian/rules file - for GNU Hello.
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself. (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified
package = hello-traditional
docdir = debian/tmp/usr/share/doc/$(package)
BUILD_DATE := $(shell dpkg-parsechangelog -S Date)
CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall
LDFLAGS := `dpkg-buildflags --get LDFLAGS`
CPPFLAGS := `dpkg-buildflags --get CPPFLAGS`
# ...(其余内容未变)
英文:
I'm trying to add to the standard: hello-traditional Debian package
I downloaded it and unpacked it and I added the postinst script into the debian folder.
It is a very basic script which just echo a string.
#!/bin/sh
# This `DEBIAN/postinst` script is run post-installation
set -e
echo "Prova..............."
exit 0
I rebuild the package locally using:
dpkg-buildpackage -uc -us
or
debuild -us -uc
but when I test it the postinst script is not called: I don't see the echo string.
Any clue?
EDIT
rules file below (which is the orginal one in the package actually)
#!/usr/bin/make -f
# Sample debian/rules file - for GNU Hello.
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself. (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified
package = hello-traditional
docdir = debian/tmp/usr/share/doc/$(package)
BUILD_DATE := $(shell dpkg-parsechangelog -S Date)
CFLAGS := `dpkg-buildflags --get CFLAGS` -Wall
LDFLAGS := `dpkg-buildflags --get LDFLAGS`
CPPFLAGS := `dpkg-buildflags --get CPPFLAGS`
STRIP = true
export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
export AM_UPDATE_INFO_DIR = no
# Recommended snippet for Autoconf 2.52 or later
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
confflags += --build $(DEB_HOST_GNU_TYPE)
stripcmd = strip
else
confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
stripcmd = $(DEB_HOST_GNU_TYPE)-strip
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
STRIP = $(stripcmd) --remove-section=.comment --remove-section=.note
endif
build:
./configure CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
LDFLAGS="$(LDFLAGS)" $(confflags) --prefix=/usr
$(MAKE)
touch build
clean:
rm -f build
[ ! -f Makefile ] || $(MAKE) distclean
rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars
binary-indep: build
# There are no architecture-independent files to be uploaded
# generated by this package. If there were any they would be
# made here.
binary-arch: build
rm -rf debian/tmp
install -d debian/tmp/DEBIAN $(docdir)
$(MAKE) prefix="$$(pwd)/debian/tmp/usr" install
$(STRIP) debian/tmp/usr/bin/hello
cp -a NEWS debian/copyright $(docdir)
cp -a debian/changelog $(docdir)/changelog.Debian
cp -a ChangeLog $(docdir)/changelog
cd $(docdir) && gzip -9n changelog changelog.Debian
gzip -r9n debian/tmp/usr/share/man
gzip -9n debian/tmp/usr/share/info/*
dpkg-shlibdeps debian/tmp/usr/bin/hello
dpkg-gencontrol
cd debian/tmp && \
find * -type f ! -regex "DEBIAN/.*" -print0 |\
LC_ALL=C sort -z | xargs -0r md5sum > DEBIAN/md5sums
chown -R 0:0 debian/tmp
chmod -R u+w,go=rX debian/tmp
find debian/tmp -newermt '$(BUILD_DATE)' -print0 |\
xargs -0r touch -h --date='$(BUILD_DATE)'
dpkg --build debian/tmp ..
binary: binary-indep binary-arch
build-arch: build
build-indep: build
.PHONY: binary binary-arch binary-indep build-arch build-indep clean
答案1
得分: 0
我终于找到了问题所在:postinst 没有复制到 debian/tmp/DEBIAN
文件夹,因此没有导出到软件包中。
目前的解决方法是修改 rules 文件,添加复制命令:
[...]
binary-arch: build
rm -rf debian/tmp
install -d debian/tmp/DEBIAN $(docdir)
$(MAKE) prefix="$$(pwd)/debian/tmp/usr" install
$(STRIP) debian/tmp/usr/bin/hello
cp -a NEWS debian/copyright $(docdir)
cp -a debian/changelog $(docdir)/changelog.Debian
cp -a ChangeLog $(docdir)/changelog
cd $(docdir) && gzip -9n changelog changelog.Debian
gzip -r9n debian/tmp/usr/share/man
gzip -9n debian/tmp/usr/share/info/*
dpkg-shlibdeps debian/tmp/usr/bin/hello
dpkg-gencontrol
cd debian/tmp && \
find * -type f ! -regex "DEBIAN/.*" -print0 |\
LC_ALL=C sort -z | xargs -0r md5sum > DEBIAN/md5sums
cp -a debian/postinst debian/tmp/DEBIAN/ # <---- 复制添加
chown -R 0:0 debian/tmp
chmod -R u+w,go=rX debian/tmp
find debian/tmp -newermt '$(BUILD_DATE)' -print0 |\
xargs -0r touch -h --date='$(BUILD_DATE)';
dpkg --build debian/tmp ..
[...]
英文:
I finally found out the problem: the postinst wasn't copied to debian/tmp/DEBIAN
folder so it was not exported to the package.
The solution, at the moment, is to modify the rules file adding the copy command
[...]
binary-arch: build
rm -rf debian/tmp
install -d debian/tmp/DEBIAN $(docdir)
$(MAKE) prefix="$$(pwd)/debian/tmp/usr" install
$(STRIP) debian/tmp/usr/bin/hello
cp -a NEWS debian/copyright $(docdir)
cp -a debian/changelog $(docdir)/changelog.Debian
cp -a ChangeLog $(docdir)/changelog
cd $(docdir) && gzip -9n changelog changelog.Debian
gzip -r9n debian/tmp/usr/share/man
gzip -9n debian/tmp/usr/share/info/*
dpkg-shlibdeps debian/tmp/usr/bin/hello
dpkg-gencontrol
cd debian/tmp && \
find * -type f ! -regex "DEBIAN/.*" -print0 |\
LC_ALL=C sort -z | xargs -0r md5sum > DEBIAN/md5sums
cp -a debian/postinst debian/tmp/DEBIAN/ # <---- COPY ADDED
chown -R 0:0 debian/tmp
chmod -R u+w,go=rX debian/tmp
find debian/tmp -newermt '$(BUILD_DATE)' -print0 |\
xargs -0r touch -h --date='$(BUILD_DATE)'
dpkg --build debian/tmp ..
[...]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论