From 6451369a6d41f12ff79211ca5d613e4b4062b4f0 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Sat, 25 Nov 2023 14:03:12 +1100
Subject: [PATCH] adapt to new 66 code

---
 INSTALL.md                                    | 13 +++-----
 Makefile                                      | 31 +++++--------------
 configure                                     | 15 ++++-----
 {service => module}/boot-user@                |  9 +++---
 module/{boot-user@ => }/configure/.xinitrc    |  2 +-
 module/{boot-user@ => }/configure/.xsession   |  2 +-
 module/{boot-user@ => }/configure/configure   | 19 +++++++++---
 .../service@ => frontend}/mount-run@          |  6 ++--
 package/info                                  |  2 +-
 package/modes                                 |  2 ++
 package/targets.mak                           | 10 +++---
 11 files changed, 51 insertions(+), 60 deletions(-)
 rename {service => module}/boot-user@ (80%)
 rename module/{boot-user@ => }/configure/.xinitrc (97%)
 rename module/{boot-user@ => }/configure/.xsession (93%)
 rename module/{boot-user@ => }/configure/configure (83%)
 rename module/{boot-user@/service@ => frontend}/mount-run@ (91%)

diff --git a/INSTALL.md b/INSTALL.md
index 2b4f626..db569c4 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -4,7 +4,7 @@ Build Instructions
 ## Requirements
 
 - GNU make version 3.81 or later
-  
+
 This software will install on any operating system that implements POSIX.1-2008, available at [opengroup](http://pubs.opengroup.org/onlinepubs/9699919799/).
 
 ## Standard usage
@@ -16,10 +16,7 @@ This software will install on any operating system that implements POSIX.1-2008,
 You can customize paths via flags given to configure. See `./configure --help` for a list of all available configure options.
 
 ## Runtime dependencies
-  
-- 66 version 0.5.1.0 or later https://framagit.org/Obarun/66/
-- 66-tools version 0.0.6.2 or later https://framagit.org/Obarun/66-tools/
-- scandir-66serv version 0.2.1 or later https://framagit.org/pkg/obmods/scandir-66erv
-- optional dependencies:
-   * console-tracker-66serv version 0.2.1 or later https://framagit.org/pkg/obmods/console-tracker-66serv
-   * display-manager-66serv version 0.2.1 or later https://framagit.org/pkg/obmods/display-manager-66serv
+
+- 66 version 0.5.1.0 or later https://git.obarun.org/Obarun/66/
+- 66-tools version 0.0.6.2 or later https://git.obarun.org/Obarun/66-tools/
+- scandir-66serv version 0.2.1 or later https://git.obarun.org/pkg/obmods/scandir-66erv
diff --git a/Makefile b/Makefile
index 91b8d03..e4a452b 100644
--- a/Makefile
+++ b/Makefile
@@ -15,31 +15,12 @@ include package/targets.mak
 
 INSTALL := ./tools/install.sh
 
-install: install-script install-service install-service-module install-service-instance-module install-configure
-install-script: $(SCRIPT_TARGET:module/boot-user@/configure/%=$(DESTDIR)$(module_directory)/boot-user@/configure/%)
-install-service: $(SERVICE_TARGET:service/%=$(DESTDIR)$(service_directory)/%)
-install-service-module: $(MODULE_TARGET:module/boot-user@/service/%=$(DESTDIR)$(module_directory)/boot-user@/service/%)
-install-service-instance-module: $(MODULE_INSTANCE_TARGET:module/boot-user@/service@/%=$(DESTDIR)$(module_directory)/boot-user@/service@/%)
-install-configure: $(MODULE_CONFIGURE_TARGET:module/boot-user@/configure/configure=$(DESTDIR)$(module_directory)/boot-user@/configure/configure)
+install: install-module install-script
 
+install-module: $(MODULE_TARGET:module/%=$(DESTDIR)$(service_directory)/$(package)/%)
+install-script: $(SCRIPT_TARGET:module/configure/%=$(DESTDIR)$(service_directory)/$(package)/configure/%)
 
-$(DESTDIR)$(module_directory)/boot-user@/configure/%: module/boot-user@/configure/%
-	exec $(INSTALL) -D -m 755 $< $@
-	sed -i -e 's,@BINDIR@,$(bindir),' $@
-
-$(DESTDIR)$(module_directory)/boot-user@/configure/configure: module/boot-user@/configure/configure
-	exec $(INSTALL) -D -m 755 $< $@
-	sed -i -e 's,@BINDIR@,$(bindir),' $@
-
-$(DESTDIR)$(module_directory)/boot-user@/service/%: module/boot-user@/service/%
-	exec $(INSTALL) -D -m 644 $< $@
-
-$(DESTDIR)$(module_directory)/boot-user@/service@/%: module/boot-user@/service@/%
-	exec $(INSTALL) -D -m 644 $< $@
-
-
-
-$(DESTDIR)$(service_directory)/%: service/%
+$(DESTDIR)$(service_directory)/$(package)/%: module/%
 	exec $(INSTALL) -D -m 644 $< $@
 	sed -i -e 's,@VERSION@,$(version),' \
 		-e "s,@DISPLAY_MANAGER@,$(DISPLAY_MANAGER)," \
@@ -47,6 +28,10 @@ $(DESTDIR)$(service_directory)/%: service/%
 		-e "s,@XDG_RUNTIME@,$(XDG_RUNTIME)," \
 		-e "s,@DESKTOP_CMDLINE@,$(DESKTOP_CMDLINE)," $@
 
+$(DESTDIR)$(service_directory)/$(package)/configure/%: module/configure/%
+	exec $(INSTALL) -D -m 755 $< $@
+	sed -i -e 's,@BINDIR@,$(bindir),' $@
+
 version:
 	@echo $(version)
 
diff --git a/configure b/configure
index 9ebc148..5c22f61 100755
--- a/configure
+++ b/configure
@@ -16,16 +16,15 @@ Fine tuning of the installation directories:
   --bindir=BINDIR                  user executables [EPREFIX/bin]
   --datarootdir=DATAROOTDIR        read-only architecture-independent data root [PREFIX/share]
   --with-system-service=DIR        66 service intallation directory [DATAROOTDIR/$package_macro_dir/service]
-  --with-system-module=DIR         66 module intallation directory [DATAROOTDIR/$package_macro_dir/module]
-  
+
 Fine tunning of boot-user configuration:
   --DISPLAY_MANAGER=VALUE          display manager to use []
   --CONSOLE_TRACKER=VALUE          console tracker to use []
   --XDG_RUNTIME=BOOLEAN            create and mount the XDG_RUNTIME directory [!yes]
   --DESKTOP_CMDLINE=VALUE          commandline to use in the .xinitrc file [!jwm]
-  
+
  Use yes or no with lowercase character to set BOOLEAN values.
- 
+
  Empty value is a commented one and not used at all.
 
  An exclamation mark '!' at the begin of the value unexport the variable
@@ -89,7 +88,6 @@ exec_prefix='$prefix'
 bindir='$exec_prefix/bin'
 datarootdir='$prefix/share'
 service_directory='$datarootdir/$package_macro_dir/service'
-module_directory='$datarootdir/$package_macro_dir/module'
 DISPLAY_MANAGER=
 CONSOLE_TRACKER=
 XDG_RUNTIME='!yes'
@@ -103,7 +101,6 @@ for arg ; do
     --bindir=*) bindir=${arg#*=} ;;
     --datarootdir=*) datarootdir=${arg#*=} ;;
     --with-system-service=*) service_directory=${arg#*=} ;;
-    --with-system-module=*) module_directory=${arg#*=} ;;
     --DISPLAY_MANAGER=*) DISPLAY_MANAGER=${arg#*=} ;;
     --CONSOLE_TRACKER=*) CONSOLE_TRACKER=${arg#*=} ;;
     --XDG_RUNTIME=*) XDG_RUNTIME=${arg#*=} ;;
@@ -124,14 +121,14 @@ fi
 # Expand installation directories
 stripdir prefix
 for i in exec_prefix bindir datarootdir \
-		service_directory module_directory ; do
+		service_directory; do
   eval tmp=\${$i}
   eval $i=$tmp
   stripdir $i
 done
 
 stripdir datarootdir
-for i in service_directory module_directory; do
+for i in service_directory; do
   eval tmp=\${$i}
   eval $i=$tmp
   stripdir $i
@@ -175,13 +172,13 @@ cat << EOF
 # $cmdline
 # Any changes made here will be lost if configure is re-run.
 
+package := $package
 version := $version
 prefix := $prefix
 exec_prefix := $exec_prefix
 bindir := $bindir
 datarootdir := $datarootdir
 service_directory := $service_directory
-module_directory := $module_directory
 package_macro_dir := $package_macro_dir
 $DISPLAY_MANAGER
 $CONSOLE_TRACKER
diff --git a/service/boot-user@ b/module/boot-user@
similarity index 80%
rename from service/boot-user@
rename to module/boot-user@
index 5848dff..d447d19 100644
--- a/service/boot-user@
+++ b/module/boot-user@
@@ -5,15 +5,16 @@
 @user = ( root )
 @options = ( env )
 @depends = ( scandir@@I )
+@intree = session
 
 [regex]
 @configure = "@I"
 @infiles = ( ::@version@=@VERSION@ )
 
 [environment]
-## Uncomment it to use a display manager. 
+## Uncomment it to use a display manager.
 ## Can be any display manager as long as the
-## corresponding frontend file exist on your system 
+## corresponding frontend file exist on your system
 ## e.g sddm,lightdm,...
 ## It also prepare the .xsession file.
 
@@ -21,7 +22,7 @@
 
 ## Uncomment it to use a console tracker.
 ## Can be any console tracker as long as the
-## corresponding frontend file exist on your system 
+## corresponding frontend file exist on your system
 ## e.g consolekit,elogind,...
 
 @CONSOLE_TRACKER@
@@ -35,4 +36,4 @@
 ## to launch your desktop e.g.: openbox-session.
 ## If commented the .xinitrc file is not configured.
 
-@DESKTOP_CMDLINE@ 
+@DESKTOP_CMDLINE@
diff --git a/module/boot-user@/configure/.xinitrc b/module/configure/.xinitrc
similarity index 97%
rename from module/boot-user@/configure/.xinitrc
rename to module/configure/.xinitrc
index 95fd778..1b4872c 100755
--- a/module/boot-user@/configure/.xinitrc
+++ b/module/configure/.xinitrc
@@ -15,7 +15,7 @@ for i in ${list[@]};do
     done
 done
 
-66-all up
+66 tree start
 
 ## Try consolekit
 if 66-which -q ck-launch-session; then
diff --git a/module/boot-user@/configure/.xsession b/module/configure/.xsession
similarity index 93%
rename from module/boot-user@/configure/.xsession
rename to module/configure/.xsession
index 0ad28d2..0a6b153 100755
--- a/module/boot-user@/configure/.xsession
+++ b/module/configure/.xsession
@@ -8,5 +8,5 @@ for i in ${list[@]};do
     done
 done
 
-66-all up
+66 tree start
 
diff --git a/module/boot-user@/configure/configure b/module/configure/configure
similarity index 83%
rename from module/boot-user@/configure/configure
rename to module/configure/configure
index 97cc33d..b0b861c 100755
--- a/module/boot-user@/configure/configure
+++ b/module/configure/configure
@@ -6,6 +6,11 @@ export VERBOSITY="${MOD_VERBOSITY}"
 export CLOCK_ENABLED=0
 export COLOR_ENABLED="${MOD_COLOR}"
 
+## script variable
+FRONTEND_PATH="${MOD_MODULE_DIR}/frontend"
+ACTIVATED_PATH="${MOD_MODULE_DIR}/activated"
+DEPENDS_PATH="${ACTIVATED_PATH}/depends"
+
 owner="${1}"
 home=$(homeof "${owner}")
 uid=$(id -u "${owner}")
@@ -25,16 +30,22 @@ check_empty_var(){
     fi
 }
 
+depends(){
+    name="${1}"
+    66-yeller %badd%n dependency: "${consolekit}"
+    touch  "${DEPENDS_PATH}/${name}" || die "unable to add dependency ${MOD_MODULE_DIR}/service/${name}"
+}
+
 enable(){
     name="${1}"
     66-yeller %benable%n service: "${name}"
-    touch "${MOD_MODULE_DIR}/service/${name}" || die "unable to enable ${MOD_MODULE_DIR}/service/${1}"
+    touch "${ACTIVATED_PATH}/${name}" || die "unable to enable ${MOD_MODULE_DIR}/service/${1}"
 }
 
 disable(){
     name="${1}"
     66-yeller %rdisable%n service: "${name}"
-    rm -f "${MOD_MODULE_DIR}/service/${name}" || die "disable to enable ${MOD_MODULE_DIR}/service/${1}"
+    rm -f "${ACTIVATED_PATH}/${name}" || die "disable to enable ${MOD_MODULE_DIR}/service/${1}"
 }
 
 if execl-toc -X -V DISPLAY_MANAGER; then
@@ -45,7 +56,7 @@ if execl-toc -X -V DISPLAY_MANAGER; then
         die "the ${DISPLAY_MANAGER} frontend service file do not exist on your system -- please install it and try again"
     fi
 
-    enable "display-manager@${DISPLAY_MANAGER}"
+    depends "${DISPLAY_MANAGER}"
 
     66-yeller set environment at .xsession file to: %b"${home_env}"%n
     sed -i "s:@PATH_ENVIRONMENT@:${home_env}:g" ".xsession" || die "unable to set environment directory at .xsession file"
@@ -67,7 +78,7 @@ if execl-toc -X -V CONSOLE_TRACKER; then
     if ! [ -e "${MOD_SERVICE_ADMDIR}${CONSOLE_TRACKER}" ] && ! [ -e "${MOD_SERVICE_SYSDIR}${CONSOLE_TRACKER}" ]; then
         die "the ${CONSOLE_TRACKER} frontend service file do not exist on your system -- please install it and try again"
     fi
-    enable "console-tracker@${CONSOLE_TRACKER}"
+    depends "${CONSOLE_TRACKER}"
 fi
 
 if [ "${XDG_RUNTIME}" = "yes" ]; then
diff --git a/module/boot-user@/service@/mount-run@ b/module/frontend/mount-run@
similarity index 91%
rename from module/boot-user@/service@/mount-run@
rename to module/frontend/mount-run@
index 8582513..af526a1 100644
--- a/module/boot-user@/service@/mount-run@
+++ b/module/frontend/mount-run@
@@ -3,14 +3,14 @@
 @version = @version@
 @description = "Mount /run/user directory of user @I"
 @user = ( root )
-@options = ( log )
+
 
 [start]
-@execute = 
+@execute =
 (
 	if { 66-yeller -p mount-run@@I starts... }
 	if -nt {
-		
+
 		execl-subuidgid -o @I
 		execl-toc -X -m /run/user/${UID} -o noatime,nodev,nosuid,gid=${GID},uid=${UID},mode=0700,size=64M -t tmpfs -d user
 	}
diff --git a/package/info b/package/info
index 2b814bd..5a9f8e4 100644
--- a/package/info
+++ b/package/info
@@ -1,3 +1,3 @@
-package=boot-user-66serv
+package=boot-user
 version=0.4.3
 package_macro_dir=66
diff --git a/package/modes b/package/modes
index e67454a..4a830fd 100644
--- a/package/modes
+++ b/package/modes
@@ -1 +1,3 @@
 configure   0755
+.xsession   0755
+.xinitrc    0755
diff --git a/package/targets.mak b/package/targets.mak
index e62c507..3273c25 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -1,9 +1,7 @@
 SCRIPT_TARGET := \
-module/boot-user@/configure/.xinitrc \
-module/boot-user@/configure/.xsession
+module/configure/configure \
+module/configure/.xinitrc \
+module/configure/.xsession
+MODULE_TARGET := $(shell find module/ -type f)
 
-SERVICE_TARGET := service/boot-user@
-MODULE_TARGET := $(shell find module/boot-user@/service -type f)
-MODULE_INSTANCE_TARGET := $(shell find module/boot-user@/service@ -type f)
 
-MODULE_CONFIGURE_TARGET := module/boot-user@/configure/configure
-- 
GitLab