pkg.sh: Evaluate pkg.run on Debian

pkg.run is not evaluated on Debian, fix that. For now it's hacked
into pkg.sh, which is bound to be replaced by Python. The limited
hassle is still worth the detour.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-28 12:42:10 +00:00
commit ca7a5a5265
2 changed files with 74 additions and 24 deletions

View file

@ -128,7 +128,7 @@ _cat <<- EOT
| mkdir -p \`dirname \$INSTALL_LOG\` | mkdir -p \`dirname \$INSTALL_LOG\`
| > \$INSTALL_LOG | > \$INSTALL_LOG
| \\\$(MAKE) ENV_PREFIX=\\\$(ENV_PREFIX) INSTALL_LOG=\\\$(INSTALL_LOG) install | \\\$(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 | dh_installdirs
| |
|override_dh_install: |override_dh_install:

View file

@ -39,6 +39,21 @@ os()
/bin/bash $JWB_SCRIPT_DIR/get-os.sh /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() scm_commit()
{ {
case $SCM in case $SCM in
@ -941,15 +956,6 @@ cmd_milk_install_log()
echo "$*" | sed "s/.*attr(\(LINK\|[0-9]\+\),\([^,]\+\),\([^,)]\+\)).*/\\$attr/" 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_log()
{ {
cat $in | sed ' cat $in | sed '
@ -1048,9 +1054,28 @@ 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 -ve $filter_devel > $out/conffiles.$name-run
cat_log | grep "%config" | cleanup_line_deb | grep -e $filter_devel > $out/conffiles.$name-devel cat_log | grep "%config" | cleanup_line_deb | grep -e $filter_devel > $out/conffiles.$name-devel
# Create maintainer scripts
for p in run devel; do for p in run devel; do
postinst=$out/$name-$p.postinst
milk_install_log_init_postinst $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 cat $out/$name-$p.dirs $out/$name-$p.install | grep . | while read file dir; do
#echo read file \"$file\" >&2 #echo read file \"$file\" >&2
file=`echo /$file | sed 's/inst-root\///; s%^//*%/%'` file=`echo /$file | sed 's/inst-root\///; s%^//*%/%'`
@ -1060,8 +1085,30 @@ cmd_milk_install_log()
perm=`milk_install_log_spec_attr 1 "$line"` perm=`milk_install_log_spec_attr 1 "$line"`
owner=`milk_install_log_spec_attr 2 "$line"` owner=`milk_install_log_spec_attr 2 "$line"`
group=`milk_install_log_spec_attr 3 "$line"` group=`milk_install_log_spec_attr 3 "$line"`
echo "chown $owner:$group $file" >> $postinst echo "chown $owner:$group $file" >> $script
[ "$perm" = "LINK" ] || echo "chmod $perm $file" >> $postinst [ "$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
done done
;; ;;
@ -1168,9 +1215,12 @@ while [ ${1:0:1} = - ]; do
shift shift
done done
[ "$JWB_SCRIPT_DIR" ] || JWB_SCRIPT_DIR=`dirname $0` [ "$JWB_SCRIPT_DIR" ] || JWB_SCRIPT_DIR="$(dirname $0)"
[ "$PROJECT" ] || PROJECT=`abspath $TOPDIR | xargs basename` [ "$PROJECT" ] || PROJECT=`abspath $TOPDIR | xargs basename`
inifile=$PROJECT_DESCR_FILE
. $JWB_SCRIPT_DIR/ini-tools.sh
cmd=$1 cmd=$1
shift shift