pthbs_genpkgpy

Template engine for producing packages for pthbs written using Python and Jinja
git clone https://ccx.te2000.cz/git/pthbs_genpkgpy
Log | Files | Refs | Submodules | README

commit b67e94c3cab9a702cc40e7c0c25dbb869ed9b5a2
parent fed9e0bfd05da1e49657b68046cd38936c43c268
Author: ccx <ccx@te2000.cz>
Date:   Fri,  8 Mar 2024 19:52:25 +0000

login now works

Diffstat:
MMakefile | 2+-
Mcommand/pthbs-enter-gen | 37+++++++++++++++++++++++++++----------
Mpackages/core-system-conf | 9+++++----
Mpackages/core-system-init | 4++--
Mpackages/core-system-rc | 4++--
Mpackages/default.environment | 8++++----
Mpackages/logincaps | 2+-
Apackages/mdev-scripts | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apackages/mdevd.environment | 6++++++
Mpackages/userspace.environment | 2+-
Mtemplates/pkg/core-system-conf | 1+
Mtemplates/pkg/logincaps | 2+-
Atemplates/pkg/mdev-scripts | 19+++++++++++++++++++
Atemplates/pkg/mdevd.environment | 5+++++
14 files changed, 149 insertions(+), 26 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,7 +4,7 @@ VERSIONS:=$(patsubst /root/%,/%,$(HOME)/versions) export PATH:=$(CURDIR)/command:$(PATH) export pthbs_versions:=$(VERSIONS) -default: default.environment +default: default.environment userspace.environment containers.environment mdevd.environment $(VERSIONS)/environment.%/.env: @echo mkdir "$$(dirname '$@')" diff --git a/command/pthbs-enter-gen b/command/pthbs-enter-gen @@ -8,7 +8,6 @@ fi envtop=$1 envdir=$envtop/env envcommand=$envtop/command -exe=$envcommand/pthbs-enter case $(basename "$envtop") in (env.*) ;; @@ -32,25 +31,44 @@ if test -d "$envtop/library/pkgconfig"; then printf '%s\n' "$envtop/library/pkgconfig" >"$envdir/PKG_CONFIG_LIBDIR" fi +mkscript() { + exe=$envcommand/$1 + cat >"$exe.new" + chmod +x "$exe.new" + mv "$exe.new" "$exe" +} + +exe=$envcommand/pthbs-enter if test -x "$envcommand/execlineb" && test -x "$envcommand/s6-envdir"; then - cat >"$exe" <<EOF + mkscript pthbs-enter <<EOF #!$envcommand/execlineb -S0 "$envcommand/s6-envdir" "$envdir" "$envcommand/exec" \$@ EOF - chmod +x "$exe" - "$exe" true # TODO: don't run executables without sandbox + "$envcommand/pthbs-enter" true # TODO: don't run executables without sandbox + mkscript pthbs-enter-execlineb <<EOF +#!$envcommand/execlineb -S0 +"$envcommand/s6-envdir" "$envdir" "$envcommand/execlineb" \$@ +EOF + if test -x "$envcommand/sh"; then + mkscript pthbs-enter-sh <<EOF +#!$envcommand/execlineb -S0 +"$envcommand/s6-envdir" "$envdir" "$envcommand/sh" \$@ +EOF + fi elif test -x "$envcommand/sh" && test -x "$envcommand/envdir"; then - cat >"$exe" <<EOF + mkscript pthbs-enter <<EOF #!$envcommand/sh exec "$envcommand/envdir" "$envdir" "$envcommand/env" -- "\$@" EOF - chmod +x "$exe" - "$exe" true # TODO: don't run executables without sandbox + "$envcommand/pthbs-enter" true # TODO: don't run executables without sandbox + mkscript pthbs-enter-sh <<EOF +#!$envcommand/sh +exec "$envcommand/envdir" "$envdir" "$envcommand/sh" "\$@" +EOF fi -exe="$envcommand/install-as-current-environment" if test -x "$envcommand/install-as-current-environment.postinstall"; then - cat >"$exe" <<EOF + mkscript install-as-current-environment <<EOF #!$envcommand/execlineb -P "$envcommand/s6-envdir" "$envdir" "$envcommand/exec" ifelse -n { test -L /run/current } { @@ -79,5 +97,4 @@ if { mv -v /run/previous.\${NS_PID} /run/current } #foreground { /run/current/command/install-as-current-environment.postinstall } exit 1 EOF - chmod +x "$exe" fi diff --git a/packages/core-system-conf b/packages/core-system-conf @@ -13,8 +13,8 @@ #+s6.bb3974d7b49c2034b5064bac508beae2d4bfc1a7b6543aefcbc1af9e9e94f1a7 #+zsh.762204e14953017be79e356d4bf9f7681625a750ecc951f3510bf144ea7b51bb #+core-system-scripts.132a3b1c6b226dee79156049db1244ebeacdf5a4bfcffc74b6b97175dad000fd -#+logincaps.d91b19069a50bdc149c19a468e1aa30252308ce2366858d85e1b36279f79c933 -#@git:aa6e56d2a3e1cf0d53d70db8348c35272e876677:core-system-conf +#+logincaps.475e97436e9a1786e39f2a08462f197140ba4de2e17e06c79d5f76d0a5612de2 +#@git:f57730644b1cceeae0dd190f26927883b4cc8cda:core-system-conf def_prefix() { prefix=/versions/$pthbs_package @@ -42,11 +42,12 @@ linkdep() { cd 'core-system-conf' printf '%s\n' >config/etc/motd \ "Welcome to $(cat ./config/hostname)!" \ - 'Current running configuration was generated from core-system-conf:aa6e56d2a3e1cf0d53d70db8348c35272e876677' \ - 'Last change on 2024-03-08 13:19:44 +0000 by ccx' + 'Current running configuration was generated from core-system-conf:f57730644b1cceeae0dd190f26927883b4cc8cda' \ + 'Last change on 2024-03-08 19:02:48 +0000 by ccx' env 'pthbs_path_core-system-conf'="$prefix" \ 'pthbs_path_containers=/versions/env.9cf55586e2295800df02539537b4c0407b2f5a19bf5e648083e92f419eb321e5' \ + 'pthbs_path_mdevd=/versions/env.9ff4ae1aa76157d331d77b75c4dec8d6fd85395776d90a931bfb285a671a5c32' \ make -j${JOBS:-1} -l$((1+${JOBS:-1})) all sort -u build/execfile | while IFS= read exename; do diff --git a/packages/core-system-init b/packages/core-system-init @@ -5,9 +5,9 @@ #+s6-portable-utils.39f4babb8cd30769f1a931708e5442244b0305c36ddafe32348c7dc30c000b00 #+s6-linux-init.396413eed542c149346f51a569f2d686c03b2104f4d062f52422e444ad9b502d #+execline.9d9d14aad09d9643f578727ab1ed3363b975772358c4ac8e756abdad4fca7a3d -#+core-system-rc.3995e5ea62be56347d3d84443f0de1dd9c2b021f59170809a35bd81c9e455eab +#+core-system-rc.9604d0dac18456fc5af77ea9ab16dca585ad5fcb5854945b47281b1295a3f582 -s6rcdb=/versions/core-system-rc.3995e5ea62be56347d3d84443f0de1dd9c2b021f59170809a35bd81c9e455eab/config/s6-rc-db +s6rcdb=/versions/core-system-rc.9604d0dac18456fc5af77ea9ab16dca585ad5fcb5854945b47281b1295a3f582/config/s6-rc-db prefix=/versions/$pthbs_package pkgdir="$pthbs_destdir/$prefix" diff --git a/packages/core-system-rc b/packages/core-system-rc @@ -3,7 +3,7 @@ #+busybox-diffutils.4f5a07b29246414b77a7d71b103263af8f1249d75ddcbd9864e00def3d6feded #+s6-rc.6cefe2791153127e0a783521ab97f3b124f023f21cdc2eddadbb865496ad0b45 #+fileset.22d9abf3009dbbfe507bd7ff93fdd0bf7f86ee0bc317b37b423b89d70ab950a2 -#+core-system-conf.ca6eb3340c075b6860f7c8c6e8f7fbf2036f1f20977f2200a09001d008901dd0 +#+core-system-conf.77e085927bd24f87018573434d43d14ea7ac1e92bb2a724bd0786e4e7eb31190 def_prefix() { prefix=/versions/$pthbs_package @@ -13,7 +13,7 @@ def_dest() { } def_dest -src=/versions/core-system-conf.ca6eb3340c075b6860f7c8c6e8f7fbf2036f1f20977f2200a09001d008901dd0/config/s6-rc-source +src=/versions/core-system-conf.77e085927bd24f87018573434d43d14ea7ac1e92bb2a724bd0786e4e7eb31190/config/s6-rc-source s6-rc-compile ./s6-rc-db "$src" mkdir -p "$dest/config" mv -v s6-rc-db "$dest/config/" diff --git a/packages/default.environment b/packages/default.environment @@ -1,7 +1,7 @@ -#+core-system-conf.ca6eb3340c075b6860f7c8c6e8f7fbf2036f1f20977f2200a09001d008901dd0 -#+core-system-rc.3995e5ea62be56347d3d84443f0de1dd9c2b021f59170809a35bd81c9e455eab +#+core-system-conf.77e085927bd24f87018573434d43d14ea7ac1e92bb2a724bd0786e4e7eb31190 +#+core-system-rc.9604d0dac18456fc5af77ea9ab16dca585ad5fcb5854945b47281b1295a3f582 #+core-system-scripts.132a3b1c6b226dee79156049db1244ebeacdf5a4bfcffc74b6b97175dad000fd -#+core-system-init.553229c8a34a8f564447d966c8646e7299e7101ab4abad414756119add88ee0e +#+core-system-init.241086865d7897cba12a880be6343e775307a00c1f47bf9a11b00514d48959a6 #+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 #+gnu-make.782c9e6625fd7420e2cd38b847afed19db3b3844cae8a0426a0dbf73e10d78e5 #+musl-cross-make.65f98305f5666435bf0c6b9ccedffae2179ff1b3286752756886f760cf7771d2 @@ -26,7 +26,7 @@ #+confz.6658089fa0f90962e97d41b3fd8400d7ea37c6872828f5f7bd122a2d07a9c467 #+containers.60c1acf0dfce9a977591b80f5ae29b57f6b436815af20c2a4cbd3c28d8308427 #+fileset.22d9abf3009dbbfe507bd7ff93fdd0bf7f86ee0bc317b37b423b89d70ab950a2 -#+logincaps.d91b19069a50bdc149c19a468e1aa30252308ce2366858d85e1b36279f79c933 +#+logincaps.475e97436e9a1786e39f2a08462f197140ba4de2e17e06c79d5f76d0a5612de2 #+snaprep.42b7b97b7530a211dd0f01680c9b15362aa2e7249bc27cea0deb0632f7535bb1 #+curl.b82f818e85570a561ca20ca417adba2f1c3214ef5c3e01626c0a4aa099b90f0c #+git.1839db7305bbee32d184adc0ece64d40ab58132d3c7749b426c4d680659bd4eb diff --git a/packages/logincaps b/packages/logincaps @@ -32,7 +32,7 @@ sh build_static.sh cp -a login "$pkgdir/command/" cat >"$pkgdir/command/login-keepenv" <<EOF #!$(which execlineb) -S0 -$pkgdir/command/login -p $@ +$prefix/command/login -p \$@ EOF chmod +x "$pkgdir/command/login-keepenv" diff --git a/packages/mdev-scripts b/packages/mdev-scripts @@ -0,0 +1,74 @@ +#!/usr/bin/env pthbs-build +#+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 +#+zsh.762204e14953017be79e356d4bf9f7681625a750ecc951f3510bf144ea7b51bb +#+pthbs-banginstall.d1e43ec62e6d2b3a2a03a2d9ce487f6fe768fb7131c09ce0d2dd9e165233cff1 +#@git:6f990f8e9d46667a1a128d49d822968830d36c99:mdev-scripts + +def_prefix() { + prefix=/versions/$pthbs_package +} +def_dest() { + dest=${pthbs_destdir%/}//versions/$pthbs_package +} +def_prefix +def_dest + +cd 'mdev-scripts' +mkdir -p "$dest" +for script in persistent-storage dvbdev ptpdev usbdev; do + mv -v $script mdev-hook-$script + chmod +x mdev-hook-$script + pthbs-banginstall mdev-hook-$script "$dest" +done + +cd "$pthbs_destdir/versions/$pthbs_package" +find -type d -o -print | awk -F/ ' +BEGIN { +} + +function r1(s) { + sub("^[.]/[^/]*", ".", s) + return s +} +function s1(repl, s) { + sub("^[.]/[^/]*", "./"repl, s) + return s +} +function link(src) { + x[$0]=0 + printf "%s\t%s\n", $0, src + printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" +} +$1!="."{exit 1} + + +$2 == "command" { link($0); next } +$2 == "bin" { link(s1("command", $0)); next } + +$2 == "library.so" { link($0); next } +$2 == "library" { link($0); next } +$2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } +$2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } + +$2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } + +$2 == "man" { link($0); next } +$2 == "info" { link($0); next } +$2 == "doc" { link($0); next } +$2 == "icons" { link($0); next } +$2 == "terminfo" { link($0); next } +$2 == "data" { link($0); next } +$2 == "include" { link($0); next } + +{ printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } + +END { + for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } + for(fname in x) { + if(x[fname]) { + printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" + exit 3 + } + } +}' >.install-links.new +mv .install-links.new .install-links diff --git a/packages/mdevd.environment b/packages/mdevd.environment @@ -0,0 +1,5 @@ +#+busybox.e60885fe93ee85c01831673bb29f0e62a64903f4ce3094e3dc35bc8ec8887ad9 +#+execline.9d9d14aad09d9643f578727ab1ed3363b975772358c4ac8e756abdad4fca7a3d +#+s6.bb3974d7b49c2034b5064bac508beae2d4bfc1a7b6543aefcbc1af9e9e94f1a7 +#+mdev-scripts.650e56bda7f6be74be2a29ac756ffef0dc765f2557640d6764908c8f5e98930e +#+mdevd.d0ffd7f79efbd9ff9af5e2a93e8fe5fae0d994325eb28e2af7e5d6783c50afb3+ \ No newline at end of file diff --git a/packages/userspace.environment b/packages/userspace.environment @@ -22,7 +22,7 @@ #+confz.6658089fa0f90962e97d41b3fd8400d7ea37c6872828f5f7bd122a2d07a9c467 #+containers.60c1acf0dfce9a977591b80f5ae29b57f6b436815af20c2a4cbd3c28d8308427 #+fileset.22d9abf3009dbbfe507bd7ff93fdd0bf7f86ee0bc317b37b423b89d70ab950a2 -#+logincaps.d91b19069a50bdc149c19a468e1aa30252308ce2366858d85e1b36279f79c933 +#+logincaps.475e97436e9a1786e39f2a08462f197140ba4de2e17e06c79d5f76d0a5612de2 #+snaprep.42b7b97b7530a211dd0f01680c9b15362aa2e7249bc27cea0deb0632f7535bb1 #+curl.b82f818e85570a561ca20ca417adba2f1c3214ef5c3e01626c0a4aa099b90f0c #+git.1839db7305bbee32d184adc0ece64d40ab58132d3c7749b426c4d680659bd4eb diff --git a/templates/pkg/core-system-conf b/templates/pkg/core-system-conf @@ -43,6 +43,7 @@ printf '%s\n' >config/etc/motd \ env 'pthbs_path_{{name}}'="$prefix" \ 'pthbs_path_containers={{pkg_install_dir("containers.environment")}}' \ + 'pthbs_path_mdevd={{pkg_install_dir("mdevd.environment")}}' \ {{make}} all sort -u build/execfile | while IFS= read exename; do diff --git a/templates/pkg/logincaps b/templates/pkg/logincaps @@ -9,7 +9,7 @@ sh build_static.sh cp -a login "$pkgdir/command/" cat >"$pkgdir/command/login-keepenv" <<EOF #!$(which execlineb) -S0 -$pkgdir/command/login -p $@ +$prefix/command/login -p \$@ EOF chmod +x "$pkgdir/command/login-keepenv" {%- endblock %} diff --git a/templates/pkg/mdev-scripts b/templates/pkg/mdev-scripts @@ -0,0 +1,19 @@ +{% extends "genlinks" %} +{%- block script %} +#+{{pkg_install_name("busybox")}} +#+{{pkg_install_name("zsh")}} +#+{{pkg_install_name("pthbs-banginstall")}} +#@git:{{submodule.current["mdev-conf"]}}:{{name}} + +{% include "functions/vars" %} +def_prefix +def_dest + +cd '{{name}}' +mkdir -p "$dest" +for script in persistent-storage dvbdev ptpdev usbdev; do + mv -v $script mdev-hook-$script + chmod +x mdev-hook-$script + pthbs-banginstall mdev-hook-$script "$dest" +done +{% endblock %} diff --git a/templates/pkg/mdevd.environment b/templates/pkg/mdevd.environment @@ -0,0 +1,5 @@ +#+{{pkg_install_name("busybox")}} +#+{{pkg_install_name("execline")}} +#+{{pkg_install_name("s6")}} +#+{{pkg_install_name("mdev-scripts")}} +#+{{pkg_install_name("mdevd")}}