From 9eaf81f05fe79db2dc3085556412264bd30acdc7 Mon Sep 17 00:00:00 2001 From: Santiago Vila Date: Wed, 17 Apr 2024 12:30:00 +0200 Subject: Rename postinst.in to postinst. Use dh_installdeb token feature instead. --- debian/clean | 1 - debian/postinst | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/postinst.in | 108 ----------------------------------------------------- debian/rules | 4 +- 4 files changed, 111 insertions(+), 110 deletions(-) create mode 100644 debian/postinst delete mode 100644 debian/postinst.in diff --git a/debian/clean b/debian/clean index ccba3ce..e69de29 100644 --- a/debian/clean +++ b/debian/clean @@ -1 +0,0 @@ -debian/postinst diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..0ad4ce3 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,108 @@ +#!/bin/sh +set -e + +ensure_file_owner_mode() { + if [ ! -f "$DPKG_ROOT$1" ]; then + : > "$DPKG_ROOT$1" + fi + chown "$2" "$DPKG_ROOT$1" + chmod "$3" "$DPKG_ROOT$1" +} + +install_local_dir() { + if [ ! -d "$DPKG_ROOT$1" ]; then + mkdir -p "$DPKG_ROOT$1" + fi + if [ -f "$DPKG_ROOT/etc/staff-group-for-usr-local" ]; then + chown root:staff "$DPKG_ROOT$1" 2>/dev/null || true + chmod 2775 "$DPKG_ROOT$1" 2> /dev/null || true + fi +} + +install_from_default() { + if [ ! -f "$DPKG_ROOT$2" ]; then + cp -p "$DPKG_ROOT/usr/share/base-files/$1" "$DPKG_ROOT$2" + fi +} + +install_directory() { + if [ ! -d "$DPKG_ROOT/$1" ]; then + mkdir "$DPKG_ROOT/$1" + chown "root:$3" "$DPKG_ROOT/$1" + chmod "$2" "$DPKG_ROOT/$1" + fi +} + +migrate_directory() { + if [ ! -L "$DPKG_ROOT$1" ]; then + rmdir "$DPKG_ROOT$1" + ln -s "$2" "$DPKG_ROOT$1" + fi +} + +update_to_current_default() { + if [ -f "$2" ]; then + md5=$(md5sum "$2" | cut -f 1 -d " ") + if grep -q "$md5" "/usr/share/base-files/$1.md5sums"; then + if ! cmp -s "/usr/share/base-files/$1" "$2"; then + cp -p "/usr/share/base-files/$1" "$2" + echo Updating $2 to current default. + fi + fi + fi +} + +if [ ! -e "$DPKG_ROOT/etc/dpkg/origins/default" ]; then + if [ -e "$DPKG_ROOT/etc/dpkg/origins/#VENDORFILE#" ]; then + ln -sf #VENDORFILE# "$DPKG_ROOT/etc/dpkg/origins/default" + fi +fi + +if [ "$1" = "configure" ] && [ "$2" = "" ]; then + install_from_default dot.profile /root/.profile + install_from_default dot.bashrc /root/.bashrc + install_from_default profile /etc/profile + install_from_default motd /etc/motd + install_directory mnt 755 root + install_directory srv 755 root + install_directory opt 755 root + install_directory etc/opt 755 root + install_directory var/opt 755 root + install_directory media 755 root + install_directory var/mail 2775 mail + if [ ! -L "$DPKG_ROOT/var/spool/mail" ]; then + ln -s ../mail "$DPKG_ROOT/var/spool/mail" + fi + install_directory run/lock 1777 root + migrate_directory /var/run /run + migrate_directory /var/lock /run/lock + + install_local_dir /usr/local + install_local_dir /usr/local/share + install_local_dir /usr/local/share/man + install_local_dir /usr/local/bin + install_local_dir /usr/local/games + install_local_dir /usr/local/lib + install_local_dir /usr/local/include + install_local_dir /usr/local/sbin + install_local_dir /usr/local/src + install_local_dir /usr/local/etc + ln -sf share/man "$DPKG_ROOT/usr/local/man" + + ensure_file_owner_mode /var/log/wtmp root:utmp 664 + ensure_file_owner_mode /var/log/btmp root:utmp 660 + ensure_file_owner_mode /var/log/lastlog root:utmp 664 +fi + +if [ -d "$DPKG_ROOT/usr/share/info" ] && [ ! -f "$DPKG_ROOT/usr/info/dir" ] && [ ! -f "$DPKG_ROOT/usr/share/info/dir" ]; then + install_from_default info.dir /usr/share/info/dir + chmod 644 $DPKG_ROOT/usr/share/info/dir +fi + +if [ "$1" = "configure" ] && [ "$2" != "" ]; then + update_to_current_default profile /etc/profile + update_to_current_default dot.profile /root/.profile + if dpkg --compare-versions "$2" lt-nl "7.7"; then + install_directory mnt 755 root + fi +fi diff --git a/debian/postinst.in b/debian/postinst.in deleted file mode 100644 index 0ad4ce3..0000000 --- a/debian/postinst.in +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/sh -set -e - -ensure_file_owner_mode() { - if [ ! -f "$DPKG_ROOT$1" ]; then - : > "$DPKG_ROOT$1" - fi - chown "$2" "$DPKG_ROOT$1" - chmod "$3" "$DPKG_ROOT$1" -} - -install_local_dir() { - if [ ! -d "$DPKG_ROOT$1" ]; then - mkdir -p "$DPKG_ROOT$1" - fi - if [ -f "$DPKG_ROOT/etc/staff-group-for-usr-local" ]; then - chown root:staff "$DPKG_ROOT$1" 2>/dev/null || true - chmod 2775 "$DPKG_ROOT$1" 2> /dev/null || true - fi -} - -install_from_default() { - if [ ! -f "$DPKG_ROOT$2" ]; then - cp -p "$DPKG_ROOT/usr/share/base-files/$1" "$DPKG_ROOT$2" - fi -} - -install_directory() { - if [ ! -d "$DPKG_ROOT/$1" ]; then - mkdir "$DPKG_ROOT/$1" - chown "root:$3" "$DPKG_ROOT/$1" - chmod "$2" "$DPKG_ROOT/$1" - fi -} - -migrate_directory() { - if [ ! -L "$DPKG_ROOT$1" ]; then - rmdir "$DPKG_ROOT$1" - ln -s "$2" "$DPKG_ROOT$1" - fi -} - -update_to_current_default() { - if [ -f "$2" ]; then - md5=$(md5sum "$2" | cut -f 1 -d " ") - if grep -q "$md5" "/usr/share/base-files/$1.md5sums"; then - if ! cmp -s "/usr/share/base-files/$1" "$2"; then - cp -p "/usr/share/base-files/$1" "$2" - echo Updating $2 to current default. - fi - fi - fi -} - -if [ ! -e "$DPKG_ROOT/etc/dpkg/origins/default" ]; then - if [ -e "$DPKG_ROOT/etc/dpkg/origins/#VENDORFILE#" ]; then - ln -sf #VENDORFILE# "$DPKG_ROOT/etc/dpkg/origins/default" - fi -fi - -if [ "$1" = "configure" ] && [ "$2" = "" ]; then - install_from_default dot.profile /root/.profile - install_from_default dot.bashrc /root/.bashrc - install_from_default profile /etc/profile - install_from_default motd /etc/motd - install_directory mnt 755 root - install_directory srv 755 root - install_directory opt 755 root - install_directory etc/opt 755 root - install_directory var/opt 755 root - install_directory media 755 root - install_directory var/mail 2775 mail - if [ ! -L "$DPKG_ROOT/var/spool/mail" ]; then - ln -s ../mail "$DPKG_ROOT/var/spool/mail" - fi - install_directory run/lock 1777 root - migrate_directory /var/run /run - migrate_directory /var/lock /run/lock - - install_local_dir /usr/local - install_local_dir /usr/local/share - install_local_dir /usr/local/share/man - install_local_dir /usr/local/bin - install_local_dir /usr/local/games - install_local_dir /usr/local/lib - install_local_dir /usr/local/include - install_local_dir /usr/local/sbin - install_local_dir /usr/local/src - install_local_dir /usr/local/etc - ln -sf share/man "$DPKG_ROOT/usr/local/man" - - ensure_file_owner_mode /var/log/wtmp root:utmp 664 - ensure_file_owner_mode /var/log/btmp root:utmp 660 - ensure_file_owner_mode /var/log/lastlog root:utmp 664 -fi - -if [ -d "$DPKG_ROOT/usr/share/info" ] && [ ! -f "$DPKG_ROOT/usr/info/dir" ] && [ ! -f "$DPKG_ROOT/usr/share/info/dir" ]; then - install_from_default info.dir /usr/share/info/dir - chmod 644 $DPKG_ROOT/usr/share/info/dir -fi - -if [ "$1" = "configure" ] && [ "$2" != "" ]; then - update_to_current_default profile /etc/profile - update_to_current_default dot.profile /root/.profile - if dpkg --compare-versions "$2" lt-nl "7.7"; then - install_directory mnt 755 root - fi -fi diff --git a/debian/rules b/debian/rules index 4c0497b..c7a291d 100755 --- a/debian/rules +++ b/debian/rules @@ -16,7 +16,6 @@ DESTDIR = debian/base-files override_dh_auto_build: sh debian/check-md5sum-etc profile - sed -e "s/#VENDORFILE#/$(VENDORFILE)/g" debian/postinst.in > debian/postinst override_dh_auto_install: install -p -m 644 etc/* $(DESTDIR)/etc @@ -51,3 +50,6 @@ override_dh_fixperms: cd debian/base-files && chmod 1777 `cat ../1777-dirs` cd debian/base-files && chmod 2775 `cat ../2775-dirs` cd debian/base-files && chmod 700 root + +override_dh_installdeb: + dh_installdeb -DVENDORFILE=$(VENDORFILE) -- cgit v1.2.3