From 0f936e1351d95d7b7bb8ac4b64fc2a87f2982d8c Mon Sep 17 00:00:00 2001
From: PS
Date: Sun, 1 Feb 2026 12:06:01 +0100
Subject: version 0.2.0.0
---
AUTHORS | 10 ++
CONTRIBUTING | 5 +
COPYING | 13 ++
DCO | 37 +++++
INSTALL | 83 +++++++++++
Makefile | 87 +++++++++++
NEWS | 6 +
configure | 196 +++++++++++++++++++++++++
package/deps.mak | 16 ++
package/info | 4 +
package/modes | 6 +
package/targets.mak | 28 ++++
src/bin/system-init | 29 ++++
src/bin/system-shutdown | 14 ++
src/lib/service/system/goetia-shutdown/down | 0
src/lib/service/system/goetia-shutdown/run | 7 +
src/lib/service/system/goetia-shutdown/stage3b | 14 ++
src/lib/service/system/goetia-shutdown/stage4 | 14 ++
tools/gen-deps.sh | 35 +++++
tools/gen-targets.sh | 56 +++++++
tools/install.sh | 69 +++++++++
21 files changed, 729 insertions(+)
create mode 100644 AUTHORS
create mode 100644 CONTRIBUTING
create mode 100644 COPYING
create mode 100644 DCO
create mode 100644 INSTALL
create mode 100644 Makefile
create mode 100644 NEWS
create mode 100755 configure
create mode 100644 package/deps.mak
create mode 100644 package/info
create mode 100644 package/modes
create mode 100644 package/targets.mak
create mode 100755 src/bin/system-init
create mode 100755 src/bin/system-shutdown
create mode 100644 src/lib/service/system/goetia-shutdown/down
create mode 100755 src/lib/service/system/goetia-shutdown/run
create mode 100644 src/lib/service/system/goetia-shutdown/stage3b
create mode 100644 src/lib/service/system/goetia-shutdown/stage4
create mode 100755 tools/gen-deps.sh
create mode 100755 tools/gen-targets.sh
create mode 100755 tools/install.sh
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..1d835d3
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,10 @@
+Main author:
+ Paul Sopka
+
+Contributors:
+
+Thanks to:
+ Laurent Bercot
+ Dan J. Bernstein
+ Paul Jarc
+ Jonathan de Boyne Pollard
diff --git a/CONTRIBUTING b/CONTRIBUTING
new file mode 100644
index 0000000..6279422
--- /dev/null
+++ b/CONTRIBUTING
@@ -0,0 +1,5 @@
+ Please add a Signed-Off-By: line at the end of your commit,
+which certifies that you have the right and authority to pass
+it on as an open-source patch, as explicited in the Developer's
+Certificate of Origin available in this project's DCO file,
+or at https://developercertificate.org/
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..2dec60d
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,13 @@
+Copyright (c) 2024-2025 Paul Sopka
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/DCO b/DCO
new file mode 100644
index 0000000..8201f99
--- /dev/null
+++ b/DCO
@@ -0,0 +1,37 @@
+Developer Certificate of Origin
+Version 1.1
+
+Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
+1 Letterman Drive
+Suite D4700
+San Francisco, CA, 94129
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+
+Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+(a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+(b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+(c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified
+ it.
+
+(d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..19c0276
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,83 @@
+Build Instructions
+------------------
+
+* Requirements
+ ------------
+
+ - A POSIX-compliant set of utils
+ - A set of OS specific utils
+ - s6 https://skarnet.org/software/s6/
+ - s6-rc https://skarnet.org/software/s6-rc/
+ - execline https://skarnet.org/software/execline/
+
+ This software will run on any operating system that implements
+POSIX.1-2008, available at:
+ https://pubs.opengroup.org/onlinepubs/9699919799/
+
+
+* Standard usage
+ --------------
+
+ ./configure && make && sudo make install
+
+ will work for most users.
+
+
+* Customization
+ -------------
+
+ You can customize paths via flags given to configure.
+ See ./configure --help for a list of all available configure options.
+
+* Make variables
+ --------------
+
+ You can invoke make with a few variables for more configuration.
+
+ INSTALL can be overridden on the make command line. This is
+an even bigger hammer than running ./configure with environment
+variables, so it is advised to only do this when it is the only way of
+obtaining the behaviour you want.
+
+ DESTDIR can be given on the "make install" command line in order to
+install to a staging directory.
+
+* The slashpackage convention
+ ---------------------------
+
+ The slashpackage convention (http://cr.yp.to/slashpackage.html)
+is a package installation scheme that provides a few guarantees
+over other conventions such as the FHS, for instance fixed
+absolute pathnames. skarnet.org packages support it: use the
+--enable-slashpackage option to configure, or
+--enable-slashpackage=DIR for a prefixed DIR/package tree.
+This option will activate slashpackage support during the build
+and set slashpackage-compatible installation directories.
+If $package_home is the home of the package, defined as
+DIR/package/$category/$package-$version with the variables
+read from the package/info file, then:
+
+ --bindir is set to $package_home/command
+ --sbindir is also set to $package_home/command (slashpackage
+differentiates root-only binaries by their Unix rights, not their
+location in the filesystem)
+ --libdir is set to $package_home/
+
+ --prefix is pretty much ignored when you use --enable-slashpackage.
+You should probably not use both --enable-slashpackage and --prefix.
+
+ When using slashpackage, two additional Makefile targets are
+available after "make install":
+ - "make update" changes the default version of the software to the
+freshly installed one. (This is useful when you have several installed
+versions of the same software, which slashpackage supports.)
+ - "make global-links" adds links from /command and /library.so to the
+default version of the binaries and shared libraries.
+
+
+* Out-of-tree builds
+ ------------------
+
+ This package does not support out-of-tree builds. It
+is small, so it does not cost much to duplicate the entire
+source tree if parallel builds are needed.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0e68c25
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,87 @@
+#
+# This makefile requires make compliant with POSIX Issue 8.
+# It also reliably works with modern GNU make.
+# Do not make changes here.
+# Use the included .mak files.
+#
+
+.POSIX:
+
+IT = conferror
+
+-include config.mak
+
+it: $(IT)
+
+conferror:
+ @echo "Please use ./configure first." ; exit 1
+
+ALL_EXTRAS ::=
+INSTALL_EXTRAS ::=
+
+-include package/extras.mak
+
+include package/targets.mak
+include package/deps.mak
+
+INSTALL ::= ./tools/install.sh
+
+all: $(ALL_BINS) $(ALL_LIBS) $(ALL_EXTRAS)
+
+clean:
+ @exec rm -rf -- $(ALL_BINS) service source bundle etc
+
+distclean: clean
+ @exec rm -f -- config.mak
+
+tgz: distclean
+ @. package/info && \
+ rm -rf /tmp/$$package-$$version && \
+ cp -a . /tmp/$$package-$$version && \
+ cd /tmp && \
+ tar -zpcv --owner=0 --group=0 --numeric-owner --exclude=.git* -f /tmp/$$package-$$version.tar.gz $$package-$$version && \
+ exec rm -rf /tmp/$$package-$$version
+
+install: $(INSTALL_BINS) $(INSTALL_LIBS) $(INSTALL_EXTRAS)
+
+$(ALL_BINS) $(ALL_LIBS):
+ @test -z $$(dirname "$@") || mkdir -p -- $$(dirname "$@")
+ exec sed \
+ -e 's/@syslogdir@/$(syslogdir)/g' \
+ -e 's/@usrlogdir@/$(usrlogdir)/g' \
+ -e 's/@logdep@/$(logdep)/g' \
+ -e 's/@logconfig@/$(logconfig)/g' \
+ -e 's/@loguser@/$(loguser)/g' \
+ -e 's/@sysconfdir@/$(sysconfdir)/g' \
+ -e 's/@usrconfdir@/$(usrconfdir)/g' \
+ -e 's/@tmpfsdir@/$(tmpfsdir)/g' \
+ -e 's/@sysrundir@/$(sysrundir)/g' \
+ -e 's/@usrrundir@/$(usrrundir)/g' \
+ -e 's/@timeout@/$(timeout)/g' \
+ -e 's/@shebangdir@/$(shebangdir)/g' \
+ -- $^ > $@
+
+$(INSTALL_BINS) $(INSTALL_LIBS):
+ exec $(INSTALL) -D -m 644 $^ $@
+ grep -F -- $^ - < package/modes | { read name mode owner && \
+ if [ x$${mode} != x ] ; then chmod $${mode} $@ ; fi && \
+ if [ x$${owner} != x ] ; then chown -- $${owner} $@ ; fi ; } || exit 0
+
+
+$(DESTDIR)$(exthome):
+ exec $(INSTALL) -D -l $(package)-$(version) $@
+
+$(SLASHCOMMAND_BINS):
+ exec $(INSTALL) -D -l $(exthome)/command/$$(basename $@) $@
+
+update: $(DESTDIR)$(exthome)
+global-links: $(SLASHCOMMAND_BINS)
+
+uninstall:
+ exec rm -f $(INSTALL_BINS) $(SLASHCOMMAND_BINS)
+ exec rm -Rf $(libdir)
+
+.PHONY: \
+ it all clean distclean tgz update global-links \
+ install uninstall \
+ $(DESTDIR)$(exthome) $(SLASHCOMMAND_BINS)
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..843464f
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,6 @@
+Changelog for goetia-base.
+
+In 0.0.0.1
+----------
+
+ - Initial release
diff --git a/configure b/configure
new file mode 100755
index 0000000..5facfc0
--- /dev/null
+++ b/configure
@@ -0,0 +1,196 @@
+#!/bin/sh
+
+cd `dirname "$0"`
+. package/info
+
+usage () {
+cat </dev/null 2>&1 && { echo "$1" ; return 0 ; }
+$1
+EOF
+ echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g"
+}
+
+fail () {
+ echo "$*"
+ exit 1
+}
+
+fnmatch () {
+ eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac"
+}
+
+stripdir () {
+ while eval "fnmatch '*/' \"\${$1}\"" ; do
+ eval "$1=\${$1%/}"
+ done
+}
+
+escapeslash () {
+ echo "$1" | sed -e 's/\//\\\//g'
+}
+
+# Actual script
+
+prefix=
+exec_prefix='$prefix'
+bindir='$exec_prefix/bin'
+libdir='$prefix/lib/$package'
+
+shebangdir='$prefix/bin'
+
+syslogdir='$prefix/var/log/goetia'
+usrlogdir='.local/state/log'
+
+logconfig='n3 T'
+loguser='logger'
+logdep='mount'
+
+sysconfdir='$prefix/etc/goetia/system'
+usrconfdir='.config/goetia'
+
+tmpfsdir='$prefix/run'
+sysrundir='system'
+usrrundir='user'
+
+timeout=60000
+
+slashpackage=false
+sproot=
+home=
+exthome=
+build=
+
+for arg ; do
+ case "$arg" in
+ --help) usage ;;
+ --prefix=*) prefix=${arg#*=} ;;
+ --exec-prefix=*) exec_prefix=${arg#*=} ;;
+ --bindir=*) bindir=${arg#*=} ;;
+ --libdir=*) libdir=${arg#*=} ;;
+ --shebangdir=*) shebangdir=${arg#*=} ;;
+ --syslogdir=*) syslogdir=${arg#*=} ;;
+ --usrlogdir=*) usrlogdir=${arg#*=} ;;
+ --logconfig=*) logconfig=${arg#*=} ;;
+ --loguser=*) loguser=${arg#*=} ;;
+ --logdep=*) logdep=${arg#*=} ;;
+ --sysconfdir=*) sysconfdir=${arg#*=} ;;
+ --usrconfdir=*) usrconfdir=${arg#*=} ;;
+ --tmpfsdir=*) tmpfsdir=${arg#*=} ;;
+ --sysrundir=*) sysrundir=${arg#*=} ;;
+ --usrrundir=*) usrrundir=${arg#*=} ;;
+ --timeout=*) timeout=${arg#*=} ;;
+ --enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;;
+ --enable-slashpackage) sproot= ; slashpackage=true ;;
+ --disable-slashpackage) sproot= ; installtype=fhs ;;
+ --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
+ -* ) echo "$0: unknown option $arg" ;;
+ *=*) eval "${arg%%=*}=\${arg#*=}" ;;
+ *) target=$arg ;;
+ esac
+done
+
+# Expand installation directories
+stripdir prefix
+for i in exec_prefix bindir libdir shebangdir syslogdir usrlogdir sysconfdir usrconfdir tmpfsdir sysrundir usrrundir sproot ; do
+ eval tmp=\${$i}
+ eval $i=$tmp
+ stripdir $i
+done
+
+# Set slashpackage values
+if $slashpackage ; then
+ home=${sproot}/package/${category}/${package}-${version}
+ exthome=${sproot}/package/${category}/${package}
+ extbinprefix=${exthome}/command
+ bindir=${home}/command
+ libdir=${home}
+fi
+
+echo "Creating config.mak..."
+cmdline=$(quote "$0")
+for i ; do cmdline="$cmdline $(quote "$i")" ; done
+exec 3>&1 1>config.mak
+cat << EOF
+# This file was generated by:
+# $cmdline
+# Any changes made here will be lost if configure is re-run.
+
+IT ::= all
+
+package ::= $package
+prefix ::= $prefix
+exec_prefix ::= $exec_prefix
+bindir ::= $bindir
+libdir ::= $libdir
+shebangdir ::= $(escapeslash "$shebangdir")
+syslogdir ::= $(escapeslash "$syslogdir")
+usrlogdir ::= $(escapeslash "$usrlogdir")
+logconfig ::= $(escapeslash "$logconfig")
+loguser ::= $(escapeslash "$loguser")
+logdep ::= $(escapeslash "$logdep")
+sysconfdir ::= $(escapeslash "$sysconfdir")
+usrconfdir ::= $(escapeslash "$usrconfdir")
+tmpfsdir ::= $(escapeslash "$tmpfsdir")
+sysrundir ::= $(escapeslash "$sysrundir")
+usrrundir ::= $(escapeslash "$usrrundir")
+timeout ::= $timeout
+slashpackage ::= $slashpackage
+sproot ::= $sproot
+version ::= $version
+home ::= $home
+exthome ::= $exthome
+EOF
+
+exec 1>&3 3>&-
+echo " ... done."
diff --git a/package/deps.mak b/package/deps.mak
new file mode 100644
index 0000000..0608555
--- /dev/null
+++ b/package/deps.mak
@@ -0,0 +1,16 @@
+#
+# This file has been generated by tools/gen-deps.sh
+#
+
+system-init: src/bin/system-init
+$(DESTDIR)$(bindir)/system-init: system-init
+system-shutdown: src/bin/system-shutdown
+$(DESTDIR)$(bindir)/system-shutdown: system-shutdown
+service/system/goetia-shutdown/run: src/lib/service/system/goetia-shutdown/run
+$(DESTDIR)$(libdir)/service/system/goetia-shutdown/run: service/system/goetia-shutdown/run
+service/system/goetia-shutdown/stage3b: src/lib/service/system/goetia-shutdown/stage3b
+$(DESTDIR)$(libdir)/service/system/goetia-shutdown/stage3b: service/system/goetia-shutdown/stage3b
+service/system/goetia-shutdown/down: src/lib/service/system/goetia-shutdown/down
+$(DESTDIR)$(libdir)/service/system/goetia-shutdown/down: service/system/goetia-shutdown/down
+service/system/goetia-shutdown/stage4: src/lib/service/system/goetia-shutdown/stage4
+$(DESTDIR)$(libdir)/service/system/goetia-shutdown/stage4: service/system/goetia-shutdown/stage4
diff --git a/package/info b/package/info
new file mode 100644
index 0000000..e872a8d
--- /dev/null
+++ b/package/info
@@ -0,0 +1,4 @@
+package=goetia-freebsd-init
+version=0.0.0.1
+category=admin
+package_macro_name=GOETIA-FREEBSD-INIT
diff --git a/package/modes b/package/modes
new file mode 100644
index 0000000..1a7a245
--- /dev/null
+++ b/package/modes
@@ -0,0 +1,6 @@
+goetia-pam-wrapper 0755
+system-init 0755
+system-shutdown 0755
+
+service/system/getty-12-srv/run 0755
+service/system/goetia-shutdown/run 0755
diff --git a/package/targets.mak b/package/targets.mak
new file mode 100644
index 0000000..17eb540
--- /dev/null
+++ b/package/targets.mak
@@ -0,0 +1,28 @@
+#
+# This file has been generated by tools/gen-targets.sh
+#
+
+ALL_BINS ::= \
+ system-init \
+ system-shutdown \
+
+INSTALL_BINS ::= \
+ $(DESTDIR)$(bindir)/system-init \
+ $(DESTDIR)$(bindir)/system-shutdown \
+
+SLASHCOMMAND_BINS ::= \
+ $(DESTDIR)$(sproot)/command/system-init \
+ $(DESTDIR)$(sproot)/command/system-shutdown \
+
+ALL_LIBS ::= \
+ service/system/goetia-shutdown/run \
+ service/system/goetia-shutdown/stage3b \
+ service/system/goetia-shutdown/down \
+ service/system/goetia-shutdown/stage4 \
+
+INSTALL_LIBS ::= \
+ $(DESTDIR)$(libdir)/service/system/goetia-shutdown/run \
+ $(DESTDIR)$(libdir)/service/system/goetia-shutdown/stage3b \
+ $(DESTDIR)$(libdir)/service/system/goetia-shutdown/down \
+ $(DESTDIR)$(libdir)/service/system/goetia-shutdown/stage4 \
+
diff --git a/src/bin/system-init b/src/bin/system-init
new file mode 100755
index 0000000..59ca114
--- /dev/null
+++ b/src/bin/system-init
@@ -0,0 +1,29 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+redirfd -a 1 /dev/console
+redirfd -a 2 /dev/console
+
+multisubstitute {
+ importas -SD default BUNDLE
+ importas -SD
+ /command:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/libexec:/usr/local/libexec
+ PATH
+}
+export PATH ${PATH}
+
+execline-cd /
+s6-setsid
+
+if { mount -t tmpfs -o mode=0755 tmpfs @tmpfsdir@ }
+
+prepare-svscan
+ @sysconfdir@
+ @tmpfsdir@/@sysrundir@
+ ${BUNDLE}
+
+foreground { mkdir -p -- @tmpfsdir@/@sysrundir@/log }
+foreground { cp -Rpf -- @syslogdir@/uncaught-logs @tmpfsdir@/@sysrundir@/log/ }
+
+s6-svscan @tmpfsdir@/@sysrundir@/service
diff --git a/src/bin/system-shutdown b/src/bin/system-shutdown
new file mode 100755
index 0000000..53b2d4b
--- /dev/null
+++ b/src/bin/system-shutdown
@@ -0,0 +1,14 @@
+#!@shebangdir@/execlineb -s0
+
+# ISC license.
+
+ifelse { eltest \\\\${@} =~ ^-[hpr]$ } {
+ if { mkdir -p @tmpfsdir@/@sysrundir@/shutdown-directive }
+ if {
+ redirfd -w 1 @tmpfsdir@/@sysrundir@/shutdown-directive/DIRECTIVE
+ echo ${@}
+ }
+ s6-svc -U @tmpfsdir@/@sysrundir@/service/goetia-shutdown
+}
+if { echo "system-shutdown: usage: system-shutdown -h | -p | -r" }
+exit 100
diff --git a/src/lib/service/system/goetia-shutdown/down b/src/lib/service/system/goetia-shutdown/down
new file mode 100644
index 0000000..e69de29
diff --git a/src/lib/service/system/goetia-shutdown/run b/src/lib/service/system/goetia-shutdown/run
new file mode 100755
index 0000000..32f37fe
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/run
@@ -0,0 +1,7 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+fdmove -c 2 1
+
+system-shutdown-daemon
diff --git a/src/lib/service/system/goetia-shutdown/stage3b b/src/lib/service/system/goetia-shutdown/stage3b
new file mode 100644
index 0000000..3daf81f
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/stage3b
@@ -0,0 +1,14 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+if -n {
+ tryexec { ./stage4 }
+ foreground { chmod u+x stage4 }
+
+ foreground { kill -SIGCONT -- -1 }
+ foreground { sleep 1 }
+ foreground { echo sending all processes the KILL signal... }
+ foreground { kill -SIGKILL -- -1 }
+}
+chmod a-x stage3b stage4
diff --git a/src/lib/service/system/goetia-shutdown/stage4 b/src/lib/service/system/goetia-shutdown/stage4
new file mode 100644
index 0000000..d8e8bcc
--- /dev/null
+++ b/src/lib/service/system/goetia-shutdown/stage4
@@ -0,0 +1,14 @@
+#!@shebangdir@/execlineb -P
+
+# ISC license.
+
+if -n {
+ s6-envdir -I @tmpfsdir@/@sysrundir@/shutdown-directive
+ importas -SD "-r" DIRECTIVE
+
+ foreground { umount -A }
+ foreground { mount -ur / }
+
+ shutdown -o ${DIRECTIVE} now
+}
+chmod a-x stage3b stage4
diff --git a/tools/gen-deps.sh b/tools/gen-deps.sh
new file mode 100755
index 0000000..fafb347
--- /dev/null
+++ b/tools/gen-deps.sh
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+. package/info
+
+echo '#'
+echo '# This file has been generated by tools/gen-deps.sh'
+echo '#'
+echo
+
+if test -d src/bin
+then
+ cd src/bin
+ for FILE in $(find * -type f 2> /dev/null); do
+ echo "${FILE}: src/bin/${FILE}"
+ echo "\$(DESTDIR)\$(bindir)/${FILE}: ${FILE}"
+ done
+ cd ../..
+fi
+
+if test -d src/lib
+then
+ cd src/lib
+ for FILE in $(find * -type f 2> /dev/null); do
+ echo "${FILE}: src/lib/${FILE}"
+ echo "\$(DESTDIR)\$(libdir)/${FILE}: ${FILE}"
+ done
+ cd ../..
+fi
+
+if test -f package/extras
+then
+ for EXTRA in $(cat package/extras); do
+ echo "\$(DESTDIR)\$(libdir)/${EXTRA}: ${EXTRA}"
+ done
+fi
diff --git a/tools/gen-targets.sh b/tools/gen-targets.sh
new file mode 100755
index 0000000..3280748
--- /dev/null
+++ b/tools/gen-targets.sh
@@ -0,0 +1,56 @@
+#!/bin/sh -e
+
+. package/info
+
+echo '#'
+echo '# This file has been generated by tools/gen-targets.sh'
+echo '#'
+echo
+
+if test -d src/bin
+then
+ cd src/bin
+
+ echo "ALL_BINS ::= \\"
+
+ for FILE in $(find * -type f 2> /dev/null) ; do
+ echo "\t${FILE} \\"
+ done
+
+ echo
+ echo "INSTALL_BINS ::= \\"
+
+ for FILE in $(find * -type f 2> /dev/null) ; do
+ echo "\t\$(DESTDIR)\$(bindir)/${FILE} \\"
+ done
+
+ echo
+ echo "SLASHCOMMAND_BINS ::= \\"
+
+ for FILE in $(find * -type f 2> /dev/null) ; do
+ echo "\t\$(DESTDIR)\$(sproot)/command/${FILE} \\"
+ done
+
+ cd ../..
+ echo
+fi
+
+if test -d src/lib
+then
+ cd src/lib
+
+ echo "ALL_LIBS ::= \\"
+ for FILE in $(find * -type f 2> /dev/null) ; do
+ echo "\t${FILE} \\"
+ done
+
+ echo
+
+ echo "INSTALL_LIBS ::= \\"
+ for FILE in $(find * -type f 2> /dev/null) ; do
+ echo "\t\$(DESTDIR)\$(libdir)/${FILE} \\"
+ done
+
+ cd ../..
+ echo
+fi
diff --git a/tools/install.sh b/tools/install.sh
new file mode 100755
index 0000000..e96dd7b
--- /dev/null
+++ b/tools/install.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+usage() {
+ echo "usage: $0 [ -D ] [ -l ] [ -m mode ] [ -O owner:group ] src dst" 1>&2
+ exit 1
+}
+
+mkdirp=false
+symlink=false
+mode=0755
+og=
+
+while getopts Dlm:O: name ; do
+ case "$name" in
+ D) mkdirp=true ;;
+ l) symlink=true ;;
+ m) mode=$OPTARG ;;
+ O) og=$OPTARG ;;
+ ?) usage ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+test "$#" -eq 2 || usage
+src=$1
+dst=$2
+tmp="$dst.tmp.$$"
+
+case "$dst" in
+ */) echo "$0: $dst ends in /" 1>&2 ; exit 1 ;;
+esac
+
+set -C
+set -e
+
+if $mkdirp ; then
+ umask 022
+ case "$2" in
+ */*) mkdir -p "${dst%/*}" ;;
+ esac
+fi
+
+trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP
+
+umask 077
+
+if $symlink ; then
+ ln -s "$src" "$tmp"
+else
+ cat < "$1" > "$tmp"
+ if test -n "$og" ; then
+ chown -- "$og" "$tmp"
+ fi
+ chmod -- "$mode" "$tmp"
+fi
+
+mv -f "$tmp" "$dst"
+if test -d "$dst" ; then
+ rm -f "$dst/$(basename $tmp)"
+ if $symlink ; then
+ mkdir "$tmp"
+ ln -s "$src" "$tmp/$(basename $dst)"
+ mv -f "$tmp/$(basename $dst)" "${dst%/*}"
+ rmdir "$tmp"
+ else
+ echo "$0: $dst is a directory" 1>&2
+ exit 1
+ fi
+fi
--
cgit v1.2.3