diff --git a/scripts/create-mkdebian.sh b/scripts/create-mkdebian.sh index a1cfda4d..860ca74b 100644 --- a/scripts/create-mkdebian.sh +++ b/scripts/create-mkdebian.sh @@ -128,7 +128,7 @@ _cat <<- EOT | mkdir -p \`dirname \$INSTALL_LOG\` | > \$INSTALL_LOG | \\\$(MAKE) ENV_PREFIX=\\\$(ENV_PREFIX) INSTALL_LOG=\\\$(INSTALL_LOG) install - | PATH=$JWB_SCRIPT_DIR:\\\$(PATH) /bin/bash pkg.sh milk-install-log -p \\\$(ENV_PREFIX) -n \\\$(NAME) -t deb \$INSTALL_LOG \\\$(DEB_DIR) + | PATH=$JWB_SCRIPT_DIR:\\\$(PATH) /bin/bash pkg.sh -m $JWB_SCRIPT_DIR milk-install-log -p \\\$(ENV_PREFIX) -n \\\$(NAME) -t deb \$INSTALL_LOG \\\$(DEB_DIR) | dh_installdirs | |override_dh_install: diff --git a/scripts/pkg.sh b/scripts/pkg.sh index 1d5b4d85..1943a7fb 100644 --- a/scripts/pkg.sh +++ b/scripts/pkg.sh @@ -39,6 +39,21 @@ os() /bin/bash $JWB_SCRIPT_DIR/get-os.sh } +os_cascade() +{ + /usr/bin/python3 $JWB_SCRIPT_DIR/jw-pkg.py projects os-cascade +} + +cfg_section() +{ + ini_section "$inifile" $@ +} + +cfg_escape() +{ + sed 's/\\/\\\\/g; s/\$/\\$/g; s/`/\\`/g' +} + scm_commit() { case $SCM in @@ -941,15 +956,6 @@ cmd_milk_install_log() echo "$*" | sed "s/.*attr(\(LINK\|[0-9]\+\),\([^,]\+\),\([^,)]\+\)).*/\\$attr/" } - milk_install_log_init_postinst() - { - cat <<- EOT > $1 - #!/bin/sh - - EOT - chmod 755 $1 - } - cat_log() { cat $in | sed ' @@ -1048,20 +1054,61 @@ cmd_milk_install_log() cat_log | grep "%config" | cleanup_line_deb | grep -ve $filter_devel > $out/conffiles.$name-run cat_log | grep "%config" | cleanup_line_deb | grep -e $filter_devel > $out/conffiles.$name-devel + # Create maintainer scripts for p in run devel; do - postinst=$out/$name-$p.postinst - milk_install_log_init_postinst $postinst - cat $out/$name-$p.dirs $out/$name-$p.install | grep . | while read file dir; do - #echo read file \"$file\" >&2 - file=`echo /$file | sed 's/inst-root\///; s%^//*%/%'` - #echo file is now \"$file\" >&2 - #echo grep \"$prefix/*$file$\" $in >&2 - line=`grep $file$ $in` - perm=`milk_install_log_spec_attr 1 "$line"` - owner=`milk_install_log_spec_attr 2 "$line"` - group=`milk_install_log_spec_attr 3 "$line"` - echo "chown $owner:$group $file" >> $postinst - [ "$perm" = "LINK" ] || echo "chmod $perm $file" >> $postinst + + local stage + for stage in pre preun post postun; do + + case $stage in + pre) deb_stage=preinst;; + post) deb_stage=postinst;; + preun) deb_stage=prerm;; + postun) deb_stage=postrm;; + esac + local script=$out/$name-$p.$deb_stage + + cat <<- EOT > $script + #!/bin/sh + + EOT + chmod 755 $script + + case $stage in + post) + cat $out/$name-$p.dirs $out/$name-$p.install | grep . | while read file dir; do + #echo read file \"$file\" >&2 + file=`echo /$file | sed 's/inst-root\///; s%^//*%/%'` + #echo file is now \"$file\" >&2 + #echo grep \"$prefix/*$file$\" $in >&2 + line=`grep $file$ $in` + perm=`milk_install_log_spec_attr 1 "$line"` + owner=`milk_install_log_spec_attr 2 "$line"` + group=`milk_install_log_spec_attr 3 "$line"` + echo "chown $owner:$group $file" >> $script + [ "$perm" = "LINK" ] || echo "chmod $perm $file" >> $script + done + ;; + *) + ;; + esac + + echo "== processing stage $stage: cfg_section pkg.$p.$stage" >&2 + local os content="" + for os in '' `os_cascade`; do + local sec=pkg.$p.$stage head="" + if [ "$os" ]; then + sec="$sec.$os" + head="\n# --- $os\n" + fi + cfg_section $sec | grep -q . || continue + content="$content$head`cfg_section $sec`" + done + if [ "$content" ]; then + echo -e "$content" >&2 + echo -e "\n$content" | cfg_escape >> $script + fi + cat $script | grep -v '^#!/bin\|^$' | grep -q . || rm $script done done ;; @@ -1168,9 +1215,12 @@ while [ ${1:0:1} = - ]; do shift done -[ "$JWB_SCRIPT_DIR" ] || JWB_SCRIPT_DIR=`dirname $0` +[ "$JWB_SCRIPT_DIR" ] || JWB_SCRIPT_DIR="$(dirname $0)" [ "$PROJECT" ] || PROJECT=`abspath $TOPDIR | xargs basename` +inifile=$PROJECT_DESCR_FILE +. $JWB_SCRIPT_DIR/ini-tools.sh + cmd=$1 shift