From f44e84ee528b07fb61ddc5a791968ac1c5589554 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Wed, 29 Dec 2021 23:46:58 -0500 Subject: [PATCH 01/15] Initial commit --- lsd/dist/documentation/trinitx.7 | 49 ++++++++++++++++++++++++++++++++ lsd/dist/install | 20 +++++++++++++ lsd/dist/macro.sh | 31 ++++++++++++++++++++ lsd/dist/sync_musl | 14 +++++++++ lsd/dist/trinitx | 11 +++++++ 5 files changed, 125 insertions(+) create mode 100644 lsd/dist/documentation/trinitx.7 create mode 100755 lsd/dist/install create mode 100644 lsd/dist/macro.sh create mode 100644 lsd/dist/sync_musl create mode 100755 lsd/dist/trinitx diff --git a/lsd/dist/documentation/trinitx.7 b/lsd/dist/documentation/trinitx.7 new file mode 100644 index 0000000..8038026 --- /dev/null +++ b/lsd/dist/documentation/trinitx.7 @@ -0,0 +1,49 @@ +.TH TRINITX 7 + +.SH PRONUNCIATION + +Trinity, but replace the final syllable with tech. + +.SH SYNOPSIS + +.I Trinitx +is a UNIX-like software distribution built upon the Linux kernel and the +musl C standard library, with nearly all configuration options left to the +user's own device. + +.SH BASE SYSTEM + +.I Trinitx +explicitly relies on the existence of the following programs and +packages: +dash(1), +ftp(1), +the GNU compiler collection, +GNU make, +musl, +linux, +bsdtar(1), +and util-linux. +.PP +In addition, +.I Trinitx +needs a core utilities package. +The GNU coreutils are a popular choice but Busybox or your own may be used. +.PP +.I Trinitx +also needs an initialization system. +OpenRC is the suggested choice but others may be used. +SystemD is discouraged; it's mentioned for its popularity and frowned upon for +its generally lax security. + +.SH HISTORY + +The +.I Trinitx +project was started 2021-12-28. + +.SH COPYRIGHT + +.I Trinitx +documentation and all in-house tools are part of the public domain. +Components of the distribution are of course subject to their own licenses. diff --git a/lsd/dist/install b/lsd/dist/install new file mode 100755 index 0000000..7517d25 --- /dev/null +++ b/lsd/dist/install @@ -0,0 +1,20 @@ +#!/bin/true +set -e + +depend_on cd +depend_on mkdir +depend_on nonzero +depend_on test + +if ! nonzero "$PREFIX"; then + printf 'Please select a $PREFIX for installation. +For example, "PREFIX=/ %s".\n' "$0" 1>&2 + exit 1 +fi + +# constant definitions +MUSL_UPSTREAM="git://git.musl-libc.org/musl" + +argv0="$0" + +trinitx sync_musl diff --git a/lsd/dist/macro.sh b/lsd/dist/macro.sh new file mode 100644 index 0000000..0a82a0d --- /dev/null +++ b/lsd/dist/macro.sh @@ -0,0 +1,31 @@ +#!/bin/true + +# constant definitions +MUSL_UPSTREAM="git://git.musl-libc.org/musl" + +depend_on(){ + ! command -v "$1" >/dev/null \ + && printf "Missing %s.\n" "$1" 1>&2 \ + && exit 1 \ + || true +} + +fetch_upstream(){ + url="$1" + scheme="$(scheme_from_uri "$url")" + case "$scheme" in + git) + git clone "$url" + ;; + *) + printf "%s: Invalid upstream URL %s (scheme is %s)\n" \ + "$argv0" "$1" "$scheme" + exit 1 + esac +} + +scheme_from_uri(){ + # There are no colons in scheme names and no ways to separate schemes + # from scheme-specific content without colons (RFC 3986). + printf "%s\n" "$1" | cut -d ':' -f 1 +} diff --git a/lsd/dist/sync_musl b/lsd/dist/sync_musl new file mode 100644 index 0000000..ccd4b33 --- /dev/null +++ b/lsd/dist/sync_musl @@ -0,0 +1,14 @@ +#!/bin/true +set -e + +depend_on cd +depend_on make +depend_on mkdir + +mkdir -p "$PREFIX/src" +cd "$PREFIX/src" + +fetch_upstream "$MUSL_UPSTREAM" +cd "$PREFIX/src/musl" +./configure --prefix="$PREFIX" +make install diff --git a/lsd/dist/trinitx b/lsd/dist/trinitx new file mode 100755 index 0000000..0a03993 --- /dev/null +++ b/lsd/dist/trinitx @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ -z "$PREFIX" ]; then + printf 'Please select a $PREFIX for installation. +For example, "PREFIX=/ %s".\n' "$0" 1>&2 + exit 1 +fi + +cd "$PREFIX"/dist +. ./macro.sh +. ./"$1" From 30eab38539b39a1e85fdb0f456cf585bad72de8a Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Wed, 29 Dec 2021 23:56:03 -0500 Subject: [PATCH 02/15] clean crud --- lsd/dist/install | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lsd/dist/install b/lsd/dist/install index 7517d25..7cf5ebd 100755 --- a/lsd/dist/install +++ b/lsd/dist/install @@ -1,10 +1,7 @@ #!/bin/true set -e -depend_on cd -depend_on mkdir depend_on nonzero -depend_on test if ! nonzero "$PREFIX"; then printf 'Please select a $PREFIX for installation. @@ -12,9 +9,4 @@ For example, "PREFIX=/ %s".\n' "$0" 1>&2 exit 1 fi -# constant definitions -MUSL_UPSTREAM="git://git.musl-libc.org/musl" - -argv0="$0" - -trinitx sync_musl +. ./sync_musl From 54832e65bc32750be47e0ae3a2bc72535ec74d3c Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Wed, 29 Dec 2021 23:58:37 -0500 Subject: [PATCH 03/15] it works now --- lsd/dist/sync_musl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lsd/dist/sync_musl b/lsd/dist/sync_musl index ccd4b33..8da240c 100644 --- a/lsd/dist/sync_musl +++ b/lsd/dist/sync_musl @@ -8,7 +8,10 @@ depend_on mkdir mkdir -p "$PREFIX/src" cd "$PREFIX/src" -fetch_upstream "$MUSL_UPSTREAM" +if [ -d musl ] +then cd musl; git pull +else fetch_upstream "$MUSL_UPSTREAM"; fi + cd "$PREFIX/src/musl" ./configure --prefix="$PREFIX" make install From a98278a541e94a3f1460b573046dacc1c9945884 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Thu, 30 Dec 2021 00:02:44 -0500 Subject: [PATCH 04/15] UNLICENSE --- lsd/LICENSE | 24 ++++++++++++++++++++++++ lsd/dist/unrepo | 4 ++++ 2 files changed, 28 insertions(+) create mode 100644 lsd/LICENSE create mode 100644 lsd/dist/unrepo diff --git a/lsd/LICENSE b/lsd/LICENSE new file mode 100644 index 0000000..68a49da --- /dev/null +++ b/lsd/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/lsd/dist/unrepo b/lsd/dist/unrepo new file mode 100644 index 0000000..e74d56c --- /dev/null +++ b/lsd/dist/unrepo @@ -0,0 +1,4 @@ +#!/bin/true + +rm -rf "$PREFIX/.git" +rm -f "$PREFIX/LICENSE" From ca348329f106a2d92417fbf5f48d8b8faeb0f9d7 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Thu, 30 Dec 2021 10:06:52 -0500 Subject: [PATCH 05/15] Rename --- lsd/dist/config.sh | 3 + .../documentation/{trinitx.7 => trilsd.7} | 39 ++++++++----- lsd/dist/documentation/try.1 | 55 +++++++++++++++++++ lsd/dist/install | 2 +- lsd/dist/macro.sh | 8 +-- lsd/dist/sync_musl | 2 +- lsd/dist/{trinitx => try} | 0 lsd/dist/unrepo | 4 +- 8 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 lsd/dist/config.sh rename lsd/dist/documentation/{trinitx.7 => trilsd.7} (59%) create mode 100644 lsd/dist/documentation/try.1 rename lsd/dist/{trinitx => try} (100%) diff --git a/lsd/dist/config.sh b/lsd/dist/config.sh new file mode 100644 index 0000000..9d09e0a --- /dev/null +++ b/lsd/dist/config.sh @@ -0,0 +1,3 @@ +#!/bin/false + +MUSL_UPSTREAM="git://git.musl-libc.org/musl" diff --git a/lsd/dist/documentation/trinitx.7 b/lsd/dist/documentation/trilsd.7 similarity index 59% rename from lsd/dist/documentation/trinitx.7 rename to lsd/dist/documentation/trilsd.7 index 8038026..2a7ec4e 100644 --- a/lsd/dist/documentation/trinitx.7 +++ b/lsd/dist/documentation/trilsd.7 @@ -1,19 +1,16 @@ .TH TRINITX 7 .SH PRONUNCIATION - -Trinity, but replace the final syllable with tech. +"Try LSD" .SH SYNOPSIS - -.I Trinitx +.I TriLSD is a UNIX-like software distribution built upon the Linux kernel and the musl C standard library, with nearly all configuration options left to the user's own device. .SH BASE SYSTEM - -.I Trinitx +.I TriLSD explicitly relies on the existence of the following programs and packages: dash(1), @@ -26,24 +23,40 @@ bsdtar(1), and util-linux. .PP In addition, -.I Trinitx +.I TriLSD needs a core utilities package. The GNU coreutils are a popular choice but Busybox or your own may be used. .PP -.I Trinitx +.I TriLSD also needs an initialization system. OpenRC is the suggested choice but others may be used. SystemD is discouraged; it's mentioned for its popularity and frowned upon for its generally lax security. -.SH HISTORY +.SH PACKAGE MANAGEMENT +.I TriLSD +does not come with a package manager; the user may choose whatever +system-independent package manager they prefer. +.PP +Certain system tools that aren't necessarily packaged in system-independent +package managers (pkgsrc comes to mind) can be updated with the +.RB try (1) +command. +.SH CONTRIBUTING +Pay attention to projects' guidelines for distributions. +.PP +musl guidelines: https://wiki.musl-libc.org/guidelines-for-distributions.html + +.SH HISTORY The -.I Trinitx -project was started 2021-12-28. +.I TriLSD +project was started 2021-12-28 as Trinitx. .SH COPYRIGHT - -.I Trinitx +.I TriLSD documentation and all in-house tools are part of the public domain. Components of the distribution are of course subject to their own licenses. + +.SH SEE ALSO +.RB try (1) diff --git a/lsd/dist/documentation/try.1 b/lsd/dist/documentation/try.1 new file mode 100644 index 0000000..41145af --- /dev/null +++ b/lsd/dist/documentation/try.1 @@ -0,0 +1,55 @@ +.TH TRINITX 1 + +.SH NAME +try \- distribution management + +.SH SYNOPSIS +.B try +.RB { install , sync_musl , unrepo } + +.SH DESCRIPTION +.I try +exists to conduct system tasks normally conducted by operating systems +themselves and for which there's no easy alternative (though the system is not +tightly coupled with these utilities and they can easily be replaced). + +.SH FUNCTIONS +.SS INSTALL +Installs the software distribution base into an environment variable specified +prefix. If +.I install +is not called in the form +.IP +\fCPREFIX=/ try install\fP +.LP +it will print a diagnostic message and exit; PREFIX must not be empty. + +.SS SYNC_MUSL +Fetches musl from the upstream source and installs it into the PREFIX. PREFIX +may not be specified but behavior will be unspecified (probably function as if +PREFIX is '/') if it's not. + +.SS UNREPO +Deletes git repository files from PREFIX if they exist; this is a +post-installation task and need only be performed once. PREFIX may not be +specified; if it isn't, it'll function as if PREFIX is '/'. + +.SH CONFIGURATION +.I try +may be configured via +.B config.sh +in the same directory. + +.SH LOCATIONS +.I try +distribution-specific files are always located in $PREFIX/dist. +For example, the +.I try +script is always at $PREFIX/dist/try, and configuration is always at +$PREFIX/dist/config.sh. + +.SH COPYRIGHT +Public domain. + +.SH SEE ALSO +.RB trilsd (7) diff --git a/lsd/dist/install b/lsd/dist/install index 7cf5ebd..2d435c2 100755 --- a/lsd/dist/install +++ b/lsd/dist/install @@ -1,4 +1,4 @@ -#!/bin/true +#!/bin/false set -e depend_on nonzero diff --git a/lsd/dist/macro.sh b/lsd/dist/macro.sh index 0a82a0d..f2813ca 100644 --- a/lsd/dist/macro.sh +++ b/lsd/dist/macro.sh @@ -1,7 +1,4 @@ -#!/bin/true - -# constant definitions -MUSL_UPSTREAM="git://git.musl-libc.org/musl" +#!/bin/false depend_on(){ ! command -v "$1" >/dev/null \ @@ -15,6 +12,7 @@ fetch_upstream(){ scheme="$(scheme_from_uri "$url")" case "$scheme" in git) + depend_on git git clone "$url" ;; *) @@ -24,6 +22,8 @@ fetch_upstream(){ esac } +depend_on cut + scheme_from_uri(){ # There are no colons in scheme names and no ways to separate schemes # from scheme-specific content without colons (RFC 3986). diff --git a/lsd/dist/sync_musl b/lsd/dist/sync_musl index 8da240c..e086230 100644 --- a/lsd/dist/sync_musl +++ b/lsd/dist/sync_musl @@ -1,4 +1,4 @@ -#!/bin/true +#!/bin/false set -e depend_on cd diff --git a/lsd/dist/trinitx b/lsd/dist/try similarity index 100% rename from lsd/dist/trinitx rename to lsd/dist/try diff --git a/lsd/dist/unrepo b/lsd/dist/unrepo index e74d56c..3ecb9a2 100644 --- a/lsd/dist/unrepo +++ b/lsd/dist/unrepo @@ -1,4 +1,6 @@ -#!/bin/true +#!/bin/false + +depend_on rm rm -rf "$PREFIX/.git" rm -f "$PREFIX/LICENSE" From 93bb2e8ab6e2a6b5a0f0d9b68fc2a6c12075c4af Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sun, 9 Jan 2022 11:29:17 -0500 Subject: [PATCH 06/15] README --- lsd/README.md | 5 +++++ lsd/dist/unrepo | 1 + 2 files changed, 6 insertions(+) create mode 100644 lsd/README.md diff --git a/lsd/README.md b/lsd/README.md new file mode 100644 index 0000000..0d1fe9f --- /dev/null +++ b/lsd/README.md @@ -0,0 +1,5 @@ +# trilsd + +*trinity's linux software distribution* + +See `/dist/documentation/trilsd.7'. diff --git a/lsd/dist/unrepo b/lsd/dist/unrepo index 3ecb9a2..ca9e9a6 100644 --- a/lsd/dist/unrepo +++ b/lsd/dist/unrepo @@ -4,3 +4,4 @@ depend_on rm rm -rf "$PREFIX/.git" rm -f "$PREFIX/LICENSE" +rm -f "$PREFIX/README.md" From 752110b0dfd1f2ec68c7affb343153fb51532eb0 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Tue, 25 Jan 2022 10:56:40 -0500 Subject: [PATCH 07/15] Filesystem Hierarchy Standard --- lsd/dist/config.sh | 2 ++ lsd/dist/fhs | 85 ++++++++++++++++++++++++++++++++++++++++++++++ lsd/dist/install | 12 ++++++- lsd/dist/sync_musl | 5 ++- lsd/dist/try | 6 ++-- 5 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 lsd/dist/fhs diff --git a/lsd/dist/config.sh b/lsd/dist/config.sh index 9d09e0a..fdb6c9c 100644 --- a/lsd/dist/config.sh +++ b/lsd/dist/config.sh @@ -1,3 +1,5 @@ #!/bin/false +GCC_UPSTREAM="git://gcc.gnu.org/git/gcc.git" MUSL_UPSTREAM="git://git.musl-libc.org/musl" +PKGSRC_UPSTREAM="https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz" diff --git a/lsd/dist/fhs b/lsd/dist/fhs new file mode 100644 index 0000000..1378d4d --- /dev/null +++ b/lsd/dist/fhs @@ -0,0 +1,85 @@ +#!/bin/false + +# Filesystem Hierarchy Standard 3.0, 2015 +# https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf + +# section 3.2 +mkdir -p "$PREFIX/bin" +mkdir -p "$PREFIX/boot" +mkdir -p "$PREFIX/dev" +mkdir -p "$PREFIX/etc" +mkdir -p "$PREFIX/lib" +mkdir -p "$PREFIX/media" +mkdir -p "$PREFIX/mnt" +mkdir -p "$PREFIX/opt" +mkdir -p "$PREFIX/run" +mkdir -p "$PREFIX/sbin" +mkdir -p "$PREFIX/srv" +mkdir -p "$PREFIX/tmp" +mkdir -p "$PREFIX/usr" +mkdir -p "$PREFIX/var" + +# section 3.7.4 +mkdir -p "$PREFIX/etc/opt" + +# section 4.2 +mkdir -p "$PREFIX/usr/bin" +mkdir -p "$PREFIX/usr/lib" +mkdir -p "$PREFIX/usr/local" +mkdir -p "$PREFIX/usr/sbin" +mkdir -p "$PREFIX/usr/share" + +# section 4.3 +mkdir -p "$PREFIX/usr/include" +ln -s "$PREFIX/usr/spool" "$PREFIX/var/spool" +ln -s "$PREFIX/usr/tmp" "$PREFIX/var/tmp" +ln -s "$PREFIX/usr/spool/locks" "$PREFIX/var/lock" + +# section 4.6 +mkdir -p "$PREFIX/usr/lib" + +# section 4.9 +mkdir -p "$PREFIX/usr/local" + +# section 4.9.2 +mkdir -p "$PREFIX/usr/local/bin" +#mkdir -p "$PREFIX/usr/local/etc" # see section 4.9.3 +mkdir -p "$PREFIX/usr/local/games" +mkdir -p "$PREFIX/usr/local/include" +mkdir -p "$PREFIX/usr/local/lib" +mkdir -p "$PREFIX/usr/local/man" +mkdir -p "$PREFIX/usr/local/sbin" +mkdir -p "$PREFIX/usr/local/share" +mkdir -p "$PREFIX/usr/local/src" + +# section 4.9.3 +ln -s "$PREFIX/usr/local/etc" "$PREFIX/etc/local" + +# section 4.11.6 +mkdir -p "$PREFIX/usr/share/man" + +# section 4.11.7 +mkdir -p "$PREFIX/usr/share/misc" + +# section 4.12 +mkdir -p "$PREFIX/usr/src" + +# section 5.2 +mkdir -p "$PREFIX/var/cache" +mkdir -p "$PREFIX/var/lib" +mkdir -p "$PREFIX/var/local" +mkdir -p "$PREFIX/var/lock" +mkdir -p "$PREFIX/var/log" +mkdir -p "$PREFIX/var/opt" +#mkdir -p "$PREFIX/var/run" # see section 5.13.2 +mkdir -p "$PREFIX/var/spool" +mkdir -p "$PREFIX/var/tmp" + +# section 5.8.2 +mkdir -p "$PREFIX/var/lib/misc" + +# section 5.13.2 +ln -s "$PREFIX/var/run" "$PREFIX/run" + +# section 6.1.10 +mkdir -p "$PREFIX/var/spool/cron" diff --git a/lsd/dist/install b/lsd/dist/install index 2d435c2..f3438e8 100755 --- a/lsd/dist/install +++ b/lsd/dist/install @@ -9,4 +9,14 @@ For example, "PREFIX=/ %s".\n' "$0" 1>&2 exit 1 fi -. ./sync_musl +. "$PREFIX/dist/unrepo" +. "$PREFIX/dist/fhs" +. "$PREFIX/dist/sync_musl" + +cd "$PREFIX/usr/src" +if [ -d gcc ]; then + cd gcc + git pull +else + fetch_upstream "$GCC_UPSTREAM" +fi diff --git a/lsd/dist/sync_musl b/lsd/dist/sync_musl index e086230..37f5a72 100644 --- a/lsd/dist/sync_musl +++ b/lsd/dist/sync_musl @@ -5,13 +5,12 @@ depend_on cd depend_on make depend_on mkdir -mkdir -p "$PREFIX/src" -cd "$PREFIX/src" +cd "$PREFIX/usr/src" if [ -d musl ] then cd musl; git pull else fetch_upstream "$MUSL_UPSTREAM"; fi -cd "$PREFIX/src/musl" +cd "$PREFIX/usr/src/musl" ./configure --prefix="$PREFIX" make install diff --git a/lsd/dist/try b/lsd/dist/try index 0a03993..5ed111e 100755 --- a/lsd/dist/try +++ b/lsd/dist/try @@ -6,6 +6,6 @@ For example, "PREFIX=/ %s".\n' "$0" 1>&2 exit 1 fi -cd "$PREFIX"/dist -. ./macro.sh -. ./"$1" +. "$PREFIX/dist/config.sh" +. "$PREFIX/dist/macro.sh" +. "$PREFIX/dist/$1" From e278cee0d93c11ffb9c7f74788b2cb46e2b6ef1d Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Tue, 25 Jan 2022 12:45:03 -0500 Subject: [PATCH 08/15] destroy --- lsd/dist/destroy | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 lsd/dist/destroy diff --git a/lsd/dist/destroy b/lsd/dist/destroy new file mode 100644 index 0000000..953d2e0 --- /dev/null +++ b/lsd/dist/destroy @@ -0,0 +1,4 @@ +#!/bin/false + +cd "$PREFIX" +git clean -f -d From bb2ed71aaf741a3f34d7e1b0311347938173b707 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Tue, 25 Jan 2022 12:45:59 -0500 Subject: [PATCH 09/15] fix permissions --- lsd/dist/fhs | 6 +++--- lsd/dist/install | 0 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 lsd/dist/install diff --git a/lsd/dist/fhs b/lsd/dist/fhs index 1378d4d..c656dd0 100644 --- a/lsd/dist/fhs +++ b/lsd/dist/fhs @@ -31,6 +31,9 @@ mkdir -p "$PREFIX/usr/share" # section 4.3 mkdir -p "$PREFIX/usr/include" +mkdir -p "$PREFIX/var/spool" +mkdir -p "$PREFIX/var/tmp" +mkdir -p "$PREFIX/var/lock" ln -s "$PREFIX/usr/spool" "$PREFIX/var/spool" ln -s "$PREFIX/usr/tmp" "$PREFIX/var/tmp" ln -s "$PREFIX/usr/spool/locks" "$PREFIX/var/lock" @@ -68,12 +71,9 @@ mkdir -p "$PREFIX/usr/src" mkdir -p "$PREFIX/var/cache" mkdir -p "$PREFIX/var/lib" mkdir -p "$PREFIX/var/local" -mkdir -p "$PREFIX/var/lock" mkdir -p "$PREFIX/var/log" mkdir -p "$PREFIX/var/opt" #mkdir -p "$PREFIX/var/run" # see section 5.13.2 -mkdir -p "$PREFIX/var/spool" -mkdir -p "$PREFIX/var/tmp" # section 5.8.2 mkdir -p "$PREFIX/var/lib/misc" diff --git a/lsd/dist/install b/lsd/dist/install old mode 100755 new mode 100644 From 1a74221122771815e01e14fdc7e91dd12070709b Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Tue, 25 Jan 2022 12:48:32 -0500 Subject: [PATCH 10/15] unrepoing during install could make testing a little difficult --- lsd/dist/install | 1 - 1 file changed, 1 deletion(-) diff --git a/lsd/dist/install b/lsd/dist/install index f3438e8..6c04a8d 100644 --- a/lsd/dist/install +++ b/lsd/dist/install @@ -9,7 +9,6 @@ For example, "PREFIX=/ %s".\n' "$0" 1>&2 exit 1 fi -. "$PREFIX/dist/unrepo" . "$PREFIX/dist/fhs" . "$PREFIX/dist/sync_musl" From f335433447eb51c1d83b16a56594dedea099525b Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sat, 29 Jan 2022 03:10:32 -0500 Subject: [PATCH 11/15] try learn --- lsd/dist/{documentation => doc}/trilsd.7 | 0 lsd/dist/{documentation => doc}/try.1 | 0 lsd/dist/learn | 4 ++++ 3 files changed, 4 insertions(+) rename lsd/dist/{documentation => doc}/trilsd.7 (100%) rename lsd/dist/{documentation => doc}/try.1 (100%) create mode 100644 lsd/dist/learn diff --git a/lsd/dist/documentation/trilsd.7 b/lsd/dist/doc/trilsd.7 similarity index 100% rename from lsd/dist/documentation/trilsd.7 rename to lsd/dist/doc/trilsd.7 diff --git a/lsd/dist/documentation/try.1 b/lsd/dist/doc/try.1 similarity index 100% rename from lsd/dist/documentation/try.1 rename to lsd/dist/doc/try.1 diff --git a/lsd/dist/learn b/lsd/dist/learn new file mode 100644 index 0000000..20d108e --- /dev/null +++ b/lsd/dist/learn @@ -0,0 +1,4 @@ +#!/bin/false + +cp "$PREFIX/dist/doc/*.1" "$PREFIX/usr/man/man1/" +cp "$PREFIX/dist/doc/*.7" "$PREFIX/usr/man/man8/" From 49901a7a95b0a545f61910597f78b1896801c909 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sat, 29 Jan 2022 03:11:11 -0500 Subject: [PATCH 12/15] mkdir -p --- lsd/dist/learn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lsd/dist/learn b/lsd/dist/learn index 20d108e..c3fbd9c 100644 --- a/lsd/dist/learn +++ b/lsd/dist/learn @@ -1,4 +1,6 @@ #!/bin/false +mkdir -p "$PREFIX/usr/man/man1" cp "$PREFIX/dist/doc/*.1" "$PREFIX/usr/man/man1/" -cp "$PREFIX/dist/doc/*.7" "$PREFIX/usr/man/man8/" +mkdir -p "$PREFIX/usr/man/man7" +cp "$PREFIX/dist/doc/*.7" "$PREFIX/usr/man/man7/" From 7b6e55522b30e053859933c20ee8754add637895 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sat, 29 Jan 2022 16:46:15 -0500 Subject: [PATCH 13/15] rewriting in makefile --- lsd/dist/Makefile | 112 +++++++++++++++++++++++++++++++++++++++++++++ lsd/dist/config.sh | 5 -- lsd/dist/destroy | 4 -- lsd/dist/fhs | 85 ---------------------------------- lsd/dist/install | 21 --------- lsd/dist/learn | 6 --- lsd/dist/mk.conf | 3 ++ lsd/dist/sync_musl | 16 ------- lsd/dist/unrepo | 7 --- 9 files changed, 115 insertions(+), 144 deletions(-) create mode 100644 lsd/dist/Makefile delete mode 100644 lsd/dist/config.sh delete mode 100644 lsd/dist/destroy delete mode 100644 lsd/dist/fhs delete mode 100644 lsd/dist/install delete mode 100644 lsd/dist/learn create mode 100644 lsd/dist/mk.conf delete mode 100644 lsd/dist/sync_musl delete mode 100644 lsd/dist/unrepo diff --git a/lsd/dist/Makefile b/lsd/dist/Makefile new file mode 100644 index 0000000..641ce33 --- /dev/null +++ b/lsd/dist/Makefile @@ -0,0 +1,112 @@ +include mk.conf + +all: fhs learn + +destroy: + cd "$(PREFIX)" + git clean -f -d + +fhs: + # Filesystem Hierarchy Standard 3.0, 2015 + # https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf + + # section 3.2 + mkdir -p "$(PREFIX)/bin" + mkdir -p "$(PREFIX)/boot" + mkdir -p "$(PREFIX)/dev" + mkdir -p "$(PREFIX)/etc" + mkdir -p "$(PREFIX)/lib" + mkdir -p "$(PREFIX)/media" + mkdir -p "$(PREFIX)/mnt" + mkdir -p "$(PREFIX)/opt" + mkdir -p "$(PREFIX)/run" + mkdir -p "$(PREFIX)/sbin" + mkdir -p "$(PREFIX)/srv" + mkdir -p "$(PREFIX)/tmp" + mkdir -p "$(PREFIX)/usr" + mkdir -p "$(PREFIX)/var" + + # section 3.7.4 + mkdir -p "$(PREFIX)/etc/opt" + + # section 4.2 + mkdir -p "$(PREFIX)/usr/bin" + mkdir -p "$(PREFIX)/usr/lib" + mkdir -p "$(PREFIX)/usr/local" + mkdir -p "$(PREFIX)/usr/sbin" + mkdir -p "$(PREFIX)/usr/share" + + # section 4.3 + mkdir -p "$(PREFIX)/usr/include" + mkdir -p "$(PREFIX)/var/spool" + mkdir -p "$(PREFIX)/var/tmp" + mkdir -p "$(PREFIX)/var/lock" + ln -s "$(PREFIX)/usr/spool" "$(PREFIX)/var/spool" + ln -s "$(PREFIX)/usr/tmp" "$(PREFIX)/var/tmp" + ln -s "$(PREFIX)/usr/spool/locks" "$(PREFIX)/var/lock" + + # section 4.6 + mkdir -p "$(PREFIX)/usr/lib" + + # section 4.9 + mkdir -p "$(PREFIX)/usr/local" + + # section 4.9.2 + mkdir -p "$(PREFIX)/usr/local/bin" + #mkdir -p "$(PREFIX)/usr/local/etc" # see section 4.9.3 + mkdir -p "$(PREFIX)/usr/local/games" + mkdir -p "$(PREFIX)/usr/local/include" + mkdir -p "$(PREFIX)/usr/local/lib" + mkdir -p "$(PREFIX)/usr/local/man" + mkdir -p "$(PREFIX)/usr/local/sbin" + mkdir -p "$(PREFIX)/usr/local/share" + mkdir -p "$(PREFIX)/usr/local/src" + + # section 4.9.3 + ln -s "$(PREFIX)/usr/local/etc" "$(PREFIX)/etc/local" + + # section 4.11.6 + mkdir -p "$(PREFIX)/usr/share/man" + + # section 4.11.7 + mkdir -p "$(PREFIX)/usr/share/misc" + + # section 4.12 + mkdir -p "$(PREFIX)/usr/src" + + # section 5.2 + mkdir -p "$(PREFIX)/var/lib" + mkdir -p "$(PREFIX)/var/local" + mkdir -p "$(PREFIX)/var/log" + mkdir -p "$(PREFIX)/var/opt" + #mkdir -p "$(PREFIX)/var/run" # see section 5.13.2 + + # section 5.8.2 + mkdir -p "$(PREFIX)/var/lib/misc" + + # section 5.13.2 + ln -s "$(PREFIX)/var/run" "$(PREFIX)/run" + + # section 6.1.10 + mkdir -p "$(PREFIX)/var/spool/cron" + +learn: fhs + mkdir -p "$(PREFIX)/usr/man/man1" + cp "$(PREFIX)/dist/doc/*.1" "$(PREFIX)/usr/man/man1/" + mkdir -p "$(PREFIX)/usr/man/man7" + cp "$(PREFIX)/dist/doc/*.7" "$(PREFIX)/usr/man/man7/" + +musl_fetch: + git clone "$(MUSL_UPSTREAM)" "$(PREFIX)/usr/src/musl" || true + +musl: musl_fetch + cd "$(PREFIX)/usr/src/musl" + ./configure --prefix="$(PREFIX)" + $(MAKE) install + +unrepo: + rm -rf "$(PREFIX)/.git" + rm -f "$(PREFIX)/LICENSE" + rm -f "$(PREFIX)/README.md" + +.PHONY: all destroy diff --git a/lsd/dist/config.sh b/lsd/dist/config.sh deleted file mode 100644 index fdb6c9c..0000000 --- a/lsd/dist/config.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/false - -GCC_UPSTREAM="git://gcc.gnu.org/git/gcc.git" -MUSL_UPSTREAM="git://git.musl-libc.org/musl" -PKGSRC_UPSTREAM="https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz" diff --git a/lsd/dist/destroy b/lsd/dist/destroy deleted file mode 100644 index 953d2e0..0000000 --- a/lsd/dist/destroy +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/false - -cd "$PREFIX" -git clean -f -d diff --git a/lsd/dist/fhs b/lsd/dist/fhs deleted file mode 100644 index c656dd0..0000000 --- a/lsd/dist/fhs +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/false - -# Filesystem Hierarchy Standard 3.0, 2015 -# https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf - -# section 3.2 -mkdir -p "$PREFIX/bin" -mkdir -p "$PREFIX/boot" -mkdir -p "$PREFIX/dev" -mkdir -p "$PREFIX/etc" -mkdir -p "$PREFIX/lib" -mkdir -p "$PREFIX/media" -mkdir -p "$PREFIX/mnt" -mkdir -p "$PREFIX/opt" -mkdir -p "$PREFIX/run" -mkdir -p "$PREFIX/sbin" -mkdir -p "$PREFIX/srv" -mkdir -p "$PREFIX/tmp" -mkdir -p "$PREFIX/usr" -mkdir -p "$PREFIX/var" - -# section 3.7.4 -mkdir -p "$PREFIX/etc/opt" - -# section 4.2 -mkdir -p "$PREFIX/usr/bin" -mkdir -p "$PREFIX/usr/lib" -mkdir -p "$PREFIX/usr/local" -mkdir -p "$PREFIX/usr/sbin" -mkdir -p "$PREFIX/usr/share" - -# section 4.3 -mkdir -p "$PREFIX/usr/include" -mkdir -p "$PREFIX/var/spool" -mkdir -p "$PREFIX/var/tmp" -mkdir -p "$PREFIX/var/lock" -ln -s "$PREFIX/usr/spool" "$PREFIX/var/spool" -ln -s "$PREFIX/usr/tmp" "$PREFIX/var/tmp" -ln -s "$PREFIX/usr/spool/locks" "$PREFIX/var/lock" - -# section 4.6 -mkdir -p "$PREFIX/usr/lib" - -# section 4.9 -mkdir -p "$PREFIX/usr/local" - -# section 4.9.2 -mkdir -p "$PREFIX/usr/local/bin" -#mkdir -p "$PREFIX/usr/local/etc" # see section 4.9.3 -mkdir -p "$PREFIX/usr/local/games" -mkdir -p "$PREFIX/usr/local/include" -mkdir -p "$PREFIX/usr/local/lib" -mkdir -p "$PREFIX/usr/local/man" -mkdir -p "$PREFIX/usr/local/sbin" -mkdir -p "$PREFIX/usr/local/share" -mkdir -p "$PREFIX/usr/local/src" - -# section 4.9.3 -ln -s "$PREFIX/usr/local/etc" "$PREFIX/etc/local" - -# section 4.11.6 -mkdir -p "$PREFIX/usr/share/man" - -# section 4.11.7 -mkdir -p "$PREFIX/usr/share/misc" - -# section 4.12 -mkdir -p "$PREFIX/usr/src" - -# section 5.2 -mkdir -p "$PREFIX/var/cache" -mkdir -p "$PREFIX/var/lib" -mkdir -p "$PREFIX/var/local" -mkdir -p "$PREFIX/var/log" -mkdir -p "$PREFIX/var/opt" -#mkdir -p "$PREFIX/var/run" # see section 5.13.2 - -# section 5.8.2 -mkdir -p "$PREFIX/var/lib/misc" - -# section 5.13.2 -ln -s "$PREFIX/var/run" "$PREFIX/run" - -# section 6.1.10 -mkdir -p "$PREFIX/var/spool/cron" diff --git a/lsd/dist/install b/lsd/dist/install deleted file mode 100644 index 6c04a8d..0000000 --- a/lsd/dist/install +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/false -set -e - -depend_on nonzero - -if ! nonzero "$PREFIX"; then - printf 'Please select a $PREFIX for installation. -For example, "PREFIX=/ %s".\n' "$0" 1>&2 - exit 1 -fi - -. "$PREFIX/dist/fhs" -. "$PREFIX/dist/sync_musl" - -cd "$PREFIX/usr/src" -if [ -d gcc ]; then - cd gcc - git pull -else - fetch_upstream "$GCC_UPSTREAM" -fi diff --git a/lsd/dist/learn b/lsd/dist/learn deleted file mode 100644 index c3fbd9c..0000000 --- a/lsd/dist/learn +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/false - -mkdir -p "$PREFIX/usr/man/man1" -cp "$PREFIX/dist/doc/*.1" "$PREFIX/usr/man/man1/" -mkdir -p "$PREFIX/usr/man/man7" -cp "$PREFIX/dist/doc/*.7" "$PREFIX/usr/man/man7/" diff --git a/lsd/dist/mk.conf b/lsd/dist/mk.conf new file mode 100644 index 0000000..b7cd31a --- /dev/null +++ b/lsd/dist/mk.conf @@ -0,0 +1,3 @@ +GCC_UPSTREAM=git://gcc.gnu.org/git/gcc.git +MUSL_UPSTREAM=git://git.musl-libc.org/musl +PKGSRC_UPSTREAM=https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz diff --git a/lsd/dist/sync_musl b/lsd/dist/sync_musl deleted file mode 100644 index 37f5a72..0000000 --- a/lsd/dist/sync_musl +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/false -set -e - -depend_on cd -depend_on make -depend_on mkdir - -cd "$PREFIX/usr/src" - -if [ -d musl ] -then cd musl; git pull -else fetch_upstream "$MUSL_UPSTREAM"; fi - -cd "$PREFIX/usr/src/musl" -./configure --prefix="$PREFIX" -make install diff --git a/lsd/dist/unrepo b/lsd/dist/unrepo deleted file mode 100644 index ca9e9a6..0000000 --- a/lsd/dist/unrepo +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/false - -depend_on rm - -rm -rf "$PREFIX/.git" -rm -f "$PREFIX/LICENSE" -rm -f "$PREFIX/README.md" From 3bfd03e2365e8944e36e59bdcb563c338c38b0f8 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sun, 30 Jan 2022 19:51:21 -0500 Subject: [PATCH 14/15] clean out the rest of the shell stuff, remove try(1) --- lsd/dist/doc/trilsd.7 | 27 +++++++++++---------- lsd/dist/doc/try.1 | 55 ------------------------------------------- lsd/dist/macro.sh | 31 ------------------------ lsd/dist/try | 11 --------- 4 files changed, 15 insertions(+), 109 deletions(-) delete mode 100644 lsd/dist/doc/try.1 delete mode 100644 lsd/dist/macro.sh delete mode 100755 lsd/dist/try diff --git a/lsd/dist/doc/trilsd.7 b/lsd/dist/doc/trilsd.7 index 2a7ec4e..88d2cd1 100644 --- a/lsd/dist/doc/trilsd.7 +++ b/lsd/dist/doc/trilsd.7 @@ -10,17 +10,15 @@ musl C standard library, with nearly all configuration options left to the user's own device. .SH BASE SYSTEM +A .I TriLSD -explicitly relies on the existence of the following programs and -packages: -dash(1), -ftp(1), +system always has the following packages: +dash, the GNU compiler collection, GNU make, musl, -linux, -bsdtar(1), -and util-linux. +and +linux and util-linux. .PP In addition, .I TriLSD @@ -33,15 +31,20 @@ OpenRC is the suggested choice but others may be used. SystemD is discouraged; it's mentioned for its popularity and frowned upon for its generally lax security. +.SH INSTALLATION +To install +.I TriLSD +most of the POSIX specified utilities including awk, git(1), GNU make, and a C +compiler that can build the GNU compiler collection must be installed. + +.PP +For the installation process see +.RB try (1) + .SH PACKAGE MANAGEMENT .I TriLSD does not come with a package manager; the user may choose whatever system-independent package manager they prefer. -.PP -Certain system tools that aren't necessarily packaged in system-independent -package managers (pkgsrc comes to mind) can be updated with the -.RB try (1) -command. .SH CONTRIBUTING Pay attention to projects' guidelines for distributions. diff --git a/lsd/dist/doc/try.1 b/lsd/dist/doc/try.1 deleted file mode 100644 index 41145af..0000000 --- a/lsd/dist/doc/try.1 +++ /dev/null @@ -1,55 +0,0 @@ -.TH TRINITX 1 - -.SH NAME -try \- distribution management - -.SH SYNOPSIS -.B try -.RB { install , sync_musl , unrepo } - -.SH DESCRIPTION -.I try -exists to conduct system tasks normally conducted by operating systems -themselves and for which there's no easy alternative (though the system is not -tightly coupled with these utilities and they can easily be replaced). - -.SH FUNCTIONS -.SS INSTALL -Installs the software distribution base into an environment variable specified -prefix. If -.I install -is not called in the form -.IP -\fCPREFIX=/ try install\fP -.LP -it will print a diagnostic message and exit; PREFIX must not be empty. - -.SS SYNC_MUSL -Fetches musl from the upstream source and installs it into the PREFIX. PREFIX -may not be specified but behavior will be unspecified (probably function as if -PREFIX is '/') if it's not. - -.SS UNREPO -Deletes git repository files from PREFIX if they exist; this is a -post-installation task and need only be performed once. PREFIX may not be -specified; if it isn't, it'll function as if PREFIX is '/'. - -.SH CONFIGURATION -.I try -may be configured via -.B config.sh -in the same directory. - -.SH LOCATIONS -.I try -distribution-specific files are always located in $PREFIX/dist. -For example, the -.I try -script is always at $PREFIX/dist/try, and configuration is always at -$PREFIX/dist/config.sh. - -.SH COPYRIGHT -Public domain. - -.SH SEE ALSO -.RB trilsd (7) diff --git a/lsd/dist/macro.sh b/lsd/dist/macro.sh deleted file mode 100644 index f2813ca..0000000 --- a/lsd/dist/macro.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/false - -depend_on(){ - ! command -v "$1" >/dev/null \ - && printf "Missing %s.\n" "$1" 1>&2 \ - && exit 1 \ - || true -} - -fetch_upstream(){ - url="$1" - scheme="$(scheme_from_uri "$url")" - case "$scheme" in - git) - depend_on git - git clone "$url" - ;; - *) - printf "%s: Invalid upstream URL %s (scheme is %s)\n" \ - "$argv0" "$1" "$scheme" - exit 1 - esac -} - -depend_on cut - -scheme_from_uri(){ - # There are no colons in scheme names and no ways to separate schemes - # from scheme-specific content without colons (RFC 3986). - printf "%s\n" "$1" | cut -d ':' -f 1 -} diff --git a/lsd/dist/try b/lsd/dist/try deleted file mode 100755 index 5ed111e..0000000 --- a/lsd/dist/try +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -if [ -z "$PREFIX" ]; then - printf 'Please select a $PREFIX for installation. -For example, "PREFIX=/ %s".\n' "$0" 1>&2 - exit 1 -fi - -. "$PREFIX/dist/config.sh" -. "$PREFIX/dist/macro.sh" -. "$PREFIX/dist/$1" From e4d67f2bd276c7736c8b86ca875cd20bda4f559d Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sun, 30 Jan 2022 19:52:22 -0500 Subject: [PATCH 15/15] better musl_fetch --- lsd/dist/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsd/dist/Makefile b/lsd/dist/Makefile index 641ce33..368d2b6 100644 --- a/lsd/dist/Makefile +++ b/lsd/dist/Makefile @@ -96,7 +96,7 @@ learn: fhs mkdir -p "$(PREFIX)/usr/man/man7" cp "$(PREFIX)/dist/doc/*.7" "$(PREFIX)/usr/man/man7/" -musl_fetch: +musl_fetch: "$(PREFIX)/usr/src/musl" git clone "$(MUSL_UPSTREAM)" "$(PREFIX)/usr/src/musl" || true musl: musl_fetch