From 960ab5f74e39d71c74bd87beaeb9dcc3e8db5704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 18 Oct 2023 17:06:27 -0300 Subject: [PATCH 001/128] docs: Take note about new builds using LLVM. --- README.md | 20 +++++++++++++++++++- sources.txt | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85939bb..57f4053 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,27 @@ # The Copacabana Linux(R) distribution -![Pindorama Copacabana Linux](https://raw.githubusercontent.com/Projeto-Pindorama/artworks/master/Pindorama%20Copacabana%20Banner/Pindorama%20Copacabana%20Banner.png) + +![Pindorama Copacabana Linux](https://raw.githubusercontent.com/Projeto-Pindorama/artworks/master/Pindorama%20Copacabana%20Banner/Pindorama%20Copacabana%20Banner.png) + +### *Now built with LLVM!* + +Hell yeah. + +|![Hell yeah](https://licensing.imageconscious.com/wp-content/uploads/sites/2/2021/01/H1753D-1.jpg) | +|:--:| +| Hell yeah | + +## What is this repository about? This repository contains most of the resources that you would need to build Copacabana, in case a build consolidation made of small scripts that automate the process. +This time, we're trying a build using LLVM and following a considerable part of +dslm4515's [Clang Musl Linux from Scratch](https://github.com/dslm4515/CMLFS.git) +guide for building the toolchain. We aim to both get Copacabana fully built wit +LLVM and to cooperate with CMLFS, sending patches when help needed and/or flaws +discovered in the process. +If it succeeds and presents a nice performance, this branch will be merged into +the main branch. For more information about porting, translation, documentation etc, read the website: http://copacabana.pindorama.dob.jp diff --git a/sources.txt b/sources.txt index 17312e5..0042760 100644 --- a/sources.txt +++ b/sources.txt @@ -97,7 +97,7 @@ https://www.mpfr.org/mpfr-4.1.0/mpfr-4.1.0.tar.xz https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz -https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz +https://ftp.gnu.org/gnu/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz https://ftp.gnu.org/gnu/make/make-3.81.tar.gz https://ftp.gnu.org/pub/gnu/gdbm/gdbm-1.8.3.tar.gz https://ftp.gnu.org/gnu/gperf/gperf-3.1.tar.gz From 6b2ba3c5f256865a1c9ad7a7610ecdf70a08e0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 18 Oct 2023 17:07:35 -0300 Subject: [PATCH 002/128] docs: Removed GCC and some utilities that won't be used for now, added Pindorama's fork of firasuke's mussel, LLVM etc. --- sources.txt | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sources.txt b/sources.txt index 0042760..7e02e87 100644 --- a/sources.txt +++ b/sources.txt @@ -59,8 +59,13 @@ https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #< pkgs #> pkgs/dev +https://github.com/Projeto-Pindorama/mussel/archive/refs/heads/main.tar.gz +https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.1/llvm-project-17.0.1.src.tar.xz +https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.6.tar.xz https://mirrors.edge.kernel.org/pub/software/scm/git/git-manpages-2.36.6.tar.xz +https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz +https://dl.google.com/go/go1.21.3.src.tar.gz https://www.cpan.org/src/5.0/perl-5.32.0.tar.xz https://sources.buildroot.net/perl/perl-cross-1.3.5.tar.gz https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.46.tar.gz @@ -68,14 +73,15 @@ https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tar.xz https://www.python.org/ftp/python/doc/3.11.4/python-3.11.4-docs-text.tar.bz2 https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz https://www.python.org/ftp/python/doc/2.7.18/python-2.7.18-docs-text.tar.bz2 -http://downloads.sourceforge.net/tcl/tcl8.6.10-src.tar.gz -http://downloads.sourceforge.net/tcl/tcl8.6.10-html.tar.gz -http://github.com/michaelforney/samurai/releases/download/1.2/samurai-1.2.tar.gz -http://github.com/mesonbuild/meson/releases/download/0.55.0/meson-0.55.0.tar.gz -http://invisible-island.net/datafiles/release/byacc.tar.gz -http://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz -http://downloads.sourceforge.net/project/expat/expat/2.5.0/expat-2.5.0.tar.xz -http://downloads.sourceforge.net/project/expect/Expect/5.45.4/expect5.45.4.tar.gz +https://downloads.sourceforge.net/tcl/tcl8.6.10-src.tar.gz +https://downloads.sourceforge.net/tcl/tcl8.6.10-html.tar.gz +https://github.com/michaelforney/samurai/releases/download/1.2/samurai-1.2.tar.gz +https://github.com/Kitware/CMake/releases/download/v3.28.0-rc1/cmake-3.28.0-rc1.tar.gz +https://github.com/mesonbuild/meson/releases/download/0.55.0/meson-0.55.0.tar.gz +https://invisible-island.net/datafiles/release/byacc.tar.gz +https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz +https://downloads.sourceforge.net/project/expat/expat/2.5.0/expat-2.5.0.tar.xz +https://downloads.sourceforge.net/project/expect/Expect/5.45.4/expect5.45.4.tar.gz #< pkgs/dev #> pkgs/extra @@ -89,15 +95,10 @@ https://github.com/hfiref0x/LightFTP/archive/refs/tags/v2.3.tar.gz #> pkgs/gnu https://ftp.gnu.org/gnu/bash/bash-3.2.57.tar.gz -https://ftp.gnu.org/gnu/sed/sed-4.4.tar.gz +https://ftp.gnu.org/gnu/sed/sed-4.1.5.tar.gz https://ftp.gnu.org/gnu/gawk/gawk-3.1.5.tar.gz https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.xz -https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz -https://www.mpfr.org/mpfr-4.1.0/mpfr-4.1.0.tar.xz -https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz -https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz -https://ftp.gnu.org/gnu/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz https://ftp.gnu.org/gnu/make/make-3.81.tar.gz https://ftp.gnu.org/pub/gnu/gdbm/gdbm-1.8.3.tar.gz https://ftp.gnu.org/gnu/gperf/gperf-3.1.tar.gz From e15a45b86abe2fdb24fda43cf9ed8ce3399a1514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 18 Oct 2023 17:47:34 -0300 Subject: [PATCH 003/128] chore: Switch to firasuke's original mussel repository since our first patches were applied. See https://github.com/firasuke/mussel/pull/15 --- sources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources.txt b/sources.txt index 7e02e87..74f7e67 100644 --- a/sources.txt +++ b/sources.txt @@ -59,7 +59,7 @@ https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #< pkgs #> pkgs/dev -https://github.com/Projeto-Pindorama/mussel/archive/refs/heads/main.tar.gz +https://github.com/firasuke/mussel/archive/refs/heads/main.tar.gz https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.1/llvm-project-17.0.1.src.tar.xz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.6.tar.xz From 609d03070f1d2293cd94d8d527ff611b42f1a4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 20 Oct 2023 02:09:56 -0300 Subject: [PATCH 004/128] chore: Use the copaclang branch from Alambiko. --- .gitmodules | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitmodules b/.gitmodules index 3db86b1..c6fff88 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "packages"] path = packages url = https://github.com/Projeto-Pindorama/alambiko.git + branch = copaclang From 877c9bdc2553b279ef79d06e92e3e7ece29b6b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 20 Oct 2023 03:20:13 -0300 Subject: [PATCH 005/128] feat: Added "TARGET_TUPLE" at machine.conf --- build-system/machine.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-system/machine.conf b/build-system/machine.conf index 2696e4e..9428ff5 100644 --- a/build-system/machine.conf +++ b/build-system/machine.conf @@ -4,6 +4,9 @@ # Target COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" +# The default/unvendored "target tuple" that we will need when configuring LLVM. +TARGET_TUPLE="x86_64-pc-linux-musl" + # CPU information ARCH="x86" CPU="x86-64" From 7dd4d521ce93d14f5fdcad0e9fd76efe359ce5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 24 Oct 2023 10:18:11 -0300 Subject: [PATCH 006/128] feat: Use new directories for both LLVM and GNU C tools. --- build-system/tasks/disk_managenment.ksh | 44 ++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index 356677a..a7a37b0 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -111,45 +111,45 @@ function populate { # toolchain and intermediary chroot toolchain. printerr 'Info: Making directories in %s for the building toolchains.\n' \ "$COPA" - elevate mkdir "$COPA/"{cross-,}tools + elevate mkdir "$COPA/"{cgnu,llvm}tools (cd "$COPA"; ls -lah .) - # Make a symbolic link from $COPA/cross-tools to /cross-tools, the same + # Make a symbolic link from $COPA/cgnutools to /cgnutools, the same # for /tools. # For instance: - # {"$COPA/",/}cross-tools expands to $COPA/cross-tools /cross-tools, + # {"$COPA/",/}cgnutools expands to $COPA/cgnutools /cgnutools, # which is the input that we'd need to ln(1). - if [[ -d "$COPA/cross-tools" && -d "$COPA/tools" ]]; then + if [[ -d "$COPA/cgnutools" && -d "$COPA/llvmtools" ]]; then printerr 'Info: Symbolic linking %s to %s...\n' \ - {"$COPA/",/}cross-tools {"$COPA/",/}tools + {"$COPA/",/}cgnutools {"$COPA/",/}llvmtools - # If /cross-tools is already a symbolic link to - # $COPA/cross-tools, then don't re-do it. Else, if it's a - # symbolic link but it doesn't link to $COPA/cross-tools, + # If /cgnutools is already a symbolic link to + # $COPA/cgnutools, then don't re-do it. Else, if it's a + # symbolic link but it doesn't link to $COPA/cgnutools, # re-do it. - # The same applies to /tools. - [[ $(realpath /cross-tools) != "$COPA/cross-tools" ]] \ - && elevate rm /cross-tools - ( test -L /cross-tools \ - && [[ $(realpath /cross-tools) == "$COPA/cross-tools" ]] ) \ - || elevate ln -s {"$COPA/",/}cross-tools + # The same applies to /llvmtools. + [[ $(realpath /cgnutools) != "$COPA/cgnutools" ]] \ + && elevate rm /cgnutools + ( test -L /cgnutools \ + && [[ $(realpath /cgnutools) == "$COPA/cgnutools" ]] ) \ + || elevate ln -s {"$COPA/",/}cgnutools - [[ $(realpath /tools) != "$COPA/tools" ]] \ - && elevate rm /tools - ( test -L /tools \ - && [[ $(realpath /tools) == "$COPA/tools" ]] ) \ - || elevate ln -s {"$COPA/",/}tools + [[ $(realpath /llvmtools) != "$COPA/llvmtools" ]] \ + && elevate rm /llvmtools + ( test -L /llvmtools \ + && [[ $(realpath /llvmtools) == "$COPA/llvmtools" ]] ) \ + || elevate ln -s {"$COPA/",/}llvmtools - (cd /; ls -l ./{cross-,}tools) + (cd /; ls -l ./{cgnu,llvm}tools) fi printerr 'Info: Making directories in %s for populating the file system.\n' \ "$COPA" (cd "$COPA"; elevate $run_shell -c "COPA=$COPA $progdir/cmd/populate_fhs.ksh") printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ - $(realpaths /{cross-,}tools) "$COPA/usr/src" - elevate chown -RH "$user" /{cross-,}tools "$COPA/usr/src" + $(realpaths /{cgnu,llvm}tools) "$COPA/usr/src" + elevate chown -RH "$user" /{cgnu,llvm}tools "$COPA/usr/src" } function unmount_and_detach { From f1922f4164b4bdb8f0a8f6859b3710e7b445689c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 24 Oct 2023 17:37:20 -0300 Subject: [PATCH 007/128] chore: Rewrote rconfig() --- build-system/internals/helpers/helpers.shi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 6baac09..3fc1d55 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -13,7 +13,7 @@ export readonly BUILD_KSH=true function rconfig { (sed '/#/d; /^$/d' "$1") \ | while IFS='=' read identifier value; do - eval $identifier=$value + eval $(printf '%s=%s' $identifier "$value") done } @@ -37,7 +37,7 @@ function defined { function execscript { command="$1"; shift; command_args=( "$@" ) - /bin/sh -c "$command "${command_args[@]}"" + ( exec "$command "${command_args[@]}"" ) } # Multiple file input support for realpath(1) From 226ac56364f808fa861f346361ca3fec18574acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 2 Nov 2023 20:00:58 -0300 Subject: [PATCH 008/128] feat: Implemented aria2c support for downloading source code. --- build-system/machine.conf | 6 ++++ build-system/tasks/get_source-code.ksh | 39 +++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/build-system/machine.conf b/build-system/machine.conf index 9428ff5..568637d 100644 --- a/build-system/machine.conf +++ b/build-system/machine.conf @@ -59,6 +59,12 @@ UMOUNT_ON_EXIT="false" # "sources.sha256" file before. This option is case-insensitive. SHA256CHECK="YES" +# Use aria2c instead of the good ol' homebrew download_sources.ksh? +# Use "true" if you have aria2c on your system, or "false" if you're on a small +# environment (such as the Copacabana 0.4 Dockerimage/Mitzune prefix) with only +# cURL and/or taking considerably more time isn't a big deal. +USE_ARIA2C="true" + # Programs CC="gcc" CXX="g++" diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_source-code.ksh index 731aac7..405a5ae 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_source-code.ksh @@ -11,7 +11,44 @@ function get_sources { printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ "$source_list" - "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" + if ! $USE_ARIA2C; then + # Get the good ol' download_sources.ksh as our default and + # secure option since 2021. + "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" + else + # A considerable part of this code comes from download_sources.ksh. + categories=($(grep '#>' "$source_list" | tr -d '#> ')) + n_categories=$(n ${categories[@]}) + + for ((c=0; c < n_categories; c++)); do + # foo/var => foo\/var + category_id="$(echo ${categories[$c]} | sed 's~\/~\\\/~g')" + + printerr 'Info: Downloading %s sources...\n' "${categories[$c]}" + + # sed: Remove comments (lines starting with %%) + # AWK: Matches #> $category_id | counts until the next and last match | matches #< $category_id | it ends here + urls=($(sed '/%%/d' "$source_list" \ + | awk "/^#> $category_id$/{flag=1;next}/^#< $category_id$/{flag=0}flag")) + n_urls=$(n urls) + + category_dir="$SRCDIR/${categories[$c]}" + mkdir -p "$category_dir" + + # Hell yeah, speed. + ( for ((u=0; u < $(n ${urls[@]}); u++ )); do + printf '%s\n\tout=%s\n' \ + "${urls[$u]}" "${urls[$u]##*/}" + done ) \ + | aria2c -j $(nproc) -s $(nproc) -d "$category_dir" -i - + unset category_id category_dir urls n_urls + done + if $(printf '%s' "$SHA256CHECK" | grep -i '^y' &>/dev/null); then + (cd "$SRCDIR"; \ + "$progdir/cmd/sha256sum.ksh" -c "$source_hash") + fi + unset categories n_categories + fi unset SHA256CHECK } From 6da2c9e585e9f8e86d667bc0deef4d38abc51f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 2 Nov 2023 20:13:11 -0300 Subject: [PATCH 009/128] chore: Explicity if one's using aria2c instead of download_sources.ksh --- build-system/tasks/get_source-code.ksh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_source-code.ksh index 405a5ae..3ee6e92 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_source-code.ksh @@ -24,6 +24,7 @@ function get_sources { # foo/var => foo\/var category_id="$(echo ${categories[$c]} | sed 's~\/~\\\/~g')" + printerr 'Info: Using aria2c instead of cmd/download_sources.ksh...\n' printerr 'Info: Downloading %s sources...\n' "${categories[$c]}" # sed: Remove comments (lines starting with %%) From a217c106fe7914c3fdaff1bd3977e1d00bd6423e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 2 Nov 2023 20:45:35 -0300 Subject: [PATCH 010/128] feat: Moved aria2c support to download_sources.ksh as an alternative to the cURL backend. --- build-system/machine.conf | 2 +- build-system/tasks/get_source-code.ksh | 43 ++------------------------ cmd/download_sources.ksh | 32 ++++++++++++++++--- 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/build-system/machine.conf b/build-system/machine.conf index 568637d..ac7a666 100644 --- a/build-system/machine.conf +++ b/build-system/machine.conf @@ -59,7 +59,7 @@ UMOUNT_ON_EXIT="false" # "sources.sha256" file before. This option is case-insensitive. SHA256CHECK="YES" -# Use aria2c instead of the good ol' homebrew download_sources.ksh? +# Use aria2c instead of the good ol' cURL backend on download_sources.ksh? # Use "true" if you have aria2c on your system, or "false" if you're on a small # environment (such as the Copacabana 0.4 Dockerimage/Mitzune prefix) with only # cURL and/or taking considerably more time isn't a big deal. diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_source-code.ksh index 3ee6e92..d2222c6 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_source-code.ksh @@ -6,50 +6,13 @@ function get_sources { source_hash="$(readlink -f "$2")" SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" SHA256CHECK="$SHA256CHECK" - export SHA256CHECK SRCDIR + USE_ARIA2C="$USE_ARIA2C" + export USE_ARIA2C SHA256CHECK SRCDIR printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ "$source_list" - if ! $USE_ARIA2C; then - # Get the good ol' download_sources.ksh as our default and - # secure option since 2021. - "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" - else - # A considerable part of this code comes from download_sources.ksh. - categories=($(grep '#>' "$source_list" | tr -d '#> ')) - n_categories=$(n ${categories[@]}) - - for ((c=0; c < n_categories; c++)); do - # foo/var => foo\/var - category_id="$(echo ${categories[$c]} | sed 's~\/~\\\/~g')" - - printerr 'Info: Using aria2c instead of cmd/download_sources.ksh...\n' - printerr 'Info: Downloading %s sources...\n' "${categories[$c]}" - - # sed: Remove comments (lines starting with %%) - # AWK: Matches #> $category_id | counts until the next and last match | matches #< $category_id | it ends here - urls=($(sed '/%%/d' "$source_list" \ - | awk "/^#> $category_id$/{flag=1;next}/^#< $category_id$/{flag=0}flag")) - n_urls=$(n urls) - - category_dir="$SRCDIR/${categories[$c]}" - mkdir -p "$category_dir" - - # Hell yeah, speed. - ( for ((u=0; u < $(n ${urls[@]}); u++ )); do - printf '%s\n\tout=%s\n' \ - "${urls[$u]}" "${urls[$u]##*/}" - done ) \ - | aria2c -j $(nproc) -s $(nproc) -d "$category_dir" -i - - unset category_id category_dir urls n_urls - done - if $(printf '%s' "$SHA256CHECK" | grep -i '^y' &>/dev/null); then - (cd "$SRCDIR"; \ - "$progdir/cmd/sha256sum.ksh" -c "$source_hash") - fi - unset categories n_categories - fi + "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" unset SHA256CHECK } diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index bfbdbc6..62b7711 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -16,6 +16,7 @@ # download_sources.ksh if running from build.ksh SHA256CHECK=${SHA256CHECK:-YES} +USE_ARIA2C=${USE_ARIA2C:-false} COPA=${COPA:-/dsk/0v} SRCDIR=${SRCDIR:-$COPA/usr/src} umask 0022 @@ -42,6 +43,16 @@ realpath(){ echo "`cd "${file_dirname}"; pwd`/${file_basename}" } +# Drop-in replacement to GNU nproc. +nproc(){ + case "`uname -s`" in + Darwin | Linux) getconf '_NPROCESSORS_ONLN';; + FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN';; + SunOS) echo "`ksh93 -c 'getconf NPROCESSORS_ONLN'`" ;; + *) echo 1 ;; + esac +} + main() { sources_file="`realpath ${1}`" sources_directory="`realpath ${SRCDIR}`" @@ -62,12 +73,23 @@ main() { category_dir="$sources_directory/${categories[${i}]}" mkdir -p "${category_dir}" - cd "${category_dir}" || exit 2 - for ((j = 0; j < n_urls; j++)) { - printf 'Downloading %s\n' "`basename ${urls[${j}]}`" - curl -LO "${urls[${j}]}" - } + # cURL is slower, but it's present on more systems per default than aria2c, + # so we're going with it. + if ! $USE_ARIA2C; then + cd "${category_dir}" || exit 2 + for ((j = 0; j < n_urls; j++)) { + printf 'Downloading %s\n' "`basename ${urls[${j}]}`" + curl -LO "${urls[${j}]}" + } + else + # Hell yeah, speed. + ( for ((k=0; k < $n_urls; k++ )); do + printf '%s\n\tout=%s\n' \ + "${urls[$u]}" "${urls[$u]##*/}" + done ) \ + | aria2c -j `nproc` -s `nproc` -d "$category_dir" -i - + fi } if `echo ${SHA256CHECK} | grep -i '^y' &>/dev/null` \ && `test -n "${hashsum_file}"`; then From 72f08f61ca4c69a4a61df8d2ae90c31555a11ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 2 Nov 2023 20:47:38 -0300 Subject: [PATCH 011/128] feat: Update sources one more time New pigz and dhcpcd versions --- sources.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources.txt b/sources.txt index 74f7e67..fdac603 100644 --- a/sources.txt +++ b/sources.txt @@ -25,7 +25,7 @@ https://github.com/Mic92/iana-etc/releases/download/20230202/iana-etc-20230202.t https://data.iana.org/time-zones/releases/tzcode2023a.tar.gz https://data.iana.org/time-zones/releases/tzdata2023a.tar.gz https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-5.17.0.tar.xz -https://roy.marples.name/downloads/dhcpcd/dhcpcd-9.4.1.tar.xz +https://github.com/NetworkConfiguration/dhcpcd/releases/download/v10.0.4/dhcpcd-10.0.4.tar.xz https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.7.2.tar.gz %% Real men test in production %% FIXME: Talking serious now, we shall move to the next stable @@ -50,7 +50,7 @@ https://download.savannah.nongnu.org/releases/acl/acl-2.3.1.tar.xz https://download.savannah.nongnu.org/releases/attr/attr-2.5.1.tar.xz https://master.dl.sourceforge.net/project/openpam/openpam/Tabebuia/openpam-20190224.tar.gz https://master.dl.sourceforge.net/project/s-tar/star-1.6.tar.bz2 -https://zlib.net/pigz/pigz-2.7.tar.gz +https://zlib.net/pigz/pigz-2.8.tar.gz https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.tar.gz https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz https://tukaani.org/xz/xz-5.4.2.tar.xz From f713fc32c9f0d249202f3e94e498ca0dabaeccf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 2 Nov 2023 22:08:16 -0300 Subject: [PATCH 012/128] feat: Fixes on cmd/download_sources.ksh's aria2c support. --- cmd/download_sources.ksh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index 62b7711..b46d0f5 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -84,10 +84,10 @@ main() { } else # Hell yeah, speed. - ( for ((k=0; k < $n_urls; k++ )); do + ( for ((k = 0; k < $n_urls; k++)){ printf '%s\n\tout=%s\n' \ - "${urls[$u]}" "${urls[$u]##*/}" - done ) \ + "${urls[$k]}" "${urls[$k]##*/}" + } ) \ | aria2c -j `nproc` -s `nproc` -d "$category_dir" -i - fi } From 5c0bf6dc8e3dd6c9bb0bbe5f754844a4c97f6552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 2 Nov 2023 23:31:02 -0300 Subject: [PATCH 013/128] feat: Pre-define SRCDIR from disk_managenment.ksh instead of hard-coding it as /usr/src. --- build-system/tasks/disk_managenment.ksh | 12 ++++++++---- build-system/tasks/get_source-code.ksh | 5 +++-- cmd/populate_fhs.ksh | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index a7a37b0..e17e779 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -1,3 +1,7 @@ +# That's the time to decide which will be, in fact, our source-code directory. +SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" +export SRCDIR + function create_disk { disk_block="$1" @@ -115,7 +119,7 @@ function populate { (cd "$COPA"; ls -lah .) # Make a symbolic link from $COPA/cgnutools to /cgnutools, the same - # for /tools. + # for /llvmtools. # For instance: # {"$COPA/",/}cgnutools expands to $COPA/cgnutools /cgnutools, # which is the input that we'd need to ln(1). @@ -145,11 +149,11 @@ function populate { fi printerr 'Info: Making directories in %s for populating the file system.\n' \ "$COPA" - (cd "$COPA"; elevate $run_shell -c "COPA=$COPA $progdir/cmd/populate_fhs.ksh") + (cd "$COPA"; elevate $run_shell -c "COPA=$COPA $progdir/cmd/populate_fhs.ksh; mkdir -p "$COPA/$SRCDIR"") printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ - $(realpaths /{cgnu,llvm}tools) "$COPA/usr/src" - elevate chown -RH "$user" /{cgnu,llvm}tools "$COPA/usr/src" + $(realpaths /{cgnu,llvm}tools) "$COPA/$SRCDIR" + elevate chown -RH "$user" /{cgnu,llvm}tools "$COPA/$SRCDIR" } function unmount_and_detach { diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_source-code.ksh index d2222c6..5f6ec73 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_source-code.ksh @@ -4,8 +4,9 @@ function get_sources { # function. source_list="$(readlink -f "$1")" source_hash="$(readlink -f "$2")" - SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" + SHA256CHECK="$SHA256CHECK" + SRCDIR="$SRCDIR" USE_ARIA2C="$USE_ARIA2C" export USE_ARIA2C SHA256CHECK SRCDIR @@ -14,5 +15,5 @@ function get_sources { "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" - unset SHA256CHECK + unset SHA256CHECK USE_ARIA2C } diff --git a/cmd/populate_fhs.ksh b/cmd/populate_fhs.ksh index 0f77a96..4579559 100755 --- a/cmd/populate_fhs.ksh +++ b/cmd/populate_fhs.ksh @@ -6,7 +6,7 @@ # if you don't have AT&T's ksh93 installed. COPA=${COPA:-/dsk/0v} -directory_tree=({bin,boot,dev,etc,lib,lib64,opt,proc,run,sbin,sys,tmp,usr/{,bin,ccs,etc,include,lib,lib64,sbin,share/{,doc,man,misc},skel,spool,src,tmp},var/{,adm,cache,lib/{,color,misc},log,mail,tmp,run/{,lock},spool/{,mail}}}) +directory_tree=({bin,boot,dev,etc,lib,lib64,opt,proc,run,sbin,sys,tmp,usr/{,bin,ccs,etc,include,lib,lib64,sbin,share/{,doc,man,misc},skel,spool,tmp},var/{,adm,cache,lib/{,color,misc},log,mail,tmp,run/{,lock},spool/{,mail}}}) function main { n_directory_tree=`n ${directory_tree[@]}` From 8ad87fe776eaa991e2a541d1fc5fac5cad80b8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 3 Nov 2023 16:20:22 -0300 Subject: [PATCH 014/128] feat: Borrow record function from [herbiec](https://github.com/takusuman/herbiec). --- build-system/internals/helpers/helpers.shi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 3fc1d55..592670a 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -8,6 +8,17 @@ # Make everyone aware we're running from BUILD_KSH. export readonly BUILD_KSH=true +# Creates an associative array with identifier, variable name and value as +# its parameters. It's really similar to the code found on herbiec in this +# sense, but it was originally used as a "pointeroid" for accessing an A.S.T. +function record { + identifier="$1" + variable="$2" + value="$3" + + eval $(printf '%s+=([%s]="%s")' "$identifier" "$variable" "$value") +} + # Reads simple Shell-based configuration files. # "#" is used for comments, and white spaces are ignored for read(1). function rconfig { From b54380288ad743e8323a60f7a36a685625ca640d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 3 Nov 2023 19:39:18 -0300 Subject: [PATCH 015/128] fix: aria2c parallelization support on cmd/download_sources.ksh --- cmd/download_sources.ksh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index b46d0f5..8636a38 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -84,11 +84,11 @@ main() { } else # Hell yeah, speed. - ( for ((k = 0; k < $n_urls; k++)){ + ( for ((k = 0; k < n_urls; k++)){ printf '%s\n\tout=%s\n' \ "${urls[$k]}" "${urls[$k]##*/}" } ) \ - | aria2c -j `nproc` -s `nproc` -d "$category_dir" -i - + | aria2c -j `nproc` -x `nproc` -d "$category_dir" -i - fi } if `echo ${SHA256CHECK} | grep -i '^y' &>/dev/null` \ From 125888f6ffa97d85eab3ee527c806bc37110d17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 3 Nov 2023 21:33:51 -0300 Subject: [PATCH 016/128] feat!: Deprecate execscript() --- build-system/internals/helpers/helpers.shi | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 592670a..6aa8df7 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -41,16 +41,6 @@ function defined { || return 1 } -# This will be used inside Alambiko's driver.ksh. -# It executes a shell script with its arguments via the running shell. -# If you need to use some variable defined in the pkgbuild or in some build.ksh -# task, export it before calling execscript(). -function execscript { - command="$1"; - shift; command_args=( "$@" ) - ( exec "$command "${command_args[@]}"" ) -} - # Multiple file input support for realpath(1) # Basically a boilerplate. function realpaths { From f4e01dc8434e24d30d4b01fc96a976178fc84104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 4 Nov 2023 23:18:03 -0300 Subject: [PATCH 017/128] feat: Added initial description headers for each task. --- build-system/tasks/build_all.ksh | 49 +++++++++++++++++++---- build-system/tasks/check_dependencies.ksh | 11 +++-- build-system/tasks/disk_managenment.ksh | 22 +++++++--- build-system/tasks/get_source-code.ksh | 18 +++++++++ build-system/tasks/platform_checks.ksh | 18 +++++++-- 5 files changed, 98 insertions(+), 20 deletions(-) diff --git a/build-system/tasks/build_all.ksh b/build-system/tasks/build_all.ksh index bbbf8d7..119c210 100644 --- a/build-system/tasks/build_all.ksh +++ b/build-system/tasks/build_all.ksh @@ -1,9 +1,23 @@ -# This will be used in Alambiko when installing the "packages" to a destination -# directory. -package_dir="$trash/pkg" +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023: Pindorama +# SPDX-Licence-Identifier: NCSA + +# STEP 3: Build +# "Around 3 a.m., the colonel pushed a bunch of papers that were on his front at +# his table. He strected his arms and leaned his head on the cold glass tabletop. +# - 'I need to cool down my head. It looks like it's on fire.' +# Soon after, the red telephone rang. The head of the Agency was calling and he +# wanted to know how the operation was going. +# - 'Yellow Cake already got started, General. So far, so good', Ary responded." +# -- Alexandre Von Baumgarten's "Yellow Cake" +# +# In this step, there will be the definition of functions to create and format a +# disk, populate it with directories and then, at the end of the build, unmount +# it, respectively. # And this will be used inside driver.ksh to find where packages/ is. -export progdir +export progdir trash # Syntax: build [stage_name] packages ... function build { @@ -11,6 +25,7 @@ function build { cross-tools) shift; build_xtools "$@" ;; tools) shift; build_tools "$@" ;; base) shift; build_base "$@" ;; + close) shift; close_build ;; esac } @@ -18,10 +33,7 @@ function build_xtools { packages=( "$@" ) n_packages=$(n "${packages[@]}") for (( n=0; n < n_packages; n++ )); do - # GNUcc pkgbuild will use it in a kind of messy way to determine - # if we're building stage 1 of cross-tools' G.C.C. or not. - (( n == 2 )) && export n; - "$progdir/build-system/internals/cmd/driver.ksh" -i ${packages[$n]} + "$progdir/build-system/internals/cmd/driver.ksh" -Dcross "${packages[$n]}" done } @@ -33,4 +45,25 @@ function build_base { return 0 } +# Note: the titles shall change insofar the script is written. +# STEP 4: Closing the build +# This function will just write the "/etc/copacabana-release" file on +# the final system, closing the build process. +function close_build { + version="$progdir/version" + release_file="$COPA/etc/copacabana-release" + if [[ ! -s "$version" ]] || ; then + printf '%.1f' 0.0 > "$version" + fi + record dtime final "$(date +'%Hh%Mmin on %B %d, %Y')" + + printf > "$release_file" \ + 'Copacabana %.1f/%s\nCopyright (c) %d-%d Pindorama. All rights reserved.\n\nDesigned between %s and %s. Built from %s until %s (UTC %s).\n' \ + "$(cat $version)" "$CPU" '2019' "$(date +"%Y")" \ + 'February 2021' "$(date +'%B %Y')" \ + "${dtime[initial]}" "${dtime[final]}" "$(date +%Z)" + + return 0 +} + build "$@" diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 772c486..c91755a 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -1,12 +1,17 @@ # This task script is part of Copacabana's build system. -# It contains a function for checking if all the dependencies needed for -# building Copacabana are present. # # Copyright (c) 2023: Pindorama # SPDX-Licence-Identifier: NCSA # C and C++ sanity checks by Samuel (callsamu), Lucas (volatusveritas) # and Luiz Antônio Rangel (takusuman) +# STEP 0: Resources, part II +# This file is part of the "step 0" of building Copacabana, it is one of the +# tools that's being used for checking resources on the machine. In this case, +# differently from the platform_checks, it contains a function for checking if +# all the dependencies needed for building Copacabana are present. +# It looks awful, I apologize. + function check_dependencies { # The place were sanity tests will be placed ksh_sanity_test="$trash/sanity.ksh" @@ -52,7 +57,7 @@ function check_dependencies { "$(type -p tar)" printerr \ 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' - function tar { "$(readlink -f "$(type -p tar)")" --no-secure-links $@ ;} + function tar { "$(type -p tar)" --no-secure-links $@ ;} typeset -xf tar fi diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index e17e779..9ce313a 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -1,7 +1,10 @@ -# That's the time to decide which will be, in fact, our source-code directory. -SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" -export SRCDIR +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023: Pindorama +# SPDX-Licence-Identifier: NCSA +# STEP 1: "Pindorama presents: Fubá Cake" +# In this step, we will create and format a disk, virtual or physical. function create_disk { disk_block="$1" @@ -110,7 +113,13 @@ function create_disk { printerr 'Info: Copacabana disk %s mounted at %s.\n' "$disk_block" "$COPA" } +# STEP 1.5: Populate the file system +# This function will run the cmd/populate_fhs.ksh script and create directories +# for the toolchains that will be built. function populate { + # That's the time to decide which will be, in fact, our source-code directory. + SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" + # Self-explanatory, just create the directories for the initial # toolchain and intermediary chroot toolchain. printerr 'Info: Making directories in %s for the building toolchains.\n' \ @@ -149,11 +158,12 @@ function populate { fi printerr 'Info: Making directories in %s for populating the file system.\n' \ "$COPA" - (cd "$COPA"; elevate $run_shell -c "COPA=$COPA $progdir/cmd/populate_fhs.ksh; mkdir -p "$COPA/$SRCDIR"") + (cd "$COPA"; elevate $run_shell -c "COPA=$COPA $progdir/cmd/populate_fhs.ksh; mkdir -p "$SRCDIR"") printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ - $(realpaths /{cgnu,llvm}tools) "$COPA/$SRCDIR" - elevate chown -RH "$user" /{cgnu,llvm}tools "$COPA/$SRCDIR" + $(realpaths /{cgnu,llvm}tools) "$SRCDIR" + elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" + export SRCDIR } function unmount_and_detach { diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_source-code.ksh index 5f6ec73..83f7f2c 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_source-code.ksh @@ -1,3 +1,21 @@ +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023: Pindorama +# SPDX-Licence-Identifier: NCSA + +# STEP 2: Ingredients +# "Cr$ 600.000.000? In cash? I can not afford this, General." +# -- Alexandre Von Baumgarten's "Yellow Cake" +# +# In this step, we'll be getting source code for building the distribution from +# the 'Net. Sounds cool, eh? +# As you can see, we're not calling aria2 or cURL directly, instead we're using +# --- since 2021 --- a script that does it for us. +# +# Some of them are coming from inside --- remember that "eating your own dog +# food" philosophy? So ---, but it's not included inside the Copacabana +# repository for obvious reasons. + function get_sources { # Get precise path for both sources.txt and sources.sha256, even though # download_sources.ksh already does this internally using a realpath() diff --git a/build-system/tasks/platform_checks.ksh b/build-system/tasks/platform_checks.ksh index 904844f..d1b5693 100644 --- a/build-system/tasks/platform_checks.ksh +++ b/build-system/tasks/platform_checks.ksh @@ -1,3 +1,15 @@ +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023: Pindorama +# SPDX-Licence-Identifier: NCSA + +# STEP 0: Resources, part I +# This file is part of the "step 0" of building Copacabana, it is one of the +# tools that's being used for checking resources on the machine. +# It's not a vulgar task file, since it will be called before others. +# To be honest, this needs a, let's say, "refactor". It was created back when +# the project was being desined. + function platform_checks { # Small checks about the shell being used for running this, if not # the more recent versions ( 2012-08-01 < ) of Korn Shell 93. @@ -59,11 +71,11 @@ source code to an object file in Oracle VirtualBox with multiple jobs-per-thread enabled in gmake. For avoiding this sort of problem later on, we will be defining the nproc function as just an alias to "echo 1". -If you wish to risk anyway, you can define "FIX_VBOX_BUILD" as 0 at '\''machine.conf'\''.\n' \ +If you wish to risk anyway, you can define "FIX_VBOX_BUILD" as "false" at '\''machine.conf'\''.\n' \ "$(grep -c 'processor' /proc/cpuinfo)" \ 1>&2 - typeset -x FIX_VBOX_BUILD=1 - if (( FIX_VBOX_BUILD == 1 )); then + typeset -x FIX_VBOX_BUILD="${FIX_VBOX_BUILD:-true}" + if $FIX_VBOX_BUILD; then function nproc { echo 1; } typeset -xf nproc; fi From 2f38e891c80339b68d180b62e8f3cd62ff4269cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 8 Nov 2023 20:03:16 -0300 Subject: [PATCH 018/128] fix: Schily tar-specific configuration --- build-system/tasks/check_dependencies.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index c91755a..bf04590 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -57,7 +57,7 @@ function check_dependencies { "$(type -p tar)" printerr \ 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' - function tar { "$(type -p tar)" --no-secure-links $@ ;} + function tar { STAR_SECURE_LINKS='N'; export STAR_SECURE_LINKS; "$(type -p tar)" $@ ;} typeset -xf tar fi From b1c5f16e6b62259a56dc0cf2f4baebc686e6962b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 15 Nov 2023 22:45:17 -0300 Subject: [PATCH 019/128] chore: Just export STAR_SECURE_LINKS --- build-system/tasks/check_dependencies.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index bf04590..d3d91b1 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -57,7 +57,7 @@ function check_dependencies { "$(type -p tar)" printerr \ 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' - function tar { STAR_SECURE_LINKS='N'; export STAR_SECURE_LINKS; "$(type -p tar)" $@ ;} + function tar { export STAR_SECURE_LINKS='N'; "$(type -p tar)" $@ ;} typeset -xf tar fi From e0c6f85b8fc2075ee505dd80df059bbfe5a10408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 15 Nov 2023 22:48:26 -0300 Subject: [PATCH 020/128] feat: Implement logto() function, that will be useful for not filling our terminal when building big packages. --- build-system/internals/helpers/helpers.shi | 12 +++++++++ build-system/machine.conf | 30 ++++++++++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 6aa8df7..f5dc140 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -8,6 +8,18 @@ # Make everyone aware we're running from BUILD_KSH. export readonly BUILD_KSH=true +# This function writes everything in a program output to a file passed as a +# parameter, else it also writes it to the standard output using tee(1). +# Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. +function logto { + file="$1" + # Do not be scared, just a boolean having a rendezvous with a + # more compact alternative to if-else statements. + c29waGlhZmljYWNvbWlnbwo=$I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR + { $c29waGlhZmljYWNvbWlnbwo && tee "$file"; } \ + || { cat - >> "$file"; } +} + # Creates an associative array with identifier, variable name and value as # its parameters. It's really similar to the code found on herbiec in this # sense, but it was originally used as a "pointeroid" for accessing an A.S.T. diff --git a/build-system/machine.conf b/build-system/machine.conf index ac7a666..2df1872 100644 --- a/build-system/machine.conf +++ b/build-system/machine.conf @@ -33,14 +33,19 @@ VIRTUADISK_SIZE=10 # not, just use "true". UMOUNT_ON_EXIT="false" -# This is used on the Korn Shell 93 implementation of sha256sum, -# present at cmd/ on this repository. -# The default is "openssl", you may change this if you're using -# LibreSSL or another fork and it doesn't provide its -# OpenSSL-compatible shell API binary symbolic/hard linked to -# "openssl" in your path. -# If changed, the value here must be lower-case. -# SSL_CMD="" +# Do you enjoy to sit for hours reading haphazardly shell-generated +# instructions given by GNU auto*tools for building enormous programs such as +# G.C.C. directly on your main terminal instead of just sending all of it for +# a log file and waiting for when some error happens? +# Are you getting paranoic with GNU's miraculous build system freezing your +# machine and absolutely needs to read pretty much meaningless --- and, again, +# haphazardly shell-generated --- instructions running on your screen just to +# realize that it's not your fault and just some funky bug? Marvellous! +# So this option shall be "true" for you! Else, just let it as it is. +# +# Anyway, if you have to read the logs, they will be sent to inside the +# Copacabana root directory in a file called "build.log." +I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" # Where do you want the source code to be saved? # This is the suffix for the source code directory. @@ -65,6 +70,15 @@ SHA256CHECK="YES" # cURL and/or taking considerably more time isn't a big deal. USE_ARIA2C="true" +# This is used on the Korn Shell 93 implementation of sha256sum, +# present at cmd/ on this repository. +# The default is "openssl", you may change this if you're using +# LibreSSL or another fork and it doesn't provide its +# OpenSSL-compatible shell API binary symbolic/hard linked to +# "openssl" in your path. +# If changed, the value here must be lower-case. +# SSL_CMD="" + # Programs CC="gcc" CXX="g++" From 2b8d7c4e67edbd995cce9864f968db73bc4a8b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 13 Dec 2023 00:19:28 -0300 Subject: [PATCH 021/128] feat!: Implemented dotini function for reading INI files. Also implemented rematch and panic. Reimplementation of record()/map() is to be made. --- build-system/internals/helpers/helpers.shi | 146 ++++++++++++++++++++- 1 file changed, 140 insertions(+), 6 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index f5dc140..75a30a8 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -8,6 +8,87 @@ # Make everyone aware we're running from BUILD_KSH. export readonly BUILD_KSH=true +# This function parses .INI files into +function dotini { + file="$1" + + # The function shall fail before "allocating" anything in memory. + if [[ ! -e "$file" ]]; then + panic '%s: file %s does not exist.\n' $0 "$file" + fi + + # Allocate an array for recording the file and declarate a + # integer that represents the number of the line. + typeset -a inibuf confline[2] + integer nl l s nconf + + # First of all, we shall remove comments. + # I know this could be done manually using a for-loop, but I think sed + # can be more relyable. + (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ + for ((nl=0; ; nl++)); do + if read line; then + inibuf[$nl]="$line" + else + break + fi + done + + # Open compound variable syntax + printf '%c' '(' + for ((l=0; l < ${#inibuf[@]}; l++)); do + line="${inibuf[l]}" + + # This gets the INI section. + if section_title="$(rematch "$line" '\[\(.*\)\]')"; then + # The formatted section title. + formatted_section="$(printf '%s' "$section_title" \ + | nawk '{ sub(" ", "_"); print(tolower($0)) }')" + # We can procceed to the next line. + continue + fi + + nconf=0 + for ((s=0; s < ${#line}; s++ )); do + q="${line:s:1}" + # A value declaration in INI follows the format: + # identifier = "value" + # Or + # identifier=value + # confline[1]=id + # confline[2]=val + + if [[ "$q" == '=' ]]; then + ((nconf+= 1 )) + continue + fi + + confline[$nconf]+="$q" + done + + # If there is not a section, it will only declare the INI + # variable and its value on the compound variable. + if [[ ! -n $formatted_section ]]; then + printf '%s="%s" ' \ + "${confline[0]}" "${confline[1]}" + + # Continue to the next line. + continue + fi + + # If it there's a section and the value declaration was already + # parsed, return it as a associative array declaration. + printf '[%s]+=([%s]=%s) ' \ + $formatted_section "${confline[0]}" "${confline[1]}" + + # Clean confline[] array. + unset confline[0] confline[1] + done + + # Close compound variable + printf '%c' ')' +} + # This function writes everything in a program output to a file passed as a # parameter, else it also writes it to the standard output using tee(1). # Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. @@ -20,16 +101,37 @@ function logto { || { cat - >> "$file"; } } +# Shall rework this later, one minute. + # Creates an associative array with identifier, variable name and value as # its parameters. It's really similar to the code found on herbiec in this # sense, but it was originally used as a "pointeroid" for accessing an A.S.T. -function record { - identifier="$1" - variable="$2" - value="$3" +#function map { +# identifier="$1" +# variable="$2" +# value="$3" +# +# eval $(printf '%s+=([%s]="%s")' "$identifier" "$variable" "$value") +#} - eval $(printf '%s+=([%s]="%s")' "$identifier" "$variable" "$value") -} +# And this creates a compound variable, which approachs more a Pascal record +# than the "old" record() that was renamed to "map" (as in Google Go's maps, but +# weakly typed). +#function record { +# identifier="$1" +# variable="$2" +# value="$3" +# +# eval $(printf '%s+=(%s="%s")' "$identifier" "$variable" "$value") +#} + +#function __record { +# identifier="$1" +# variable="$2" +# value="$3" + +# eval $(printf '%s+=(%s="%s")' "$identifier" "$variable" "$value") +#} # Reads simple Shell-based configuration files. # "#" is used for comments, and white spaces are ignored for read(1). @@ -40,6 +142,31 @@ function rconfig { done } +# Luiz' stupid match/rematch. +# It's my attempt on mimicking BASH_REMATCH functionality on pretty much +# any shell. Made it for using on dotini(), but pretty much anyone can adapt +# this. +# le.match is just a function that compares a string with a RegEx pattern to +# check if it matches it. If it does, it can me combined with le.rematch to +# obtain the capture group. +function rematch { + # Input string. + s="$1" + + # Regular expression "rule", as a filter. + re="$2" + + # If $re is empty, just exit without questions. + [[ ! -n "$re" ]] && return 0 + + # This gets rid of the capture group syntax that we will be using again + # on sed. egrep(1) could also be used, but I opted for shell built-ins + # since we're already on Korn Shell. + [[ "$s" =~ $(printf '%s' "$re" | sed 's/\\(//; s/\\)//') ]] || return 1 + + printf '%s' "$s" | sed "s/$re/\1/" +} + # Checks if a function or a variable is defined via its identifier. Analogous # on purpose to the C preprocessor special operator defined(), meant for being # used in if conditions. @@ -127,3 +254,10 @@ function check_elevate_method { function printerr { printf "$@" 1>&2 } + +# And use this for fatal errors, it will exit the script. +function panic { + msgbuf="$(printf "$@")" + printf 1>&2 'panic: %s' "$msgbuf" + exit 255 +} From da49acc531af85f8c874ccd8948ab0c57dc74463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 13 Dec 2023 01:50:04 -0300 Subject: [PATCH 022/128] feat: Refactor record() and map(). --- build-system/internals/helpers/helpers.shi | 111 +++++++++++++-------- 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 75a30a8..703ca8b 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -8,11 +8,22 @@ # Make everyone aware we're running from BUILD_KSH. export readonly BUILD_KSH=true -# This function parses .INI files into +# This function parses .INI files into a compound variable that can be used +# inside the script via eval. +# For example: +# +# eval private_config=$(dotini conf.ini) +# Then you could just access like so: +# printf '%s\n' "${private_config[SectName][KeyName]}" +# It does not outsource record() or map(), so there's more independence and +# flexibility on choosing identifiers for your INI file configuration. function dotini { file="$1" # The function shall fail before "allocating" anything in memory. + # This may sound like a worry that a C programmer might have, but it's + # just a formality when the topic are ksh-ish languages such as + # GNU's Bash or even ksh93 itself. if [[ ! -e "$file" ]]; then panic '%s: file %s does not exist.\n' $0 "$file" fi @@ -26,7 +37,7 @@ function dotini { # I know this could be done manually using a for-loop, but I think sed # can be more relyable. (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ - for ((nl=0; ; nl++)); do + for ((nl=0 ;; nl++)); do if read line; then inibuf[$nl]="$line" else @@ -55,8 +66,8 @@ function dotini { # identifier = "value" # Or # identifier=value - # confline[1]=id - # confline[2]=val + # confline[1]=identifier + # confline[2]=value if [[ "$q" == '=' ]]; then ((nconf+= 1 )) @@ -101,40 +112,65 @@ function logto { || { cat - >> "$file"; } } -# Shall rework this later, one minute. - -# Creates an associative array with identifier, variable name and value as -# its parameters. It's really similar to the code found on herbiec in this -# sense, but it was originally used as a "pointeroid" for accessing an A.S.T. -#function map { -# identifier="$1" -# variable="$2" -# value="$3" -# -# eval $(printf '%s+=([%s]="%s")' "$identifier" "$variable" "$value") -#} - -# And this creates a compound variable, which approachs more a Pascal record -# than the "old" record() that was renamed to "map" (as in Google Go's maps, but -# weakly typed). -#function record { -# identifier="$1" -# variable="$2" -# value="$3" +# map() and record() functions below. +# For the "back-end" implementation, see __record(), +# with the old Bourne/POSIX shell function prototype. # -# eval $(printf '%s+=(%s="%s")' "$identifier" "$variable" "$value") -#} +# map(): Creates an associative array with identifier, +# variable name and value as its parameters. +# It's really similar to the code found on herbiec in +# this sense, but it was originally used as a "pointeroid" +# for accessing an A.S.T. +function map { + identifier="$1" + variable="$2" + value="$3" + + eval $(__record "$identifier" "$variable" "$value") +} -#function __record { -# identifier="$1" -# variable="$2" -# value="$3" +# record(): And this creates a compound variable, which +# approachs more a Pascal record than the "old" record() +# --- that was renamed to "map" (as-in Google Go's maps, +# but weakly typed). +function record { + identifier="$1" + variable="$2" + value="$3" -# eval $(printf '%s+=(%s="%s")' "$identifier" "$variable" "$value") -#} + eval $(__record "$identifier" "$variable" "$value") +} + +# Using the good old Bourne function prototype because it permits that the +# function caller name "escapes" into it. +__record() { + # "London calling to the faraway towns... + # But it wasn't my love... + # Is she still upset with me?" + whos_calling="$0" + identifier="$1" + variable="$2" + value="$3" + + # The only thing that changes between record() and map() is the printf + # format before evaluating it into the script. + if [[ "$whos_calling" == 'record' ]]; then + format='%s+=(%s="%s")' + elif [[ "$whos_calling" == 'map' ]]; then + format='%s+=([%s]="%s")' + else + panic '%s: invalid caller '%s'.\n' \ + "record()/map() backend" "$whos_calling" + fi + + # Hope this works. + printf "$format" "$identifier" "$variable" "$value" +} # Reads simple Shell-based configuration files. # "#" is used for comments, and white spaces are ignored for read(1). +# Could be better written, sed did not need to be here. +# Deprecated in favour of dotini(), see above. function rconfig { (sed '/#/d; /^$/d' "$1") \ | while IFS='=' read identifier value; do @@ -142,13 +178,10 @@ function rconfig { done } -# Luiz' stupid match/rematch. -# It's my attempt on mimicking BASH_REMATCH functionality on pretty much -# any shell. Made it for using on dotini(), but pretty much anyone can adapt -# this. -# le.match is just a function that compares a string with a RegEx pattern to -# check if it matches it. If it does, it can me combined with le.rematch to -# obtain the capture group. +# Luiz' stupid (re)match. +# It's my attempt on mimicking BASH_REMATCH functionality +# on pretty much any shell. Made it for using on dotini(), +# but pretty much anyone can adapt this. function rematch { # Input string. s="$1" From febeeb73b7ccc1b3af90d9a07fe064057a4a4e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 15 Dec 2023 00:06:10 -0300 Subject: [PATCH 023/128] feat: Implemented inicompat() function, which takes a INI file in a compound variable form and disponibilizes its variables as vulgar shell declarations. --- build-system/internals/helpers/helpers.shi | 59 +++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 703ca8b..8e564d5 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -17,6 +17,28 @@ export readonly BUILD_KSH=true # printf '%s\n' "${private_config[SectName][KeyName]}" # It does not outsource record() or map(), so there's more independence and # flexibility on choosing identifiers for your INI file configuration. +# +# FIXME: When I got time --- or someone else that knows at least a bit of +# KornShell shows up ---, this parser needs to be fixed to support INI files +# that don't explicitly declare a section. +# Sure thing that second-rate hacks such as creating a default section called +# "global" were already thought of, so the ideal is to have just what is being +# described in the code. +# I could fix this in some hours, but I'm willing to work more on the rest of +# the build system instead of just some isolate functions that are already +# compliant with its needs. +# +# FIXME: Also it would be helpful to support files that use spaces between the +# identifier and value, for example: +# +# [sectname] +# keyname = value +# keyname_2 = "Another value" +# +# Being optimistic and careless about using shell built-ins (read as "read") +# instead of manipulating the string utilizing just KornShell's repetition +# control structures, this could be done just like it was done before at the +# old rconfig() function. function dotini { file="$1" @@ -35,7 +57,7 @@ function dotini { # First of all, we shall remove comments. # I know this could be done manually using a for-loop, but I think sed - # can be more relyable. + # can be more reliable. (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ for ((nl=0 ;; nl++)); do if read line; then @@ -100,6 +122,41 @@ function dotini { printf '%c' ')' } +# This function "converts" a compound variable generated from a .ini file via +# dotini() to the format "IDENTIFIER=VALUE". +# It can be useful if the program had just implemented .ini files as a way of +# configuration and developers doesn't want to mess with the entire source code. +# It takes the compound variable identifier as a input, for example: +# +# inicompat conf +# +# NOTE: See dotini()'s first "FIXME" and then implement a way to do it. +function inicompat { + set -x + + nameref inirecord=$1 + integer s k + typeset -a sections + + sections=( ${!inirecord[@]} ) + + for ((s=0; s<${#sections[@]}; s++ )); do + typeset -a confkeys + + section=${sections[s]} + confkeys=( ${!inirecord[$section][@]} ) + print -v confkeys + + for (( k=0; k < ${#confkeys[@]}; k++ )); do + confkey=${confkeys[$k]} + confval="${inirecord[$section][$confkey]}" + eval $(printf '%s=%s' $confkey "$confval") + unset confkey confval + done + unset section confkeys confkey confval + done +} + # This function writes everything in a program output to a file passed as a # parameter, else it also writes it to the standard output using tee(1). # Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. From aeb6a57e0739b4532e209d99945a8b6bc825ad5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 16 Dec 2023 03:36:48 -0300 Subject: [PATCH 024/128] feat: Rewrote rconfig to support INI files. --- build-system/internals/helpers/helpers.shi | 73 +++++++++++++++++----- build.ksh | 17 ++--- 2 files changed, 67 insertions(+), 23 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 8e564d5..7982dc2 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -4,10 +4,50 @@ # Copyright (c) 2023 Pindorama # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA +# +# "'Liberdade, Igualdade, Fraternidade', +# é o seguinte: se tem Liberdade, tem que +# ter Igualdade, Amor e Fraternidade [...]" # Make everyone aware we're running from BUILD_KSH. export readonly BUILD_KSH=true +# Reads INI configuration files, now a boilerplate function +# to dotini/inicompat --- and, in case of using +# GNU's Broken-Again Shell, it does a coarse conversion of +# the INI file to a simple Shell-based configuration file +# format. +function rconfig { + file="$1" + + if [[ -z $BASH && -n $KSH_VERSION ]]; then + # Load the .ini configuration file as + # a compound variable to the memory. + # Simple as that. + eval conf=$(dotini "$file") + inicompat conf + elif [[ -n $BASH ]]; then # BASH + cat "$1" | \ + for (( ;; )); do + if read line; then + if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] \ + || [[ "$line" =~ '^[#;].*$' ]]; then + continue + else + keyval="$(printf '%s' "$line" \ + | sed 's/^\(.*\)[#;].*/\1/;')" + identifier="${keyval%%=*}" + value="${keyval##*=}" + [[ "$keyval" =~ ^$ ]] && continue + eval $(printf '%s='\''%s'\''' $identifier "$value") + fi + else + break + fi + done + fi +} + # This function parses .INI files into a compound variable that can be used # inside the script via eval. # For example: @@ -102,7 +142,17 @@ function dotini { # If there is not a section, it will only declare the INI # variable and its value on the compound variable. if [[ ! -n $formatted_section ]]; then - printf '%s="%s" ' \ + # Using a apostrophe instead of quotations marks + # because, apart from the fact that it works as a + # micro-optimization --- since the shell will be + # treating its contents as vulgar strings instead of + # trying to interpret what is inside them ---, also + # prevents globbing of strings. + # The only thing that it doesn't prevents, + # unfortunately, is the abuse of subshells or malicious + # substitutions, but I do not think this can be a + # problem here. + printf '%s='\''%s'\'' ' \ "${confline[0]}" "${confline[1]}" # Continue to the next line. @@ -111,7 +161,7 @@ function dotini { # If it there's a section and the value declaration was already # parsed, return it as a associative array declaration. - printf '[%s]+=([%s]=%s) ' \ + printf '[%s]+=([%s]='\''%s'\'') ' \ $formatted_section "${confline[0]}" "${confline[1]}" # Clean confline[] array. @@ -132,8 +182,6 @@ function dotini { # # NOTE: See dotini()'s first "FIXME" and then implement a way to do it. function inicompat { - set -x - nameref inirecord=$1 integer s k typeset -a sections @@ -145,11 +193,11 @@ function inicompat { section=${sections[s]} confkeys=( ${!inirecord[$section][@]} ) - print -v confkeys for (( k=0; k < ${#confkeys[@]}; k++ )); do confkey=${confkeys[$k]} confval="${inirecord[$section][$confkey]}" + eval $(printf '%s=%s' $confkey "$confval") unset confkey confval done @@ -200,6 +248,10 @@ function record { # Using the good old Bourne function prototype because it permits that the # function caller name "escapes" into it. +# This is broken in GNU's Broken-Again Shell --- well, maybe I'm repeating +# this joke too many times, but Bash lives up to its nickname --- but this +# is no problem for now since Bash doesn't support compound variables, +# just associative arrays, so both "map" and "record" can be the same to Bash. __record() { # "London calling to the faraway towns... # But it wasn't my love... @@ -224,17 +276,6 @@ __record() { printf "$format" "$identifier" "$variable" "$value" } -# Reads simple Shell-based configuration files. -# "#" is used for comments, and white spaces are ignored for read(1). -# Could be better written, sed did not need to be here. -# Deprecated in favour of dotini(), see above. -function rconfig { - (sed '/#/d; /^$/d' "$1") \ - | while IFS='=' read identifier value; do - eval $(printf '%s=%s' $identifier "$value") - done -} - # Luiz' stupid (re)match. # It's my attempt on mimicking BASH_REMATCH functionality # on pretty much any shell. Made it for using on dotini(), diff --git a/build.ksh b/build.ksh index bc3a76b..24a01b0 100755 --- a/build.ksh +++ b/build.ksh @@ -9,12 +9,14 @@ progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" trash="$(mktemp -d /tmp/CopaBuild.XXXXXX)" +# Immediatly source and run the platform checks before doing anything else. +. "$progdir/build-system/tasks/platform_checks.ksh"; platform_checks + # Internal build system functions . "$progdir/build-system/internals/helpers/helpers.shi" . "$progdir/build-system/internals/helpers/posix-alt.shi" # Task files -. "$progdir/build-system/tasks/platform_checks.ksh" . "$progdir/build-system/tasks/check_dependencies.ksh" . "$progdir/build-system/tasks/disk_managenment.ksh" . "$progdir/build-system/tasks/get_source-code.ksh" @@ -22,22 +24,23 @@ trash="$(mktemp -d /tmp/CopaBuild.XXXXXX)" . "$progdir/build-system/tasks/finish.ksh" -rconfig "$progdir/build-system/machine.conf" -rconfig "$progdir/build-system/paths.conf" +rconfig "$progdir/build-system/machine.ini" + +map dtime initial "$(date +'%Hh%Mmin on %B %d, %Y')" -platform_checks check_elevate_method check_dependencies create_disk "$DISK_BLOCK" populate get_sources sources.txt sources.sha256 -build cross-tools "base/kernel-headers" "dev/GNUBinutils" \ - "dev/GNUcc" "base/LibC" "dev/GNUcc" +build cross-tools cross/mussel +#build cross-tools "base/kernel-headers" "dev/GNUBinutils" \ +# "dev/GNUcc" "base/LibC" "dev/GNUcc" #build tools "base/kernel-headers" "dev/GNUBinutils" \ # "dev/GNUcc" "base/LibC" "dev/GNUcc" #build base "base/kernel-headers" "dev/GNUBinutils" \ # "dev/GNUcc" "base/LibC" "dev/GNUcc" - +build close finish From b71dcba79a07c2334e27e1d82fd166ecbdbb06bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 22 Dec 2023 06:15:52 -0300 Subject: [PATCH 025/128] fix dotini(): Use NAWK's ``gsub()`` for global pattern substitution. --- build-system/internals/helpers/helpers.shi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 7982dc2..09bd89b 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -116,7 +116,7 @@ function dotini { if section_title="$(rematch "$line" '\[\(.*\)\]')"; then # The formatted section title. formatted_section="$(printf '%s' "$section_title" \ - | nawk '{ sub(" ", "_"); print(tolower($0)) }')" + | nawk '{ gsub(" ", "_"); print(tolower($0)) }')" # We can procceed to the next line. continue fi From 4e6a2997cbfb3edd253befbe7eafc6cc6bda5f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 22 Dec 2023 06:38:28 -0300 Subject: [PATCH 026/128] fix dependency checks: Finally fixed Schily's tar --no-secure-links and also bypassed 8 GiB limit. --- build-system/tasks/check_dependencies.ksh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index d3d91b1..8b9c99e 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -57,7 +57,12 @@ function check_dependencies { "$(type -p tar)" printerr \ 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' - function tar { export STAR_SECURE_LINKS='N'; "$(type -p tar)" $@ ;} + printerr \ + 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).\n' + function tar { + "$(type -p tar)" "$@" \ + --no-secure-links --artype=xustar + } typeset -xf tar fi From fbdccb00048941b1f9e1d28adba5f3a1b98008dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 23 Dec 2023 14:41:16 -0300 Subject: [PATCH 027/128] Load configuration completely from .ini files. --- build-system/fhs.ini | 6 + build-system/internals/cmd/driver.ksh | 112 +- .../internals/helpers/ini-test/php.ini | 1918 +++++++++++++++++ .../internals/helpers/ini-test/test2.ini | 10 + build-system/machine.conf | 86 - build-system/machine.ini | 28 + build-system/paths.conf | 13 - build-system/tasks/build_all.ksh | 13 +- build-system/tasks/check_dependencies.ksh | 2 +- build-system/tasks/disk_managenment.ksh | 13 +- build-system/tasks/finish.ksh | 2 +- build-system/work.ini | 18 + build.ksh | 2 + 13 files changed, 2079 insertions(+), 144 deletions(-) create mode 100644 build-system/fhs.ini create mode 100644 build-system/internals/helpers/ini-test/php.ini create mode 100644 build-system/internals/helpers/ini-test/test2.ini delete mode 100644 build-system/machine.conf create mode 100644 build-system/machine.ini delete mode 100644 build-system/paths.conf create mode 100644 build-system/work.ini diff --git a/build-system/fhs.ini b/build-system/fhs.ini new file mode 100644 index 0000000..c8b8d5b --- /dev/null +++ b/build-system/fhs.ini @@ -0,0 +1,6 @@ +; Unless you know what you are doing, please, ignore this file +; and leave it untouched. +[File System Hierarchy] +DIRS="sbin bin boot dev etc lib lib64 opt proc run/ run/lock sys tmp" +USRDIRS="usr/ usr/sbin usr/bin usr/ccs usr/etc usr/include usr/lib usr/share/ usr/share/doc usr/share/man usr/share/misc usr/share/lib usr/skel usr/src usr/tmp" +VARDIRS="var/ var/adm var/cache var/lib/ var/lib/color var/lib/misc var/spool/ var/spool/mail" diff --git a/build-system/internals/cmd/driver.ksh b/build-system/internals/cmd/driver.ksh index 918d8c1..5155a90 100755 --- a/build-system/internals/cmd/driver.ksh +++ b/build-system/internals/cmd/driver.ksh @@ -2,13 +2,10 @@ # Driver for running Copacabana package build recipes. # Note: This script isn't meant to be run standalone, since it makes use of # variables exported from the main script, build.ksh -set -x - -set -e # shellcheck disable=SC2068 -drvname="$1" +drvname="$0" # If (and when) ran from build.ksh, this will $0 will be build.ksh, so we can # get its directory and touché: we also have the base directory for pkgbuilds @@ -19,6 +16,10 @@ progdir="$build_kshdir" alambiko_directory="$progdir/packages" patch_directory="$progdir/patches" +# Load helper library +source "$build_kshdir/build-system/internals/helpers/helpers.shi" +source "$build_kshdir/build-system/internals/helpers/dirs.shi" + # Base directories for building packages, one is for residue, object # files and source code ("slact"), the other is for built packages ("aqua # vitæ"). @@ -26,9 +27,7 @@ base_objdir="$trash/slact" base_destdir="$trash/aqua_vitæ" function main { - if (( $# == 0 )); then - print_help - fi + set -e while getopts ":D:i" options; do case "$options" in @@ -38,10 +37,15 @@ function main { esac done shift $(( OPTIND - 1 )) + + if (( $# == 0 )); then + print_help + fi [ $info_flag ] \ && print_pkgbuild_info "$1" - + + printerr '%s: Info: Building %s for %s.\n' "$drvname" "$1" "$VARIANT" | tee "$blackbox" transmutacio "$1" } @@ -59,6 +63,8 @@ function eval_pkgbuild_path { } function read_pkgbuild { + package_recipe="$(eval_pkgbuild_path "$1")" + # Treat the output from get_package_info() to remove white lines and # comments, also eval the variables in the script. rconfig <(get_pkgbuild_info "$package_recipe") @@ -76,7 +82,7 @@ function print_pkgbuild_info { } function get_pkgbuild_info { - package_recipe="$(eval_pkgbuild_path "$1")" + package_recipe="$1" printf "pkgbuild_dir=%s\n" "$package_recipe" # This will read package information from the pkgbuild header, which is @@ -85,14 +91,16 @@ function get_pkgbuild_info { } function get_pkgbuild_functions { - package_recipe="$(eval_pkgbuild_path "$1")" - + package_recipe="$1" + # This will read the pkgbuild functions until the end of the file. - nawk '/.\(\)/, !/./' "$package_recipe" + # nawk '/.\(\)/, !/./' "$package_recipe" + cat "$package_recipe" } function transmutacio { set -x + set -e package="$1" read_pkgbuild "$package" @@ -101,33 +109,63 @@ function transmutacio { # depending on the packages built. OBJDIR="$base_objdir/$VARIANT" - # + # Destdir for packages. DESTDIR="$base_destdir/$VARIANT/${Archive_name%.t*}" export OBJDIR DESTDIR - - # Check if every "standard" pkgbuild function is defined before running, - # so we won't have problems with future "boilerplate" pkgbuilds that - # just create symbolic links, for instance. - if $(defined unarchive); then - # Find the source code archive inside the $SRCDIR using find(1) - # so we won't be having to alias categories from Alambiko with - # internal Copacabana category names. - source_archive_dir="$(dirname "$(find "$SRCDIR" -name "$Archive_name" -type f -print)")" - - pushd "$source_archive_dir" - unarchive - popd - fi - - if $(defined package_conf); then - # If $Destdir not defined from the pkgbuild, default it - # to $DESTDIR. It is expected to be declared when the package - # needs to be installed in a custom location. - # For instance, cross-tools' and tools' base/LibC package. - pushd "${Destdir:-$DESTDIR}" - package_conf - popd - fi + + # Create them. + mkdir -p "$OBJDIR" "$DESTDIR" + + # Find the source code archive inside the $SRCDIR using find(1) + # so we won't be having to alias categories from Alambiko with + # internal Copacabana category names. + source_archive_dir="$(dirname "$(find "$SRCDIR" -name "$Archive_name" -type f -print)")" + + # "Shared" methods for functions defined + shared_methods=('configure' 'build' 'make_pkg') + + { + if $(defined unarchive); then + ( cd "$source_archive_dir"; unarchive ) + if (( $? != 0 )); then + printerr 'Error: Failed to unarchive %s from %s. Error code: %d\n' \ + "$Archive_name" "$package" $? + fi + fi + + # Check if every "standard" pkgbuild function is defined before running, + # so we won't have problems with future "boilerplate" pkgbuilds that + # just create symbolic links, for instance. + for (( c=0; c <= ${#shared_methods[@]}; c++ )); do + if $(defined $(printf '%s' ${shared_methods[$c]})); then + if [[ "${shared_methods[$c]}" == 'make_pkg' ]]; then + Destdir="$DESTDIR/$Destdir" + DESTDIR="$Destdir" + ROOT="$DESTDIR" + export DESTDIR OBJDIR ROOT + mkdir -p "$ROOT" + fi + ( cd "$OBJDIR"; ${shared_methods[$c]} ) + if (( $? != 0 )); then + printerr 'Error: Failed to %s %s. Error code: %d\n' \ + "${shared_methods[$c]}" "$package" $? + fi + fi + done + + if $(defined post_install); then + # If $Destdir not defined from the pkgbuild, default it + # to $DESTDIR. It is expected to be declared when the package + # needs to be installed in a custom location. + # For instance, cross-tools' and tools' base/LibC package. + ( cd "$DESTDIR"; post_install ) + if (( $? != 0 )); then + printerr \ + 'Error: Failed to do the post install process on %s at %s. Error code: %d\n' \ + "$package" "$DESTDIR" $? + fi + fi + } 2>&1 | logto "$blackbox" } function print_help { diff --git a/build-system/internals/helpers/ini-test/php.ini b/build-system/internals/helpers/ini-test/php.ini new file mode 100644 index 0000000..349df05 --- /dev/null +++ b/build-system/internals/helpers/ini-test/php.ini @@ -0,0 +1,1918 @@ +[PHP] + +;;;;;;;;;; +; About php.ini ; +;;;;;;;;;; +; PHP's initialization file, generally called php.ini, is responsible for +; configuring many of the aspects of PHP's behavior. + +; PHP attempts to find and load this configuration from a number of locations. +; The following is a summary of its search order: +; 1. SAPI module specific location. +; 2. The PHPRC environment variable. (As of PHP 5.2.0) +; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) +; 4. Current working directory (except CLI) +; 5. The web server's directory (for SAPI modules), or directory of PHP +; (otherwise in Windows) +; 6. The directory from the --with-config-file-path compile time option, or the +; Windows directory (C:\windows or C:\winnt) +; See the PHP docs for more specific information. +; http://php.net/configuration.file + +; The syntax of the file is extremely simple. Whitespace and lines +; beginning with a semicolon are silently ignored (as you probably guessed). +; Section headers (e.g. [Foo]) are also silently ignored, even though +; they might mean something in the future. + +; Directives following the section heading [PATH=/www/mysite] only +; apply to PHP files in the /www/mysite directory. Directives +; following the section heading [HOST=www.example.com] only apply to +; PHP files served from www.example.com. Directives set in these +; special sections cannot be overridden by user-defined INI files or +; at runtime. Currently, [PATH=] and [HOST=] sections only work under +; CGI/FastCGI. +; http://php.net/ini.sections + +; Directives are specified using the following syntax: +; directive = value +; Directive names are *case sensitive* - foo=bar is different from FOO=bar. +; Directives are variables used to configure PHP or PHP extensions. +; There is no name validation. If PHP can't find an expected +; directive because it is not set or is mistyped, a default value will be used. + +; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one +; of the INI constants (On, Off, True, False, Yes, No and None) or an expression +; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a +; previously set variable or directive (e.g. ${foo}) + +; Expressions in the INI file are limited to bitwise operators and parentheses: +; | bitwise OR +; ^ bitwise XOR +; & bitwise AND +; ~ bitwise NOT +; ! boolean NOT + +; Boolean flags can be turned on using the values 1, On, True or Yes. +; They can be turned off using the values 0, Off, False or No. + +; An empty string can be denoted by simply not writing anything after the equal +; sign, or by using the None keyword: + +; foo = ; sets foo to an empty string +; foo = None ; sets foo to an empty string +; foo = "None" ; sets foo to the string 'None' + +; If you use constants in your value, and these constants belong to a +; dynamically loaded extension (either a PHP extension or a Zend extension), +; you may only use these constants *after* the line that loads the extension. + +;;;;;;;;;; +; About this file ; +;;;;;;;;;; +; PHP comes packaged with two INI files. One that is recommended to be used +; in production environments and one that is recommended to be used in +; development environments. + +; php.ini-production contains settings which hold security, performance and +; best practices at its core. But please be aware, these settings may break +; compatibility with older or less security conscience applications. We +; recommending using the production ini in production and testing environments. + +; php.ini-development is very similar to its production variant, except it is +; much more verbose when it comes to errors. We recommend using the +; development version only in development environments, as errors shown to +; application users can inadvertently leak otherwise secure information. + +; This is php.ini-production INI file. + +;;;;;;;;;; +; Quick Reference ; +;;;;;;;;;; +; The following are all the settings which are different in either the production +; or development versions of the INIs with respect to PHP's default behavior. +; Please see the actual settings later in the document for more details as to why +; we recommend these changes in PHP's behavior. + +; display_errors +; Default Value: On +; Development Value: On +; Production Value: Off + +; display_startup_errors +; Default Value: Off +; Development Value: On +; Production Value: Off + +; error_reporting +; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED +; Development Value: E_ALL +; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT + +; html_errors +; Default Value: On +; Development Value: On +; Production value: On + +; log_errors +; Default Value: Off +; Development Value: On +; Production Value: On + +; max_input_time +; Default Value: -1 (Unlimited) +; Development Value: 60 (60 seconds) +; Production Value: 60 (60 seconds) + +; output_buffering +; Default Value: Off +; Development Value: 4096 +; Production Value: 4096 + +; register_argc_argv +; Default Value: On +; Development Value: Off +; Production Value: Off + +; request_order +; Default Value: None +; Development Value: "GP" +; Production Value: "GP" + +; session.gc_divisor +; Default Value: 100 +; Development Value: 1000 +; Production Value: 1000 + +; session.sid_bits_per_character +; Default Value: 4 +; Development Value: 5 +; Production Value: 5 + +; short_open_tag +; Default Value: On +; Development Value: Off +; Production Value: Off + +; track_errors +; Default Value: Off +; Development Value: On +; Production Value: Off + +; variables_order +; Default Value: "EGPCS" +; Development Value: "GPCS" +; Production Value: "GPCS" + +;;;;;;;;;; +; php.ini Options ; +;;;;;;;;;; +; Name for user-defined php.ini (.htaccess) files. Default is ".user.ini" +user_ini.filename = ".user.ini" + +; To disable this feature set this option to empty value +user_ini.filename = + +; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) +user_ini.cache_ttl = 300 + +;;;;;;;;;; +; Language Options ; +;;;;;;;;;; + +; Enable the PHP scripting language engine under Apache. +; http://php.net/engine +engine = On + +; This directive determines whether or not PHP will recognize code between +; tags as PHP source which should be processed as such. It is +; generally recommended that should be used and that this feature +; should be disabled, as enabling it may result in issues when generating XML +; documents, however this remains supported for backward compatibility reasons. +; Note that this directive does not control the would work. +; http://php.net/syntax-highlighting +highlight.string = #DD0000 +highlight.comment = #FF9900 +highlight.keyword = #007700 +highlight.default = #0000BB +highlight.html = #000000 + +; If enabled, the request will be allowed to complete even if the user aborts +; the request. Consider enabling it if executing long requests, which may end up +; being interrupted by the user or a browser timing out. PHP's default behavior +; is to disable this feature. +; http://php.net/ignore-user-abort +ignore_user_abort = On + +; Determines the size of the realpath cache to be used by PHP. This value should +; be increased on systems where PHP opens many files to reflect the quantity of +; the file operations performed. +; http://php.net/realpath-cache-size +realpath_cache_size = 4096k + +; Duration of time, in seconds for which to cache realpath information for a given +; file or directory. For systems with rarely changing files, consider increasing this +; value. +; http://php.net/realpath-cache-ttl +realpath_cache_ttl = 120 + +; Enables or disables the circular reference collector. +; http://php.net/zend.enable-gc +zend.enable_gc = On + +; If enabled, scripts may be written in encodings that are incompatible with +; the scanner. CP936, Big5, CP949 and Shift_JIS are the examples of such +; encodings. To use this feature, mbstring extension must be enabled. +; Default: Off +zend.multibyte = Off + +; Allows to set the default encoding for the scripts. This value will be used +; unless "declare(encoding=...)" directive appears at the top of the script. +; Only affects if zend.multibyte is set. +; Default: "" +zend.script_encoding = + +;;;;;;;;; +; Miscellaneous ; +;;;;;;;;; + +; Decides whether PHP may expose the fact that it is installed on the server +; (e.g. by adding its signature to the Web server header). It is no security +; threat in any way, but it makes it possible to determine whether you use PHP +; on your server or not. +; http://php.net/expose-php +expose_php = On + +;;;;;;;;;; +; Resource Limits ; +;;;;;;;;;; + +; Maximum execution time of each script, in seconds +; http://php.net/max-execution-time +; Note: This directive is hardcoded to 0 for the CLI SAPI +max_execution_time = 30 + +; Maximum amount of time each script may spend parsing request data. It's a good +; idea to limit this time on productions servers in order to eliminate unexpectedly +; long running scripts. +; Note: This directive is hardcoded to -1 for the CLI SAPI +; Default Value: -1 (Unlimited) +; Development Value: 60 (60 seconds) +; Production Value: 60 (60 seconds) +; http://php.net/max-input-time +max_input_time = 60 + +; Maximum input variable nesting level +; http://php.net/max-input-nesting-level +max_input_nesting_level = 64 + +; How many GET/POST/COOKIE input variables may be accepted +; max_input_vars = 1000 + +; Maximum amount of memory a script may consume (128MB) +; http://php.net/memory-limit +memory_limit = 128M + +;;;;;;;;;;;;;;; +; Error handling and logging ; +;;;;;;;;;;;;;;; + +; This directive informs PHP of which errors, warnings and notices you would like +; it to take action for. The recommended way of setting values for this +; directive is through the use of the error level constants and bitwise +; operators. The error level constants are below here for convenience as well as +; some common settings and their meanings. +; By default, PHP is set to take action on all errors, notices and warnings EXCEPT +; those related to E_NOTICE and E_STRICT, which together cover best practices and +; recommended coding standards in PHP. For performance reasons, this is the +; recommend error reporting setting. Your production server shouldn't be wasting +; resources complaining about best practices and coding standards. That's what +; development servers and development settings are for. +; Note: The php.ini-development file has this setting as E_ALL. This +; means it pretty much reports everything which is exactly what you want during +; development and early testing. +; +; Error Level Constants: +; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0) +; E_ERROR - fatal run-time errors +; E_RECOVERABLE_ERROR - almost fatal run-time errors +; E_WARNING - run-time warnings (non-fatal errors) +; E_PARSE - compile-time parse errors +; E_NOTICE - run-time notices (these are warnings which often result +; from a bug in your code, but it's possible that it was +; intentional (e.g., using an uninitialized variable and +; relying on the fact it is automatically initialized to an +; empty string) +; E_STRICT - run-time notices, enable to have PHP suggest changes +; to your code which will ensure the best interoperability +; and forward compatibility of your code +; E_CORE_ERROR - fatal errors that occur during PHP's initial startup +; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's +; initial startup +; E_COMPILE_ERROR - fatal compile-time errors +; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) +; E_USER_ERROR - user-generated error message +; E_USER_WARNING - user-generated warning message +; E_USER_NOTICE - user-generated notice message +; E_DEPRECATED - warn about code that will not work in future versions +; of PHP +; E_USER_DEPRECATED - user-generated deprecation warnings +; +; Common Values: +; E_ALL (Show all errors, warnings and notices including coding standards.) +; E_ALL & ~E_NOTICE (Show all errors, except for notices) +; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.) +; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) +; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED +; Development Value: E_ALL +; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT +; http://php.net/error-reporting +error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT + +; This directive controls whether or not and where PHP will output errors, +; notices and warnings too. Error output is very useful during development, but +; it could be very dangerous in production environments. Depending on the code +; which is triggering the error, sensitive information could potentially leak +; out of your application such as database usernames and passwords or worse. +; For production environments, we recommend logging errors rather than +; sending them to STDOUT. +; Possible Values: +; Off = Do not display any errors +; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) +; On or stdout = Display errors to STDOUT +; Default Value: On +; Development Value: On +; Production Value: Off +; http://php.net/display-errors +display_errors = Off + +; The display of errors which occur during PHP's startup sequence are handled +; separately from display_errors. PHP's default behavior is to suppress those +; errors from clients. Turning the display of startup errors on can be useful in +; debugging configuration problems. We strongly recommend you +; set this to 'off' for production servers. +; Default Value: Off +; Development Value: On +; Production Value: Off +; http://php.net/display-startup-errors +display_startup_errors = Off + +; Besides displaying errors, PHP can also log errors to locations such as a +; server-specific log, STDERR, or a location specified by the error_log +; directive found below. While errors should not be displayed on productions +; servers they should still be monitored and logging is a great way to do that. +; Default Value: Off +; Development Value: On +; Production Value: On +; http://php.net/log-errors +log_errors = On + +; Set maximum length of log_errors. In error_log information about the source is +; added. The default is 1024 and 0 allows to not apply any maximum length at all. +; http://php.net/log-errors-max-len +log_errors_max_len = 1024 + +; Do not log repeated messages. Repeated errors must occur in same file on same +; line unless ignore_repeated_source is set true. +; http://php.net/ignore-repeated-errors +ignore_repeated_errors = Off + +; Ignore source of message when ignoring repeated messages. When this setting +; is On you will not log errors with repeated messages from different files or +; source lines. +; http://php.net/ignore-repeated-source +ignore_repeated_source = Off + +; If this parameter is set to Off, then memory leaks will not be shown (on +; stdout or in the log). This has only effect in a debug compile, and if +; error reporting includes E_WARNING in the allowed list +; http://php.net/report-memleaks +report_memleaks = On + +; This setting is on by default. +report_zend_debug = 0 + +; Store the last error/warning message in $php_errormsg (boolean). Setting this value +; to On can assist in debugging and is appropriate for development servers. It should +; however be disabled on production servers. +; Default Value: Off +; Development Value: On +; Production Value: Off +; http://php.net/track-errors +track_errors = Off + +; Turn off normal error reporting and emit XML-RPC error XML +; http://php.net/xmlrpc-errors +xmlrpc_errors = 0 + +; An XML-RPC faultCode +xmlrpc_error_number = 0 + +; When PHP displays or logs an error, it has the capability of formatting the +; error message as HTML for easier reading. This directive controls whether +; the error message is formatted as HTML or not. +; Note: This directive is hardcoded to Off for the CLI SAPI +; Default Value: On +; Development Value: On +; Production value: On +; http://php.net/html-errors +html_errors = On + +; If html_errors is set to On *and* docref_root is not empty, then PHP +; produces clickable error messages that direct to a page describing the error +; or function causing the error in detail. +; You can download a copy of the PHP manual from http://php.net/docs +; and change docref_root to the base URL of your local copy including the +; leading '/'. You must also specify the file extension being used including +; the dot. PHP's default behavior is to leave these settings empty, in which +; case no links to documentation are generated. +; Note: Never use this feature for production boxes. +; http://php.net/docref-root +; Examples +docref_root = "/phpmanual/" + +; http://php.net/docref-ext +docref_ext = .html + +; String to output before an error message. PHP's default behavior is to leave +; this setting blank. +; http://php.net/error-prepend-string +; Example: +error_prepend_string = "" + +; String to output after an error message. PHP's default behavior is to leave +; this setting blank. +; http://php.net/error-append-string +; Example: +error_append_string = "" + +; Log errors to specified file. PHP's default behavior is to leave this value +; empty. +; http://php.net/error-log +; Example: +error_log = php_errors.log +; Log errors to syslog (Event Log on Windows). +error_log = syslog + +windows.show_crt_warning +; Default value: 0 +; Development value: 0 +; Production value: 0 + +;;;;;;;;; +; Data Handling ; +;;;;;;;;; + +; The separator used in PHP generated URLs to separate arguments. +; PHP's default setting is "&". +; http://php.net/arg-separator.output +; Example: +arg_separator.output = "&" + +; List of separator(s) used by PHP to parse input URLs into variables. +; PHP's default setting is "&". +; NOTE: Every character in this directive is considered as separator! +; http://php.net/arg-separator.input +; Example: +arg_separator.input = "&" + +; This directive determines which super global arrays are registered when PHP +; starts up. G,P,C,E & S are abbreviations for the following respective super +; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty +; paid for the registration of these arrays and because ENV is not as commonly +; used as the others, ENV is not recommended on productions servers. You +; can still get access to the environment variables through getenv() should you +; need to. +; Default Value: "EGPCS" +; Development Value: "GPCS" +; Production Value: "GPCS"; +; http://php.net/variables-order +variables_order = "GPCS" + +; This directive determines which super global data (G,P & C) should be +; registered into the super global array REQUEST. If so, it also determines +; the order in which that data is registered. The values for this directive +; are specified in the same manner as the variables_order directive, +; EXCEPT one. Leaving this value empty will cause PHP to use the value set +; in the variables_order directive. It does not mean it will leave the super +; globals array REQUEST empty. +; Default Value: None +; Development Value: "GP" +; Production Value: "GP" +; http://php.net/request-order +request_order = "GP" + +; This directive determines whether PHP registers $argv & $argc each time it +; runs. $argv contains an array of all the arguments passed to PHP when a script +; is invoked. $argc contains an integer representing the number of arguments +; that were passed when the script was invoked. These arrays are extremely +; useful when running scripts from the command line. When this directive is +; enabled, registering these variables consumes CPU cycles and memory each time +; a script is executed. For performance reasons, this feature should be disabled +; on production servers. +; Note: This directive is hardcoded to On for the CLI SAPI +; Default Value: On +; Development Value: Off +; Production Value: Off +; http://php.net/register-argc-argv +register_argc_argv = Off + +; When enabled, the ENV, REQUEST and SERVER variables are created when they're +; first used (Just In Time) instead of when the script starts. If these +; variables are not used within a script, having this directive on will result +; in a performance gain. The PHP directive register_argc_argv must be disabled +; for this directive to have any affect. +; http://php.net/auto-globals-jit +auto_globals_jit = On + +; Whether PHP will read the POST data. +; This option is enabled by default. +; Most likely, you won't want to disable this option globally. It causes $_POST +; and $_FILES to always be empty; the only way you will be able to read the +; POST data will be through the php://input stream wrapper. This can be useful +; to proxy requests or to process the POST data in a memory efficient fashion. +; http://php.net/enable-post-data-reading +enable_post_data_reading = Off + +; Maximum size of POST data that PHP will accept. +; Its value may be 0 to disable the limit. It is ignored if POST data reading +; is disabled through enable_post_data_reading. +; http://php.net/post-max-size +post_max_size = 8M + +; Automatically add files before PHP document. +; http://php.net/auto-prepend-file +auto_prepend_file = + +; Automatically add files after PHP document. +; http://php.net/auto-append-file +auto_append_file = + +; By default, PHP will output a media type using the Content-Type header. To +; disable this, simply set it to be empty. +; +; PHP's built-in default media type is set to text/html. +; http://php.net/default-mimetype +default_mimetype = "text/html" + +; PHP's default character set is set to UTF-8. +; http://php.net/default-charset +default_charset = "UTF-8" + +; PHP internal character encoding is set to empty. +; If empty, default_charset is used. +; http://php.net/internal-encoding +internal_encoding = + +; PHP input character encoding is set to empty. +; If empty, default_charset is used. +; http://php.net/input-encoding +input_encoding = + +; PHP output character encoding is set to empty. +; If empty, default_charset is used. +; See also output_buffer. +; http://php.net/output-encoding +output_encoding = + +;;;;;;;;;;;;; +; Paths and Directories ; +;;;;;;;;;;;;; + +; UNIX: "/path1:/path2" +include_path = ".:/php/includes" +; +; Windows: "\path1\path2" +include_path = ".c:\php\includes" +; +; PHP's default setting for include_path is "./path/to/php/pear" +; http://php.net/include-path + +; The root of the PHP pages, used only if nonempty. +; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root +; if you are running php as a CGI under any web server (other than IIS) +; see documentation for security issues. The alternate is to use the +; cgi.force_redirect configuration below +; http://php.net/doc-root +doc_root = + +; The directory under which PHP opens the script using /~username used only +; if nonempty. +; http://php.net/user-dir +user_dir = + +; Directory in which the loadable extensions (modules) reside. +; http://php.net/extension-dir +; extension_dir = "./" +; On windows: +; extension_dir = "ext" + +; Directory where the temporary files should be placed. +; Defaults to the system default (see sys_get_temp_dir) +; sys_temp_dir = "/tmp" + +; Whether or not to enable the dl() function. The dl() function does NOT work +; properly in multithreaded servers, such as IIS or Zeus, and is automatically +; disabled on them. +; http://php.net/enable-dl +enable_dl = Off + +; cgi.force_redirect is necessary to provide security running PHP as a CGI under +; most web servers. Left undefined, PHP turns this on by default. You can +; turn it off here AT YOUR OWN RISK +; **You CAN safely turn this off for IIS, in fact, you MUST.** +; http://php.net/cgi.force-redirect +cgi.force_redirect = 1 + +; if cgi.nph is enabled it will force cgi to always sent Status: 200 with +; every request. PHP's default behavior is to disable this feature. +cgi.nph = 1 + +; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape +; (iPlanet) web servers, you MAY need to set an environment variable name that PHP +; will look for to know it is OK to continue execution. Setting this variable MAY +; cause security issues, KNOW WHAT YOU ARE DOING FIRST. +; http://php.net/cgi.redirect-status-env +cgi.redirect_status_env = + +; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's +; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok +; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting +; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting +; of zero causes PHP to behave as before. Default is 1. You should fix your scripts +; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. +; http://php.net/cgi.fix-pathinfo +cgi.fix_pathinfo=1 + +; if cgi.discard_path is enabled, the PHP CGI binary can safely be placed outside +; of the web tree and people will not be able to circumvent .htaccess security. +; http://php.net/cgi.dicard-path +cgi.discard_path=1 + +; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate +; security tokens of the calling client. This allows IIS to define the +; security context that the request runs under. mod_fastcgi under Apache +; does not currently support this feature (03/17/2002) +; Set to 1 if running under IIS. Default is zero. +; http://php.net/fastcgi.impersonate +fastcgi.impersonate = 1 + +; Disable logging through FastCGI connection. PHP's default behavior is to enable +; this feature. +fastcgi.logging = 0 + +; cgi.rfc2616_headers configuration option tells PHP what type of headers to +; use when sending HTTP response code. If set to 0, PHP sends Status: header that +; is supported by Apache. When this option is set to 1, PHP will send +; RFC2616 compliant header. +; Default is zero. +; http://php.net/cgi.rfc2616-headers +cgi.rfc2616_headers = 0 + +; cgi.check_shebang_line controls whether CGI PHP checks for line starting with #! +; (shebang) at the top of the running script. This line might be needed if the +; script support running both as stand-alone script and via PHP CGI<. PHP in CGI +; mode skips this line and ignores its content if this directive is turned on. +; http://php.net/cgi.check-shebang-line +cgi.check_shebang_line=1 + +;;;;;;;; +; File Uploads ; +;;;;;;;; + +; Whether to allow HTTP file uploads. +; http://php.net/file-uploads +file_uploads = On + +; Temporary directory for HTTP uploaded files (will use system default if not +; specified). +; http://php.net/upload-tmp-dir +upload_tmp_dir = + +; Maximum allowed size for uploaded files. +; http://php.net/upload-max-filesize +upload_max_filesize = 2M + +; Maximum number of files that can be uploaded via a single request +max_file_uploads = 20 + +;;;;;;;;; +; Fopen wrappers ; +;;;;;;;;; + +; Whether to allow the treatment of URLs (like http:// or ftp://) as files. +; http://php.net/allow-url-fopen +allow_url_fopen = On + +; Whether to allow include/require to open URLs (like http:// or ftp://) as files. +; http://php.net/allow-url-include +allow_url_include = Off + +; Define the anonymous ftp password (your email address). PHP's default setting +; for this is empty. +; http://php.net/from +from="john@doe.com" + +; Define the User-Agent string. PHP's default setting for this is empty. +; http://php.net/user-agent +user_agent="PHP" + +; Default timeout for socket based streams (seconds) +; http://php.net/default-socket-timeout +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; http://php.net/auto-detect-line-endings +auto_detect_line_endings = Off + +;;;;;;;;;;; +; Dynamic Extensions ; +;;;;;;;;;;; + +; If you wish to have an extension loaded automatically, use the following +; syntax: +; +; extension=modulename.extension +; +; For example, on Windows: +; +; extension=mysqli.dll +; +; ... or under UNIX: +; +; extension=mysqli.so +; +; ... or with a path: +; +; extension=/path/to/extension/mysqli.so +; +; If you only provide the name of the extension, PHP will look for it in its +; default extension directory. +; +; Windows Extensions +; Note that ODBC support is built in, so no dll is needed for it. +; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5+) +; extension folders as well as the separate PECL DLL download (PHP 5+). +; Be sure to appropriately set the extension_dir directive. +; +extension=php_bz2.dll +extension=php_curl.dll +extension=php_fileinfo.dll +extension=php_ftp.dll +extension=php_gd2.dll +extension=php_gettext.dll +extension=php_gmp.dll +extension=php_intl.dll +extension=php_imap.dll +extension=php_interbase.dll +extension=php_ldap.dll +extension=php_mbstring.dll +extension=php_exif.dll ; Must be after mbstring as it depends on it +extension=php_mysqli.dll +extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client +extension=php_openssl.dll +extension=php_pdo_firebird.dll +extension=php_pdo_mysql.dll +extension=php_pdo_oci.dll +extension=php_pdo_odbc.dll +extension=php_pdo_pgsql.dll +extension=php_pdo_sqlite.dll +extension=php_pgsql.dll +extension=php_shmop.dll + +; The MIBS data available in the PHP distribution must be installed. +; See http://www.php.net/manual/en/snmp.installation.php +extension=php_snmp.dll + +extension=php_soap.dll +extension=php_sockets.dll +extension=php_sqlite3.dll +extension=php_tidy.dll +extension=php_xmlrpc.dll +extension=php_xsl.dll + +;;;;;;;;;; +; Module Settings ; +;;;;;;;;;; + +[CLI Server] +; Whether the CLI web server uses ANSI color coding in its terminal output. +cli_server.color = On + +[Date] +; Defines the default timezone used by the date functions +; http://php.net/date.timezone +date.timezone = + +; http://php.net/date.default-latitude +date.default_latitude = 31.7667 + +; http://php.net/date.default-longitude +date.default_longitude = 35.2333 + +; http://php.net/date.sunrise-zenith +date.sunrise_zenith = 90.583333 + +; http://php.net/date.sunset-zenith +date.sunset_zenith = 90.583333 + +[filter] +; http://php.net/filter.default +filter.default = unsafe_raw + +; http://php.net/filter.default-flags +filter.default_flags = + +[iconv] +; Use of this INI entry is deprecated, use global input_encoding instead. +; If empty, default_charset or input_encoding or iconv.input_encoding is used. +; The precedence is: default_charset < intput_encoding < iconv.input_encoding +iconv.input_encoding = + +; Use of this INI entry is deprecated, use global internal_encoding instead. +; If empty, default_charset or internal_encoding or iconv.internal_encoding is used. +; The precedence is: default_charset < internal_encoding < iconv.internal_encoding +iconv.internal_encoding = + +; Use of this INI entry is deprecated, use global output_encoding instead. +; If empty, default_charset or output_encoding or iconv.output_encoding is used. +; The precedence is: default_charset < output_encoding < iconv.output_encoding +; To use an output encoding conversion, iconv's output handler must be set +; otherwise output encoding conversion cannot be performed. +iconv.output_encoding = + +[intl] +intl.default_locale = +; This directive allows you to produce PHP errors when some error +; happens within intl functions. The value is the level of the error produced. +; Default is 0, which does not produce any errors. +intl.error_level = E_WARNING +intl.use_exceptions = 0 + +[sqlite3] +sqlite3.extension_dir = + +[Pcre] +PCRE library backtracking limit. +; http://php.net/pcre.backtrack-limit +pcre.backtrack_limit=100000 + +PCRE library recursion limit. +Please note that if you set this value to a high number you may consume all +the available process stack and eventually crash PHP (due to reaching the +stack size limit imposed by the Operating System). +; http://php.net/pcre.recursion-limit +pcre.recursion_limit=100000 + +Enables or disables JIT compilation of patterns. This requires the PCRE +library to be compiled with JIT support. +pcre.jit=1 + +[Pdo] +; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off" +; http://php.net/pdo-odbc.connection-pooling +pdo_odbc.connection_pooling=strict + +pdo_odbc.db2_instance_name + +[Pdo_mysql] +; If mysqlnd is used: Number of cache slots for the internal result set cache +; http://php.net/pdo_mysql.cache_size +pdo_mysql.cache_size = 2000 + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +; http://php.net/pdo_mysql.default-socket +pdo_mysql.default_socket= + +[Phar] +; http://php.net/phar.readonly +phar.readonly = On + +; http://php.net/phar.require-hash +phar.require_hash = On + +phar.cache_list = + +[mail function] +; For Win32 only. +; http://php.net/smtp +SMTP = localhost +; http://php.net/smtp-port +smtp_port = 25 + +; For Win32 only. +; http://php.net/sendmail-from +sendmail_from = me@example.com + +; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). +; http://php.net/sendmail-path +sendmail_path = + +; Force the addition of the specified parameters to be passed as extra parameters +; to the sendmail binary. These parameters will always replace the value of +; the 5th parameter to mail(). +mail.force_extra_parameters = + +; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename +mail.add_x_header = On + +; The path to a log file that will log all mail() calls. Log entries include +; the full path of the script, line number, To address and headers. +mail.log = +; Log mail to syslog (Event Log on Windows). +mail.log = syslog + +[ODBC] +; http://php.net/odbc.default-db +odbc.default_db = Not yet implemented + +; http://php.net/odbc.default-user +odbc.default_user = Not yet implemented + +; http://php.net/odbc.default-pw +odbc.default_pw = Not yet implemented + +; Controls the ODBC cursor model. +; Default: SQL_CURSOR_STATIC (default). +odbc.default_cursortype + +; Allow or prevent persistent links. +; http://php.net/odbc.allow-persistent +odbc.allow_persistent = On + +; Check that a connection is still valid before reuse. +; http://php.net/odbc.check-persistent +odbc.check_persistent = On + +; Maximum number of persistent links. -1 means no limit. +; http://php.net/odbc.max-persistent +odbc.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +; http://php.net/odbc.max-links +odbc.max_links = -1 + +; Handling of LONG fields. Returns number of bytes to variables. 0 means +; passthru. +; http://php.net/odbc.defaultlrl +odbc.defaultlrl = 4096 + +; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. +; See the documentation on odbc_binmode and odbc_longreadlen for an explanation +; of odbc.defaultlrl and odbc.defaultbinmode +; http://php.net/odbc.defaultbinmode +odbc.defaultbinmode = 1 + +birdstep.max_links = -1 + +[Interbase] +; Allow or prevent persistent links. +ibase.allow_persistent = 1 + +; Maximum number of persistent links. -1 means no limit. +ibase.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +ibase.max_links = -1 + +; Default database name for ibase_connect(). +ibase.default_db = + +; Default username for ibase_connect(). +ibase.default_user = + +; Default password for ibase_connect(). +ibase.default_password = + +; Default charset for ibase_connect(). +ibase.default_charset = + +; Default timestamp format. +ibase.timestampformat = "%Y-%m-%d %H:%M:%S" + +; Default date format. +ibase.dateformat = "%Y-%m-%d" + +; Default time format. +ibase.timeformat = "%H:%M:%S" + +[MySQLi] + +; Maximum number of persistent links. -1 means no limit. +; http://php.net/mysqli.max-persistent +mysqli.max_persistent = -1 + +; Allow accessing, from PHP's perspective, local files with LOAD DATA statements +; http://php.net/mysqli.allow_local_infile +mysqli.allow_local_infile = On + +; Allow or prevent persistent links. +; http://php.net/mysqli.allow-persistent +mysqli.allow_persistent = On + +; Maximum number of links. -1 means no limit. +; http://php.net/mysqli.max-links +mysqli.max_links = -1 + +; If mysqlnd is used: Number of cache slots for the internal result set cache +; http://php.net/mysqli.cache_size +mysqli.cache_size = 2000 + +; Default port number for mysqli_connect(). If unset, mysqli_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +; http://php.net/mysqli.default-port +mysqli.default_port = 3306 + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +; http://php.net/mysqli.default-socket +mysqli.default_socket = + +; Default host for mysql_connect() (doesn't apply in safe mode). +; http://php.net/mysqli.default-host +mysqli.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +; http://php.net/mysqli.default-user +mysqli.default_user = + +; Default password for mysqli_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +; http://php.net/mysqli.default-pw +mysqli.default_pw = + +; Allow or prevent reconnect +mysqli.reconnect = Off + +[mysqlnd] +; Enable / Disable collection of general statistics by mysqlnd which can be +; used to tune and monitor MySQL operations. +; http://php.net/mysqlnd.collect_statistics +mysqlnd.collect_statistics = On + +; Enable / Disable collection of memory usage statistics by mysqlnd which can be +; used to tune and monitor MySQL operations. +; http://php.net/mysqlnd.collect_memory_statistics +mysqlnd.collect_memory_statistics = Off + +; Records communication from all extensions using mysqlnd to the specified log +; file. +; http://php.net/mysqlnd.debug +mysqlnd.debug = + +; Defines which queries will be logged. +; http://php.net/mysqlnd.log_mask +mysqlnd.log_mask = 0 + +; Default size of the mysqlnd memory pool, which is used by result sets. +; http://php.net/mysqlnd.mempool_default_size +mysqlnd.mempool_default_size = 16000 + +; Size of a pre-allocated buffer used when sending commands to MySQL in bytes. +; http://php.net/mysqlnd.net_cmd_buffer_size +mysqlnd.net_cmd_buffer_size = 2048 + +; Size of a pre-allocated buffer used for reading data sent by the server in +; bytes. +; http://php.net/mysqlnd.net_read_buffer_size +mysqlnd.net_read_buffer_size = 32768 + +; Timeout for network requests in seconds. +; http://php.net/mysqlnd.net_read_timeout +mysqlnd.net_read_timeout = 31536000 + +; SHA-256 Authentication Plugin related. File with the MySQL server public RSA +; key. +; http://php.net/mysqlnd.sha256_server_public_key +mysqlnd.sha256_server_public_key = + +[OCI8] + +; Connection: Enables privileged connections using external +; credentials (OCI_SYSOPER, OCI_SYSDBA) +; http://php.net/oci8.privileged-connect +oci8.privileged_connect = Off + +; Connection: The maximum number of persistent OCI8 connections per +; process. Using -1 means no limit. +; http://php.net/oci8.max-persistent +oci8.max_persistent = -1 + +; Connection: The maximum number of seconds a process is allowed to +; maintain an idle persistent connection. Using -1 means idle +; persistent connections will be maintained forever. +; http://php.net/oci8.persistent-timeout +oci8.persistent_timeout = -1 + +; Connection: The number of seconds that must pass before issuing a +; ping during oci_pconnect() to check the connection validity. When +; set to 0, each oci_pconnect() will cause a ping. Using -1 disables +; pings completely. +; http://php.net/oci8.ping-interval +oci8.ping_interval = 60 + +; Connection: Set this to a user chosen connection class to be used +; for all pooled server requests with Oracle 11g Database Resident +; Connection Pooling (DRCP). To use DRCP, this value should be set to +; the same string for all web servers running the same application, +; the database pool must be configured, and the connection string must +; specify to use a pooled server. +oci8.connection_class = + +; High Availability: Using On lets PHP receive Fast Application +; Notification (FAN) events generated when a database node fails. The +; database must also be configured to post FAN events. +oci8.events = Off + +; Tuning: This option enables statement caching, and specifies how +; many statements to cache. Using 0 disables statement caching. +; http://php.net/oci8.statement-cache-size +oci8.statement_cache_size = 20 + +; Tuning: Enables statement prefetching and sets the default number of +; rows that will be fetched automatically after statement execution. +; http://php.net/oci8.default-prefetch +oci8.default_prefetch = 100 + +; Compatibility. Using On means oci_close() will not close +; oci_connect() and oci_new_connect() connections. +; http://php.net/oci8.old-oci-close-semantics +oci8.old_oci_close_semantics = Off + +[PostgreSQL] +; Allow or prevent persistent links. +; http://php.net/pgsql.allow-persistent +pgsql.allow_persistent = On + +; Detect broken persistent links always with pg_pconnect(). +; Auto reset feature requires a little overheads. +; http://php.net/pgsql.auto-reset-persistent +pgsql.auto_reset_persistent = Off + +; Maximum number of persistent links. -1 means no limit. +; http://php.net/pgsql.max-persistent +pgsql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +; http://php.net/pgsql.max-links +pgsql.max_links = -1 + +; Ignore PostgreSQL backends Notice message or not. +; Notice message logging require a little overheads. +; http://php.net/pgsql.ignore-notice +pgsql.ignore_notice = 0 + +; Log PostgreSQL backends Notice message or not. +; Unless pgsql.ignore_notice=0, module cannot log notice message. +; http://php.net/pgsql.log-notice +pgsql.log_notice = 0 + +[bcmath] +; Number of decimal digits for all bcmath functions. +; http://php.net/bcmath.scale +bcmath.scale = 0 + +[browscap] +; http://php.net/browscap +browscap = extra/browscap.ini + +[Session] +; Handler used to store/retrieve data. +; http://php.net/session.save-handler +session.save_handler = files + +; Argument passed to save_handler. In the case of files, this is the path +; where data files are stored. Note: Windows users have to change this +; variable in order to use PHP's session functions. +; +; The path can be defined as: +; +; session.save_path = "N/path" +; +; where N is an integer. Instead of storing all the session files in +; /path, what this will do is use subdirectories N-levels deep, and +; store the session data in those directories. This is useful if +; your OS has problems with many files in one directory, and is +; a more efficient layout for servers that handle many sessions. +; +; NOTE 1: PHP will not create this directory structure automatically. +; You can use the script in the ext/session dir for that purpose. +; NOTE 2: See the section on garbage collection below if you choose to +; use subdirectories for session storage +; +; The file storage module creates files using mode 600 by default. +; You can change that by using +; +; session.save_path = "NMODE/path" +; +; where MODE is the octal representation of the mode. Note that this +; does not overwrite the process's umask. +; http://php.net/session.save-path +session.save_path = "/tmp" + +; Whether to use strict session mode. +; Strict session mode does not accept uninitialized session ID and regenerate +; session ID if browser sends uninitialized session ID. Strict mode protects +; applications from session fixation via session adoption vulnerability. It is +; disabled by default for maximum compatibility, but enabling it is encouraged. +; https://wiki.php.net/rfc/strict_sessions +session.use_strict_mode = 0 + +; Whether to use cookies. +; http://php.net/session.use-cookies +session.use_cookies = 1 + +; http://php.net/session.cookie-secure +session.cookie_secure = + +; This option forces PHP to fetch and use a cookie for storing and maintaining +; the session id. We encourage this operation as it's very helpful in combating +; session hijacking when not specifying and managing your own session id. It is +; not the be-all and end-all of session hijacking defense, but it's a good start. +; http://php.net/session.use-only-cookies +session.use_only_cookies = 1 + +; Name of the session (used as cookie name). +; http://php.net/session.name +session.name = PHPSESSID + +; Initialize session on request startup. +; http://php.net/session.auto-start +session.auto_start = 0 + +; Lifetime in seconds of cookie or, if 0, until browser is restarted. +; http://php.net/session.cookie-lifetime +session.cookie_lifetime = 0 + +; The path for which the cookie is valid. +; http://php.net/session.cookie-path +session.cookie_path = / + +; The domain for which the cookie is valid. +; http://php.net/session.cookie-domain +session.cookie_domain = + +; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript. +; http://php.net/session.cookie-httponly +session.cookie_httponly = + +; Handler used to serialize data. php is the standard serializer of PHP. +; http://php.net/session.serialize-handler +session.serialize_handler = php + +; Defines the probability that the 'garbage collection' process is started +; on every session initialization. The probability is calculated by using +; gc_probability/gc_divisor. Where session.gc_probability is the numerator +; and gc_divisor is the denominator in the equation. Setting this value to 1 +; when the session.gc_divisor value is 100 will give you approximately a 1% chance +; the gc will run on any give request. +; Default Value: 1 +; Development Value: 1 +; Production Value: 1 +; http://php.net/session.gc-probability +session.gc_probability = 1 + +; Defines the probability that the 'garbage collection' process is started on every +; session initialization. The probability is calculated by using the following equation: +; gc_probability/gc_divisor. Where session.gc_probability is the numerator and +; session.gc_divisor is the denominator in the equation. Setting this value to 1 +; when the session.gc_divisor value is 100 will give you approximately a 1% chance +; the gc will run on any give request. Increasing this value to 1000 will give you +; a 0.1% chance the gc will run on any give request. For high volume production servers, +; this is a more efficient approach. +; Default Value: 100 +; Development Value: 1000 +; Production Value: 1000 +; http://php.net/session.gc-divisor +session.gc_divisor = 1000 + +; After this number of seconds, stored data will be seen as 'garbage' and +; cleaned up by the garbage collection process. +; http://php.net/session.gc-maxlifetime +session.gc_maxlifetime = 1440 + +; NOTE: If you are using the subdirectory option for storing session files +; (see session.save_path above), then garbage collection does *not* +; happen automatically. You will need to do your own garbage +; collection through a shell script, cron entry, or some other method. +; For example, the following script would is the equivalent of +; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): +; find /path/to/sessions -cmin +24 -type f | xargs rm + +; Check HTTP Referer to invalidate externally stored URLs containing ids. +; HTTP_REFERER has to contain this substring for the session to be +; considered as valid. +; http://php.net/session.referer-check +session.referer_check = + +; Set to {nocache,private,public,} to determine HTTP caching aspects +; or leave this empty to avoid sending anti-caching headers. +; http://php.net/session.cache-limiter +session.cache_limiter = nocache + +; Document expires after n minutes. +; http://php.net/session.cache-expire +session.cache_expire = 180 + +; trans sid support is disabled by default. +; Use of trans sid may risk your users' security. +; Use this option with caution. +; - User may send URL contains active session ID +; to other person via. email/irc/etc. +; - URL that contains active session ID may be stored +; in publicly accessible computer. +; - User may access your site with the same session ID +; always using URL stored in browser's history or bookmarks. +; http://php.net/session.use-trans-sid +session.use_trans_sid = 0 + +; Set session ID character length. This value could be between 22 to 256. +; Shorter length than default is supported only for compatibility reason. +; Users should use 32 or more chars. +; http://php.net/session.sid-length +; Default Value: 32 +; Development Value: 26 +; Production Value: 26 +session.sid_length = 26 + +; The URL rewriter will look for URLs in a defined set of HTML tags. +;
is special; if you include them here, the rewriter will +; add a hidden field with the info which is otherwise appended +; to URLs. tag's action attribute URL will not be modified +; unless it is specified. +; Note that all valid entries require a "=", even if no value follows. +; Default Value: "a=href,area=href,frame=src,form=" +; Development Value: "a=href,area=href,frame=src,form=" +; Production Value: "a=href,area=href,frame=src,form=" +; http://php.net/url-rewriter.tags +session.trans_sid_tags = "a=href,area=href,frame=src,form=" + +; URL rewriter does not rewrite absolute URLs by default. +; To enable rewrites for absolute pathes, target hosts must be specified +; at RUNTIME. i.e. use ini_set() +; tags is special. PHP will check action attribute's URL regardless +; of session.trans_sid_tags setting. +; If no host is defined, HTTP_HOST will be used for allowed host. +; Example value: php.net,www.php.net,wiki.php.net +; Use "," for multiple hosts. No spaces are allowed. +; Default Value: "" +; Development Value: "" +; Production Value: "" +session.trans_sid_hosts="" + +; Define how many bits are stored in each character when converting +; the binary hash data to something readable. +; Possible values: +; 4 (4 bits: 0-9, a-f) +; 5 (5 bits: 0-9, a-v) +; 6 (6 bits: 0-9, a-z, A-Z, "-", ",") +; Default Value: 4 +; Development Value: 5 +; Production Value: 5 +; http://php.net/session.hash-bits-per-character +session.sid_bits_per_character = 5 + +; Enable upload progress tracking in $_SESSION +; Default Value: On +; Development Value: On +; Production Value: On +; http://php.net/session.upload-progress.enabled +session.upload_progress.enabled = On + +; Cleanup the progress information as soon as all POST data has been read +; (i.e. upload completed). +; Default Value: On +; Development Value: On +; Production Value: On +; http://php.net/session.upload-progress.cleanup +session.upload_progress.cleanup = On + +; A prefix used for the upload progress key in $_SESSION +; Default Value: "upload_progress_" +; Development Value: "upload_progress_" +; Production Value: "upload_progress_" +; http://php.net/session.upload-progress.prefix +session.upload_progress.prefix = "upload_progress_" + +; The index name (concatenated with the prefix) in $_SESSION +; containing the upload progress information +; Default Value: "PHP_SESSION_UPLOAD_PROGRESS" +; Development Value: "PHP_SESSION_UPLOAD_PROGRESS" +; Production Value: "PHP_SESSION_UPLOAD_PROGRESS" +; http://php.net/session.upload-progress.name +session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS" + +; How frequently the upload progress should be updated. +; Given either in percentages (per-file), or in bytes +; Default Value: "1%" +; Development Value: "1%" +; Production Value: "1%" +; http://php.net/session.upload-progress.freq +session.upload_progress.freq = "1%" + +; The minimum delay between updates, in seconds +; Default Value: 1 +; Development Value: 1 +; Production Value: 1 +; http://php.net/session.upload-progress.min-freq +session.upload_progress.min_freq = "1" + +; Only write session data when session data is changed. Enabled by default. +; http://php.net/session.lazy-write +session.lazy_write = On + +[Assertion] +; Switch whether to compile assertions at all (to have no overhead at run-time) +; -1: Do not compile at all +; 0: Jump over assertion at run-time +; 1: Execute assertions +; Changing from or to a negative value is only possible in php.ini! (For turning assertions on and off at run-time, see assert.active, when zend.assertions = 1) +; Default Value: 1 +; Development Value: 1 +; Production Value: -1 +; http://php.net/zend.assertions +zend.assertions = -1 + +; Assert(expr); active by default. +; http://php.net/assert.active +assert.active = On + +; Throw an AssertationException on failed assertions +; http://php.net/assert.exception +assert.exception = On + +; Issue a PHP warning for each failed assertion. (Overridden by assert.exception if active) +; http://php.net/assert.warning +assert.warning = On + +; Don't bail out by default. +; http://php.net/assert.bail +assert.bail = Off + +; User-function to be called if an assertion fails. +; http://php.net/assert.callback +assert.callback = 0 + +; Eval the expression with current error_reporting(). Set to true if you want +; error_reporting(0) around the eval(). +; http://php.net/assert.quiet-eval +assert.quiet_eval = 0 + +[COM] +; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs +; http://php.net/com.typelib-file +com.typelib_file = + +; allow Distributed-COM calls +; http://php.net/com.allow-dcom +com.allow_dcom = true + +; autoregister constants of a components typlib on com_load() +; http://php.net/com.autoregister-typelib +com.autoregister_typelib = true + +; register constants casesensitive +; http://php.net/com.autoregister-casesensitive +com.autoregister_casesensitive = false + +; show warnings on duplicate constant registrations +; http://php.net/com.autoregister-verbose +com.autoregister_verbose = true + +; The default character set code-page to use when passing strings to and from COM objects. +; Default: system ANSI code page +com.code_page= + +[mbstring] +; language for internal character representation. +; This affects mb_send_mail() and mbstring.detect_order. +; http://php.net/mbstring.language +mbstring.language = Japanese + +; Use of this INI entry is deprecated, use global internal_encoding instead. +; internal/script encoding. +; Some encoding cannot work as internal encoding. (e.g. SJIS, BIG5, ISO-2022-*) +; If empty, default_charset or internal_encoding or iconv.internal_encoding is used. +; The precedence is: default_charset < internal_encoding < iconv.internal_encoding +mbstring.internal_encoding = + +; Use of this INI entry is deprecated, use global input_encoding instead. +; http input encoding. +; mbstring.encoding_traslation = On is needed to use this setting. +; If empty, default_charset or input_encoding or mbstring.input is used. +; The precedence is: default_charset < intput_encoding < mbsting.http_input +; http://php.net/mbstring.http-input +mbstring.http_input = + +; Use of this INI entry is deprecated, use global output_encoding instead. +; http output encoding. +; mb_output_handler must be registered as output buffer to function. +; If empty, default_charset or output_encoding or mbstring.http_output is used. +; The precedence is: default_charset < output_encoding < mbstring.http_output +; To use an output encoding conversion, mbstring's output handler must be set +; otherwise output encoding conversion cannot be performed. +; http://php.net/mbstring.http-output +mbstring.http_output = + +; enable automatic encoding translation according to +; mbstring.internal_encoding setting. Input chars are +; converted to internal encoding by setting this to On. +; Note: Do _not_ use automatic encoding translation for +; portable libs/applications. +; http://php.net/mbstring.encoding-translation +mbstring.encoding_translation = Off + +; automatic encoding detection order. +; "auto" detect order is changed according to mbstring.language +; http://php.net/mbstring.detect-order +mbstring.detect_order = auto + +; substitute_character used when character cannot be converted +; one from another +; http://php.net/mbstring.substitute-character +mbstring.substitute_character = none + +; overload(replace) single byte functions by mbstring functions. +; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), +; etc. Possible values are 0,1,2,4 or combination of them. +; For example, 7 for overload everything. +; 0: No overload +; 1: Overload mail() function +; 2: Overload str*() functions +; 4: Overload ereg*() functions +; http://php.net/mbstring.func-overload +mbstring.func_overload = 0 + +; enable strict encoding detection. +; Default: Off +mbstring.strict_detection = On + +; This directive specifies the regex pattern of content types for which mb_output_handler() +; is activated. +; Default: mbstring.http_output_conv_mimetype=^(text/|application/xhtml\+xml) +mbstring.http_output_conv_mimetype= + +[gd] +; Tell the jpeg decode to ignore warnings and try to create +; a gd image. The warning will then be displayed as notices +; disabled by default +; http://php.net/gd.jpeg-ignore-warning +gd.jpeg_ignore_warning = 1 + +[exif] +; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS. +; With mbstring support this will automatically be converted into the encoding +; given by corresponding encode setting. When empty mbstring.internal_encoding +; is used. For the decode settings you can distinguish between motorola and +; intel byte order. A decode setting cannot be empty. +; http://php.net/exif.encode-unicode +exif.encode_unicode = ISO-8859-15 + +; http://php.net/exif.decode-unicode-motorola +exif.decode_unicode_motorola = UCS-2BE + +; http://php.net/exif.decode-unicode-intel +exif.decode_unicode_intel = UCS-2LE + +; http://php.net/exif.encode-jis +exif.encode_jis = + +; http://php.net/exif.decode-jis-motorola +exif.decode_jis_motorola = JIS + +; http://php.net/exif.decode-jis-intel +exif.decode_jis_intel = JIS + +[Tidy] +; The path to a default tidy configuration file to use when using tidy +; http://php.net/tidy.default-config +tidy.default_config = /usr/local/lib/php/default.tcfg + +; Should tidy clean and repair output automatically? +; WARNING: Do not use this option if you are generating non-html content +; such as dynamic images +; http://php.net/tidy.clean-output +tidy.clean_output = Off + +[soap] +; Enables or disables WSDL caching feature. +; http://php.net/soap.wsdl-cache-enabled +soap.wsdl_cache_enabled=1 + +; Sets the directory name where SOAP extension will put cache files. +; http://php.net/soap.wsdl-cache-dir +soap.wsdl_cache_dir="/tmp" + +; (time to live) Sets the number of second while cached file will be used +; instead of original one. +; http://php.net/soap.wsdl-cache-ttl +soap.wsdl_cache_ttl=86400 + +; Sets the size of the cache limit. (Max. number of WSDL files to cache) +soap.wsdl_cache_limit = 5 + +[sysvshm] +; A default size of the shared memory segment +sysvshm.init_mem = 10000 + +[ldap] +; Sets the maximum number of open links or -1 for unlimited. +ldap.max_links = -1 + +[dba] +dba.default_handler= + +[opcache] +; Determines if Zend OPCache is enabled +opcache.enable=1 + +; Determines if Zend OPCache is enabled for the CLI version of PHP +opcache.enable_cli=1 + +; The OPcache shared memory storage size. +opcache.memory_consumption=128 + +; The amount of memory for interned strings in Mbytes. +opcache.interned_strings_buffer=8 + +; The maximum number of keys (scripts) in the OPcache hash table. +; Only numbers between 200 and 1000000 are allowed. +opcache.max_accelerated_files=10000 + +; The maximum percentage of "wasted" memory until a restart is scheduled. +opcache.max_wasted_percentage=5 + +; When this directive is enabled, the OPcache appends the current working +; directory to the script key, thus eliminating possible collisions between +; files with the same name (basename). Disabling the directive improves +; performance, but may break existing applications. +opcache.use_cwd=1 + +; When disabled, you must reset the OPcache manually or restart the +; webserver for changes to the filesystem to take effect. +opcache.validate_timestamps=1 + +; How often (in seconds) to check file timestamps for changes to the shared +; memory storage allocation. ("1" means validate once per second, but only +; once per request. "0" means always validate) +opcache.revalidate_freq=2 + +; Enables or disables file search in include_path optimization +opcache.revalidate_path=0 + +; If disabled, all PHPDoc comments are dropped from the code to reduce the +; size of the optimized code. +opcache.save_comments=1 + +; If enabled, a fast shutdown sequence is used for the accelerated code +; Depending on the used Memory Manager this may cause some incompatibilities. +opcache.fast_shutdown=0 + +; Allow file existence override (file_exists, etc.) performance feature. +opcache.enable_file_override=0 + +; A bitmask, where each bit enables or disables the appropriate OPcache +; passes +opcache.optimization_level=0xffffffff + +opcache.inherited_hack=1 +opcache.dups_fix=0 + +; The location of the OPcache blacklist file (wildcards allowed). +; Each OPcache blacklist file is a text file that holds the names of files +; that should not be accelerated. The file format is to add each filename +; to a new line. The filename may be a full path or just a file prefix +; (i.e., /var/www/x blacklists all the files and directories in /var/www +; that start with 'x'). Line starting with a ; are ignored (comments). +opcache.blacklist_filename= + +; Allows exclusion of large files from being cached. By default all files +; are cached. +opcache.max_file_size=0 + +; Check the cache checksum each N requests. +; The default value of "0" means that the checks are disabled. +opcache.consistency_checks=0 + +; How long to wait (in seconds) for a scheduled restart to begin if the cache +; is not being accessed. +opcache.force_restart_timeout=180 + +; OPcache error_log file name. Empty string assumes "stderr". +opcache.error_log= + +; All OPcache errors go to the Web server log. +; By default, only fatal errors (level 0) or errors (level 1) are logged. +; You can also enable warnings (level 2), info messages (level 3) or +; debug messages (level 4). +opcache.log_verbosity_level=1 + +; Preferred Shared Memory back-end. Leave empty and let the system decide. +opcache.preferred_memory_model= + +; Protect the shared memory from unexpected writing during script execution. +; Useful for internal debugging only. +opcache.protect_memory=0 + +; Allows calling OPcache API functions only from PHP scripts which path is +; started from specified string. The default "" means no restriction +opcache.restrict_api= + +; Mapping base of shared memory segments (for Windows only). All the PHP +; processes have to map shared memory into the same address space. This +; directive allows to manually fix the "Unable to reattach to base address" +; errors. +opcache.mmap_base= + +; Enables and sets the second level cache directory. +; It should improve performance when SHM memory is full, at server restart or +; SHM reset. The default "" disables file based caching. +opcache.file_cache= + +; Enables or disables opcode caching in shared memory. +opcache.file_cache_only=0 + +; Enables or disables checksum validation when script loaded from file cache. +opcache.file_cache_consistency_checks=1 + +; Implies opcache.file_cache_only=1 for a certain process that failed to +; reattach to the shared memory (for Windows only). Explicitly enabled file +; cache is required. +opcache.file_cache_fallback=1 + +; Enables or disables copying of PHP code (text segment) into HUGE PAGES. +; This should improve performance, but requires appropriate OS configuration. +opcache.huge_code_pages=1 + +; Validate cached file permissions. +opcache.validate_permission=0 + +; Prevent name collisions in chroot'ed environment. +opcache.validate_root=0 + +[curl] +; A default value for the CURLOPT_CAINFO option. This is required to be an +; absolute path. +curl.cainfo = + +[openssl] +; The location of a Certificate Authority (CA) file on the local filesystem +; to use when verifying the identity of SSL/TLS peers. Most users should +; not specify a value for this directive as PHP will attempt to use the +; OS-managed cert stores in its absence. If specified, this value may still +; be overridden on a per-stream basis via the "cafile" SSL stream context +; option. +openssl.cafile= + +; If openssl.cafile is not specified or if the CA file is not found, the +; directory pointed to by openssl.capath is searched for a suitable +; certificate. This value must be a correctly hashed certificate directory. +; Most users should not specify a value for this directive as PHP will +; attempt to use the OS-managed cert stores in its absence. If specified, +; this value may still be overridden on a per-stream basis via the "capath" +; SSL stream context option. +openssl.capath= + +; Local Variables: +; tab-width: 4 +; End: \ No newline at end of file diff --git a/build-system/internals/helpers/ini-test/test2.ini b/build-system/internals/helpers/ini-test/test2.ini new file mode 100644 index 0000000..c705a40 --- /dev/null +++ b/build-system/internals/helpers/ini-test/test2.ini @@ -0,0 +1,10 @@ +test1a=b +test1b="b" +[test1sectionA] +test1c="b" +test1d="b" ; test comment + +test1e=b +; Liberdade, igualdade e fraternidade, é o seguinte: +; se tem liberdade, tem que ter igualdade, amor e fraternidade +; E vimos! diff --git a/build-system/machine.conf b/build-system/machine.conf deleted file mode 100644 index 2df1872..0000000 --- a/build-system/machine.conf +++ /dev/null @@ -1,86 +0,0 @@ -# The variables below will change depending on the architecture. -# The default is x86_64. - -# Target -COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" - -# The default/unvendored "target tuple" that we will need when configuring LLVM. -TARGET_TUPLE="x86_64-pc-linux-musl" - -# CPU information -ARCH="x86" -CPU="x86-64" - -# Use binary-cached toolchains -BINARY_CACHE="false" - -# Use a virtual disk or a physical one -VIRTUAL_DISK="true" -DISK_BLOCK="/tmp/COPA.IMG" - -# Uncomment to use a custom disk size in gigabytes -VIRTUADISK_SIZE=10 - -# Disk label -# Uncomment to use a custom disk label (string) for your -# Copacabana build. -# Its size is of 16 characters at maximum. -# DISK_LABEL="" - -# umount(8) on exit? -# Use "false" if you want to check how the process went, useful -# if you're a developer and trying to mess around with this, if -# not, just use "true". -UMOUNT_ON_EXIT="false" - -# Do you enjoy to sit for hours reading haphazardly shell-generated -# instructions given by GNU auto*tools for building enormous programs such as -# G.C.C. directly on your main terminal instead of just sending all of it for -# a log file and waiting for when some error happens? -# Are you getting paranoic with GNU's miraculous build system freezing your -# machine and absolutely needs to read pretty much meaningless --- and, again, -# haphazardly shell-generated --- instructions running on your screen just to -# realize that it's not your fault and just some funky bug? Marvellous! -# So this option shall be "true" for you! Else, just let it as it is. -# -# Anyway, if you have to read the logs, they will be sent to inside the -# Copacabana root directory in a file called "build.log." -I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" - -# Where do you want the source code to be saved? -# This is the suffix for the source code directory. -# May you wish to change it just in case of wanting to mess around -# with Copacabana's FHS or compatibilize some Linux From Scratch-specific -# scripts with Copacabana. -# Per default, it is "/usr/src" (over the $COPA directory, of course), -# but you can redefine if you wish to "/sources", for example. -# SRCDIR_SUFFIX="" - -# Do SHA256 checks after downloading Copacabana sources? -# Use "YES" if you're just a final user and/or developer aiming -# to port Copacabana and just wants to build a vanilla -# distribution or "NO" if you're a developer and wants to -# change/update some of the sources without regenerating the -# "sources.sha256" file before. This option is case-insensitive. -SHA256CHECK="YES" - -# Use aria2c instead of the good ol' cURL backend on download_sources.ksh? -# Use "true" if you have aria2c on your system, or "false" if you're on a small -# environment (such as the Copacabana 0.4 Dockerimage/Mitzune prefix) with only -# cURL and/or taking considerably more time isn't a big deal. -USE_ARIA2C="true" - -# This is used on the Korn Shell 93 implementation of sha256sum, -# present at cmd/ on this repository. -# The default is "openssl", you may change this if you're using -# LibreSSL or another fork and it doesn't provide its -# OpenSSL-compatible shell API binary symbolic/hard linked to -# "openssl" in your path. -# If changed, the value here must be lower-case. -# SSL_CMD="" - -# Programs -CC="gcc" -CXX="g++" -LD="ld" -AS="as" diff --git a/build-system/machine.ini b/build-system/machine.ini new file mode 100644 index 0000000..b0f3869 --- /dev/null +++ b/build-system/machine.ini @@ -0,0 +1,28 @@ +[Machine] +COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" +TARGET_TUPLE="x86_64-pc-linux-musl" +ARCH="x86" +CPU="x86-64" + +[Build] +BINARY_CACHE="false" +I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" + +[Disk managenment] +VIRTUAL_DISK="true" +DISK_BLOCK="/tmp/COPA.IMG" +VIRTUADISK_SIZE=10 +; DISK_LABEL="" +UMOUNT_ON_EXIT="false" + +[Download sources] +; SRCDIR_SUFFIX="" +SHA256CHECK="YES" +USE_ARIA2C="true" +; SSL_CMD="" + +[Programs] +CC="gcc" +CXX="g++" +LD="ld" +AS="as" diff --git a/build-system/paths.conf b/build-system/paths.conf deleted file mode 100644 index e98d117..0000000 --- a/build-system/paths.conf +++ /dev/null @@ -1,13 +0,0 @@ -# vim: set filetype=sh : -# This file sets directory configuration, you may wish to change it. - -directory_tree=({{s,}bin,boot,dev,etc,lib{,64},opt,proc,run,sys,tmp,usr/{,{s,}bin,ccs,etc,include,lib{,64},share/{,doc,man,misc,lib},skel,src,tmp},var/{,adm,cache,lib/{,color,misc},log,mail,tmp,run/{,lock},spool/{,mail}}}) - -# Object directory (where things are compiled) -OBJDIR=/usr/src/work - -# Package directory (where things are primarily installed) -PKGDIR=/usr/src/dest - -# Sources directory (where tarballs containing sources are located) -SOURCES=/usr/src/pkgs diff --git a/build-system/tasks/build_all.ksh b/build-system/tasks/build_all.ksh index 119c210..7f79a12 100644 --- a/build-system/tasks/build_all.ksh +++ b/build-system/tasks/build_all.ksh @@ -32,8 +32,12 @@ function build { function build_xtools { packages=( "$@" ) n_packages=$(n "${packages[@]}") + for (( n=0; n < n_packages; n++ )); do - "$progdir/build-system/internals/cmd/driver.ksh" -Dcross "${packages[$n]}" + "$progdir/build-system/internals/cmd/driver.ksh" -Dcross "${packages[$n]}" \ + || { $I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR \ + || printerr 'Error: Failed to build %s, please check log (%s) for more details.\n' \ + "${packages[$n]}" "$blackbox"; } done } @@ -52,16 +56,19 @@ function build_base { function close_build { version="$progdir/version" release_file="$COPA/etc/copacabana-release" - if [[ ! -s "$version" ]] || ; then + if [[ ! -s "$version" ]]; then printf '%.1f' 0.0 > "$version" fi - record dtime final "$(date +'%Hh%Mmin on %B %d, %Y')" + map dtime final "$(date +'%Hh%Mmin on %B %d, %Y')" printf > "$release_file" \ 'Copacabana %.1f/%s\nCopyright (c) %d-%d Pindorama. All rights reserved.\n\nDesigned between %s and %s. Built from %s until %s (UTC %s).\n' \ "$(cat $version)" "$CPU" '2019' "$(date +"%Y")" \ 'February 2021' "$(date +'%B %Y')" \ "${dtime[initial]}" "${dtime[final]}" "$(date +%Z)" + + printerr 'Info: Build done at %s.\n' \ + "${dtime[final]}" | tee "$blackbox" return 0 } diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 8b9c99e..3eda55b 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -20,7 +20,7 @@ function check_dependencies { archiver_sanity="$trash/archiver_sanity" # Internal helper scripts (at cmd/) - internal_scripts=( 'cmd/download_sources.ksh' 'cmd/populate_fhs.ksh' \ + internal_scripts=( 'cmd/download_sources.ksh' 'cmd/populate_fhs.sh' \ 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh' ) # GNU auto*conf commands diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index 9ce313a..bea316f 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -114,11 +114,13 @@ function create_disk { } # STEP 1.5: Populate the file system -# This function will run the cmd/populate_fhs.ksh script and create directories +# This function will run the cmd/populate_fhs.sh script and create directories # for the toolchains that will be built. function populate { # That's the time to decide which will be, in fact, our source-code directory. SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" + # Also declare who will be our log file. + blackbox="$COPA/build.log.$CPU" # Self-explanatory, just create the directories for the initial # toolchain and intermediary chroot toolchain. @@ -156,14 +158,19 @@ function populate { (cd /; ls -l ./{cgnu,llvm}tools) fi + printerr 'Info: Making directories in %s for populating the file system.\n' \ "$COPA" - (cd "$COPA"; elevate $run_shell -c "COPA=$COPA $progdir/cmd/populate_fhs.ksh; mkdir -p "$SRCDIR"") + elevate $run_shell -c "COPA=$COPA BUILD_KSH=$BUILD_KSH $progdir/cmd/populate_fhs.sh; mkdir -p "$SRCDIR"" + + printerr 'Info: Initializing blackbox file (%s) for the build.\n' \ + "$blackbox" + ( cd "$COPA"; elevate sh -c "> $blackbox; chown $user $blackbox" ) printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ $(realpaths /{cgnu,llvm}tools) "$SRCDIR" elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" - export SRCDIR + export blackbox SRCDIR } function unmount_and_detach { diff --git a/build-system/tasks/finish.ksh b/build-system/tasks/finish.ksh index 070b629..ecd28fc 100644 --- a/build-system/tasks/finish.ksh +++ b/build-system/tasks/finish.ksh @@ -4,5 +4,5 @@ function finish { fi # Remove the trash directory with sanity tests - rm -r "$trash" + rm -rf "$trash" } diff --git a/build-system/work.ini b/build-system/work.ini new file mode 100644 index 0000000..feda760 --- /dev/null +++ b/build-system/work.ini @@ -0,0 +1,18 @@ +; This file sets where build.ksh shall do the heavy work +; of unpacking and compiling source code. +; It would be recommended to use an external hard disk to +; avoid I/O overcharge. +[At Work] +; For further documentation: +; TRASH_PREFIX: Directory where the "CopaBuild.XXXXXX +; directory will be created. +; PKGDIR: Where built packages where be placed as cpio +; files in a "directory/version number/category" +; hierarchy. This does not replace the stages, though. +; OBJDIR: Where to place package source code with object files. +; Usually, when building up to the toolchain, it is placed on +; the trash. You may wish to change it if your trash directory +; is too small, or just change the trash directory to other place. +TRASH_PREFIX="/tmp" +PKGDIR="/dsk/0/plaza" +; OBJDIR="" diff --git a/build.ksh b/build.ksh index 24a01b0..8d254c6 100755 --- a/build.ksh +++ b/build.ksh @@ -25,6 +25,8 @@ trash="$(mktemp -d /tmp/CopaBuild.XXXXXX)" . "$progdir/build-system/tasks/finish.ksh" rconfig "$progdir/build-system/machine.ini" +rconfig "$progdir/build-system/work.ini" +rconfig "$progdir/build-system/fhs.ini" map dtime initial "$(date +'%Hh%Mmin on %B %d, %Y')" From 2521d36e98c89af75dd831e64677a53746f8bfc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 23 Dec 2023 14:42:39 -0300 Subject: [PATCH 028/128] feat: Rewrote populate_fhs.ksh as a POSIX shell script from scratch. --- cmd/download_sources.ksh | 2 +- cmd/populate_fhs.ksh | 52 --------------------------------- cmd/populate_fhs.sh | 63 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 53 deletions(-) delete mode 100755 cmd/populate_fhs.ksh create mode 100755 cmd/populate_fhs.sh diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index 8636a38..24fc390 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -88,7 +88,7 @@ main() { printf '%s\n\tout=%s\n' \ "${urls[$k]}" "${urls[$k]##*/}" } ) \ - | aria2c -j `nproc` -x `nproc` -d "$category_dir" -i - + | aria2c -q -j `nproc` -x `nproc` -d "$category_dir" -i - fi } if `echo ${SHA256CHECK} | grep -i '^y' &>/dev/null` \ diff --git a/cmd/populate_fhs.ksh b/cmd/populate_fhs.ksh deleted file mode 100755 index 4579559..0000000 --- a/cmd/populate_fhs.ksh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env ksh93 -# Simple shell hack to populate Copacabana's FHS on a new disk -# Copyright 2022: Luiz Antônio (takusuman). -# This script is licensed under UUIC/NCSA (as Copacabana work itself). -# PS: It can also be run in GNU Broken... eh, I mean BOURNE-Again Shell -# if you don't have AT&T's ksh93 installed. - -COPA=${COPA:-/dsk/0v} -directory_tree=({bin,boot,dev,etc,lib,lib64,opt,proc,run,sbin,sys,tmp,usr/{,bin,ccs,etc,include,lib,lib64,sbin,share/{,doc,man,misc},skel,spool,tmp},var/{,adm,cache,lib/{,color,misc},log,mail,tmp,run/{,lock},spool/{,mail}}}) - -function main { - n_directory_tree=`n ${directory_tree[@]}` - run_as_root - check_right_place - for (( i=0; i < n_directory_tree; i++ )){ - printerr 'Creating directory number %s: %s\n' $(( i + 1 )) "${directory_tree[$i]}" - mkdir "${directory_tree[$i]}" 2>/dev/null - } - exit $? -} - -function run_as_root { - if [ `whoami` != root ]; then - printerr 'This script must be run using the root user (or doas), -since we'\''ll be changing permissions for some directories later.\n' - exit 2 - fi -} - -function check_right_place { - # Are we even in the Copacabana directory? - if [ "`pwd`" != "$COPA" ] || [ -z "$COPA" ]; then - printerr 'You'\''re not currently chdir'\''d in %s.\n -Although we could chdir you into %s, we'\''re going to cowardly exit the -script.\n' "$COPA" "$COPA" - exit 1 - fi -} - -# Workaround to the # macro in arrays -# which doesn't work properly in bash 4.3 for some reason. -# From download_sources.bash -function n { - # ambiguous redirect? pipe it. - echo "${@}" | wc -w -} - -function printerr { - printf "$@" 1>&2 -} - -main diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh new file mode 100755 index 0000000..f369add --- /dev/null +++ b/cmd/populate_fhs.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Simple shell hack to populate Copacabana's FHS on a new disk +# Copyright (c) 2023 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA + +set -x + +progname="${0##*/}" +COPA=${COPA:-/dsk/0v} +mtab='/etc/mtab' +fhs_spec="$(cd "$(dirname build.ksh)"; pwd -P)/build-system/fhs.ini" +BUILD_KSH=${BUILD_KSH:-false} +F=${F:-$(sed '/.*DIRS=".*"/!d; s/.*DIRS="\(.*\)"/\1/g' "$fhs_spec")} + +# Considering that directories were not defined by build.ksh +if ! $BUILD_KSH; then + { + printf 1>&2 \ + '%s is not intended to be run outside Copacabana'\''s build system.\n' \ + "$progname" + exit 2 + } +fi + +if [ "$(whoami)" != 'root' ]; then + # panic + { + printf 1>&2 'You must be '\''root'\'' to run %s.\n' "$progname" + exit 126 + } +fi + +# Is the Copacabana build disk mounted? +printf 1>&2 'Checking if %s is a mountpoint...\n' "$COPA" +{ +while read line; do + disk="${line%%[[:space:]]*}" + dirtotest_=${line#*[[:space:]]} + dirtotest=${dirtotest_%%[[:space:]]*} + if $(printf '%s' "$dirtotest" | egrep "^$COPA\$" 2>&1 > /dev/null); then + printf 1>&2 'Found %s as a mountpoint for %s.\n' "$COPA" "$disk" + err=0 + break + fi + unset disk dirtotest_ dirtotest + # Not mounted? + err=1 +done < "$mtab" +} +if [ $err != 0 ]; then + printf 1>&2 '%s not mounted?\n' \ + "$COPA" + exit 255 +fi + +printf 1>&2 'Creating directories in '\''%s'\''.\n' $COPA +( +cd $COPA +eval $(printf 'for folder in %s; do mkdir -m 755 "./$folder"; done; err=$?' "$F") +) + +exit $err From 94bbd6df93c82817386597bffa2c517838d80987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 24 Dec 2023 02:19:01 -0300 Subject: [PATCH 029/128] cmd/populate_fhs.sh: Remove tracing. --- cmd/populate_fhs.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh index f369add..fe8828a 100755 --- a/cmd/populate_fhs.sh +++ b/cmd/populate_fhs.sh @@ -4,8 +4,6 @@ # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA -set -x - progname="${0##*/}" COPA=${COPA:-/dsk/0v} mtab='/etc/mtab' From fc11230d7148b9d82109292aeea46f698daf62fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 24 Dec 2023 15:07:17 -0300 Subject: [PATCH 030/128] feat: "Implement" TRASH_PREFIX at trash --- build.ksh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.ksh b/build.ksh index 8d254c6..7e7bc38 100755 --- a/build.ksh +++ b/build.ksh @@ -7,7 +7,6 @@ set -e progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" -trash="$(mktemp -d /tmp/CopaBuild.XXXXXX)" # Immediatly source and run the platform checks before doing anything else. . "$progdir/build-system/tasks/platform_checks.ksh"; platform_checks @@ -28,6 +27,8 @@ rconfig "$progdir/build-system/machine.ini" rconfig "$progdir/build-system/work.ini" rconfig "$progdir/build-system/fhs.ini" +trash="$(mktemp -d "$TRASH_PREFIX/CopaBuild.XXXXXX")" + map dtime initial "$(date +'%Hh%Mmin on %B %d, %Y')" check_elevate_method From 1fd283a1095ee5dc0500df9019bc079244f77368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 25 Dec 2023 10:43:08 -0300 Subject: [PATCH 031/128] Merry Christmas! And already advancing a Happy New Year of 2024. --- LICENSE.txt | 2 +- build-system/tasks/build_all.ksh | 2 +- build-system/tasks/check_dependencies.ksh | 2 +- build-system/tasks/disk_managenment.ksh | 2 +- build-system/tasks/get_source-code.ksh | 2 +- build-system/tasks/platform_checks.ksh | 2 +- build.ksh | 2 +- cmd/download_sources.ksh | 2 +- cmd/populate_fhs.sh | 4 ++-- cmd/sha256sum.ksh | 4 ++-- cmd/snapshot_stage.ksh | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 86174e9..4ab0681 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ University of Illinois/NCSA Open Source License -Copyright (c) 2019-2023 Pindorama. All rights reserved. +Copyright (c) 2019-2024 Pindorama. All rights reserved. Developed by: Pindorama Caio Novais (caioyoshimura) diff --git a/build-system/tasks/build_all.ksh b/build-system/tasks/build_all.ksh index 7f79a12..842dfb2 100644 --- a/build-system/tasks/build_all.ksh +++ b/build-system/tasks/build_all.ksh @@ -1,6 +1,6 @@ # This task script is part of Copacabana's build system. # -# Copyright (c) 2023: Pindorama +# Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA # STEP 3: Build diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 3eda55b..7a28482 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -1,6 +1,6 @@ # This task script is part of Copacabana's build system. # -# Copyright (c) 2023: Pindorama +# Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA # C and C++ sanity checks by Samuel (callsamu), Lucas (volatusveritas) # and Luiz Antônio Rangel (takusuman) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index bea316f..114835b 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -1,6 +1,6 @@ # This task script is part of Copacabana's build system. # -# Copyright (c) 2023: Pindorama +# Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA # STEP 1: "Pindorama presents: Fubá Cake" diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_source-code.ksh index 83f7f2c..e8e0048 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_source-code.ksh @@ -1,6 +1,6 @@ # This task script is part of Copacabana's build system. # -# Copyright (c) 2023: Pindorama +# Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA # STEP 2: Ingredients diff --git a/build-system/tasks/platform_checks.ksh b/build-system/tasks/platform_checks.ksh index d1b5693..866ebc2 100644 --- a/build-system/tasks/platform_checks.ksh +++ b/build-system/tasks/platform_checks.ksh @@ -1,6 +1,6 @@ # This task script is part of Copacabana's build system. # -# Copyright (c) 2023: Pindorama +# Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA # STEP 0: Resources, part I diff --git a/build.ksh b/build.ksh index 7e7bc38..da42697 100755 --- a/build.ksh +++ b/build.ksh @@ -1,6 +1,6 @@ #!/usr/bin/env ksh93 # This script is the head of Copacabana's build system. -# Copyright (c) 2023: Pindorama +# Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA set -e diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index 24fc390..ce3deee 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -1,7 +1,7 @@ #!/usr/bin/env ksh93 # Simple shell hack to download and SHA256 check source tarballs. # -# Copyright 2021 - 2023 Luiz Antônio Rangel (takusuman). +# Copyright 2021 - 2024 Luiz Antônio Rangel (takusuman). # n() function by Caio Novais (caionova). # This script is licensed under UUIC/NCSA (as Copacabana work itself). # Forked from CMLFS, which was originally dual-licensed between diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh index fe8828a..933a949 100755 --- a/cmd/populate_fhs.sh +++ b/cmd/populate_fhs.sh @@ -1,7 +1,7 @@ #!/bin/sh # Simple shell hack to populate Copacabana's FHS on a new disk -# Copyright (c) 2023 Pindorama -# Luiz Antônio Rangel +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA progname="${0##*/}" diff --git a/cmd/sha256sum.ksh b/cmd/sha256sum.ksh index 4dcc233..9a015a6 100755 --- a/cmd/sha256sum.ksh +++ b/cmd/sha256sum.ksh @@ -2,8 +2,8 @@ # sha256sum.ksh - Generate SHA256 hashes for a file using Open/LibreSSL. # Can be extended to more digest formats later, the code is pretty maleable. # -# Copyright (c) 2023 Pindorama -# Luiz Antônio Rangel +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA progname=${0##*/} diff --git a/cmd/snapshot_stage.ksh b/cmd/snapshot_stage.ksh index 5c1090e..f1acd77 100755 --- a/cmd/snapshot_stage.ksh +++ b/cmd/snapshot_stage.ksh @@ -1,6 +1,6 @@ #!/usr/bin/env ksh93 # Simple shell hack to snapshot a Copacabana stage. -# Copyright 2022: Luiz Antônio (takusuman). +# Copyright 2022-2024: Luiz Antônio (takusuman). # This script is licensed under UUIC/NCSA (as Copacabana work itself). # PS: It can also be run in GNU Broken... eh, I mean BOURNE-Again Shell # if you don't have AT&T's ksh93 installed. From dc62cd4676fceafa9be54d725c8614710a2de409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 30 Dec 2023 11:44:01 -0300 Subject: [PATCH 032/128] feat: Compatibility of __record() with GNU Bash. --- build-system/internals/helpers/helpers.shi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 09bd89b..014cd9e 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -261,6 +261,7 @@ __record() { variable="$2" value="$3" + if [[ -z "$BASH" ]]; then # This is for KornShell 93 # The only thing that changes between record() and map() is the printf # format before evaluating it into the script. if [[ "$whos_calling" == 'record' ]]; then @@ -269,7 +270,15 @@ __record() { format='%s+=([%s]="%s")' else panic '%s: invalid caller '%s'.\n' \ - "record()/map() backend" "$whos_calling" + 'record()/map() backend' "$whos_calling" + fi + else # Broken-Again + format='%s['%s']="%s"' + fi + + if [[ -n "$BASH" ]]; then + # Declare a global, associative array. + printf 'declare -gA %s\n' "$identifier" fi # Hope this works. From 35ad42b0f7a31d6d34ab62847b99a566ab276af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 30 Dec 2023 11:52:26 -0300 Subject: [PATCH 033/128] feat!: Made record() not functional on Bash; recommend using map(). --- build-system/internals/helpers/helpers.shi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 014cd9e..d26a562 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -243,6 +243,16 @@ function record { variable="$2" value="$3" + # Broken-Again Shell, unlike KornShell, can not get + # a function caller by $0, so we will need to define + # a new variable with this information. + # Doing it specifically on record() because compound + # variables are not supported on Bash. + if [[ -n $BASH ]]; then + bash_caller=$FUNCNAME + export bash_caller + fi + eval $(__record "$identifier" "$variable" "$value") } @@ -273,6 +283,14 @@ __record() { 'record()/map() backend' "$whos_calling" fi else # Broken-Again + if [[ "$bash_caller" == 'record' ]]; then + panic \ + '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.\n' \ + 'record()/map() backend' + # Basic sanitizing in case of panic() does + # not quitting the program as intended. + unset bash_caller + fi format='%s['%s']="%s"' fi From af4f7acdf988ed50e2bd0a82f8337a5972d3e805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 30 Dec 2023 11:59:52 -0300 Subject: [PATCH 034/128] chore: Use a boolean instead of comparing strings to know if record() is being called in GNU Bash. --- build-system/internals/helpers/helpers.shi | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index d26a562..ac2056f 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -243,14 +243,12 @@ function record { variable="$2" value="$3" - # Broken-Again Shell, unlike KornShell, can not get - # a function caller by $0, so we will need to define - # a new variable with this information. - # Doing it specifically on record() because compound - # variables are not supported on Bash. + # Shouting to __record() that, since we are on Bash, + # record() shall not be supported as is, because + # compound variables are not supported on Bash. if [[ -n $BASH ]]; then - bash_caller=$FUNCNAME - export bash_caller + bash_supports_compound=false + export bash_supports_compound fi eval $(__record "$identifier" "$variable" "$value") @@ -283,13 +281,13 @@ __record() { 'record()/map() backend' "$whos_calling" fi else # Broken-Again - if [[ "$bash_caller" == 'record' ]]; then + if ! $bash_supports_compound; then panic \ '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.\n' \ 'record()/map() backend' # Basic sanitizing in case of panic() does # not quitting the program as intended. - unset bash_caller + unset bash_supports_compound fi format='%s['%s']="%s"' fi From 7615001e95ab3677e6011d5a1428b0ef1a681942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 8 Jan 2024 17:36:25 -0300 Subject: [PATCH 035/128] feat!: Also require ed(1) at check_dependencies.ksh. --- build-system/tasks/check_dependencies.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 7a28482..ebfd357 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -34,7 +34,7 @@ function check_dependencies { 'size' 'strings' 'strip' ) # General commands - general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'patch' \ + general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'patch' \ 'find' 'grep' 'm4' 'mitzune' \ ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) From 3a233a2352fa69509fa0a4688b8b672e460024f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 8 Jan 2024 19:25:11 -0300 Subject: [PATCH 036/128] feat!: Also check for L.E.``mount``, since ``tasks/disk_nanagenment.ksh`` uses it. --- build-system/tasks/check_dependencies.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index ebfd357..bac504e 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -35,7 +35,7 @@ function check_dependencies { # General commands general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'patch' \ - 'find' 'grep' 'm4' 'mitzune' \ + 'find' 'grep' 'lemount' 'm4' 'mitzune' \ ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) # General compressing tools From 54f2d5e0487ab333c7e939e8d8fd2411b65fef58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 21 Jan 2024 23:50:50 -0300 Subject: [PATCH 037/128] fix: Check for aria2c instead of curl if it's enabled. --- build-system/tasks/check_dependencies.ksh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index bac504e..2458c6b 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -41,6 +41,11 @@ function check_dependencies { # General compressing tools archivers=('tar' 'bzip2' 'gzip' 'xz') + # Check for aria2c + if $USE_ARIA2C; then + general_commands[1]='aria2c' + fi + for (( g=0; g < $(n ${general_commands[@]}); g++ )); do printerr 'Searching for %s at PATH (%s)... ' \ "${general_commands[$g]}" "$PATH" From 355c1dd1595d4273fa03a56fc281a9edf2ca5e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 22 Jan 2024 10:13:04 -0300 Subject: [PATCH 038/128] chore(cmd/populate_fhs.sh): More efficient string comparison. --- cmd/populate_fhs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh index 933a949..3443f77 100755 --- a/cmd/populate_fhs.sh +++ b/cmd/populate_fhs.sh @@ -36,7 +36,7 @@ while read line; do disk="${line%%[[:space:]]*}" dirtotest_=${line#*[[:space:]]} dirtotest=${dirtotest_%%[[:space:]]*} - if $(printf '%s' "$dirtotest" | egrep "^$COPA\$" 2>&1 > /dev/null); then + if [ "x$dirtotest" = "x$COPA" ]; then printf 1>&2 'Found %s as a mountpoint for %s.\n' "$COPA" "$disk" err=0 break From 1411e0ecc615f3c0c9a161567d9cd4d36bdec84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 22 Jan 2024 10:14:43 -0300 Subject: [PATCH 039/128] chore(cmd/populate_fhs.sh): Formatting. --- cmd/populate_fhs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh index 3443f77..5556c4d 100755 --- a/cmd/populate_fhs.sh +++ b/cmd/populate_fhs.sh @@ -37,7 +37,8 @@ while read line; do dirtotest_=${line#*[[:space:]]} dirtotest=${dirtotest_%%[[:space:]]*} if [ "x$dirtotest" = "x$COPA" ]; then - printf 1>&2 'Found %s as a mountpoint for %s.\n' "$COPA" "$disk" + printf 1>&2 'Found %s as a mountpoint for %s.\n' \ + "$COPA" "$disk" err=0 break fi From 264226c63e344961bf2eda2a084489804d343ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 24 Jan 2024 04:41:49 -0300 Subject: [PATCH 040/128] chore: Outsource printerr() for panic(). --- build-system/internals/helpers/helpers.shi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index ac2056f..8900301 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -414,6 +414,7 @@ function printerr { # And use this for fatal errors, it will exit the script. function panic { msgbuf="$(printf "$@")" - printf 1>&2 'panic: %s' "$msgbuf" + printerr 'panic: %s' "$msgbuf" + exit 255 } From 92609022ee1514f0693581d9cb0dec9243935389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 8 Feb 2024 20:57:30 -0300 Subject: [PATCH 041/128] feat: Start implementing a way to "continue" a build. --- build-system/tasks/disk_managenment.ksh | 160 ++++++++++++++++++------ 1 file changed, 122 insertions(+), 38 deletions(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index 114835b..84b2650 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -8,6 +8,10 @@ function create_disk { disk_block="$1" + # Set first_time flag to indicate that it's the first time building the + # system. + first_time=true + # Estabilish a default size of 20 GB for a virtual disk virtuadisk_size=${VIRTUADISK_SIZE:-20} disk_label=${DISK_LABEL:-'Copacabana'} @@ -42,10 +46,31 @@ function create_disk { printerr 'Info: Using a physical disk, present at %s with size of %d MB.\n' \ "$disk_block" "$disk_size" - if (( disk_size < (virtuadisk_size * 1024) )); then - printerr \ - 'Warning: %s is smaller (%d MB) than the recommended capacity for building Copacabana (%d MB).\n' \ - "$disk_block" "$disk_size" $(( virtuadisk_size * 1024 )) + if (( disk_size < (10 * 1024) )); then + panic \ + 'Disk %s is too small (%d MB). %d MB is the recommended capacity for building Copacabana.\n' \ + "$disk_block" "$disk_size" $(( 10 * 1024 )) + # Do not accept disks/disk partitions larger than 50GB. + elif (( disk_size > (50 * 1024) )); then + panic \ + 'Disk %s is too large. Create a partition and/or use a virtual disk smaller than %d MB.\n' \ + "$disk_block" $(( 50 * 1024 )) + fi + + # Check if disk is already initialized. + if $(elevate fdisk -x "${disk_block%%?}" | grep "$disk_block" &>/dev/null); then + filesystem=$(eval $(blkid -o udev "$disk_block"); + printf '%s\n' "$ID_FS_TYPE") + + if ! check_linuxfs $filesystem; then + panic \ + '%s is not intended for containing a Linux system.\nDid you mean creating a virtual disk image inside %s?\n' \ + $filesystem "$disk_block" + fi + + # If we have a compatible file system on the disk, we + # shall already set as not being the first time. + first_time=false fi elif [[ "$VIRTUAL_DISK" ]]; then virtuadisk_path="$(realpath "$disk_block")" @@ -55,57 +80,72 @@ function create_disk { if [[ ! -e "$virtuadisk_path" ]]; then printerr 'Info: Inexistent disk image, creating it...\n' elif [[ -e "$virtuadisk_path" && ! -b "$virtuadisk_path" ]]; then - printerr 'Info: A disk image already exists at %s, do you wish to clean it up and start over?\n' \ + printerr 'Info: A disk image already exists at %s, do you wish to continue or clean it up and start over?\n' \ "$virtuadisk_path" - PS3='Start over? ' - select option in yes no; do - if [[ "$option" == yes ]]; then - break - else - return 1 - fi - done + first_time=false fi + fi + + if ! $first_time; then + start_over=false + PS3='Continue? ' + select option in yes no quit; do + case "$option" in + # This will (L.E.)mount the disk and view if + # there is something that can be done. + yes) break ;; + no) start_over=true ;; + quit|*) return 1 ;; + esac + done + fi - printerr 'Info: Creating a virtual disk image at %s, with size of %d MB.\n' \ - "$virtuadisk_path" $(( virtuadisk_size * 1024 )) + if "$VIRTUAL_DISK"; then + if ( $first_time || $start_over ); then + printerr 'Info: Creating a virtual disk image at %s, with size of %d MB.\n' \ + "$virtuadisk_path" $(( virtuadisk_size * 1024 )) - # 1 GB is equal to 2.097.152 blocks. - # In other words, use: - # X GB = X * [(1024^2) * 2] blocks - virtuadisk_blksize="$(( virtuadisk_size * ((1024 ** 2) * 2) ))" - dd if=/dev/zero of="$virtuadisk_path" bs=512 count=$virtuadisk_blksize + # 1 GB is equal to 2.097.152 blocks. + # In other words, use: + # X GB = X * [(1024^2) * 2] blocks + virtuadisk_blksize="$(( virtuadisk_size * ((1024 ** 2) * 2) ))" + dd if=/dev/zero of="$virtuadisk_path" bs=512 count=$virtuadisk_blksize - # Does the size in blocks matches with what du(1)'s getting? - virtuadisk_reported_size=$(du -s "$virtuadisk_path" | nawk '{ printf("%d", $1); }') + # Does the size in blocks matches with what du(1)'s getting? + virtuadisk_reported_size=$(du -s "$virtuadisk_path" | nawk '{ printf("%d", $1); }') - if (( virtuadisk_blksize == virtuadisk_reported_size )); then - printerr 'Info: %s is o.k. Proceeding.\n' "$virtuadisk_path" - else - printerr 'Error: dd failed to write %d blocks to %s.\n' \ - $virtuadisk_blksize "$virtuadisk_path" - printerr 'Error: It possible reported an error and/or an interruption signal before this message.\n' - printerr 'Error: Please, check. Stopping the build process.\n' - return 1 + if (( virtuadisk_blksize == virtuadisk_reported_size )); then + printerr 'Info: %s is o.k. Proceeding.\n' "$virtuadisk_path" + else + printerr 'Error: dd failed to write %d blocks to %s.\n' \ + $virtuadisk_blksize "$virtuadisk_path" + printerr 'Error: It possible reported an error and/or an interruption signal before this message.\n' + printerr 'Error: Please, check. Stopping the build process.\n' + return 1 + fi + + # For some reason, echo won't be working for this, so let be + # sticking with printf '%s\n'. + printf '%s\n' "${fdisk_steps[@]}" | elevate fdisk "$virtuadisk_path" fi - # For some reason, echo won't be working for this, so let be - # sticking with printf '%s\n'. - printf '%s\n' "${fdisk_steps[@]}" | elevate fdisk "$virtuadisk_path" + # Expose the virtual disk to the system. loop_disk_block="$(elevate losetup --show -P -f "$virtuadisk_path")" # That's why we hardcoded the partition to be the first. unset disk_block; export disk_block="${loop_disk_block}p1" fi - # Formats the disk block as Ext4 and label it as our defined disk label. - elevate "$run_shell" -c "mkfs -V -t ext4 '$disk_block' && e2label '$disk_block' '$disk_label'" - + if ( $first_time || $start_over ); then + # Formats the disk block as Ext4 and label it as our defined disk label. + elevate "$run_shell" -c "mkfs -V -t ext4 '$disk_block' && e2label '$disk_block' '$disk_label'" + fi + # We expect the "dsk" type to be the first in the array on L.E.mount, as # in the default /etc/leconf, so we'll be using "1" as the second # argument. printf '%s\n' "$disk_block" 1 | eval $(elevate lemount) - # And here we go + # And here we go. # Making it read-only only to be sure that it won't be getting # overwritten by a "non-build.ksh aware" script later. export readonly COPA="$ledisk" @@ -113,6 +153,35 @@ function create_disk { printerr 'Info: Copacabana disk %s mounted at %s.\n' "$disk_block" "$COPA" } +# May use this function later, no use for it for now. +function get_size_blocks { + typeset -a disk_size[2] + disk_block="$1" + + # The minimum size for a block is 512KiB, not less. + # This identifier may sound a little bit erred. + readonly blocks_per_kib=512 + + disk_size=( $(elevate fdisk -x "$disk_block" \ + | sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q') ) + + size=${disk_size[0]} + sizeunit=${disk_size[1]} + unset disk_size + + case $sizeunit in + 'TiB') ((blocks= size * (blocks_per_kib * 4194304) )) ;; + 'GiB') ((blocks= size * (blocks_per_kib * 4096) )) ;; + 'MiB') ((blocks= size * (blocks_per_kib * 4) )) ;; + 'KiB') ((blocks= size / blocks_per_kib )) ;; + esac + unset size sizeunit + + printf '%d' $blocks + + return 0 +} + # STEP 1.5: Populate the file system # This function will run the cmd/populate_fhs.sh script and create directories # for the toolchains that will be built. @@ -186,4 +255,19 @@ function unmount_and_detach { if $VIRTUAL_DISK; then elevate losetup -D "${disk_block%%*p?}" fi -} +} + +# This checks for valid file systems on +# which Copacabana builds are made and +# tested. +function check_linuxfs { + fs=$1 + err=0 + + case $fs in + btrfs|ext4) break ;; + default) err=1; break ;; + esac + + return $err +} From e8840f8a3ec31038da3674f8f1f3dff61aeb0e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 27 Feb 2024 11:04:45 -0300 Subject: [PATCH 042/128] docs: Bump Heirloom NG to 20240220-fix until it gets merged into master and/or a new release is made. This branch improves seq(1) with a safer and more complete (UNIX v8 payloads with extensions) implementation and also implements timeout(1). --- sources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources.txt b/sources.txt index fdac603..89785f4 100644 --- a/sources.txt +++ b/sources.txt @@ -31,7 +31,7 @@ https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.7.2.tar.gz %% FIXME: Talking serious now, we shall move to the next stable %% release of Heirloom NG as soon its out, but there's changes %% on the current branch that we can't forgo. -https://github.com/Projeto-Pindorama/heirloom-ng/archive/refs/heads/master.tar.gz +https://github.com/Projeto-Pindorama/heirloom-ng/archive/refs/heads/20240220-fix.tar.gz https://github.com/Projeto-Pindorama/lemount/archive/refs/tags/0.3.tar.gz https://github.com/gavinhoward/bc/releases/download/6.5.0/bc-6.5.0.tar.xz https://www.mktemp.org/dist/mktemp-1.7.tar.gz From bbf1085e13f200930a3d91a4ae7f323e7892e60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 25 Mar 2024 15:54:15 -0300 Subject: [PATCH 043/128] chore: Fix built-in timeout() function for handling parameters with space and also made it aware of a installed timeout(1) implementation. The latter was done because Heirloom NG got an timeout(1) implementation at 20240220. --- build-system/internals/helpers/posix-alt.shi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/helpers/posix-alt.shi index 699d3b7..a80c84f 100644 --- a/build-system/internals/helpers/posix-alt.shi +++ b/build-system/internals/helpers/posix-alt.shi @@ -5,7 +5,7 @@ # functions already have variables defined in local scopes. # Copyright (c) 2020-2021 Caio Novais and Luiz Antônio Rangel -# Copyright (c) 2020-2023 Luiz Antônio Rangel +# Copyright (c) 2020-2024 Luiz Antônio Rangel # SPDX-Licence-Identifier: Caldera # Include dirs(), pushd() and popd() @@ -44,7 +44,13 @@ lines(){ # timeout timeout(){ - "${2}" & PID="${!}"; sleep "${1}" && kill "${PID}" + if ! command -v timeout 2>&1 >/dev/null; then + time="$1" + shift + "$@" & PID="${!}"; sleep "$time" && kill "$PID" + else + command timeout "$@" + fi } # nproc From 39e8ecde16ef6e5e985e2c94ee46898ce194315a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 25 Mar 2024 16:18:59 -0300 Subject: [PATCH 044/128] chore: Made realpath() aware of an installed readlink(1) implementation. Since Heirloom NG got a readlink(1) implementation derived from OpenBSD at release 230228. --- build-system/internals/helpers/posix-alt.shi | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/helpers/posix-alt.shi index a80c84f..67aedb6 100644 --- a/build-system/internals/helpers/posix-alt.shi +++ b/build-system/internals/helpers/posix-alt.shi @@ -23,14 +23,18 @@ basename(){ # realpath realpath(){ - # ./sources.txt -> sources.txt - file_basename="`basename "$1"`" - # ./sources.txt -> . - file_dirname="`dirname "$1"`" - # get the absolute directory name - # example: ./sources.txt -> /usr/src/copacabana-repo/sources.txt - # cd ./; pwd -> /usr/src/copacabana-repo - echo "`cd "${file_dirname}"; pwd`/${file_basename}" + if ! command -v readlink 2>&1 >/dev/null; then + # ./sources.txt -> sources.txt + file_basename="`basename "$@"`" + # ./sources.txt -> . + file_dirname="`dirname "$@"`" + # get the absolute directory name + # example: ./sources.txt -> /usr/src/copacabana-repo/sources.txt + # cd ./; pwd -> /usr/src/copacabana-repo + echo "`(cd "${file_dirname}"; pwd)`/${file_basename}" + else + readlink -f "$@" + fi } # wc -l From 2144d9b59732c7914a6a0b41d7bc5c6339fabfc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 25 Mar 2024 16:42:55 -0300 Subject: [PATCH 045/128] chore: Made nproc() aware that Heirloom's getconf(1) didn't support _NPROCESSORS_ONLN before 230305. --- build-system/internals/helpers/posix-alt.shi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/helpers/posix-alt.shi index 67aedb6..f1d89bf 100644 --- a/build-system/internals/helpers/posix-alt.shi +++ b/build-system/internals/helpers/posix-alt.shi @@ -60,7 +60,12 @@ timeout(){ # nproc nproc(){ case "`uname -s`" in - Darwin | Linux) getconf '_NPROCESSORS_ONLN';; + Darwin) getconf '_NPROCESSORS_ONLN';; + Linux) if [ `getconf HEIRLOOM_TOOLCHEST_VERSION` -lt 230305 ]; then + grep -c 'processor' /proc/cpuinfo + else + getconf '_NPROCESSORS_ONLN' + fi ;; FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN';; SunOS) echo "`ksh93 -c 'getconf NPROCESSORS_ONLN'`" ;; esac From b97ea56c9ac667a9e3a77f39a179d3ddacf44e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 25 Mar 2024 19:29:20 -0300 Subject: [PATCH 046/128] fix: Shall not worry with globbing at realpath(). --- build-system/internals/helpers/posix-alt.shi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/helpers/posix-alt.shi index f1d89bf..be35da8 100644 --- a/build-system/internals/helpers/posix-alt.shi +++ b/build-system/internals/helpers/posix-alt.shi @@ -25,15 +25,15 @@ basename(){ realpath(){ if ! command -v readlink 2>&1 >/dev/null; then # ./sources.txt -> sources.txt - file_basename="`basename "$@"`" + file_basename="`basename "$1"`" # ./sources.txt -> . - file_dirname="`dirname "$@"`" + file_dirname="`dirname "$1"`" # get the absolute directory name # example: ./sources.txt -> /usr/src/copacabana-repo/sources.txt # cd ./; pwd -> /usr/src/copacabana-repo echo "`(cd "${file_dirname}"; pwd)`/${file_basename}" else - readlink -f "$@" + readlink -f "$1" fi } From fdfb15c79089dcf3fd298c893bc6e27553c2b9de Mon Sep 17 00:00:00 2001 From: "Dq. Louis Le Bleue" Date: Wed, 27 Mar 2024 17:51:32 -0300 Subject: [PATCH 047/128] fix: virtuadisk_path for the new realpath() implementation at posix-alt.shi. --- build-system/tasks/disk_managenment.ksh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index 84b2650..c758810 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -6,6 +6,7 @@ # STEP 1: "Pindorama presents: Fubá Cake" # In this step, we will create and format a disk, virtual or physical. function create_disk { + set -x disk_block="$1" # Set first_time flag to indicate that it's the first time building the @@ -73,7 +74,10 @@ function create_disk { first_time=false fi elif [[ "$VIRTUAL_DISK" ]]; then - virtuadisk_path="$(realpath "$disk_block")" + # This would be the equivalent of the old realpath() builtin + # at posix-alt.shi, it gets $disk_block's directory location + # and then contatenates it with its name. + virtuadisk_path="$(cd "${disk_block%/*}"; pwd -P)/${disk_block##*/}" printerr 'Info: Using a virtual disk, located at %s, with a pre-determined size of %d MB.\n' \ "$virtuadisk_path" $(( virtuadisk_size * 1024 )) From 3c355ef989c1b2bcfe656e745da41b3ac0d4884d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 27 Mar 2024 23:58:29 -0300 Subject: [PATCH 048/128] fix: Removed rconfig() call for now at driver.ksh. Maybe come back with it after doing the first FIXME at dotini(). --- build-system/internals/cmd/driver.ksh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build-system/internals/cmd/driver.ksh b/build-system/internals/cmd/driver.ksh index 5155a90..dcbf0e7 100755 --- a/build-system/internals/cmd/driver.ksh +++ b/build-system/internals/cmd/driver.ksh @@ -67,7 +67,7 @@ function read_pkgbuild { # Treat the output from get_package_info() to remove white lines and # comments, also eval the variables in the script. - rconfig <(get_pkgbuild_info "$package_recipe") + read_manifest <(get_pkgbuild_info "$package_recipe") # Source all the functions defined source <(get_pkgbuild_functions "$package_recipe") @@ -168,6 +168,17 @@ function transmutacio { } 2>&1 | logto "$blackbox" } +function read_manifest { + (sed '/#/d; /^$/d;' "$1") \ + | for ((;;)); do + if IFS='=' read id v; then + printf '%s=%s\n' "$id" "$v" + else + break + fi + done +} + function print_help { printerr '%s: illegal option "%s" The following options are used for debugging: From 091465e826d1cf935b17facd8ef2c6d0a5b3a777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 28 Mar 2024 14:48:38 -0300 Subject: [PATCH 049/128] fix: Portabilize defined() and introduce KSH93_RELEASE macro. --- build-system/internals/helpers/helpers.shi | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 8900301..d55f66f 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -10,7 +10,10 @@ # ter Igualdade, Amor e Fraternidade [...]" # Make everyone aware we're running from BUILD_KSH. -export readonly BUILD_KSH=true +readonly BUILD_KSH=true +readonly KSH93_RELEASE=$(printf '%s' "${KSH_VERSION:-0}" \ + | nawk '{ gsub("-", ""); print $NF; }') +export BUILD_KSH KSH93_RELEASE # Reads INI configuration files, now a boilerplate function # to dotini/inicompat --- and, in case of using @@ -327,10 +330,17 @@ function rematch { # on purpose to the C preprocessor special operator defined(), meant for being # used in if conditions. function defined { + set -x # First it will check if it's a function defined on the environment and/or in # a sourced file, if it's not, then it will check if it is a variable. { - type -t "$1" | grep 'function' 2>&1 > /dev/null \ + # 'type -t' first appeared in KornShell 93 1.0.0. release + # as a reimplementation of the GNU Broken-Again extension, + # earlier versions do not have it present. + { (test $KSH93_RELEASE -ge 20220801 || test -n "$BASH") \ + && type -t "$1" \ + || type -v "$1"; } \ + | grep 'function' 2>&1 > /dev/null \ || test ! -z "$(eval "echo \$$1")" } \ || return 1 From 5014e671f1027675ea77b7027c2f0ff293fcc73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 28 Mar 2024 15:15:17 -0300 Subject: [PATCH 050/128] fix: Support for ksh93 1.0.0-beta present at Copacabana 0.4 (Developer Release) and also printing some information about the physical disk. Just a note out of curiosity: `[[ "$(file "$disk_block")" =~ (.*[\t ]block special.*) ]]' works for both Heirloom Toolchest/NG's implementation of file(1) and Ian Darwin's, since it can catch both a tab or a single space. --- build-system/tasks/disk_managenment.ksh | 68 +++++++++++++------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index c758810..ae5f7cf 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -6,7 +6,6 @@ # STEP 1: "Pindorama presents: Fubá Cake" # In this step, we will create and format a disk, virtual or physical. function create_disk { - set -x disk_block="$1" # Set first_time flag to indicate that it's the first time building the @@ -38,13 +37,16 @@ function create_disk { fi printerr 'Info: %s only creates a plain disk, without partitions for /boot, /usr, etc.\n' $0 - if [[ ! "$VIRTUAL_DISK" && -b "$disk_block" ]]; then + if [[ ! "$VIRTUAL_DISK" ]] && [[ -b "$disk_block" ]] \ + || ( [[ "$(uname -s)" == "Linux" ]] && (( KSH93_RELEASE <= 20211217 )) \ + && (grep "${disk_block##*/}" /proc/partitions 2>&1 > /dev/null \ + && [[ "$(file "$disk_block")" =~ (.*[\t ]block special.*) ]]) ); then # Get the disk size from /proc/partitions, pretty # self-explanatory. disk_size="$(grep "${disk_block##*/}\$" /proc/partitions \ | nawk '{ printf "%0.1f\n", ($(NF -1) / 1024); }')" - printerr 'Info: Using a physical disk, present at %s with size of %d MB.\n' \ + printerr 'Info: Using a physical disk, present at %s with size of %d MB.\n' \ "$disk_block" "$disk_size" if (( disk_size < (10 * 1024) )); then @@ -58,7 +60,7 @@ function create_disk { "$disk_block" $(( 50 * 1024 )) fi - # Check if disk is already initialized. + # Check if disk is already initialized. if $(elevate fdisk -x "${disk_block%%?}" | grep "$disk_block" &>/dev/null); then filesystem=$(eval $(blkid -o udev "$disk_block"); printf '%s\n' "$ID_FS_TYPE") @@ -157,35 +159,6 @@ function create_disk { printerr 'Info: Copacabana disk %s mounted at %s.\n' "$disk_block" "$COPA" } -# May use this function later, no use for it for now. -function get_size_blocks { - typeset -a disk_size[2] - disk_block="$1" - - # The minimum size for a block is 512KiB, not less. - # This identifier may sound a little bit erred. - readonly blocks_per_kib=512 - - disk_size=( $(elevate fdisk -x "$disk_block" \ - | sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q') ) - - size=${disk_size[0]} - sizeunit=${disk_size[1]} - unset disk_size - - case $sizeunit in - 'TiB') ((blocks= size * (blocks_per_kib * 4194304) )) ;; - 'GiB') ((blocks= size * (blocks_per_kib * 4096) )) ;; - 'MiB') ((blocks= size * (blocks_per_kib * 4) )) ;; - 'KiB') ((blocks= size / blocks_per_kib )) ;; - esac - unset size sizeunit - - printf '%d' $blocks - - return 0 -} - # STEP 1.5: Populate the file system # This function will run the cmd/populate_fhs.sh script and create directories # for the toolchains that will be built. @@ -275,3 +248,32 @@ function check_linuxfs { return $err } + +# May use this function later, no use for it for now. +function get_size_blocks { + typeset -a disk_size[2] + disk_block="$1" + + # The minimum size for a block is 512KiB, not less. + # This identifier may sound a little bit erred. + readonly blocks_per_kib=512 + + disk_size=( $(elevate fdisk -x "$disk_block" \ + | sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q') ) + + size=${disk_size[0]} + sizeunit=${disk_size[1]} + unset disk_size + + case $sizeunit in + 'TiB') ((blocks= size * (blocks_per_kib * 4194304) )) ;; + 'GiB') ((blocks= size * (blocks_per_kib * 4096) )) ;; + 'MiB') ((blocks= size * (blocks_per_kib * 4) )) ;; + 'KiB') ((blocks= size / blocks_per_kib )) ;; + esac + unset size sizeunit + + printf '%d' $blocks + + return 0 +} From 2534751e1dd4a9c51d55c5ab322ac5d42ad7e4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 28 Mar 2024 15:20:31 -0300 Subject: [PATCH 051/128] fix: Only remove the last character from $disk_block if it's a number. --- build-system/tasks/disk_managenment.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index ae5f7cf..198987a 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -61,7 +61,7 @@ function create_disk { fi # Check if disk is already initialized. - if $(elevate fdisk -x "${disk_block%%?}" | grep "$disk_block" &>/dev/null); then + if $(elevate fdisk -x "${disk_block%%[0-9]}" | grep "$disk_block" &>/dev/null); then filesystem=$(eval $(blkid -o udev "$disk_block"); printf '%s\n' "$ID_FS_TYPE") From d14a0be851a45fe66cb50b94d9b3e16bbd2f4d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 28 Mar 2024 16:11:21 -0300 Subject: [PATCH 052/128] fix: ``break`` after no. --- build-system/tasks/disk_managenment.ksh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index 198987a..61ee99e 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -100,7 +100,8 @@ function create_disk { # This will (L.E.)mount the disk and view if # there is something that can be done. yes) break ;; - no) start_over=true ;; + no) start_over=true; + break ;; quit|*) return 1 ;; esac done From e7a8c05cd8936b4c1367d4d20dc62fd6a75ed76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 28 Mar 2024 16:13:43 -0300 Subject: [PATCH 053/128] fix: Do not call defined() in subshells because it causes an error in ksh93 1.0.0-beta. Simply put, when one tries to run a function/command in a subshell that does not print nothing, it will try to execute `1>' instead of just continuing with the return code being returned. That payload was removed in latest versions for some reason. + '1>' /dev/null /home/bleue/copacabana/build-system/internals/cmd/driver.ksh[192]: main[49]: transmutacio[140]: 1>: not found --- build-system/internals/cmd/driver.ksh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-system/internals/cmd/driver.ksh b/build-system/internals/cmd/driver.ksh index dcbf0e7..c7dda46 100755 --- a/build-system/internals/cmd/driver.ksh +++ b/build-system/internals/cmd/driver.ksh @@ -125,7 +125,7 @@ function transmutacio { shared_methods=('configure' 'build' 'make_pkg') { - if $(defined unarchive); then + if defined unarchive; then ( cd "$source_archive_dir"; unarchive ) if (( $? != 0 )); then printerr 'Error: Failed to unarchive %s from %s. Error code: %d\n' \ @@ -137,7 +137,7 @@ function transmutacio { # so we won't have problems with future "boilerplate" pkgbuilds that # just create symbolic links, for instance. for (( c=0; c <= ${#shared_methods[@]}; c++ )); do - if $(defined $(printf '%s' ${shared_methods[$c]})); then + if defined $(printf '%s' ${shared_methods[$c]}); then if [[ "${shared_methods[$c]}" == 'make_pkg' ]]; then Destdir="$DESTDIR/$Destdir" DESTDIR="$Destdir" @@ -153,7 +153,7 @@ function transmutacio { fi done - if $(defined post_install); then + if defined post_install; then # If $Destdir not defined from the pkgbuild, default it # to $DESTDIR. It is expected to be declared when the package # needs to be installed in a custom location. From 16fee2a60c9a37e3c4cb355c6337436574c7e032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 28 Mar 2024 16:27:07 -0300 Subject: [PATCH 054/128] chore: Request file(1) command at check_dependencies.ksh. --- build-system/tasks/check_dependencies.ksh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 2458c6b..5f5803b 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -34,8 +34,8 @@ function check_dependencies { 'size' 'strings' 'strip' ) # General commands - general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'patch' \ - 'find' 'grep' 'lemount' 'm4' 'mitzune' \ + general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'file' \ + 'patch' 'find' 'grep' 'lemount' 'm4' 'mitzune' \ ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) # General compressing tools From b9fe81593efb0f470e169c228f402b82462f7f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 29 Mar 2024 10:06:17 -0300 Subject: [PATCH 055/128] fix: Try to bypass (currently) broken Heirloom ``tar`` on PATH. Also changed some messages. --- build-system/tasks/check_dependencies.ksh | 66 +++++++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 5f5803b..da966f3 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -56,8 +56,65 @@ function check_dependencies { for (( h=0; h < $(n ${archivers[@]}); h++ )); do printerr 'Does %s work for what we want? ' "${archivers[$h]}" if [ "${archivers[$h]}" == 'tar' ]; then # TAR-specific tests - if [[ "$(readlink -f "$(type -p tar)")" =~ (star) ]] \ - || $(tar -h 2>&1| grep 'star' 2>&1 >/dev/null); then + tarpath="$(realpath $(type -p tar))" + if (strings "$tarpath" | grep '@(#)tar.*\(gritter\)' \ + && getconf HEIRLOOM_TOOLCHEST_VERSION) 2>&1 >/dev/null; then + printerr '\nI'\''m almost certain that %s is from the Heirloom Toolchest...\n' \ + "$(type -p tar)" + printerr 'Heirloom Toolchest'\''s tar is broken since at least 2007 for some reason.\n' + printerr \ + 'Until this is hopefully fixed, I'\''ll be searching for another tar at PATH.\n' + + printf '%s' "$PATH" \ + | nawk '{ np=split($0, p, ":"); + for (n = 1; n < np; n++) { + print p[n]; + }}' \ + | for ((;;)); do + if read -r d; then + tar_cmd="$d/tar" + if [[ ! -e "$tar_cmd" || "$d" == "${tarpath%/*}" ]]; then + continue + elif ($tar_cmd --help 2>&1| egrep 'star|bsdtar|GNU' 2>&1 >/dev/null); then + new_tarpath="$d" + tmpPATH="$new_tarpath:$PATH" + # This big chunk of code, which also + # repeats the code utilized above to + # split the PATH, works as a 'uniq' + # for the PATH variable because + # since $new_tarpath was already in PATH, + # it would be repeated in the new PATH. + PATH="$(printf '%s' "$tmpPATH" \ + | nawk '{ np=split($0, p, ":"); + for (n = 1; n <= np; n++) { + if ((n + 1) >= np) { + separator="" + } else { + separator=":" + } + # If not already present + # on the s[] array, print it. + if (!s[p[n]]++) { + printf("%s%c", p[n], separator); + } + } + }')" + printerr 'Info: Found suitable tar at %s\n' $new_tarpath + printerr 'Info: New PATH: %s\n' $PATH + export PATH + unset new_tarpath tmpPATH + break + fi + unset tar_cmd + else + panic 'Error: Couldn'\''t find a suitable tar implementation.\n' + break # Une pure formalité. + fi + done + fi + + if [[ "$tarpath" =~ (star) ]] \ + || (tar -h 2>&1| grep 'star' 2>&1 >/dev/null); then printerr '\nI'\''m almost certain that %s is Schily tar...\n' \ "$(type -p tar)" printerr \ @@ -70,6 +127,7 @@ function check_dependencies { } typeset -xf tar fi + unset tarpath { ( mkdir -p "$archiver_sanity"{,_results} @@ -111,14 +169,14 @@ function check_dependencies { done for (( k=0; k < $(n ${internal_scripts[@]}); k++ )); do - printerr 'Searching for independent script %s at %s... ' \ + printerr 'Info: Searching for independent script %s at %s... ' \ "${internal_scripts[$k]}" "$progdir" if [ -e "$progdir/${internal_scripts[$k]}" ] \ && [ ! -z "$(cat "$progdir/${internal_scripts[$k]}")" ]; then printerr 'Found!\n' else printerr '%s not found...\n' - printerr 'It seems like your Copacabana repository clone is incomplete.\n' + panic 'Error: It seems like your Copacabana repository clone is incomplete.\n' return 1 fi done From 2aa6bb3f42dffa061c6192deb0ab1a695a5c2ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 29 Mar 2024 10:51:31 -0300 Subject: [PATCH 056/128] chore: Shorten NAwk command. --- build-system/tasks/check_dependencies.ksh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index da966f3..7b45662 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -66,10 +66,7 @@ function check_dependencies { 'Until this is hopefully fixed, I'\''ll be searching for another tar at PATH.\n' printf '%s' "$PATH" \ - | nawk '{ np=split($0, p, ":"); - for (n = 1; n < np; n++) { - print p[n]; - }}' \ + | nawk '{ gsub(":", "\n"); print $0; }' \ | for ((;;)); do if read -r d; then tar_cmd="$d/tar" @@ -78,12 +75,10 @@ function check_dependencies { elif ($tar_cmd --help 2>&1| egrep 'star|bsdtar|GNU' 2>&1 >/dev/null); then new_tarpath="$d" tmpPATH="$new_tarpath:$PATH" - # This big chunk of code, which also - # repeats the code utilized above to - # split the PATH, works as a 'uniq' - # for the PATH variable because - # since $new_tarpath was already in PATH, - # it would be repeated in the new PATH. + # This big chunk of code works as a 'uniq' + # for the PATH variable because, since + # $new_tarpath was already in PATH, it + # would be repeated in the new PATH. PATH="$(printf '%s' "$tmpPATH" \ | nawk '{ np=split($0, p, ":"); for (n = 1; n <= np; n++) { From 542a69909114c6920ae049b538c3420f8182779a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 29 Mar 2024 10:53:58 -0300 Subject: [PATCH 057/128] feat: realpath()'d $d This may be useful in case of some new FHS ideas being applied and "." being used in the PATH. --- build-system/tasks/check_dependencies.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh index 7b45662..538dd79 100644 --- a/build-system/tasks/check_dependencies.ksh +++ b/build-system/tasks/check_dependencies.ksh @@ -73,7 +73,7 @@ function check_dependencies { if [[ ! -e "$tar_cmd" || "$d" == "${tarpath%/*}" ]]; then continue elif ($tar_cmd --help 2>&1| egrep 'star|bsdtar|GNU' 2>&1 >/dev/null); then - new_tarpath="$d" + new_tarpath="$(realpath $d)" tmpPATH="$new_tarpath:$PATH" # This big chunk of code works as a 'uniq' # for the PATH variable because, since From a20dd3a68c94a71f50f1f11850f5b6eb8e56ab28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 28 Jul 2024 01:41:07 -0300 Subject: [PATCH 058/128] feat!: Start refactoring the build system. --- build-system/internals/helpers/disks.shi | 45 ++ build-system/internals/helpers/helpers.shi | 193 -------- .../helpers/helpers_euvouenloquecer.shi | 420 ++++++++++++++++++ build-system/internals/helpers/makier.ksh | 11 + build-system/internals/helpers/rconfig.shi | 200 +++++++++ build-system/tasks/check_dependencies.ksh | 225 ---------- build-system/tasks/checks/dependencies.ksh | 222 +++++++++ .../platform.ksh} | 0 build-system/tasks/disk/create_disk.ksh | 147 ++++++ build-system/tasks/disk/populate.ksh | 57 +++ build-system/tasks/disk_managenment.ksh | 250 ----------- build-system/tasks/finish.ksh | 12 +- .../{get_source-code.ksh => get_sources.ksh} | 28 +- build-system/work.ini | 5 +- build.ksh | 38 +- cmd/populate_fhs.sh | 6 +- docs/build-system/machine.md | 117 +++++ packages | 2 +- version | 1 + 19 files changed, 1264 insertions(+), 715 deletions(-) create mode 100644 build-system/internals/helpers/disks.shi create mode 100644 build-system/internals/helpers/helpers_euvouenloquecer.shi create mode 100644 build-system/internals/helpers/makier.ksh create mode 100644 build-system/internals/helpers/rconfig.shi delete mode 100644 build-system/tasks/check_dependencies.ksh create mode 100644 build-system/tasks/checks/dependencies.ksh rename build-system/tasks/{platform_checks.ksh => checks/platform.ksh} (100%) create mode 100644 build-system/tasks/disk/create_disk.ksh create mode 100644 build-system/tasks/disk/populate.ksh rename build-system/tasks/{get_source-code.ksh => get_sources.ksh} (55%) create mode 100644 docs/build-system/machine.md create mode 100644 version diff --git a/build-system/internals/helpers/disks.shi b/build-system/internals/helpers/disks.shi new file mode 100644 index 0000000..9ba8f85 --- /dev/null +++ b/build-system/internals/helpers/disks.shi @@ -0,0 +1,45 @@ +# vim: set filetype=sh : + +# May use this function later, no use for it for now. +function get_size_blocks { + typeset -a disk_size[2] + disk_block="$1" + + # The minimum size for a block is 512KiB, not less. + # This identifier may sound a little bit erred. + readonly blocks_per_kib=512 + + disk_size=( $(elevate fdisk -x "$disk_block" \ + | sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q') ) + + size=${disk_size[0]} + sizeunit=${disk_size[1]} + unset disk_size + + case $sizeunit in + 'TiB') ((blocks= size * (blocks_per_kib * 4194304) )) ;; + 'GiB') ((blocks= size * (blocks_per_kib * 4096) )) ;; + 'MiB') ((blocks= size * (blocks_per_kib * 4) )) ;; + 'KiB') ((blocks= size / blocks_per_kib )) ;; + esac + unset size sizeunit + + printf '%d' $blocks + + return 0 +} + +# This checks for valid file systems on +# which Copacabana builds are made and +# tested. +function check_linuxfs { + fs=$1 + err=0 + + case $fs in + btrfs|ext4) break ;; + default) err=1; break ;; + esac + + return $err +} diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 8900301..5ab3eae 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -12,199 +12,6 @@ # Make everyone aware we're running from BUILD_KSH. export readonly BUILD_KSH=true -# Reads INI configuration files, now a boilerplate function -# to dotini/inicompat --- and, in case of using -# GNU's Broken-Again Shell, it does a coarse conversion of -# the INI file to a simple Shell-based configuration file -# format. -function rconfig { - file="$1" - - if [[ -z $BASH && -n $KSH_VERSION ]]; then - # Load the .ini configuration file as - # a compound variable to the memory. - # Simple as that. - eval conf=$(dotini "$file") - inicompat conf - elif [[ -n $BASH ]]; then # BASH - cat "$1" | \ - for (( ;; )); do - if read line; then - if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] \ - || [[ "$line" =~ '^[#;].*$' ]]; then - continue - else - keyval="$(printf '%s' "$line" \ - | sed 's/^\(.*\)[#;].*/\1/;')" - identifier="${keyval%%=*}" - value="${keyval##*=}" - [[ "$keyval" =~ ^$ ]] && continue - eval $(printf '%s='\''%s'\''' $identifier "$value") - fi - else - break - fi - done - fi -} - -# This function parses .INI files into a compound variable that can be used -# inside the script via eval. -# For example: -# -# eval private_config=$(dotini conf.ini) -# Then you could just access like so: -# printf '%s\n' "${private_config[SectName][KeyName]}" -# It does not outsource record() or map(), so there's more independence and -# flexibility on choosing identifiers for your INI file configuration. -# -# FIXME: When I got time --- or someone else that knows at least a bit of -# KornShell shows up ---, this parser needs to be fixed to support INI files -# that don't explicitly declare a section. -# Sure thing that second-rate hacks such as creating a default section called -# "global" were already thought of, so the ideal is to have just what is being -# described in the code. -# I could fix this in some hours, but I'm willing to work more on the rest of -# the build system instead of just some isolate functions that are already -# compliant with its needs. -# -# FIXME: Also it would be helpful to support files that use spaces between the -# identifier and value, for example: -# -# [sectname] -# keyname = value -# keyname_2 = "Another value" -# -# Being optimistic and careless about using shell built-ins (read as "read") -# instead of manipulating the string utilizing just KornShell's repetition -# control structures, this could be done just like it was done before at the -# old rconfig() function. -function dotini { - file="$1" - - # The function shall fail before "allocating" anything in memory. - # This may sound like a worry that a C programmer might have, but it's - # just a formality when the topic are ksh-ish languages such as - # GNU's Bash or even ksh93 itself. - if [[ ! -e "$file" ]]; then - panic '%s: file %s does not exist.\n' $0 "$file" - fi - - # Allocate an array for recording the file and declarate a - # integer that represents the number of the line. - typeset -a inibuf confline[2] - integer nl l s nconf - - # First of all, we shall remove comments. - # I know this could be done manually using a for-loop, but I think sed - # can be more reliable. - (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ - for ((nl=0 ;; nl++)); do - if read line; then - inibuf[$nl]="$line" - else - break - fi - done - - # Open compound variable syntax - printf '%c' '(' - for ((l=0; l < ${#inibuf[@]}; l++)); do - line="${inibuf[l]}" - - # This gets the INI section. - if section_title="$(rematch "$line" '\[\(.*\)\]')"; then - # The formatted section title. - formatted_section="$(printf '%s' "$section_title" \ - | nawk '{ gsub(" ", "_"); print(tolower($0)) }')" - # We can procceed to the next line. - continue - fi - - nconf=0 - for ((s=0; s < ${#line}; s++ )); do - q="${line:s:1}" - # A value declaration in INI follows the format: - # identifier = "value" - # Or - # identifier=value - # confline[1]=identifier - # confline[2]=value - - if [[ "$q" == '=' ]]; then - ((nconf+= 1 )) - continue - fi - - confline[$nconf]+="$q" - done - - # If there is not a section, it will only declare the INI - # variable and its value on the compound variable. - if [[ ! -n $formatted_section ]]; then - # Using a apostrophe instead of quotations marks - # because, apart from the fact that it works as a - # micro-optimization --- since the shell will be - # treating its contents as vulgar strings instead of - # trying to interpret what is inside them ---, also - # prevents globbing of strings. - # The only thing that it doesn't prevents, - # unfortunately, is the abuse of subshells or malicious - # substitutions, but I do not think this can be a - # problem here. - printf '%s='\''%s'\'' ' \ - "${confline[0]}" "${confline[1]}" - - # Continue to the next line. - continue - fi - - # If it there's a section and the value declaration was already - # parsed, return it as a associative array declaration. - printf '[%s]+=([%s]='\''%s'\'') ' \ - $formatted_section "${confline[0]}" "${confline[1]}" - - # Clean confline[] array. - unset confline[0] confline[1] - done - - # Close compound variable - printf '%c' ')' -} - -# This function "converts" a compound variable generated from a .ini file via -# dotini() to the format "IDENTIFIER=VALUE". -# It can be useful if the program had just implemented .ini files as a way of -# configuration and developers doesn't want to mess with the entire source code. -# It takes the compound variable identifier as a input, for example: -# -# inicompat conf -# -# NOTE: See dotini()'s first "FIXME" and then implement a way to do it. -function inicompat { - nameref inirecord=$1 - integer s k - typeset -a sections - - sections=( ${!inirecord[@]} ) - - for ((s=0; s<${#sections[@]}; s++ )); do - typeset -a confkeys - - section=${sections[s]} - confkeys=( ${!inirecord[$section][@]} ) - - for (( k=0; k < ${#confkeys[@]}; k++ )); do - confkey=${confkeys[$k]} - confval="${inirecord[$section][$confkey]}" - - eval $(printf '%s=%s' $confkey "$confval") - unset confkey confval - done - unset section confkeys confkey confval - done -} - # This function writes everything in a program output to a file passed as a # parameter, else it also writes it to the standard output using tee(1). # Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. diff --git a/build-system/internals/helpers/helpers_euvouenloquecer.shi b/build-system/internals/helpers/helpers_euvouenloquecer.shi new file mode 100644 index 0000000..4322836 --- /dev/null +++ b/build-system/internals/helpers/helpers_euvouenloquecer.shi @@ -0,0 +1,420 @@ +# vim: set filetype=sh : +# Internal helper library for the Copacabana build system. +# Meant to be used with Korn Shell 93. +# Copyright (c) 2023 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA +# +# "'Liberdade, Igualdade, Fraternidade', +# é o seguinte: se tem Liberdade, tem que +# ter Igualdade, Amor e Fraternidade [...]" + +# Make everyone aware we're running from BUILD_KSH. +export readonly BUILD_KSH=true + +# Reads INI configuration files, now a boilerplate function +# to dotini/inicompat --- and, in case of using +# GNU's Broken-Again Shell, it does a coarse conversion of +# the INI file to a simple Shell-based configuration file +# format. +function rconfig { + file="$1" + + if [[ -z $BASH && -n $KSH_VERSION ]]; then + # Load the .ini configuration file as + # a compound variable to the memory. + # Simple as that. + eval conf=$(dotini "$file") + inicompat conf + elif [[ -n $BASH ]]; then # BASH + cat "$1" | \ + for (( ;; )); do + if read line; then + if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] \ + || [[ "$line" =~ '^[#;].*$' ]]; then + continue + else + keyval="$(printf '%s' "$line" \ + | sed 's/^\(.*\)[#;].*/\1/;')" + identifier="${keyval%%=*}" + value="${keyval##*=}" + [[ "$keyval" =~ ^$ ]] && continue + eval $(printf '%s='\''%s'\''' $identifier "$value") + fi + else + break + fi + done + fi +} + +# This function parses .INI files into a compound variable that can be used +# inside the script via eval. +# For example: +# +# eval private_config=$(dotini conf.ini) +# Then you could just access like so: +# printf '%s\n' "${private_config[SectName][KeyName]}" +# It does not outsource record() or map(), so there's more independence and +# flexibility on choosing identifiers for your INI file configuration. +# +# FIXME: When I got time --- or someone else that knows at least a bit of +# KornShell shows up ---, this parser needs to be fixed to support INI files +# that don't explicitly declare a section. +# Sure thing that second-rate hacks such as creating a default section called +# "global" were already thought of, so the ideal is to have just what is being +# described in the code. +# I could fix this in some hours, but I'm willing to work more on the rest of +# the build system instead of just some isolate functions that are already +# compliant with its needs. +# +# FIXME: Also it would be helpful to support files that use spaces between the +# identifier and value, for example: +# +# [sectname] +# keyname = value +# keyname_2 = "Another value" +# +# Being optimistic and careless about using shell built-ins (read as "read") +# instead of manipulating the string utilizing just KornShell's repetition +# control structures, this could be done just like it was done before at the +# old rconfig() function. +function dotini { + file="$1" + + # The function shall fail before "allocating" anything in memory. + # This may sound like a worry that a C programmer might have, but it's + # just a formality when the topic are ksh-ish languages such as + # GNU's Bash or even ksh93 itself. + if [[ ! -e "$file" ]]; then + panic '%s: file %s does not exist.\n' $0 "$file" + fi + + # Allocate an array for recording the file and declarate a + # integer that represents the number of the line. + typeset -a inibuf confline[2] + integer nl l s nconf + + # First of all, we shall remove comments. + # I know this could be done manually using a for-loop, but I think sed + # can be more reliable. + (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ + for ((nl=0 ;; nl++)); do + if read line; then + inibuf[$nl]="$line" + else + break + fi + done + + # Open compound variable syntax + printf '%c' '(' + for ((l=0; l < ${#inibuf[@]}; l++)); do + line="${inibuf[l]}" + + # This gets the INI section. + if section_title="$(rematch "$line" '\[\(.*\)\]')"; then + # The formatted section title. + formatted_section="$(printf '%s' "$section_title" \ + | nawk '{ gsub(" ", "_"); print(tolower($0)) }')" + # We can procceed to the next line. + continue + fi + + nconf=0 + for ((s=0; s < ${#line}; s++ )); do + q="${line:s:1}" + # A value declaration in INI follows the format: + # identifier = "value" + # Or + # identifier=value + # confline[1]=identifier + # confline[2]=value + + if [[ "$q" == '=' ]]; then + ((nconf+= 1 )) + continue + fi + + confline[$nconf]+="$q" + done + + # If there is not a section, it will only declare the INI + # variable and its value on the compound variable. + if [[ ! -n $formatted_section ]]; then + # Using a apostrophe instead of quotations marks + # because, apart from the fact that it works as a + # micro-optimization --- since the shell will be + # treating its contents as vulgar strings instead of + # trying to interpret what is inside them ---, also + # prevents globbing of strings. + # The only thing that it doesn't prevents, + # unfortunately, is the abuse of subshells or malicious + # substitutions, but I do not think this can be a + # problem here. + printf '%s='\''%s'\'' ' \ + "${confline[0]}" "${confline[1]}" + + # Continue to the next line. + continue + fi + + # If it there's a section and the value declaration was already + # parsed, return it as a associative array declaration. + printf '[%s]+=([%s]='\''%s'\'') ' \ + $formatted_section "${confline[0]}" "${confline[1]}" + + # Clean confline[] array. + unset confline[0] confline[1] + done + + # Close compound variable + printf '%c' ')' +} + +# This function "converts" a compound variable generated from a .ini file via +# dotini() to the format "IDENTIFIER=VALUE". +# It can be useful if the program had just implemented .ini files as a way of +# configuration and developers doesn't want to mess with the entire source code. +# It takes the compound variable identifier as a input, for example: +# +# inicompat conf +# +# NOTE: See dotini()'s first "FIXME" and then implement a way to do it. +function inicompat { + nameref inirecord=$1 + integer s k + typeset -a sections + + sections=( ${!inirecord[@]} ) + + for ((s=0; s<${#sections[@]}; s++ )); do + typeset -a confkeys + + section=${sections[s]} + confkeys=( ${!inirecord[$section][@]} ) + + for (( k=0; k < ${#confkeys[@]}; k++ )); do + confkey=${confkeys[$k]} + confval="${inirecord[$section][$confkey]}" + + eval $(printf '%s=%s' $confkey "$confval") + unset confkey confval + done + unset section confkeys confkey confval + done +} + +# This function writes everything in a program output to a file passed as a +# parameter, else it also writes it to the standard output using tee(1). +# Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. +function logto { + file="$1" + # Do not be scared, just a boolean having a rendezvous with a + # more compact alternative to if-else statements. + c29waGlhZmljYWNvbWlnbwo=$I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR + { $c29waGlhZmljYWNvbWlnbwo && tee "$file"; } \ + || { cat - >> "$file"; } +} + +# map() and record() functions below. +# For the "back-end" implementation, see __record(), +# with the old Bourne/POSIX shell function prototype. +# +# map(): Creates an associative array with identifier, +# variable name and value as its parameters. +# It's really similar to the code found on herbiec in +# this sense, but it was originally used as a "pointeroid" +# for accessing an A.S.T. +function map { + identifier="$1" + variable="$2" + value="$3" + + eval $(__record "$identifier" "$variable" "$value") +} + +# record(): And this creates a compound variable, which +# approachs more a Pascal record than the "old" record() +# --- that was renamed to "map" (as-in Google Go's maps, +# but weakly typed). +function record { + identifier="$1" + variable="$2" + value="$3" + + # Broken-Again Shell, unlike KornShell, can not get + # a function caller by $0, so we will need to + # pre-define whos_calling. + # Doing it specifically on record() because compound + # variables are not supported on Bash. + if [[ -n $BASH ]]; then + export whos_calling=$FUNCNAME + fi + + eval $(__record "$identifier" "$variable" "$value") +} + +# Using the good old Bourne function prototype because it permits that the +# function caller name "escapes" into it. +# This is broken in GNU's Broken-Again Shell --- well, maybe I'm repeating +# this joke too many times, but Bash lives up to its nickname --- but this +# is no problem for now since Bash doesn't support compound variables, +# just associative arrays, so both "map" and "record" can be the same to Bash. +__record() { + # If we are not on Broken-Again, define 'whos_calling'. + if [[ -z $BASH ]]; then + # "London calling to the faraway towns... + # But it wasn't my love... + # Is she still upset with me?" + whos_calling="$0" + fi + identifier="$1" + variable="$2" + value="$3" + + if [[ -z "$BASH" ]]; then # This is for KornShell 93 + # The only thing that changes between record() and map() is the printf + # format before evaluating it into the script. + if [[ "$whos_calling" == 'record' ]]; then + format='%s+=(%s="%s")' + elif [[ "$whos_calling" == 'map' ]]; then + format='%s+=([%s]="%s")' + else + panic '%s: invalid caller '%s'.\n' \ + 'record()/map() backend' "$whos_calling" + fi + else # Broken-Again + if [[ "$whos_calling" == 'record' ]]; then + unset whos_calling + panic \ + '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. "record()".\n' \ + 'record()/map() backend' + fi + format='%s+=(['%s']="%s")' + fi + + if [[ -n "$BASH" ]]; then + printf 'declare -A %s\n' "$identifier" + fi + + # Hope this works. + printf "$format" "$identifier" "$variable" "$value" +} + +# Luiz' stupid (re)match. +# It's my attempt on mimicking BASH_REMATCH functionality +# on pretty much any shell. Made it for using on dotini(), +# but pretty much anyone can adapt this. +function rematch { + # Input string. + s="$1" + + # Regular expression "rule", as a filter. + re="$2" + + # If $re is empty, just exit without questions. + [[ ! -n "$re" ]] && return 0 + + # This gets rid of the capture group syntax that we will be using again + # on sed. egrep(1) could also be used, but I opted for shell built-ins + # since we're already on Korn Shell. + [[ "$s" =~ $(printf '%s' "$re" | sed 's/\\(//; s/\\)//') ]] || return 1 + + printf '%s' "$s" | sed "s/$re/\1/" +} + +# Checks if a function or a variable is defined via its identifier. Analogous +# on purpose to the C preprocessor special operator defined(), meant for being +# used in if conditions. +function defined { + # First it will check if it's a function defined on the environment and/or in + # a sourced file, if it's not, then it will check if it is a variable. + { + type -t "$1" | grep 'function' 2>&1 > /dev/null \ + || test ! -z "$(eval "echo \$$1")" + } \ + || return 1 +} + +# Multiple file input support for realpath(1) +# Basically a boilerplate. +function realpaths { + files=( ${@} ) + for (( count=0; count < ${#files[@]}; count++ )); do + realpath "${files[$count]}" + done + unset count files +} + +# Boilerplate to "cd" +function chdir { cd "$1"; } + +# Just a wrapper to a decompressor such as gzip, xz, bzip2 etc. +# Derived from copy2prefix() at https://git.io/mitzune +function c { + tarball="$2" + # First, cut the absolute path off + tarball_ext="${tarball##*/}" + # Then, the filename itself, + # we just want the extension. + tarball_ext="${tarball_ext##*.}" + case "$tarball_ext" in + gz|tgz) { gzip "$@"; } ;; + xz|txz) { xz "$@"; } ;; + bz2|tbz) { bzip2 "$@"; } ;; + tar) { shift; cat "$@"; } ;; + *) printerr "$0: File format not recognized." ;; + esac +} + +# This "generates" wrappers for elevating permissions when needed. +# Be careful. +# Derived from check_doas() at https://git.io/mitzune +function check_elevate_method { + # Clever way to get UID without having to use id(1) or $UID itself. + # Check if UID is defined; small fix for using GNU Broken-Again Shell + # instead of Korn Shell 93, since $UID is read-only on GNU's Shell. + # We'll be making it public because many scripts will use it later. + # Using export directly on variable declaration since it would require to + # use another comparison for knowing if UID is available if we export just + # at the end. + [[ -z $UID ]] && export UID="$(grep $(whoami) /etc/passwd | cut -d: -f3)" + + # Cache the user name from whoami(1) and, unlike $USER, made it read-only + # to prevent manipulation from overwriting. + readonly user="$(whoami)" + + if $(grep "$user" /etc/doas.conf &>/dev/null); then + function elevate { doas -- "$@"; } + typeset -fx elevate + elif $(sudo -v 2>/dev/null); then + function elevate { sudo -- "$@"; } + typeset -fx elevate + elif [[ $UID == 0 ]]; then + printerr 'Warning: running as root. This isn'\''t recommended.\n' + elif $(groups $user | grep 'wheel' >/dev/null); then + printerr \ + 'Warning: %s can log directly as root, although using sudo/doas is preferable.\n' \ + "$user" + function elevate { su -c "$@"; } + typeset -fx elevate + else + printerr 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' + exit 10 + fi + + export user +} + +# Use this function both for errors and warnings +function printerr { + printf "$@" 1>&2 +} + +# And use this for fatal errors, it will exit the script. +function panic { + msgbuf="$(printf "$@")" + printf 1>&2 'panic: %s' "$msgbuf" + exit 255 +} diff --git a/build-system/internals/helpers/makier.ksh b/build-system/internals/helpers/makier.ksh new file mode 100644 index 0000000..bb5a54a --- /dev/null +++ b/build-system/internals/helpers/makier.ksh @@ -0,0 +1,11 @@ +# Boilerplate for running tasks. + +_make(){ + td='build-system/tasks' + lang='.ksh' + pd="$progdir" + tak="$1" + + shift # Remove '$1' + . "$(printf '%s/%s/%s.%s' "$pd" "$td" "$tak" "$lang")" "${@:-''}" +} diff --git a/build-system/internals/helpers/rconfig.shi b/build-system/internals/helpers/rconfig.shi new file mode 100644 index 0000000..8d5bd13 --- /dev/null +++ b/build-system/internals/helpers/rconfig.shi @@ -0,0 +1,200 @@ +# vim: set filetype=sh : +# Internal library for reading INI/key-value configuration +# files in the Copacabana build system. +# Meant to be used with Korn Shell 93. +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA + +# Reads INI configuration files, now a boilerplate function +# to dotini/inicompat --- and, in case of using +# GNU's Broken-Again Shell, it does a coarse conversion of +# the INI file to a simple Shell-based configuration file +# format. +function rconfig { + file="$1" + + if [[ -z $BASH && -n $KSH_VERSION ]]; then + # Load the .ini configuration file as + # a compound variable to the memory. + # Simple as that. + eval conf=$(dotini "$file") + inicompat conf + elif [[ -n $BASH ]]; then # BASH + cat "$1" | \ + for (( ;; )); do + if read line; then + if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] \ + || [[ "$line" =~ '^[#;].*$' ]]; then + continue + else + keyval="$(printf '%s' "$line" \ + | sed 's/^\(.*\)[#;].*/\1/;')" + identifier="${keyval%%=*}" + value="${keyval##*=}" + [[ "$keyval" =~ ^$ ]] && continue + eval $(printf '%s='\''%s'\''' $identifier "$value") + fi + else + break + fi + done + fi +} + +# This function parses .INI files into a compound variable that can be used +# inside the script via eval. +# For example: +# +# eval private_config=$(dotini conf.ini) +# Then you could just access like so: +# printf '%s\n' "${private_config[SectName][KeyName]}" +# It does not outsource record() or map(), so there's more independence and +# flexibility on choosing identifiers for your INI file configuration. +# +# FIXME: When I got time --- or someone else that knows at least a bit of +# KornShell shows up ---, this parser needs to be fixed to support INI files +# that don't explicitly declare a section. +# Sure thing that second-rate hacks such as creating a default section called +# "global" were already thought of, so the ideal is to have just what is being +# described in the code. +# I could fix this in some hours, but I'm willing to work more on the rest of +# the build system instead of just some isolate functions that are already +# compliant with its needs. +# +# FIXME: Also it would be helpful to support files that use spaces between the +# identifier and value, for example: +# +# [sectname] +# keyname = value +# keyname_2 = "Another value" +# +# Being optimistic and careless about using shell built-ins (read as "read") +# instead of manipulating the string utilizing just KornShell's repetition +# control structures, this could be done just like it was done before at the +# old rconfig() function. +function dotini { + file="$1" + + # The function shall fail before "allocating" anything in memory. + # This may sound like a worry that a C programmer might have, but it's + # just a formality when the topic are ksh-ish languages such as + # GNU's Bash or even ksh93 itself. + if [[ ! -e "$file" ]]; then + panic '%s: file %s does not exist.\n' $0 "$file" + fi + + # Allocate an array for recording the file and declarate a + # integer that represents the number of the line. + typeset -a inibuf confline[2] + integer nl l s nconf + + # First of all, we shall remove comments. + # I know this could be done manually using a for-loop, but I think sed + # can be more reliable. + (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ + for ((nl=0 ;; nl++)); do + if read line; then + inibuf[$nl]="$line" + else + break + fi + done + + # Open compound variable syntax + printf '%c' '(' + for ((l=0; l < ${#inibuf[@]}; l++)); do + line="${inibuf[l]}" + + # This gets the INI section. + if section_title="$(rematch "$line" '\[\(.*\)\]')"; then + # The formatted section title. + formatted_section="$(printf '%s' "$section_title" \ + | nawk '{ gsub(" ", "_"); print(tolower($0)) }')" + # We can procceed to the next line. + continue + fi + + nconf=0 + for ((s=0; s < ${#line}; s++ )); do + q="${line:s:1}" + # A value declaration in INI follows the format: + # identifier = "value" + # Or + # identifier=value + # confline[1]=identifier + # confline[2]=value + + if [[ "$q" == '=' ]]; then + ((nconf+= 1 )) + continue + fi + + confline[$nconf]+="$q" + done + + # If there is not a section, it will only declare the INI + # variable and its value on the compound variable. + if [[ ! -n $formatted_section ]]; then + # Using a apostrophe instead of quotations marks + # because, apart from the fact that it works as a + # micro-optimization --- since the shell will be + # treating its contents as vulgar strings instead of + # trying to interpret what is inside them ---, also + # prevents globbing of strings. + # The only thing that it doesn't prevents, + # unfortunately, is the abuse of subshells or malicious + # substitutions, but I do not think this can be a + # problem here. + printf '%s='\''%s'\'' ' \ + "${confline[0]}" "${confline[1]}" + + # Continue to the next line. + continue + fi + + # If it there's a section and the value declaration was already + # parsed, return it as a associative array declaration. + printf '[%s]+=([%s]='\''%s'\'') ' \ + $formatted_section "${confline[0]}" "${confline[1]}" + + # Clean confline[] array. + unset confline[0] confline[1] + done + + # Close compound variable + printf '%c' ')' +} + +# This function "converts" a compound variable generated from a .ini file via +# dotini() to the format "IDENTIFIER=VALUE". +# It can be useful if the program had just implemented .ini files as a way of +# configuration and developers doesn't want to mess with the entire source code. +# It takes the compound variable identifier as a input, for example: +# +# inicompat conf +# +# NOTE: See dotini()'s first "FIXME" and then implement a way to do it. +function inicompat { + nameref inirecord=$1 + integer s k + typeset -a sections + + sections=( ${!inirecord[@]} ) + + for ((s=0; s<${#sections[@]}; s++ )); do + typeset -a confkeys + + section=${sections[s]} + confkeys=( ${!inirecord[$section][@]} ) + + for (( k=0; k < ${#confkeys[@]}; k++ )); do + confkey=${confkeys[$k]} + confval="${inirecord[$section][$confkey]}" + + eval $(printf '%s=%s' $confkey "$confval") + unset confkey confval + done + unset section confkeys confkey confval + done +} diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh deleted file mode 100644 index 2458c6b..0000000 --- a/build-system/tasks/check_dependencies.ksh +++ /dev/null @@ -1,225 +0,0 @@ -# This task script is part of Copacabana's build system. -# -# Copyright (c) 2023-2024: Pindorama -# SPDX-Licence-Identifier: NCSA -# C and C++ sanity checks by Samuel (callsamu), Lucas (volatusveritas) -# and Luiz Antônio Rangel (takusuman) - -# STEP 0: Resources, part II -# This file is part of the "step 0" of building Copacabana, it is one of the -# tools that's being used for checking resources on the machine. In this case, -# differently from the platform_checks, it contains a function for checking if -# all the dependencies needed for building Copacabana are present. -# It looks awful, I apologize. - -function check_dependencies { - # The place were sanity tests will be placed - ksh_sanity_test="$trash/sanity.ksh" - c_sanity_test="$trash/sanity.c" - cxx_sanity_test="$trash/sanity.cxx" - archiver_sanity="$trash/archiver_sanity" - - # Internal helper scripts (at cmd/) - internal_scripts=( 'cmd/download_sources.ksh' 'cmd/populate_fhs.sh' \ - 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh' ) - - # GNU auto*conf commands - GNUAutoconf_commands=( 'aclocal' 'automake' 'autoconf' 'autoscan' \ - 'autoreconf' 'ifnames' 'autoheader' 'autom4te' 'autoupdate' \ - 'libtool' 'libtoolize' ) - - # GNU Binutils commands - GNUBinutils_commands=( 'addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' \ - 'gprof' ld{,.bfd} 'nm' 'objcopy' 'objdump' 'ranlib' 'readelf' \ - 'size' 'strings' 'strip' ) - - # General commands - general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'patch' \ - 'find' 'grep' 'lemount' 'm4' 'mitzune' \ - ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) - - # General compressing tools - archivers=('tar' 'bzip2' 'gzip' 'xz') - - # Check for aria2c - if $USE_ARIA2C; then - general_commands[1]='aria2c' - fi - - for (( g=0; g < $(n ${general_commands[@]}); g++ )); do - printerr 'Searching for %s at PATH (%s)... ' \ - "${general_commands[$g]}" "$PATH" - type -p "${general_commands[$g]}" \ - || { printerr 'Not found.\n'; return 1; } - done - - for (( h=0; h < $(n ${archivers[@]}); h++ )); do - printerr 'Does %s work for what we want? ' "${archivers[$h]}" - if [ "${archivers[$h]}" == 'tar' ]; then # TAR-specific tests - if [[ "$(readlink -f "$(type -p tar)")" =~ (star) ]] \ - || $(tar -h 2>&1| grep 'star' 2>&1 >/dev/null); then - printerr '\nI'\''m almost certain that %s is Schily tar...\n' \ - "$(type -p tar)" - printerr \ - 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' - printerr \ - 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).\n' - function tar { - "$(type -p tar)" "$@" \ - --no-secure-links --artype=xustar - } - typeset -xf tar - fi - - { - ( mkdir -p "$archiver_sanity"{,_results} - cd "$archiver_sanity" - > vulgar_file - mkfifo pipe_test - ln -sf "$(readlink -f "$archiver_sanity")" potentially_unsafe_link - ln -f vulgar_file hard_link - # We already expect an error/warning - ln -f not_a_vulgar_file broken_link 2>/dev/null - ) - ( cd "$archiver_sanity" - tar -cf - . ) | tar -xf - -C "${archiver_sanity}_results" - } && rm -rf "${archiver_sanity}_results" - else # Bzip2, Gzip or Xz tests - for (( l=1; l <= 9; l++ )); do - printerr 'With compression level %s? ' $l - - # Test the alphabet string can be compressed - # without being corrupted, then, do a more - # "difficult" test using the main build.ksh - # script file. - { printf '%s' {a..z} | "${archivers[$h]}" -"$l" -cf \ - | "${archivers[$h]}" -dcf | wc -m | tr -d '[:space:]' \ - | test `cat` -eq 26 ; } \ - && { cat "$progdir/$progname" | "${archivers[$h]}" -"$l" -cf \ - | "${archivers[$h]}" -dcf \ - | cmp - "$progdir/$progname"; } - printerr 'Ok...\n' - done - fi - printerr 'Sounds like a yes.\n' - done - - for (( i=0; i < $(n ${utils[@]}); i++ )); do - printerr 'Is %s present on this system? ' "${utils[$i]}" - command -v ${utils[$i]} 2>&1 > /dev/null && printerr 'Sounds like a yes.\n' \ - || { printerr '%s not found.\n' ${utils[$i]}; return 1; } - done - - for (( k=0; k < $(n ${internal_scripts[@]}); k++ )); do - printerr 'Searching for independent script %s at %s... ' \ - "${internal_scripts[$k]}" "$progdir" - if [ -e "$progdir/${internal_scripts[$k]}" ] \ - && [ ! -z "$(cat "$progdir/${internal_scripts[$k]}")" ]; then - printerr 'Found!\n' - else - printerr '%s not found...\n' - printerr 'It seems like your Copacabana repository clone is incomplete.\n' - return 1 - fi - done - -# Programming language interpreters/compilers sanity checks. - -run_shell="$(readlink -f /proc/$$/exe)" -printerr 'Does the running shell (%s) work for what we need?\n' "$run_shell" - -# Not caching "$(readlink -f /proc/$$/exe)" via $run_shell on the sanity test, -# since we expect it to run as a new process, so as a new P.ID. and as a new -# "folder" at /proc, explaining in a extremely simplistic way. - -cat > "$ksh_sanity_test" << 'EO_KSHSANITY' -#!/usr/bin/env ksh -interpreter="$(readlink -f /proc/$$/exe)" - -if [[ "$interpreter" =~ (ksh|ksh93) ]]; then - print -f \ - 'It seems like %s is Korn Shell 93, but let me test it... ' \ - "$interpreter" 1>&2 - if (PATH=.; alias -x) && [ -z $BASH ] && [ -n ${.sh.version} ]; then - print -f 'Well, it is, time to move on.\n' 1>&1 - fi -elif [[ "$interpreter" =~ (bash) && -n $BASH ]]; then - printf 'It seems like %s is GNU Broken-Again Shell. -Anyway, this script is designed to work with it. Move on.\n' \ - "$interpreter" 1>&2 -else - printf '%s is unsupported. Oddly, it passed the platform checks, but not these small sanity tests. -Please, report this at https://github.com/Projeto-Pindorama/copacabana.\n' "$interpreter" - return 1 -fi -EO_KSHSANITY -"$run_shell" "$ksh_sanity_test" - -printerr 'Does the C/C++ compiler work for what we need?\n' - -cat > "$c_sanity_test" << 'EO_CSANITY' -#include - -#if defined(__GNUC__) || defined(__clang__) -#define RETURN 0 -#else -#define RETURN 1 -#endif - -int main(void) { - if (! RETURN) { - puts("Great! We're on a supported C compiler (GCC or LLVM)."); - } else { - puts("Not on a supported compiler."); - } - return RETURN; -} -EO_CSANITY - -cat > "$cxx_sanity_test" << 'EO_C++SANITY' -#include -using std::cout; - -#if defined(__GNUG__) || defined(__clang__) -#define RETURN 0 -#else -#define RETURN 1 -#endif - -int main(void) { - if (! RETURN) { - std::cout << "Great! We're on a supported C++ compiler (GCC or LLVM)." << std::endl; - } else { - std::cout << "Not on a supported compiler." << std::endl; - } - return RETURN; -} -EO_C++SANITY - -{ "$CC" -o"$trash/c_sanity" "$c_sanity_test"; "$trash/c_sanity" \ - && "$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test" && "$trash/cxx_sanity"; } \ - || exit $? - -printerr 'Info: Generating our cross-compiling host based on this machine'\''s type...\n' -printerr 'Does this system have GNU Broken-Again Shell for $MACHTYPE or we'\''ll be depending on %s? ' \ - "$CC" -if ! type -p bash 2>&1 > /dev/null; then - printerr 'Nah, it'\''s clean.\n' - has_bash=false -else - printerr 'It does, we'\''re going with it.\n' - has_bash=true -fi - -COPA_HOST="$( ( ($has_bash && bash -c 'echo $MACHTYPE') \ - || (gcc -v 2>&1 | nawk '/Target/{ sub(/.*Target:/, "", $0); printf("%s", $1); }') ) \ - | nawk '{ split($0, host, "-"); sub(host[2], "crossCOPACABANA", $0); printf("%s\n", $0); }')" -unset has_bash - -printerr 'Info: COPA_HOST will be "%s".\n' "$COPA_HOST" - -# Exporting our running Shell for using later in other tasks and also the -# $COPA_HOST, that will be used when building the cross-compiler. -export run_shell COPA_HOST - -} diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh new file mode 100644 index 0000000..d35f838 --- /dev/null +++ b/build-system/tasks/checks/dependencies.ksh @@ -0,0 +1,222 @@ +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023-2024: Pindorama +# SPDX-Licence-Identifier: NCSA +# C and C++ sanity checks by Samuel (callsamu), Lucas (volatusveritas) +# and Luiz Antônio Rangel (takusuman) + +# STEP 0: Resources, part II +# This file is part of the "step 0" of building Copacabana, it is one of the +# tools that's being used for checking resources on the machine. In this case, +# differently from the platform_checks, it contains a function for checking if +# all the dependencies needed for building Copacabana are present. +# It looks awful, I apologize. + +# The place were sanity tests will be placed +ksh_sanity_test="$trash/sanity.ksh" +c_sanity_test="$trash/sanity.c" +cxx_sanity_test="$trash/sanity.cxx" +archiver_sanity="$trash/archiver_sanity" + +# Internal helper scripts (at cmd/) +internal_scripts=( 'cmd/download_sources.ksh' 'cmd/populate_fhs.sh' \ + 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh' ) + +# GNU auto*conf commands +GNUAutoconf_commands=( 'aclocal' 'automake' 'autoconf' 'autoscan' \ + 'autoreconf' 'ifnames' 'autoheader' 'autom4te' 'autoupdate' \ + 'libtool' 'libtoolize' ) + +# GNU Binutils commands +GNUBinutils_commands=( 'addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' \ + 'gprof' ld{,.bfd} 'nm' 'objcopy' 'objdump' 'ranlib' 'readelf' \ + 'size' 'strings' 'strip' ) + +# General commands +general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'patch' \ + 'find' 'grep' 'lemount' 'm4' 'mitzune' \ + ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) + +# General compressing tools +archivers=('tar' 'bzip2' 'gzip' 'xz') + +# Check for aria2c +if $USE_ARIA2C; then + general_commands[1]='aria2c' +fi + +for (( g=0; g < $(n ${general_commands[@]}); g++ )); do + printerr 'Searching for %s at PATH (%s)... ' \ + "${general_commands[$g]}" "$PATH" + type -p "${general_commands[$g]}" \ + || { printerr 'Not found.\n'; return 1; } +done + +for (( h=0; h < $(n ${archivers[@]}); h++ )); do + printerr 'Does %s work for what we want? ' "${archivers[$h]}" + if [ "${archivers[$h]}" == 'tar' ]; then # TAR-specific tests + if [[ "$(readlink -f "$(type -p tar)")" =~ (star) ]] \ + || $(tar -h 2>&1| grep 'star' 2>&1 >/dev/null); then + printerr '\nI'\''m almost certain that %s is Schily tar...\n' \ + "$(type -p tar)" + printerr \ + 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' + printerr \ + 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).\n' + function tar { + "$(type -p tar)" "$@" \ + --no-secure-links --artype=xustar + } + typeset -xf tar + fi + + { + ( mkdir -p "$archiver_sanity"{,_results} + cd "$archiver_sanity" + > vulgar_file + mkfifo pipe_test + ln -sf "$(readlink -f "$archiver_sanity")" potentially_unsafe_link + ln -f vulgar_file hard_link + # We already expect an error/warning + ln -f not_a_vulgar_file broken_link 2>/dev/null + ) + ( cd "$archiver_sanity" + tar -cf - . ) | tar -xf - -C "${archiver_sanity}_results" + } && rm -rf "${archiver_sanity}_results" + else # Bzip2, Gzip or Xz tests + for (( l=1; l <= 9; l++ )); do + printerr 'With compression level %s? ' $l + + # Test the alphabet string can be compressed + # without being corrupted, then, do a more + # "difficult" test using the main build.ksh + # script file. + { printf '%s' {a..z} | "${archivers[$h]}" -"$l" -cf \ + | "${archivers[$h]}" -dcf | wc -m | tr -d '[:space:]' \ + | test `cat` -eq 26 ; } \ + && { cat "$progdir/$progname" | "${archivers[$h]}" -"$l" -cf \ + | "${archivers[$h]}" -dcf \ + | cmp - "$progdir/$progname"; } + printerr 'Ok...\n' + done + fi + printerr 'Sounds like a yes.\n' +done + +for (( i=0; i < $(n ${utils[@]}); i++ )); do + printerr 'Is %s present on this system? ' "${utils[$i]}" + command -v ${utils[$i]} 2>&1 > /dev/null && printerr 'Sounds like a yes.\n' \ + || { printerr '%s not found.\n' ${utils[$i]}; return 1; } +done + +for (( k=0; k < $(n ${internal_scripts[@]}); k++ )); do + printerr 'Searching for independent script %s at %s... ' \ + "${internal_scripts[$k]}" "$progdir" + if [ -e "$progdir/${internal_scripts[$k]}" ] \ + && [ ! -z "$(cat "$progdir/${internal_scripts[$k]}")" ]; then + printerr 'Found!\n' + else + printerr '%s not found...\n' + printerr 'It seems like your Copacabana repository clone is incomplete.\n' + return 1 + fi +done + +# Programming language interpreters/compilers sanity checks. + +run_shell="$(readlink -f /proc/$$/exe)" +printerr 'Does the running shell (%s) work for what we need?\n' "$run_shell" + +# Not caching "$(readlink -f /proc/$$/exe)" via $run_shell on the sanity test, +# since we expect it to run as a new process, so as a new P.ID. and as a new +# "folder" at /proc, explaining in a extremely simplistic way. + +cat > "$ksh_sanity_test" << 'EO_KSHSANITY' +#!/usr/bin/env ksh +interpreter="$(readlink -f /proc/$$/exe)" + +if [[ "$interpreter" =~ (ksh|ksh93) ]]; then +print -f \ +'It seems like %s is Korn Shell 93, but let me test it... ' \ + "$interpreter" 1>&2 +if (PATH=.; alias -x) && [ -z $BASH ] && [ -n ${.sh.version} ]; then + print -f 'Well, it is, time to move on.\n' 1>&1 +fi +elif [[ "$interpreter" =~ (bash) && -n $BASH ]]; then +printf 'It seems like %s is GNU Broken-Again Shell. +Anyway, this script is designed to work with it. Move on.\n' \ +"$interpreter" 1>&2 +else +printf '%s is unsupported. Oddly, it passed the platform checks, but not these small sanity tests. +Please, report this at https://github.com/Projeto-Pindorama/copacabana.\n' "$interpreter" +return 1 +fi +EO_KSHSANITY +"$run_shell" "$ksh_sanity_test" + +printerr 'Does the C/C++ compiler work for what we need?\n' + +cat > "$c_sanity_test" << 'EO_CSANITY' +#include + +#if defined(__GNUC__) || defined(__clang__) +#define RETURN 0 +#else +#define RETURN 1 +#endif + +int main(void) { +if (! RETURN) { + puts("Great! We're on a supported C compiler (GCC or LLVM)."); +} else { + puts("Not on a supported compiler."); +} +return RETURN; +} +EO_CSANITY + +cat > "$cxx_sanity_test" << 'EO_C++SANITY' +#include +using std::cout; + +#if defined(__GNUG__) || defined(__clang__) +#define RETURN 0 +#else +#define RETURN 1 +#endif + +int main(void) { +if (! RETURN) { + std::cout << "Great! We're on a supported C++ compiler (GCC or LLVM)." << std::endl; +} else { + std::cout << "Not on a supported compiler." << std::endl; +} +return RETURN; +} +EO_C++SANITY + +{ "$CC" -o"$trash/c_sanity" "$c_sanity_test"; "$trash/c_sanity" \ +&& "$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test" && "$trash/cxx_sanity"; } \ +|| exit $? + +printerr 'Info: Generating our cross-compiling host based on this machine'\''s type...\n' +printerr 'Does this system have GNU Broken-Again Shell for $MACHTYPE or we'\''ll be depending on %s? ' \ +"$CC" +if ! type -p bash 2>&1 > /dev/null; then +printerr 'Nah, it'\''s clean.\n' +has_bash=false +else +printerr 'It does, we'\''re going with it.\n' +has_bash=true +fi + +COPA_HOST="$( ( ($has_bash && bash -c 'echo $MACHTYPE') \ +|| (gcc -v 2>&1 | nawk '/Target/{ sub(/.*Target:/, "", $0); printf("%s", $1); }') ) \ +| nawk '{ split($0, host, "-"); sub(host[2], "crossCOPACABANA", $0); printf("%s\n", $0); }')" +unset has_bash + +printerr 'Info: COPA_HOST will be "%s".\n' "$COPA_HOST" + +# Exporting our running Shell for using later in other tasks and also the +# $COPA_HOST, that will be used when building the cross-compiler. +export run_shell COPA_HOST diff --git a/build-system/tasks/platform_checks.ksh b/build-system/tasks/checks/platform.ksh similarity index 100% rename from build-system/tasks/platform_checks.ksh rename to build-system/tasks/checks/platform.ksh diff --git a/build-system/tasks/disk/create_disk.ksh b/build-system/tasks/disk/create_disk.ksh new file mode 100644 index 0000000..3d0ed91 --- /dev/null +++ b/build-system/tasks/disk/create_disk.ksh @@ -0,0 +1,147 @@ +# STEP 1: "Pindorama presents: Fubá Cake" +# In this step, we will create and format a disk, virtual or physical. +disk_block="$1" + +# Set first_time flag to indicate that it's the first time building the +# system. +first_time=true + +# Estabilish a default size of 20 GB for a virtual disk +virtuadisk_size=${VIRTUADISK_SIZE:-20} +disk_label=${DISK_LABEL:-'Copacabana'} + +# These are only used in virtual disks +# o = Use a DOS label +# n = Create a new partition +# p = Primary, of course +# 1 = The first one in the disk +# ' ' = No-op +# t = Use a type +# 83 = Linux partition type +# w = Write 'n quit +fdisk_steps=( 'o' 'n' 'p' '1' ' ' ' ' 't' '83' 'w' ) + +if (( ${#disk_label} > 16 )); then + printerr \ + 'Warning: This disk label ("%s") exceeds e2label'\''s VOLNAMSZ (%d) in %d characters.\n' \ + "$disk_label" 16 $(( ${#disk_label} - 16 )) + printerr \ + 'Warning: Falling back to the default value so we does not get any warnings from e2label.\n' + unset disk_label; disk_label='Copacabana' +fi + +printerr 'Info: %s only creates a plain disk, without partitions for /boot, /usr, etc.\n' $0 +if [[ ! "$VIRTUAL_DISK" && -b "$disk_block" ]]; then + # Get the disk size from /proc/partitions, pretty + # self-explanatory. + disk_size="$(grep "${disk_block##*/}\$" /proc/partitions \ + | nawk '{ printf "%0.1f\n", ($(NF -1) / 1024); }')" + + printerr 'Info: Using a physical disk, present at %s with size of %d MB.\n' \ + "$disk_block" "$disk_size" + + if (( disk_size < (10 * 1024) )); then + panic \ + 'Disk %s is too small (%d MB). %d MB is the recommended capacity for building Copacabana.\n' \ + "$disk_block" "$disk_size" $(( 10 * 1024 )) + # Do not accept disks/disk partitions larger than 50GB. + elif (( disk_size > (50 * 1024) )); then + panic \ + 'Disk %s is too large. Create a partition and/or use a virtual disk smaller than %d MB.\n' \ + "$disk_block" $(( 50 * 1024 )) + fi + + # Check if disk is already initialized. + if $(elevate fdisk -x "${disk_block%%?}" | grep "$disk_block" &>/dev/null); then + filesystem=$(eval $(blkid -o udev "$disk_block"); + printf '%s\n' "$ID_FS_TYPE") + + if ! check_linuxfs $filesystem; then + panic \ + '%s is not intended for containing a Linux system.\nDid you mean creating a virtual disk image inside %s?\n' \ + $filesystem "$disk_block" + fi + + # If we have a compatible file system on the disk, we + # shall already set as not being the first time. + first_time=false + fi +elif [[ "$VIRTUAL_DISK" ]]; then + virtuadisk_path="$(realpath "$disk_block")" + printerr 'Info: Using a virtual disk, located at %s, with a pre-determined size of %d MB.\n' \ + "$virtuadisk_path" $(( virtuadisk_size * 1024 )) + + if [[ ! -e "$virtuadisk_path" ]]; then + printerr 'Info: Inexistent disk image, creating it...\n' + elif [[ -e "$virtuadisk_path" && ! -b "$virtuadisk_path" ]]; then + printerr 'Info: A disk image already exists at %s, do you wish to continue or clean it up and start over?\n' \ + "$virtuadisk_path" + first_time=false + fi +fi + +if ! $first_time; then + start_over=false + PS3='Continue? ' + select option in yes no quit; do + case "$option" in + # This will (L.E.)mount the disk and view if + # there is something that can be done. + yes) break ;; + no) start_over=true ;; + quit|*) return 1 ;; + esac + done +fi + +if "$VIRTUAL_DISK"; then + if ( $first_time || $start_over ); then + printerr 'Info: Creating a virtual disk image at %s, with size of %d MB.\n' \ + "$virtuadisk_path" $(( virtuadisk_size * 1024 )) + + # 1 GB is equal to 2.097.152 blocks. + # In other words, use: + # X GB = X * [(1024^2) * 2] blocks + virtuadisk_blksize="$(( virtuadisk_size * ((1024 ** 2) * 2) ))" + dd if=/dev/zero of="$virtuadisk_path" bs=512 count=$virtuadisk_blksize + + # Does the size in blocks matches with what du(1)'s getting? + virtuadisk_reported_size=$(du -s "$virtuadisk_path" | nawk '{ printf("%d", $1); }') + + if (( virtuadisk_blksize == virtuadisk_reported_size )); then + printerr 'Info: %s is o.k. Proceeding.\n' "$virtuadisk_path" + else + printerr 'Error: dd failed to write %d blocks to %s.\n' \ + $virtuadisk_blksize "$virtuadisk_path" + printerr 'Error: It possible reported an error and/or an interruption signal before this message.\n' + printerr 'Error: Please, check. Stopping the build process.\n' + return 1 + fi + + # For some reason, echo won't be working for this, so let be + # sticking with printf '%s\n'. + printf '%s\n' "${fdisk_steps[@]}" | elevate fdisk "$virtuadisk_path" + fi + + # Expose the virtual disk to the system. + loop_disk_block="$(elevate losetup --show -P -f "$virtuadisk_path")" + + # That's why we hardcoded the partition to be the first. + unset disk_block; export disk_block="${loop_disk_block}p1" +fi +if ( $first_time || $start_over ); then + # Formats the disk block as Ext4 and label it as our defined disk label. + elevate "$run_shell" -c "mkfs -V -t ext4 '$disk_block' && e2label '$disk_block' '$disk_label'" +fi + +# We expect the "dsk" type to be the first in the array on L.E.mount, as +# in the default /etc/leconf, so we'll be using "1" as the second +# argument. +printf '%s\n' "$disk_block" 1 | eval $(elevate lemount) + +# And here we go. +# Making it read-only only to be sure that it won't be getting +# overwritten by a "non-build.ksh aware" script later. +export readonly COPA="$ledisk" + +printerr 'Info: Copacabana disk %s mounted at %s.\n' "$disk_block" "$COPA" diff --git a/build-system/tasks/disk/populate.ksh b/build-system/tasks/disk/populate.ksh new file mode 100644 index 0000000..ce2a927 --- /dev/null +++ b/build-system/tasks/disk/populate.ksh @@ -0,0 +1,57 @@ +# STEP 1.5: Populate the file system +# This function will run the cmd/populate_fhs.sh script and create directories +# for the toolchains that will be built. + +SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" +# Also declare who will be our log file. +blackbox="$COPA/build.log.$CPU" + +# Self-explanatory, just create the directories for the initial +# toolchain and intermediary chroot toolchain. +printerr 'Info: Making directories in %s for the building toolchains.\n' \ + "$COPA" +elevate mkdir "$COPA/"{cgnu,llvm}tools +(cd "$COPA"; ls -lah .) + +# Make a symbolic link from $COPA/cgnutools to /cgnutools, the same +# for /llvmtools. +# For instance: +# {"$COPA/",/}cgnutools expands to $COPA/cgnutools /cgnutools, +# which is the input that we'd need to ln(1). +if [[ -d "$COPA/cgnutools" && -d "$COPA/llvmtools" ]]; then + printerr 'Info: Symbolic linking %s to %s...\n' \ + {"$COPA/",/}cgnutools {"$COPA/",/}llvmtools + + # If /cgnutools is already a symbolic link to + # $COPA/cgnutools, then don't re-do it. Else, if it's a + # symbolic link but it doesn't link to $COPA/cgnutools, + # re-do it. + # The same applies to /llvmtools. + [[ $(realpath /cgnutools) != "$COPA/cgnutools" ]] \ + && elevate rm /cgnutools + ( test -L /cgnutools \ + && [[ $(realpath /cgnutools) == "$COPA/cgnutools" ]] ) \ + || elevate ln -s {"$COPA/",/}cgnutools + + + [[ $(realpath /llvmtools) != "$COPA/llvmtools" ]] \ + && elevate rm /llvmtools + ( test -L /llvmtools \ + && [[ $(realpath /llvmtools) == "$COPA/llvmtools" ]] ) \ + || elevate ln -s {"$COPA/",/}llvmtools + + (cd /; ls -l ./{cgnu,llvm}tools) +fi + +printerr 'Info: Making directories in %s for populating the file system.\n' \ + "$COPA" +elevate $run_shell -c "COPA=$COPA BUILD_KSH=$BUILD_KSH $progdir/cmd/populate_fhs.sh; mkdir -p "$SRCDIR"" + +printerr 'Info: Initializing blackbox file (%s) for the build.\n' \ + "$blackbox" +( cd "$COPA"; elevate sh -c "> $blackbox; chown $user $blackbox" ) + +printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ + $(realpaths /{cgnu,llvm}tools) "$SRCDIR" +elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" +export blackbox SRCDIR diff --git a/build-system/tasks/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh index 84b2650..ee3cabc 100644 --- a/build-system/tasks/disk_managenment.ksh +++ b/build-system/tasks/disk_managenment.ksh @@ -3,244 +3,7 @@ # Copyright (c) 2023-2024: Pindorama # SPDX-Licence-Identifier: NCSA -# STEP 1: "Pindorama presents: Fubá Cake" -# In this step, we will create and format a disk, virtual or physical. -function create_disk { - disk_block="$1" - # Set first_time flag to indicate that it's the first time building the - # system. - first_time=true - - # Estabilish a default size of 20 GB for a virtual disk - virtuadisk_size=${VIRTUADISK_SIZE:-20} - disk_label=${DISK_LABEL:-'Copacabana'} - - # These are only used in virtual disks - # o = Use a DOS label - # n = Create a new partition - # p = Primary, of course - # 1 = The first one in the disk - # ' ' = No-op - # t = Use a type - # 83 = Linux partition type - # w = Write 'n quit - fdisk_steps=( 'o' 'n' 'p' '1' ' ' ' ' 't' '83' 'w' ) - - if (( ${#disk_label} > 16 )); then - printerr \ - 'Warning: This disk label ("%s") exceeds e2label'\''s VOLNAMSZ (%d) in %d characters.\n' \ - "$disk_label" 16 $(( ${#disk_label} - 16 )) - printerr \ - 'Warning: Falling back to the default value so we does not get any warnings from e2label.\n' - unset disk_label; disk_label='Copacabana' - fi - - printerr 'Info: %s only creates a plain disk, without partitions for /boot, /usr, etc.\n' $0 - if [[ ! "$VIRTUAL_DISK" && -b "$disk_block" ]]; then - # Get the disk size from /proc/partitions, pretty - # self-explanatory. - disk_size="$(grep "${disk_block##*/}\$" /proc/partitions \ - | nawk '{ printf "%0.1f\n", ($(NF -1) / 1024); }')" - - printerr 'Info: Using a physical disk, present at %s with size of %d MB.\n' \ - "$disk_block" "$disk_size" - - if (( disk_size < (10 * 1024) )); then - panic \ - 'Disk %s is too small (%d MB). %d MB is the recommended capacity for building Copacabana.\n' \ - "$disk_block" "$disk_size" $(( 10 * 1024 )) - # Do not accept disks/disk partitions larger than 50GB. - elif (( disk_size > (50 * 1024) )); then - panic \ - 'Disk %s is too large. Create a partition and/or use a virtual disk smaller than %d MB.\n' \ - "$disk_block" $(( 50 * 1024 )) - fi - - # Check if disk is already initialized. - if $(elevate fdisk -x "${disk_block%%?}" | grep "$disk_block" &>/dev/null); then - filesystem=$(eval $(blkid -o udev "$disk_block"); - printf '%s\n' "$ID_FS_TYPE") - - if ! check_linuxfs $filesystem; then - panic \ - '%s is not intended for containing a Linux system.\nDid you mean creating a virtual disk image inside %s?\n' \ - $filesystem "$disk_block" - fi - - # If we have a compatible file system on the disk, we - # shall already set as not being the first time. - first_time=false - fi - elif [[ "$VIRTUAL_DISK" ]]; then - virtuadisk_path="$(realpath "$disk_block")" - printerr 'Info: Using a virtual disk, located at %s, with a pre-determined size of %d MB.\n' \ - "$virtuadisk_path" $(( virtuadisk_size * 1024 )) - - if [[ ! -e "$virtuadisk_path" ]]; then - printerr 'Info: Inexistent disk image, creating it...\n' - elif [[ -e "$virtuadisk_path" && ! -b "$virtuadisk_path" ]]; then - printerr 'Info: A disk image already exists at %s, do you wish to continue or clean it up and start over?\n' \ - "$virtuadisk_path" - first_time=false - fi - fi - - if ! $first_time; then - start_over=false - PS3='Continue? ' - select option in yes no quit; do - case "$option" in - # This will (L.E.)mount the disk and view if - # there is something that can be done. - yes) break ;; - no) start_over=true ;; - quit|*) return 1 ;; - esac - done - fi - - if "$VIRTUAL_DISK"; then - if ( $first_time || $start_over ); then - printerr 'Info: Creating a virtual disk image at %s, with size of %d MB.\n' \ - "$virtuadisk_path" $(( virtuadisk_size * 1024 )) - - # 1 GB is equal to 2.097.152 blocks. - # In other words, use: - # X GB = X * [(1024^2) * 2] blocks - virtuadisk_blksize="$(( virtuadisk_size * ((1024 ** 2) * 2) ))" - dd if=/dev/zero of="$virtuadisk_path" bs=512 count=$virtuadisk_blksize - - # Does the size in blocks matches with what du(1)'s getting? - virtuadisk_reported_size=$(du -s "$virtuadisk_path" | nawk '{ printf("%d", $1); }') - - if (( virtuadisk_blksize == virtuadisk_reported_size )); then - printerr 'Info: %s is o.k. Proceeding.\n' "$virtuadisk_path" - else - printerr 'Error: dd failed to write %d blocks to %s.\n' \ - $virtuadisk_blksize "$virtuadisk_path" - printerr 'Error: It possible reported an error and/or an interruption signal before this message.\n' - printerr 'Error: Please, check. Stopping the build process.\n' - return 1 - fi - - # For some reason, echo won't be working for this, so let be - # sticking with printf '%s\n'. - printf '%s\n' "${fdisk_steps[@]}" | elevate fdisk "$virtuadisk_path" - fi - - # Expose the virtual disk to the system. - loop_disk_block="$(elevate losetup --show -P -f "$virtuadisk_path")" - - # That's why we hardcoded the partition to be the first. - unset disk_block; export disk_block="${loop_disk_block}p1" - fi - if ( $first_time || $start_over ); then - # Formats the disk block as Ext4 and label it as our defined disk label. - elevate "$run_shell" -c "mkfs -V -t ext4 '$disk_block' && e2label '$disk_block' '$disk_label'" - fi - - # We expect the "dsk" type to be the first in the array on L.E.mount, as - # in the default /etc/leconf, so we'll be using "1" as the second - # argument. - printf '%s\n' "$disk_block" 1 | eval $(elevate lemount) - - # And here we go. - # Making it read-only only to be sure that it won't be getting - # overwritten by a "non-build.ksh aware" script later. - export readonly COPA="$ledisk" - - printerr 'Info: Copacabana disk %s mounted at %s.\n' "$disk_block" "$COPA" -} - -# May use this function later, no use for it for now. -function get_size_blocks { - typeset -a disk_size[2] - disk_block="$1" - - # The minimum size for a block is 512KiB, not less. - # This identifier may sound a little bit erred. - readonly blocks_per_kib=512 - - disk_size=( $(elevate fdisk -x "$disk_block" \ - | sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q') ) - - size=${disk_size[0]} - sizeunit=${disk_size[1]} - unset disk_size - - case $sizeunit in - 'TiB') ((blocks= size * (blocks_per_kib * 4194304) )) ;; - 'GiB') ((blocks= size * (blocks_per_kib * 4096) )) ;; - 'MiB') ((blocks= size * (blocks_per_kib * 4) )) ;; - 'KiB') ((blocks= size / blocks_per_kib )) ;; - esac - unset size sizeunit - - printf '%d' $blocks - - return 0 -} - -# STEP 1.5: Populate the file system -# This function will run the cmd/populate_fhs.sh script and create directories -# for the toolchains that will be built. -function populate { - # That's the time to decide which will be, in fact, our source-code directory. - SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" - # Also declare who will be our log file. - blackbox="$COPA/build.log.$CPU" - - # Self-explanatory, just create the directories for the initial - # toolchain and intermediary chroot toolchain. - printerr 'Info: Making directories in %s for the building toolchains.\n' \ - "$COPA" - elevate mkdir "$COPA/"{cgnu,llvm}tools - (cd "$COPA"; ls -lah .) - - # Make a symbolic link from $COPA/cgnutools to /cgnutools, the same - # for /llvmtools. - # For instance: - # {"$COPA/",/}cgnutools expands to $COPA/cgnutools /cgnutools, - # which is the input that we'd need to ln(1). - if [[ -d "$COPA/cgnutools" && -d "$COPA/llvmtools" ]]; then - printerr 'Info: Symbolic linking %s to %s...\n' \ - {"$COPA/",/}cgnutools {"$COPA/",/}llvmtools - - # If /cgnutools is already a symbolic link to - # $COPA/cgnutools, then don't re-do it. Else, if it's a - # symbolic link but it doesn't link to $COPA/cgnutools, - # re-do it. - # The same applies to /llvmtools. - [[ $(realpath /cgnutools) != "$COPA/cgnutools" ]] \ - && elevate rm /cgnutools - ( test -L /cgnutools \ - && [[ $(realpath /cgnutools) == "$COPA/cgnutools" ]] ) \ - || elevate ln -s {"$COPA/",/}cgnutools - - - [[ $(realpath /llvmtools) != "$COPA/llvmtools" ]] \ - && elevate rm /llvmtools - ( test -L /llvmtools \ - && [[ $(realpath /llvmtools) == "$COPA/llvmtools" ]] ) \ - || elevate ln -s {"$COPA/",/}llvmtools - - (cd /; ls -l ./{cgnu,llvm}tools) - fi - - printerr 'Info: Making directories in %s for populating the file system.\n' \ - "$COPA" - elevate $run_shell -c "COPA=$COPA BUILD_KSH=$BUILD_KSH $progdir/cmd/populate_fhs.sh; mkdir -p "$SRCDIR"" - - printerr 'Info: Initializing blackbox file (%s) for the build.\n' \ - "$blackbox" - ( cd "$COPA"; elevate sh -c "> $blackbox; chown $user $blackbox" ) - - printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ - $(realpaths /{cgnu,llvm}tools) "$SRCDIR" - elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" - export blackbox SRCDIR -} function unmount_and_detach { # Korn Shell variables, unlike GNU Broken-Again Shell, are scoped to the @@ -257,17 +20,4 @@ function unmount_and_detach { fi } -# This checks for valid file systems on -# which Copacabana builds are made and -# tested. -function check_linuxfs { - fs=$1 - err=0 - case $fs in - btrfs|ext4) break ;; - default) err=1; break ;; - esac - - return $err -} diff --git a/build-system/tasks/finish.ksh b/build-system/tasks/finish.ksh index ecd28fc..2a42ba1 100644 --- a/build-system/tasks/finish.ksh +++ b/build-system/tasks/finish.ksh @@ -1,8 +1,6 @@ -function finish { - if $UMOUNT_ON_EXIT; then - unmount_and_detach "$COPA" "$disk_block" - fi +if $UMOUNT_ON_EXIT; then + unmount_and_detach "$COPA" "$disk_block" +fi - # Remove the trash directory with sanity tests - rm -rf "$trash" -} +# Remove the trash directory with sanity tests +rm -rf "$trash" diff --git a/build-system/tasks/get_source-code.ksh b/build-system/tasks/get_sources.ksh similarity index 55% rename from build-system/tasks/get_source-code.ksh rename to build-system/tasks/get_sources.ksh index e8e0048..d69f3dd 100644 --- a/build-system/tasks/get_source-code.ksh +++ b/build-system/tasks/get_sources.ksh @@ -16,22 +16,20 @@ # food" philosophy? So ---, but it's not included inside the Copacabana # repository for obvious reasons. -function get_sources { - # Get precise path for both sources.txt and sources.sha256, even though - # download_sources.ksh already does this internally using a realpath() - # function. - source_list="$(readlink -f "$1")" - source_hash="$(readlink -f "$2")" +# Get precise path for both sources.txt and sources.sha256, even though +# download_sources.ksh already does this internally using a realpath() +# function. +source_list="$(readlink -f "$1")" +source_hash="$(readlink -f "$2")" - SHA256CHECK="$SHA256CHECK" - SRCDIR="$SRCDIR" - USE_ARIA2C="$USE_ARIA2C" - export USE_ARIA2C SHA256CHECK SRCDIR +SHA256CHECK="$SHA256CHECK" +SRCDIR="$SRCDIR" +USE_ARIA2C="$USE_ARIA2C" +export USE_ARIA2C SHA256CHECK SRCDIR - printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ - "$source_list" +printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ + "$source_list" - "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" +"$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" - unset SHA256CHECK USE_ARIA2C -} +unset SHA256CHECK USE_ARIA2C diff --git a/build-system/work.ini b/build-system/work.ini index feda760..0a95a5f 100644 --- a/build-system/work.ini +++ b/build-system/work.ini @@ -13,6 +13,7 @@ ; Usually, when building up to the toolchain, it is placed on ; the trash. You may wish to change it if your trash directory ; is too small, or just change the trash directory to other place. -TRASH_PREFIX="/tmp" -PKGDIR="/dsk/0/plaza" +; TRASH_PREFIX="/tmp" +TRASH_PREFIX="/tmp/" +PKGDIR="/tmp/plaza" ; OBJDIR="" diff --git a/build.ksh b/build.ksh index da42697..a769bbb 100755 --- a/build.ksh +++ b/build.ksh @@ -8,35 +8,31 @@ set -e progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" -# Immediatly source and run the platform checks before doing anything else. -. "$progdir/build-system/tasks/platform_checks.ksh"; platform_checks +# _make +. "$progdir/build-system/internals/helpers/makier.ksh" -# Internal build system functions -. "$progdir/build-system/internals/helpers/helpers.shi" -. "$progdir/build-system/internals/helpers/posix-alt.shi" +# Immediatly source and run the platform checks +# before doing anything else. +_make "checks/platform" -# Task files -. "$progdir/build-system/tasks/check_dependencies.ksh" -. "$progdir/build-system/tasks/disk_managenment.ksh" -. "$progdir/build-system/tasks/get_source-code.ksh" -. "$progdir/build-system/tasks/build_all.ksh" - -. "$progdir/build-system/tasks/finish.ksh" +. "$progdir/build-system/internals/helpers/posix-alt.shi" +. "$progdir/build-system/internals/helpers/helpers.shi" +. "$progdir/build-system/internals/helpers/rconfig.shi" +. "$progdir/build-system/internals/helpers/disks.shi" rconfig "$progdir/build-system/machine.ini" rconfig "$progdir/build-system/work.ini" rconfig "$progdir/build-system/fhs.ini" trash="$(mktemp -d "$TRASH_PREFIX/CopaBuild.XXXXXX")" - map dtime initial "$(date +'%Hh%Mmin on %B %d, %Y')" - check_elevate_method -check_dependencies -create_disk "$DISK_BLOCK" -populate -get_sources sources.txt sources.sha256 -build cross-tools cross/mussel + +_make 'checks/dependencies' +_make 'disk/create_disk' "$DISK_BLOCK" +_make 'disk/populate' +_make get_sources sources.txt sources.sha256 +#build cross-tools cross/mussel #build cross-tools "base/kernel-headers" "dev/GNUBinutils" \ # "dev/GNUcc" "base/LibC" "dev/GNUcc" @@ -45,5 +41,5 @@ build cross-tools cross/mussel #build base "base/kernel-headers" "dev/GNUBinutils" \ # "dev/GNUcc" "base/LibC" "dev/GNUcc" -build close -finish +#build close +_make finish diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh index 5556c4d..6195b3c 100755 --- a/cmd/populate_fhs.sh +++ b/cmd/populate_fhs.sh @@ -4,6 +4,8 @@ # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA +set -x + progname="${0##*/}" COPA=${COPA:-/dsk/0v} mtab='/etc/mtab' @@ -32,6 +34,9 @@ fi # Is the Copacabana build disk mounted? printf 1>&2 'Checking if %s is a mountpoint...\n' "$COPA" { +# Declare 'err' as being 1 since it will +# only be changed if a disk is mounted. +err=1 while read line; do disk="${line%%[[:space:]]*}" dirtotest_=${line#*[[:space:]]} @@ -44,7 +49,6 @@ while read line; do fi unset disk dirtotest_ dirtotest # Not mounted? - err=1 done < "$mtab" } if [ $err != 0 ]; then diff --git a/docs/build-system/machine.md b/docs/build-system/machine.md new file mode 100644 index 0000000..f72cfa0 --- /dev/null +++ b/docs/build-system/machine.md @@ -0,0 +1,117 @@ +# The variables below will change depending on the architecture. +# The default is x86_64. + +```ini +[Machine] +COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" +TARGET_TUPLE="x86_64-pc-linux-musl" +ARCH="x86" +CPU="x86-64" + +[Build] +BINARY_CACHE="false" +I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" + +[Disk managenment] +VIRTUAL_DISK="true" +DISK_BLOCK="/tmp/COPA.IMG" +VIRTUADISK_SIZE=10 +; DISK_LABEL="" +UMOUNT_ON_EXIT="false" + +[Download sources] +; SRCDIR_SUFFIX="" +SHA256CHECK="YES" +USE_ARIA2C="true" +; SSL_CMD="" + +[Programs] +CC="gcc" +CXX="g++" +LD="ld" +AS="as" +``` + +# Target +COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" + +# The default/unvendored "target tuple" that we will need when configuring LLVM. +TARGET_TUPLE="x86_64-pc-linux-musl" + +# CPU information +ARCH="x86" +CPU="x86-64" + +# Use binary-cached toolchains +BINARY_CACHE="false" + +# Use a virtual disk or a physical one +VIRTUAL_DISK="true" +DISK_BLOCK="/tmp/COPA.IMG" + +# Uncomment to use a custom disk size in gigabytes +VIRTUADISK_SIZE=10 + +# Disk label +# Uncomment to use a custom disk label (string) for your +# Copacabana build. +# Its size is of 16 characters at maximum. +# DISK_LABEL="" + +# umount(8) on exit? +# Use "false" if you want to check how the process went, useful +# if you're a developer and trying to mess around with this, if +# not, just use "true". +UMOUNT_ON_EXIT="false" + +# Do you enjoy to sit for hours reading seemingly haphazardly shell-generated +# instructions given by GNU auto*tools for building enormous programs such as +# G.C.C. directly on your main terminal instead of just sending all of it for +# a log file and waiting for when some error happens? +# Are you getting paranoic with GNU's miraculous build system freezing your +# machine and absolutely needs to read pretty much meaningless --- and, again, +# haphazardly shell-generated --- instructions running on your screen just to +# realize that it's not your fault and just some funky bug? Marvellous! +# So this option shall be "true" for you! Else, just let it as it is. +# +# Anyway, if you have to read the logs, they will be sent to inside the +# Copacabana root directory in a file called "build.log." +I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" + +# Where do you want the source code to be saved? +# This is the suffix for the source code directory. +# May you wish to change it just in case of wanting to mess around +# with Copacabana's FHS or compatibilize some Linux From Scratch-specific +# scripts with Copacabana. +# Per default, it is "/usr/src" (over the $COPA directory, of course), +# but you can redefine if you wish to "/sources", for example. +# SRCDIR_SUFFIX="" + +# Do SHA256 checks after downloading Copacabana sources? +# Use "YES" if you're just a final user and/or developer aiming +# to port Copacabana and just wants to build a vanilla +# distribution or "NO" if you're a developer and wants to +# change/update some of the sources without regenerating the +# "sources.sha256" file before. This option is case-insensitive. +SHA256CHECK="YES" + +# Use aria2c instead of the good ol' cURL backend on download_sources.ksh? +# Use "true" if you have aria2c on your system, or "false" if you're on a small +# environment (such as the Copacabana 0.4 Dockerimage/Mitzune prefix) with only +# cURL and/or taking considerably more time isn't a big deal. +USE_ARIA2C="true" + +# This is used on the Korn Shell 93 implementation of sha256sum, +# present at cmd/ on this repository. +# The default is "openssl", you may change this if you're using +# LibreSSL or another fork and it doesn't provide its +# OpenSSL-compatible shell API binary symbolic/hard linked to +# "openssl" in your path. +# If changed, the value here must be lower-case. +# SSL_CMD="" + +# Programs +CC="gcc" +CXX="g++" +LD="ld" +AS="as" diff --git a/packages b/packages index a1d678b..97f5592 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit a1d678b6f049792ef1a586e02260c355aef0ba42 +Subproject commit 97f5592f3e815e832621fbd4117f61cc74aecacd diff --git a/version b/version new file mode 100644 index 0000000..171538e --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.0 \ No newline at end of file From cd0db89b52b4aec6a73759671c574721c489ee88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 28 Jul 2024 01:51:49 -0300 Subject: [PATCH 059/128] chore: Remove temporary copy of helpers.shi. --- .../helpers/helpers_euvouenloquecer.shi | 420 ------------------ 1 file changed, 420 deletions(-) delete mode 100644 build-system/internals/helpers/helpers_euvouenloquecer.shi diff --git a/build-system/internals/helpers/helpers_euvouenloquecer.shi b/build-system/internals/helpers/helpers_euvouenloquecer.shi deleted file mode 100644 index 4322836..0000000 --- a/build-system/internals/helpers/helpers_euvouenloquecer.shi +++ /dev/null @@ -1,420 +0,0 @@ -# vim: set filetype=sh : -# Internal helper library for the Copacabana build system. -# Meant to be used with Korn Shell 93. -# Copyright (c) 2023 Pindorama -# Luiz Antônio Rangel -# SPDX-Licence-Identifier: NCSA -# -# "'Liberdade, Igualdade, Fraternidade', -# é o seguinte: se tem Liberdade, tem que -# ter Igualdade, Amor e Fraternidade [...]" - -# Make everyone aware we're running from BUILD_KSH. -export readonly BUILD_KSH=true - -# Reads INI configuration files, now a boilerplate function -# to dotini/inicompat --- and, in case of using -# GNU's Broken-Again Shell, it does a coarse conversion of -# the INI file to a simple Shell-based configuration file -# format. -function rconfig { - file="$1" - - if [[ -z $BASH && -n $KSH_VERSION ]]; then - # Load the .ini configuration file as - # a compound variable to the memory. - # Simple as that. - eval conf=$(dotini "$file") - inicompat conf - elif [[ -n $BASH ]]; then # BASH - cat "$1" | \ - for (( ;; )); do - if read line; then - if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] \ - || [[ "$line" =~ '^[#;].*$' ]]; then - continue - else - keyval="$(printf '%s' "$line" \ - | sed 's/^\(.*\)[#;].*/\1/;')" - identifier="${keyval%%=*}" - value="${keyval##*=}" - [[ "$keyval" =~ ^$ ]] && continue - eval $(printf '%s='\''%s'\''' $identifier "$value") - fi - else - break - fi - done - fi -} - -# This function parses .INI files into a compound variable that can be used -# inside the script via eval. -# For example: -# -# eval private_config=$(dotini conf.ini) -# Then you could just access like so: -# printf '%s\n' "${private_config[SectName][KeyName]}" -# It does not outsource record() or map(), so there's more independence and -# flexibility on choosing identifiers for your INI file configuration. -# -# FIXME: When I got time --- or someone else that knows at least a bit of -# KornShell shows up ---, this parser needs to be fixed to support INI files -# that don't explicitly declare a section. -# Sure thing that second-rate hacks such as creating a default section called -# "global" were already thought of, so the ideal is to have just what is being -# described in the code. -# I could fix this in some hours, but I'm willing to work more on the rest of -# the build system instead of just some isolate functions that are already -# compliant with its needs. -# -# FIXME: Also it would be helpful to support files that use spaces between the -# identifier and value, for example: -# -# [sectname] -# keyname = value -# keyname_2 = "Another value" -# -# Being optimistic and careless about using shell built-ins (read as "read") -# instead of manipulating the string utilizing just KornShell's repetition -# control structures, this could be done just like it was done before at the -# old rconfig() function. -function dotini { - file="$1" - - # The function shall fail before "allocating" anything in memory. - # This may sound like a worry that a C programmer might have, but it's - # just a formality when the topic are ksh-ish languages such as - # GNU's Bash or even ksh93 itself. - if [[ ! -e "$file" ]]; then - panic '%s: file %s does not exist.\n' $0 "$file" - fi - - # Allocate an array for recording the file and declarate a - # integer that represents the number of the line. - typeset -a inibuf confline[2] - integer nl l s nconf - - # First of all, we shall remove comments. - # I know this could be done manually using a for-loop, but I think sed - # can be more reliable. - (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ - for ((nl=0 ;; nl++)); do - if read line; then - inibuf[$nl]="$line" - else - break - fi - done - - # Open compound variable syntax - printf '%c' '(' - for ((l=0; l < ${#inibuf[@]}; l++)); do - line="${inibuf[l]}" - - # This gets the INI section. - if section_title="$(rematch "$line" '\[\(.*\)\]')"; then - # The formatted section title. - formatted_section="$(printf '%s' "$section_title" \ - | nawk '{ gsub(" ", "_"); print(tolower($0)) }')" - # We can procceed to the next line. - continue - fi - - nconf=0 - for ((s=0; s < ${#line}; s++ )); do - q="${line:s:1}" - # A value declaration in INI follows the format: - # identifier = "value" - # Or - # identifier=value - # confline[1]=identifier - # confline[2]=value - - if [[ "$q" == '=' ]]; then - ((nconf+= 1 )) - continue - fi - - confline[$nconf]+="$q" - done - - # If there is not a section, it will only declare the INI - # variable and its value on the compound variable. - if [[ ! -n $formatted_section ]]; then - # Using a apostrophe instead of quotations marks - # because, apart from the fact that it works as a - # micro-optimization --- since the shell will be - # treating its contents as vulgar strings instead of - # trying to interpret what is inside them ---, also - # prevents globbing of strings. - # The only thing that it doesn't prevents, - # unfortunately, is the abuse of subshells or malicious - # substitutions, but I do not think this can be a - # problem here. - printf '%s='\''%s'\'' ' \ - "${confline[0]}" "${confline[1]}" - - # Continue to the next line. - continue - fi - - # If it there's a section and the value declaration was already - # parsed, return it as a associative array declaration. - printf '[%s]+=([%s]='\''%s'\'') ' \ - $formatted_section "${confline[0]}" "${confline[1]}" - - # Clean confline[] array. - unset confline[0] confline[1] - done - - # Close compound variable - printf '%c' ')' -} - -# This function "converts" a compound variable generated from a .ini file via -# dotini() to the format "IDENTIFIER=VALUE". -# It can be useful if the program had just implemented .ini files as a way of -# configuration and developers doesn't want to mess with the entire source code. -# It takes the compound variable identifier as a input, for example: -# -# inicompat conf -# -# NOTE: See dotini()'s first "FIXME" and then implement a way to do it. -function inicompat { - nameref inirecord=$1 - integer s k - typeset -a sections - - sections=( ${!inirecord[@]} ) - - for ((s=0; s<${#sections[@]}; s++ )); do - typeset -a confkeys - - section=${sections[s]} - confkeys=( ${!inirecord[$section][@]} ) - - for (( k=0; k < ${#confkeys[@]}; k++ )); do - confkey=${confkeys[$k]} - confval="${inirecord[$section][$confkey]}" - - eval $(printf '%s=%s' $confkey "$confval") - unset confkey confval - done - unset section confkeys confkey confval - done -} - -# This function writes everything in a program output to a file passed as a -# parameter, else it also writes it to the standard output using tee(1). -# Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. -function logto { - file="$1" - # Do not be scared, just a boolean having a rendezvous with a - # more compact alternative to if-else statements. - c29waGlhZmljYWNvbWlnbwo=$I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR - { $c29waGlhZmljYWNvbWlnbwo && tee "$file"; } \ - || { cat - >> "$file"; } -} - -# map() and record() functions below. -# For the "back-end" implementation, see __record(), -# with the old Bourne/POSIX shell function prototype. -# -# map(): Creates an associative array with identifier, -# variable name and value as its parameters. -# It's really similar to the code found on herbiec in -# this sense, but it was originally used as a "pointeroid" -# for accessing an A.S.T. -function map { - identifier="$1" - variable="$2" - value="$3" - - eval $(__record "$identifier" "$variable" "$value") -} - -# record(): And this creates a compound variable, which -# approachs more a Pascal record than the "old" record() -# --- that was renamed to "map" (as-in Google Go's maps, -# but weakly typed). -function record { - identifier="$1" - variable="$2" - value="$3" - - # Broken-Again Shell, unlike KornShell, can not get - # a function caller by $0, so we will need to - # pre-define whos_calling. - # Doing it specifically on record() because compound - # variables are not supported on Bash. - if [[ -n $BASH ]]; then - export whos_calling=$FUNCNAME - fi - - eval $(__record "$identifier" "$variable" "$value") -} - -# Using the good old Bourne function prototype because it permits that the -# function caller name "escapes" into it. -# This is broken in GNU's Broken-Again Shell --- well, maybe I'm repeating -# this joke too many times, but Bash lives up to its nickname --- but this -# is no problem for now since Bash doesn't support compound variables, -# just associative arrays, so both "map" and "record" can be the same to Bash. -__record() { - # If we are not on Broken-Again, define 'whos_calling'. - if [[ -z $BASH ]]; then - # "London calling to the faraway towns... - # But it wasn't my love... - # Is she still upset with me?" - whos_calling="$0" - fi - identifier="$1" - variable="$2" - value="$3" - - if [[ -z "$BASH" ]]; then # This is for KornShell 93 - # The only thing that changes between record() and map() is the printf - # format before evaluating it into the script. - if [[ "$whos_calling" == 'record' ]]; then - format='%s+=(%s="%s")' - elif [[ "$whos_calling" == 'map' ]]; then - format='%s+=([%s]="%s")' - else - panic '%s: invalid caller '%s'.\n' \ - 'record()/map() backend' "$whos_calling" - fi - else # Broken-Again - if [[ "$whos_calling" == 'record' ]]; then - unset whos_calling - panic \ - '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. "record()".\n' \ - 'record()/map() backend' - fi - format='%s+=(['%s']="%s")' - fi - - if [[ -n "$BASH" ]]; then - printf 'declare -A %s\n' "$identifier" - fi - - # Hope this works. - printf "$format" "$identifier" "$variable" "$value" -} - -# Luiz' stupid (re)match. -# It's my attempt on mimicking BASH_REMATCH functionality -# on pretty much any shell. Made it for using on dotini(), -# but pretty much anyone can adapt this. -function rematch { - # Input string. - s="$1" - - # Regular expression "rule", as a filter. - re="$2" - - # If $re is empty, just exit without questions. - [[ ! -n "$re" ]] && return 0 - - # This gets rid of the capture group syntax that we will be using again - # on sed. egrep(1) could also be used, but I opted for shell built-ins - # since we're already on Korn Shell. - [[ "$s" =~ $(printf '%s' "$re" | sed 's/\\(//; s/\\)//') ]] || return 1 - - printf '%s' "$s" | sed "s/$re/\1/" -} - -# Checks if a function or a variable is defined via its identifier. Analogous -# on purpose to the C preprocessor special operator defined(), meant for being -# used in if conditions. -function defined { - # First it will check if it's a function defined on the environment and/or in - # a sourced file, if it's not, then it will check if it is a variable. - { - type -t "$1" | grep 'function' 2>&1 > /dev/null \ - || test ! -z "$(eval "echo \$$1")" - } \ - || return 1 -} - -# Multiple file input support for realpath(1) -# Basically a boilerplate. -function realpaths { - files=( ${@} ) - for (( count=0; count < ${#files[@]}; count++ )); do - realpath "${files[$count]}" - done - unset count files -} - -# Boilerplate to "cd" -function chdir { cd "$1"; } - -# Just a wrapper to a decompressor such as gzip, xz, bzip2 etc. -# Derived from copy2prefix() at https://git.io/mitzune -function c { - tarball="$2" - # First, cut the absolute path off - tarball_ext="${tarball##*/}" - # Then, the filename itself, - # we just want the extension. - tarball_ext="${tarball_ext##*.}" - case "$tarball_ext" in - gz|tgz) { gzip "$@"; } ;; - xz|txz) { xz "$@"; } ;; - bz2|tbz) { bzip2 "$@"; } ;; - tar) { shift; cat "$@"; } ;; - *) printerr "$0: File format not recognized." ;; - esac -} - -# This "generates" wrappers for elevating permissions when needed. -# Be careful. -# Derived from check_doas() at https://git.io/mitzune -function check_elevate_method { - # Clever way to get UID without having to use id(1) or $UID itself. - # Check if UID is defined; small fix for using GNU Broken-Again Shell - # instead of Korn Shell 93, since $UID is read-only on GNU's Shell. - # We'll be making it public because many scripts will use it later. - # Using export directly on variable declaration since it would require to - # use another comparison for knowing if UID is available if we export just - # at the end. - [[ -z $UID ]] && export UID="$(grep $(whoami) /etc/passwd | cut -d: -f3)" - - # Cache the user name from whoami(1) and, unlike $USER, made it read-only - # to prevent manipulation from overwriting. - readonly user="$(whoami)" - - if $(grep "$user" /etc/doas.conf &>/dev/null); then - function elevate { doas -- "$@"; } - typeset -fx elevate - elif $(sudo -v 2>/dev/null); then - function elevate { sudo -- "$@"; } - typeset -fx elevate - elif [[ $UID == 0 ]]; then - printerr 'Warning: running as root. This isn'\''t recommended.\n' - elif $(groups $user | grep 'wheel' >/dev/null); then - printerr \ - 'Warning: %s can log directly as root, although using sudo/doas is preferable.\n' \ - "$user" - function elevate { su -c "$@"; } - typeset -fx elevate - else - printerr 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' - exit 10 - fi - - export user -} - -# Use this function both for errors and warnings -function printerr { - printf "$@" 1>&2 -} - -# And use this for fatal errors, it will exit the script. -function panic { - msgbuf="$(printf "$@")" - printf 1>&2 'panic: %s' "$msgbuf" - exit 255 -} From 686231f8b5b7cbf6781bee697eabf4119c872c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 28 Jul 2024 01:53:46 -0300 Subject: [PATCH 060/128] chore: Simple quotes --- build.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ksh b/build.ksh index a769bbb..3986294 100755 --- a/build.ksh +++ b/build.ksh @@ -13,7 +13,7 @@ progdir="$(cd "$(dirname "$progname")"; pwd -P)" # Immediatly source and run the platform checks # before doing anything else. -_make "checks/platform" +_make 'checks/platform' . "$progdir/build-system/internals/helpers/posix-alt.shi" . "$progdir/build-system/internals/helpers/helpers.shi" From bcefab7855b92c0baf728d4ea5eb38b7af7f3eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 27 Jul 2024 23:17:34 -0300 Subject: [PATCH 061/128] fix: Removed duplicated dot at _make(). --- build-system/internals/helpers/makier.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/internals/helpers/makier.ksh b/build-system/internals/helpers/makier.ksh index bb5a54a..08134f2 100644 --- a/build-system/internals/helpers/makier.ksh +++ b/build-system/internals/helpers/makier.ksh @@ -7,5 +7,5 @@ _make(){ tak="$1" shift # Remove '$1' - . "$(printf '%s/%s/%s.%s' "$pd" "$td" "$tak" "$lang")" "${@:-''}" + . "$(printf '%s/%s/%s%s' "$pd" "$td" "$tak" "$lang")" "${@:-''}" } From 921e69cd616844b2d4060f6431185b747f168dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 28 Jul 2024 09:36:38 -0300 Subject: [PATCH 062/128] fix: Define OBJDIR --- build-system/tasks/disk/populate.ksh | 13 ++++++++----- build-system/work.ini | 8 +++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/build-system/tasks/disk/populate.ksh b/build-system/tasks/disk/populate.ksh index ce2a927..4dac4bd 100644 --- a/build-system/tasks/disk/populate.ksh +++ b/build-system/tasks/disk/populate.ksh @@ -1,8 +1,11 @@ # STEP 1.5: Populate the file system # This function will run the cmd/populate_fhs.sh script and create directories # for the toolchains that will be built. +set -x +SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" +PKGDIR="${PKGDIR:-"$COPA/usr/tmp/plaza"}" +OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" -SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" # Also declare who will be our log file. blackbox="$COPA/build.log.$CPU" @@ -10,7 +13,7 @@ blackbox="$COPA/build.log.$CPU" # toolchain and intermediary chroot toolchain. printerr 'Info: Making directories in %s for the building toolchains.\n' \ "$COPA" -elevate mkdir "$COPA/"{cgnu,llvm}tools +elevate mkdir "$COPA/"{cgnu,llvm}tools "$OBJDIR" "$PKGDIR" (cd "$COPA"; ls -lah .) # Make a symbolic link from $COPA/cgnutools to /cgnutools, the same @@ -51,7 +54,7 @@ printerr 'Info: Initializing blackbox file (%s) for the build.\n' \ "$blackbox" ( cd "$COPA"; elevate sh -c "> $blackbox; chown $user $blackbox" ) -printerr 'Info: Making %s, %s and %s writable by the current user.\n' \ - $(realpaths /{cgnu,llvm}tools) "$SRCDIR" -elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" +printerr 'Info: Making %s, %s, %s, %s and %s writable by the current user.\n' \ + $(realpaths /{cgnu,llvm}tools) "$SRCDIR" "$OBJDIR" "$PKGDIR" +elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" "$OBJDIR" "$PKGDIR" export blackbox SRCDIR diff --git a/build-system/work.ini b/build-system/work.ini index 0a95a5f..28098ff 100644 --- a/build-system/work.ini +++ b/build-system/work.ini @@ -13,7 +13,9 @@ ; Usually, when building up to the toolchain, it is placed on ; the trash. You may wish to change it if your trash directory ; is too small, or just change the trash directory to other place. -; TRASH_PREFIX="/tmp" -TRASH_PREFIX="/tmp/" -PKGDIR="/tmp/plaza" +; Per default, PKGDIR and OBJDIR are saved in the same disk in +; which Copacabana is going to be built. +; +; TRASH_PREFIX="" +; PKGDIR="" ; OBJDIR="" From 8c70a955e289881d6bf486b707a4b7b720d0b474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 31 Jul 2024 18:58:29 -0300 Subject: [PATCH 063/128] fix: INI parser. Both FIXME's fixed, the first one kind of cowardly. --- build-system/internals/helpers/rconfig.shi | 118 +++++++++------------ 1 file changed, 48 insertions(+), 70 deletions(-) diff --git a/build-system/internals/helpers/rconfig.shi b/build-system/internals/helpers/rconfig.shi index 8d5bd13..68167be 100644 --- a/build-system/internals/helpers/rconfig.shi +++ b/build-system/internals/helpers/rconfig.shi @@ -2,6 +2,7 @@ # Internal library for reading INI/key-value configuration # files in the Copacabana build system. # Meant to be used with Korn Shell 93. +# # Copyright (c) 2023-2024 Pindorama # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA @@ -38,7 +39,7 @@ function rconfig { else break fi - done + done fi } @@ -49,49 +50,27 @@ function rconfig { # eval private_config=$(dotini conf.ini) # Then you could just access like so: # printf '%s\n' "${private_config[SectName][KeyName]}" -# It does not outsource record() or map(), so there's more independence and -# flexibility on choosing identifiers for your INI file configuration. -# -# FIXME: When I got time --- or someone else that knows at least a bit of -# KornShell shows up ---, this parser needs to be fixed to support INI files -# that don't explicitly declare a section. -# Sure thing that second-rate hacks such as creating a default section called -# "global" were already thought of, so the ideal is to have just what is being -# described in the code. -# I could fix this in some hours, but I'm willing to work more on the rest of -# the build system instead of just some isolate functions that are already -# compliant with its needs. -# -# FIXME: Also it would be helpful to support files that use spaces between the -# identifier and value, for example: -# -# [sectname] -# keyname = value -# keyname_2 = "Another value" -# -# Being optimistic and careless about using shell built-ins (read as "read") -# instead of manipulating the string utilizing just KornShell's repetition -# control structures, this could be done just like it was done before at the -# old rconfig() function. +# It does not outsource record() or map(), so there's more independence +# and flexibility on choosing identifiers for your INI file configuration. function dotini { file="$1" # The function shall fail before "allocating" anything in memory. - # This may sound like a worry that a C programmer might have, but it's - # just a formality when the topic are ksh-ish languages such as - # GNU's Bash or even ksh93 itself. + # This may sound like a worry that a C programmer might have, but + # it's just a formality when the topic are ksh-ish languages such + # as GNU's Bash or even ksh93 itself. if [[ ! -e "$file" ]]; then panic '%s: file %s does not exist.\n' $0 "$file" fi - # Allocate an array for recording the file and declarate a - # integer that represents the number of the line. + # Allocate an array for recording the file and declarate + # a integer that represents the number of the line. typeset -a inibuf confline[2] - integer nl l s nconf + integer nl l s # First of all, we shall remove comments. - # I know this could be done manually using a for-loop, but I think sed - # can be more reliable. + # I know this could be done manually using a for-loop, + # but I think sed can be more reliable. (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ for ((nl=0 ;; nl++)); do if read line; then @@ -101,11 +80,13 @@ function dotini { fi done - # Open compound variable syntax + # Open compound variable syntax. printf '%c' '(' + + # Parse each line. for ((l=0; l < ${#inibuf[@]}; l++)); do line="${inibuf[l]}" - + # This gets the INI section. if section_title="$(rematch "$line" '\[\(.*\)\]')"; then # The formatted section title. @@ -115,23 +96,14 @@ function dotini { continue fi - nconf=0 - for ((s=0; s < ${#line}; s++ )); do - q="${line:s:1}" - # A value declaration in INI follows the format: - # identifier = "value" - # Or - # identifier=value - # confline[1]=identifier - # confline[2]=value - - if [[ "$q" == '=' ]]; then - ((nconf+= 1 )) - continue - fi - - confline[$nconf]+="$q" - done + # A value declaration in INI follows the format: + # identifier = "value" + # Or + # identifier=value + # confline[1]=identifier + # confline[2]=value + confline[0]="${line%%=*}" + confline[1]="${line##*=}" # If there is not a section, it will only declare the INI # variable and its value on the compound variable. @@ -145,25 +117,29 @@ function dotini { # The only thing that it doesn't prevents, # unfortunately, is the abuse of subshells or malicious # substitutions, but I do not think this can be a - # problem here. - printf '%s='\''%s'\'' ' \ - "${confline[0]}" "${confline[1]}" - + # problem here. + printf '[%s]='\''%s'\'' ' \ + "${confline[0]}" "${confline[1]}" + # Continue to the next line. continue fi - # If it there's a section and the value declaration was already - # parsed, return it as a associative array declaration. + # If it there's a section and the value declaration was + # already parsed, return it as a associative array declaration. printf '[%s]+=([%s]='\''%s'\'') ' \ - $formatted_section "${confline[0]}" "${confline[1]}" + $formatted_section "${confline[0]}" "${confline[1]}" # Clean confline[] array. unset confline[0] confline[1] done - # Close compound variable + # Close compound variable. printf '%c' ')' + + # Remove the section name from the memory, + # since it can cause fuss later. + unset formatted_section } # This function "converts" a compound variable generated from a .ini file via @@ -173,13 +149,10 @@ function dotini { # It takes the compound variable identifier as a input, for example: # # inicompat conf -# -# NOTE: See dotini()'s first "FIXME" and then implement a way to do it. function inicompat { nameref inirecord=$1 integer s k typeset -a sections - sections=( ${!inirecord[@]} ) for ((s=0; s<${#sections[@]}; s++ )); do @@ -188,13 +161,18 @@ function inicompat { section=${sections[s]} confkeys=( ${!inirecord[$section][@]} ) - for (( k=0; k < ${#confkeys[@]}; k++ )); do - confkey=${confkeys[$k]} - confval="${inirecord[$section][$confkey]}" - - eval $(printf '%s=%s' $confkey "$confval") - unset confkey confval - done + case "${confkeys[0]}" in + 0) # If dealing with section-less file. + eval $(printf '%s=%s' \ + $section "${inirecord[$section]}") ;; + *) # Default... Or dealing with sections. + for (( k=0; k < ${#confkeys[@]}; k++ )); do + confkey=${confkeys[$k]} + confval="${inirecord[$section][$confkey]}" + eval $(printf '%s=%s' $confkey "$confval") + unset confkey confval + done ;; + esac unset section confkeys confkey confval done } From 345e2d8c95574d2f92896ea93a60141b097d4d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 31 Jul 2024 19:29:08 -0300 Subject: [PATCH 064/128] feat: More refactoring. --- build-system/internals/helpers/disks.shi | 5 ++ build-system/internals/helpers/helpers.shi | 30 +------- build-system/internals/helpers/log.shi | 31 ++++++++ build-system/internals/helpers/makier.ksh | 5 +- build-system/internals/helpers/posix-alt.shi | 75 ++++++++++---------- build-system/machine.ini | 4 +- build-system/tasks/disk/populate.ksh | 2 +- build-system/work.ini | 2 +- build.ksh | 9 +-- 9 files changed, 86 insertions(+), 77 deletions(-) create mode 100644 build-system/internals/helpers/log.shi diff --git a/build-system/internals/helpers/disks.shi b/build-system/internals/helpers/disks.shi index 9ba8f85..a3865de 100644 --- a/build-system/internals/helpers/disks.shi +++ b/build-system/internals/helpers/disks.shi @@ -1,4 +1,9 @@ # vim: set filetype=sh : +# Functions to deal with disks and filesystems. + +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA # May use this function later, no use for it for now. function get_size_blocks { diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi index 5eb87be..40e6db2 100644 --- a/build-system/internals/helpers/helpers.shi +++ b/build-system/internals/helpers/helpers.shi @@ -1,8 +1,9 @@ # vim: set filetype=sh : # Internal helper library for the Copacabana build system. # Meant to be used with Korn Shell 93. -# Copyright (c) 2023 Pindorama -# Luiz Antônio Rangel +# +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA # # "'Liberdade, Igualdade, Fraternidade', @@ -15,18 +16,6 @@ readonly KSH93_RELEASE=$(printf '%s' "${KSH_VERSION:-0}" \ | nawk '{ gsub("-", ""); print $NF; }') export BUILD_KSH KSH93_RELEASE -# This function writes everything in a program output to a file passed as a -# parameter, else it also writes it to the standard output using tee(1). -# Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. -function logto { - file="$1" - # Do not be scared, just a boolean having a rendezvous with a - # more compact alternative to if-else statements. - c29waGlhZmljYWNvbWlnbwo=$I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR - { $c29waGlhZmljYWNvbWlnbwo && tee "$file"; } \ - || { cat - >> "$file"; } -} - # map() and record() functions below. # For the "back-end" implementation, see __record(), # with the old Bourne/POSIX shell function prototype. @@ -222,16 +211,3 @@ function check_elevate_method { export user } - -# Use this function both for errors and warnings -function printerr { - printf "$@" 1>&2 -} - -# And use this for fatal errors, it will exit the script. -function panic { - msgbuf="$(printf "$@")" - printerr 'panic: %s' "$msgbuf" - - exit 255 -} diff --git a/build-system/internals/helpers/log.shi b/build-system/internals/helpers/log.shi new file mode 100644 index 0000000..c2da47d --- /dev/null +++ b/build-system/internals/helpers/log.shi @@ -0,0 +1,31 @@ +# vim: set filetype=sh : +# Error handling and logging in general. + +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA + +# Use this function both for errors and warnings +function printerr { + printf "$@" 1>&2 +} + +# And use this for fatal errors, it will exit the script. +function panic { + msgbuf="$(printf "$@")" + printerr 'panic: %s' "$msgbuf" + + exit 255 +} + +# This function writes everything in a program output to a file passed as a +# parameter, else it also writes it to the standard output using tee(1). +# Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. +function logto { + file="$1" + # Do not be scared, just a boolean having a rendezvous with a + # more compact alternative to if-else statements. + c29waGlhZmljYWNvbWlnbwo=$I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR + { $c29waGlhZmljYWNvbWlnbwo && tee "$file"; } \ + || { cat - >> "$file"; } +} diff --git a/build-system/internals/helpers/makier.ksh b/build-system/internals/helpers/makier.ksh index 08134f2..7114e6d 100644 --- a/build-system/internals/helpers/makier.ksh +++ b/build-system/internals/helpers/makier.ksh @@ -1,11 +1,10 @@ # Boilerplate for running tasks. _make(){ - td='build-system/tasks' lang='.ksh' - pd="$progdir" + tasks="${tasks:?"task directory not defined"}" tak="$1" shift # Remove '$1' - . "$(printf '%s/%s/%s%s' "$pd" "$td" "$tak" "$lang")" "${@:-''}" + . "$(printf '%s/%s%s' "$tasks" "$tak" "$lang")" "${@:-''}" } diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/helpers/posix-alt.shi index be35da8..71851f5 100644 --- a/build-system/internals/helpers/posix-alt.shi +++ b/build-system/internals/helpers/posix-alt.shi @@ -9,9 +9,7 @@ # SPDX-Licence-Identifier: Caldera # Include dirs(), pushd() and popd() -. "$progdir/build-system/internals/helpers/dirs.shi" - -# vim: filetype=sh : +#. "$progdir/build-system/internals/helpers/dirs.shi" # basename basename(){ @@ -23,52 +21,57 @@ basename(){ # realpath realpath(){ - if ! command -v readlink 2>&1 >/dev/null; then - # ./sources.txt -> sources.txt - file_basename="`basename "$1"`" - # ./sources.txt -> . - file_dirname="`dirname "$1"`" - # get the absolute directory name - # example: ./sources.txt -> /usr/src/copacabana-repo/sources.txt - # cd ./; pwd -> /usr/src/copacabana-repo - echo "`(cd "${file_dirname}"; pwd)`/${file_basename}" - else - readlink -f "$1" - fi + if ! command -v readlink 2>&1 >/dev/null; then + # ./sources.txt -> sources.txt + file_basename="`basename "$1"`" + # ./sources.txt -> . + file_dirname="`dirname "$1"`" + # get the absolute directory name + # example: ./sources.txt -> /usr/src/copacabana-repo/sources.txt + # cd ./; pwd -> /usr/src/copacabana-repo + echo "`(cd "${file_dirname}"; pwd)`/${file_basename}" + else + readlink -f "$1" + fi } # wc -l lines(){ - while IFS= read -r LINE || [ -n "${LINE}" ]; do - LINES=$[ ${LINES} + 1 ] - done < "${1}" - printf '%s\n' "$LINES" + LINES=0 + while IFS= read -r l || [ -n "$l" ]; do + LINES=$((LINES + 1)) + done < "$1" + printf '%d\n' "$LINES" unset LINES } # timeout timeout(){ + time="$1" + shift if ! command -v timeout 2>&1 >/dev/null; then - time="$1" - shift - "$@" & PID="${!}"; sleep "$time" && kill "$PID" + "$@" & PID="$!"; sleep "$time" && kill "$PID" else - command timeout "$@" + command timeout "$time" "$@" fi } # nproc nproc(){ - case "`uname -s`" in - Darwin) getconf '_NPROCESSORS_ONLN';; - Linux) if [ `getconf HEIRLOOM_TOOLCHEST_VERSION` -lt 230305 ]; then - grep -c 'processor' /proc/cpuinfo - else - getconf '_NPROCESSORS_ONLN' - fi ;; - FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN';; - SunOS) echo "`ksh93 -c 'getconf NPROCESSORS_ONLN'`" ;; - esac + case "`uname -s`" in + Darwin) getconf '_NPROCESSORS_ONLN' + break ;; + Linux) if [ `getconf HEIRLOOM_TOOLCHEST_VERSION` -lt 230305 ]; then + grep -c 'processor' /proc/cpuinfo + else + getconf '_NPROCESSORS_ONLN' + fi + break ;; + FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN' + break ;; + SunOS) echo "`ksh93 -c 'getconf NPROCESSORS_ONLN'`" + break ;; + esac } # The # macro for arrays. @@ -86,9 +89,9 @@ trim_home_path(){ # which can't source a file from the current # directory. source(){ - { [ -e "$1" ] && [ -r "$1" ] \ - && . "$(realpath "$1")"; } \ - || return 1 + { [ -e "$1" ] && [ -r "$1" ] \ + && . "$(realpath "$1")"; } \ + || return 1 } ##End of alternatives section diff --git a/build-system/machine.ini b/build-system/machine.ini index b0f3869..922f0f7 100644 --- a/build-system/machine.ini +++ b/build-system/machine.ini @@ -9,8 +9,8 @@ BINARY_CACHE="false" I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" [Disk managenment] -VIRTUAL_DISK="true" -DISK_BLOCK="/tmp/COPA.IMG" +VIRTUAL_DISK="false" +DISK_BLOCK="/dev/sdb" VIRTUADISK_SIZE=10 ; DISK_LABEL="" UMOUNT_ON_EXIT="false" diff --git a/build-system/tasks/disk/populate.ksh b/build-system/tasks/disk/populate.ksh index 4dac4bd..b07fc17 100644 --- a/build-system/tasks/disk/populate.ksh +++ b/build-system/tasks/disk/populate.ksh @@ -13,7 +13,7 @@ blackbox="$COPA/build.log.$CPU" # toolchain and intermediary chroot toolchain. printerr 'Info: Making directories in %s for the building toolchains.\n' \ "$COPA" -elevate mkdir "$COPA/"{cgnu,llvm}tools "$OBJDIR" "$PKGDIR" +elevate mkdir -p "$COPA/"{cgnu,llvm}tools "$OBJDIR" "$PKGDIR" (cd "$COPA"; ls -lah .) # Make a symbolic link from $COPA/cgnutools to /cgnutools, the same diff --git a/build-system/work.ini b/build-system/work.ini index 28098ff..5526926 100644 --- a/build-system/work.ini +++ b/build-system/work.ini @@ -16,6 +16,6 @@ ; Per default, PKGDIR and OBJDIR are saved in the same disk in ; which Copacabana is going to be built. ; -; TRASH_PREFIX="" +TRASH_PREFIX="/tmp" ; PKGDIR="" ; OBJDIR="" diff --git a/build.ksh b/build.ksh index 3986294..44125cd 100755 --- a/build.ksh +++ b/build.ksh @@ -9,6 +9,7 @@ progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" # _make +tasks="$progdir/build-system/tasks" . "$progdir/build-system/internals/helpers/makier.ksh" # Immediatly source and run the platform checks @@ -16,6 +17,7 @@ progdir="$(cd "$(dirname "$progname")"; pwd -P)" _make 'checks/platform' . "$progdir/build-system/internals/helpers/posix-alt.shi" +. "$progdir/build-system/internals/helpers/log.shi" . "$progdir/build-system/internals/helpers/helpers.shi" . "$progdir/build-system/internals/helpers/rconfig.shi" . "$progdir/build-system/internals/helpers/disks.shi" @@ -32,14 +34,7 @@ _make 'checks/dependencies' _make 'disk/create_disk' "$DISK_BLOCK" _make 'disk/populate' _make get_sources sources.txt sources.sha256 -#build cross-tools cross/mussel #build cross-tools "base/kernel-headers" "dev/GNUBinutils" \ # "dev/GNUcc" "base/LibC" "dev/GNUcc" -#build tools "base/kernel-headers" "dev/GNUBinutils" \ -# "dev/GNUcc" "base/LibC" "dev/GNUcc" - -#build base "base/kernel-headers" "dev/GNUBinutils" \ -# "dev/GNUcc" "base/LibC" "dev/GNUcc" -#build close _make finish From 53936f5c7728ae3ffe1e5ad63f899f12c1ab88ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 31 Jul 2024 21:19:18 -0300 Subject: [PATCH 065/128] fix: Only match first '=' for confline[1] at rconfig.shi. --- build-system/internals/helpers/rconfig.shi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/internals/helpers/rconfig.shi b/build-system/internals/helpers/rconfig.shi index 68167be..57792d6 100644 --- a/build-system/internals/helpers/rconfig.shi +++ b/build-system/internals/helpers/rconfig.shi @@ -103,7 +103,7 @@ function dotini { # confline[1]=identifier # confline[2]=value confline[0]="${line%%=*}" - confline[1]="${line##*=}" + confline[1]="${line#*=}" # If there is not a section, it will only declare the INI # variable and its value on the compound variable. From 9b02f311c463c30e322c50cb45063e4d778a647f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 31 Jul 2024 21:48:59 -0300 Subject: [PATCH 066/128] chore: Bullet-proofing against subshells at .INI files. --- build-system/internals/helpers/rconfig.shi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build-system/internals/helpers/rconfig.shi b/build-system/internals/helpers/rconfig.shi index 57792d6..81173f3 100644 --- a/build-system/internals/helpers/rconfig.shi +++ b/build-system/internals/helpers/rconfig.shi @@ -103,7 +103,8 @@ function dotini { # confline[1]=identifier # confline[2]=value confline[0]="${line%%=*}" - confline[1]="${line#*=}" + # Bullet-proofing against subshells. + confline[1]="$(printf '%q' "${line#*=}")" # If there is not a section, it will only declare the INI # variable and its value on the compound variable. @@ -118,7 +119,7 @@ function dotini { # unfortunately, is the abuse of subshells or malicious # substitutions, but I do not think this can be a # problem here. - printf '[%s]='\''%s'\'' ' \ + printf '[%s]=%s ' \ "${confline[0]}" "${confline[1]}" # Continue to the next line. @@ -127,7 +128,7 @@ function dotini { # If it there's a section and the value declaration was # already parsed, return it as a associative array declaration. - printf '[%s]+=([%s]='\''%s'\'') ' \ + printf '[%s]+=([%s]=%s) ' \ $formatted_section "${confline[0]}" "${confline[1]}" # Clean confline[] array. From dbb8770a6a716c6e99c79fcadd1c97d3e9564bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 31 Jul 2024 21:57:52 -0300 Subject: [PATCH 067/128] chore: Also on inicompat() at rconfig.shi. --- build-system/internals/helpers/rconfig.shi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build-system/internals/helpers/rconfig.shi b/build-system/internals/helpers/rconfig.shi index 81173f3..30444ec 100644 --- a/build-system/internals/helpers/rconfig.shi +++ b/build-system/internals/helpers/rconfig.shi @@ -154,8 +154,8 @@ function inicompat { nameref inirecord=$1 integer s k typeset -a sections + fmt='%s='\''%s'\''' sections=( ${!inirecord[@]} ) - for ((s=0; s<${#sections[@]}; s++ )); do typeset -a confkeys @@ -164,13 +164,14 @@ function inicompat { case "${confkeys[0]}" in 0) # If dealing with section-less file. - eval $(printf '%s=%s' \ + eval $(printf "$fmt" \ $section "${inirecord[$section]}") ;; *) # Default... Or dealing with sections. for (( k=0; k < ${#confkeys[@]}; k++ )); do confkey=${confkeys[$k]} confval="${inirecord[$section][$confkey]}" - eval $(printf '%s=%s' $confkey "$confval") + eval $(printf "$fmt" \ + $confkey "$confval") unset confkey confval done ;; esac From 766d46588f472ee9f80a7b6b2f1fcf8a7d126334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 1 Aug 2024 09:21:06 -0300 Subject: [PATCH 068/128] chore!: Removed cmd/ and helpers/ subfolders and use just internal/. Also removed driver.ksh since the method for building packages will be differing from now. --- build-system/internals/cmd/driver.ksh | 192 ------------------ build-system/internals/{helpers => }/dirs.shi | 0 .../internals/{helpers => }/disks.shi | 0 .../internals/{helpers => }/helpers.shi | 0 .../internals/{helpers => }/ini-test/php.ini | 0 .../{helpers => }/ini-test/test2.ini | 1 + build-system/internals/{helpers => }/log.shi | 0 .../internals/{helpers => }/makier.ksh | 0 .../internals/{helpers => }/posix-alt.shi | 0 .../internals/{helpers => }/rconfig.shi | 0 build.ksh | 16 +- 11 files changed, 9 insertions(+), 200 deletions(-) delete mode 100755 build-system/internals/cmd/driver.ksh rename build-system/internals/{helpers => }/dirs.shi (100%) rename build-system/internals/{helpers => }/disks.shi (100%) rename build-system/internals/{helpers => }/helpers.shi (100%) rename build-system/internals/{helpers => }/ini-test/php.ini (100%) rename build-system/internals/{helpers => }/ini-test/test2.ini (90%) rename build-system/internals/{helpers => }/log.shi (100%) rename build-system/internals/{helpers => }/makier.ksh (100%) rename build-system/internals/{helpers => }/posix-alt.shi (100%) rename build-system/internals/{helpers => }/rconfig.shi (100%) diff --git a/build-system/internals/cmd/driver.ksh b/build-system/internals/cmd/driver.ksh deleted file mode 100755 index c7dda46..0000000 --- a/build-system/internals/cmd/driver.ksh +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env ksh93 -# Driver for running Copacabana package build recipes. -# Note: This script isn't meant to be run standalone, since it makes use of -# variables exported from the main script, build.ksh - -# shellcheck disable=SC2068 - -drvname="$0" - -# If (and when) ran from build.ksh, this will $0 will be build.ksh, so we can -# get its directory and touché: we also have the base directory for pkgbuilds -# --- since it is intended to be in the same directory as the build system -# itself. -build_kshdir="$(cd "$(dirname "${0##*/}")"; pwd -P)" -progdir="$build_kshdir" -alambiko_directory="$progdir/packages" -patch_directory="$progdir/patches" - -# Load helper library -source "$build_kshdir/build-system/internals/helpers/helpers.shi" -source "$build_kshdir/build-system/internals/helpers/dirs.shi" - -# Base directories for building packages, one is for residue, object -# files and source code ("slact"), the other is for built packages ("aqua -# vitæ"). -base_objdir="$trash/slact" -base_destdir="$trash/aqua_vitæ" - -function main { - set -e - - while getopts ":D:i" options; do - case "$options" in - i) info_flag='true' ;; - D) typeset -x VARIANT="${OPTARG:-base}" ;; - *|h) print_help "$OPTARG" ;; - esac - done - shift $(( OPTIND - 1 )) - - if (( $# == 0 )); then - print_help - fi - - [ $info_flag ] \ - && print_pkgbuild_info "$1" - - printerr '%s: Info: Building %s for %s.\n' "$drvname" "$1" "$VARIANT" | tee "$blackbox" - transmutacio "$1" -} - -function eval_pkgbuild_path { - set -x - package="$1" - package_name="${package#*/}" - category="${package%/*}" - - package_recipe="$(find \ - "$alambiko_directory/$category/$package_name" \ - -name 'pkgbuild' -type f -print)" \ - || { printerr '%s: find failed.\n' "$driver_name"; return 1; } - printf '%s\n' "$package_recipe" -} - -function read_pkgbuild { - package_recipe="$(eval_pkgbuild_path "$1")" - - # Treat the output from get_package_info() to remove white lines and - # comments, also eval the variables in the script. - read_manifest <(get_pkgbuild_info "$package_recipe") - - # Source all the functions defined - source <(get_pkgbuild_functions "$package_recipe") -} - -function print_pkgbuild_info { - get_pkgbuild_info "$1" | sed '/#/d; /^$/d' \ - | while IFS='=' read identifier value; do - printf '%s:%10s\n' "$identifier" "$value" - done - exit -} - -function get_pkgbuild_info { - package_recipe="$1" - - printf "pkgbuild_dir=%s\n" "$package_recipe" - # This will read package information from the pkgbuild header, which is - # defined until it reachs a function declaration - nawk '/.\(\)/{ exit } 1' "$package_recipe" -} - -function get_pkgbuild_functions { - package_recipe="$1" - - # This will read the pkgbuild functions until the end of the file. - # nawk '/.\(\)/, !/./' "$package_recipe" - cat "$package_recipe" -} - -function transmutacio { - set -x - set -e - package="$1" - - read_pkgbuild "$package" - - # Where will files be extracted, this folder may ocupy a lot of space - # depending on the packages built. - OBJDIR="$base_objdir/$VARIANT" - - # Destdir for packages. - DESTDIR="$base_destdir/$VARIANT/${Archive_name%.t*}" - export OBJDIR DESTDIR - - # Create them. - mkdir -p "$OBJDIR" "$DESTDIR" - - # Find the source code archive inside the $SRCDIR using find(1) - # so we won't be having to alias categories from Alambiko with - # internal Copacabana category names. - source_archive_dir="$(dirname "$(find "$SRCDIR" -name "$Archive_name" -type f -print)")" - - # "Shared" methods for functions defined - shared_methods=('configure' 'build' 'make_pkg') - - { - if defined unarchive; then - ( cd "$source_archive_dir"; unarchive ) - if (( $? != 0 )); then - printerr 'Error: Failed to unarchive %s from %s. Error code: %d\n' \ - "$Archive_name" "$package" $? - fi - fi - - # Check if every "standard" pkgbuild function is defined before running, - # so we won't have problems with future "boilerplate" pkgbuilds that - # just create symbolic links, for instance. - for (( c=0; c <= ${#shared_methods[@]}; c++ )); do - if defined $(printf '%s' ${shared_methods[$c]}); then - if [[ "${shared_methods[$c]}" == 'make_pkg' ]]; then - Destdir="$DESTDIR/$Destdir" - DESTDIR="$Destdir" - ROOT="$DESTDIR" - export DESTDIR OBJDIR ROOT - mkdir -p "$ROOT" - fi - ( cd "$OBJDIR"; ${shared_methods[$c]} ) - if (( $? != 0 )); then - printerr 'Error: Failed to %s %s. Error code: %d\n' \ - "${shared_methods[$c]}" "$package" $? - fi - fi - done - - if defined post_install; then - # If $Destdir not defined from the pkgbuild, default it - # to $DESTDIR. It is expected to be declared when the package - # needs to be installed in a custom location. - # For instance, cross-tools' and tools' base/LibC package. - ( cd "$DESTDIR"; post_install ) - if (( $? != 0 )); then - printerr \ - 'Error: Failed to do the post install process on %s at %s. Error code: %d\n' \ - "$package" "$DESTDIR" $? - fi - fi - } 2>&1 | logto "$blackbox" -} - -function read_manifest { - (sed '/#/d; /^$/d;' "$1") \ - | for ((;;)); do - if IFS='=' read id v; then - printf '%s=%s\n' "$id" "$v" - else - break - fi - done -} - -function print_help { - printerr '%s: illegal option "%s" -The following options are used for debugging: - -i: Print pkgbuild information. -The following options are meant for defining custom build options: - -D: Define the pkgbuild '\''VARIANT'\'' internal variable.\n' \ - "$drvname" "$1" - exit 1 -} - -main $@ diff --git a/build-system/internals/helpers/dirs.shi b/build-system/internals/dirs.shi similarity index 100% rename from build-system/internals/helpers/dirs.shi rename to build-system/internals/dirs.shi diff --git a/build-system/internals/helpers/disks.shi b/build-system/internals/disks.shi similarity index 100% rename from build-system/internals/helpers/disks.shi rename to build-system/internals/disks.shi diff --git a/build-system/internals/helpers/helpers.shi b/build-system/internals/helpers.shi similarity index 100% rename from build-system/internals/helpers/helpers.shi rename to build-system/internals/helpers.shi diff --git a/build-system/internals/helpers/ini-test/php.ini b/build-system/internals/ini-test/php.ini similarity index 100% rename from build-system/internals/helpers/ini-test/php.ini rename to build-system/internals/ini-test/php.ini diff --git a/build-system/internals/helpers/ini-test/test2.ini b/build-system/internals/ini-test/test2.ini similarity index 90% rename from build-system/internals/helpers/ini-test/test2.ini rename to build-system/internals/ini-test/test2.ini index c705a40..78349e0 100644 --- a/build-system/internals/helpers/ini-test/test2.ini +++ b/build-system/internals/ini-test/test2.ini @@ -5,6 +5,7 @@ test1c="b" test1d="b" ; test comment test1e=b +breaking=$(echo bad) ; Liberdade, igualdade e fraternidade, é o seguinte: ; se tem liberdade, tem que ter igualdade, amor e fraternidade ; E vimos! diff --git a/build-system/internals/helpers/log.shi b/build-system/internals/log.shi similarity index 100% rename from build-system/internals/helpers/log.shi rename to build-system/internals/log.shi diff --git a/build-system/internals/helpers/makier.ksh b/build-system/internals/makier.ksh similarity index 100% rename from build-system/internals/helpers/makier.ksh rename to build-system/internals/makier.ksh diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/posix-alt.shi similarity index 100% rename from build-system/internals/helpers/posix-alt.shi rename to build-system/internals/posix-alt.shi diff --git a/build-system/internals/helpers/rconfig.shi b/build-system/internals/rconfig.shi similarity index 100% rename from build-system/internals/helpers/rconfig.shi rename to build-system/internals/rconfig.shi diff --git a/build.ksh b/build.ksh index 44125cd..f9a38cd 100755 --- a/build.ksh +++ b/build.ksh @@ -10,17 +10,17 @@ progdir="$(cd "$(dirname "$progname")"; pwd -P)" # _make tasks="$progdir/build-system/tasks" -. "$progdir/build-system/internals/helpers/makier.ksh" +. "$progdir/build-system/internals/makier.ksh" -# Immediatly source and run the platform checks -# before doing anything else. +# Immediatly source and run the platform +# checks before doing anything else. _make 'checks/platform' -. "$progdir/build-system/internals/helpers/posix-alt.shi" -. "$progdir/build-system/internals/helpers/log.shi" -. "$progdir/build-system/internals/helpers/helpers.shi" -. "$progdir/build-system/internals/helpers/rconfig.shi" -. "$progdir/build-system/internals/helpers/disks.shi" +. "$progdir/build-system/internals/posix-alt.shi" +. "$progdir/build-system/internals/log.shi" +. "$progdir/build-system/internals/helpers.shi" +. "$progdir/build-system/internals/rconfig.shi" +. "$progdir/build-system/internals/disks.shi" rconfig "$progdir/build-system/machine.ini" rconfig "$progdir/build-system/work.ini" From 3223602875ae0b9d2c0cccf85d435ab7655911ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 2 Aug 2024 18:47:46 -0300 Subject: [PATCH 069/128] docs: Package manager rebranding --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57f4053..5434dbf 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Any other contributions are entirely accepted, for more information read the - [Alambiko (Copacabana package repository)](https://github.com/Projeto-Pindorama/alambiko); - [Heirloom New Generation](http://heirloom-ng.pindorama.dob.jp); -- [The Motoko Package Manager](https://github.com/Projeto-Pindorama/motoko) (**W.I.P**); +- [The Pacote Package Manager](https://github.com/Projeto-Pindorama/pacote) (**W.I.P**); - [Mitzune](https://github.com/Projeto-Pindorama/mitzune); - [L.E.`mount`](https://github.com/Projeto-Pindorama/lemount); - [`isainfo`](https://github.com/Projeto-Pindorama/isainfo); From 1eacc0114526d09bb27ad35179a18ada75012924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 21 Aug 2024 04:24:00 -0300 Subject: [PATCH 070/128] chore: Short change at cmd/download_sources.ksh --- cmd/download_sources.ksh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index ce3deee..baf7518 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -35,7 +35,7 @@ n() { echo "${@}" | wc -w } -realpath(){ +realpath() { file_basename=`basename $1` file_dirname=`dirname $1` # get the absolute directory name @@ -44,7 +44,7 @@ realpath(){ } # Drop-in replacement to GNU nproc. -nproc(){ +nproc() { case "`uname -s`" in Darwin | Linux) getconf '_NPROCESSORS_ONLN';; FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN';; @@ -61,14 +61,18 @@ main() { categories=(`grep '#>' ${sources_file} | tr -d '#> '`) n_categories="`n ${categories[*]}`" - for ((i = 0; i < n_categories; i++)) { - + for ((i=0; i < n_categories; i++)) { + set -x # foo/var => foo\/var category_id="`echo ${categories[${i}]} | sed 's~\/~\\\/~g'`" printf '==> %s\n' "${categories[${i}]}" - # sed: Remove comments (lines starting with %%) - # AWK: Matches #> $category_id | counts until the next and last match | matches #< $category_id | it ends here - urls=(`sed '/%%/d' ${sources_file} | awk "/^#> $category_id$/{flag=1;next}/^#< $category_id$/{flag=0}flag"`) + # AWK: Matches #> $category_id | + # counts until the next and last match | + # matches #< $category_id | + # then removes comments (lines starting with %%) + urls=(`nawk "/^#> $category_id$/{ flag=1; next } + /^#< $category_id$/{ flag=0 } flag && !/^%%/" \ + "$sources_file"`) n_urls="`n ${urls[*]}`" category_dir="$sources_directory/${categories[${i}]}" @@ -78,15 +82,15 @@ main() { # so we're going with it. if ! $USE_ARIA2C; then cd "${category_dir}" || exit 2 - for ((j = 0; j < n_urls; j++)) { - printf 'Downloading %s\n' "`basename ${urls[${j}]}`" + for ((j=0; j < n_urls; j++)) { + printf 'Downloading %s\n' "${urls[$j]##*/}" curl -LO "${urls[${j}]}" } else # Hell yeah, speed. - ( for ((k = 0; k < n_urls; k++)){ + ( for ((j=0; j < n_urls; j++)) { printf '%s\n\tout=%s\n' \ - "${urls[$k]}" "${urls[$k]##*/}" + "${urls[$j]}" "${urls[$j]##*/}" } ) \ | aria2c -q -j `nproc` -x `nproc` -d "$category_dir" -i - fi From d55f6fa632ac1f8bba383bab958b0c6b8660e8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 21 Aug 2024 05:01:00 -0300 Subject: [PATCH 071/128] chore: Another short change at cmd/download_sources.ksh --- cmd/download_sources.ksh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index baf7518..ae48870 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -54,15 +54,14 @@ nproc() { } main() { - sources_file="`realpath ${1}`" - sources_directory="`realpath ${SRCDIR}`" - test -n "${2}" && hashsum_file="`realpath ${2}`" + sources_file="`realpath $1`" + sources_directory="`realpath $SRCDIR`" + test -n "$2" && hashsum_file="`realpath $2`" mkdir -p "$sources_directory" - categories=(`grep '#>' ${sources_file} | tr -d '#> '`) + categories=(`awk '/#>/{$1=""; print $NF }' "$sources_file"`) n_categories="`n ${categories[*]}`" for ((i=0; i < n_categories; i++)) { - set -x # foo/var => foo\/var category_id="`echo ${categories[${i}]} | sed 's~\/~\\\/~g'`" printf '==> %s\n' "${categories[${i}]}" @@ -76,12 +75,12 @@ main() { n_urls="`n ${urls[*]}`" category_dir="$sources_directory/${categories[${i}]}" - mkdir -p "${category_dir}" + mkdir -p "$category_dir" # cURL is slower, but it's present on more systems per default than aria2c, # so we're going with it. if ! $USE_ARIA2C; then - cd "${category_dir}" || exit 2 + cd "$category_dir" || exit 2 for ((j=0; j < n_urls; j++)) { printf 'Downloading %s\n' "${urls[$j]##*/}" curl -LO "${urls[${j}]}" @@ -96,10 +95,10 @@ main() { fi } if `echo ${SHA256CHECK} | grep -i '^y' &>/dev/null` \ - && `test -n "${hashsum_file}"`; then - cd "${sources_directory}" - sha256sum -c "${hashsum_file}" \ - && cd "${OLDPWD}" + && `test -n "$hashsum_file"`; then + cd "$sources_directory" + sha256sum -c "$hashsum_file" \ + && cd "$OLDPWD" fi } From eb5b6c0dfc193d8a5f068bf9b967294c585054fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 21 Aug 2024 05:04:25 -0300 Subject: [PATCH 072/128] chore: Improve nawk command at cmd/download_sources.ksh --- cmd/download_sources.ksh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index ae48870..37db1b2 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -54,11 +54,12 @@ nproc() { } main() { - sources_file="`realpath $1`" - sources_directory="`realpath $SRCDIR`" - test -n "$2" && hashsum_file="`realpath $2`" + sources_file="`realpath "$1"`" + sources_directory="`realpath "$SRCDIR"`" + test -n "$2" && hashsum_file="`realpath "$2"`" mkdir -p "$sources_directory" - categories=(`awk '/#>/{$1=""; print $NF }' "$sources_file"`) + categories=(`nawk '/#>/{$1=""; sub(/^ /,"", $0); print $0 }' \ + "$sources_file"`) n_categories="`n ${categories[*]}`" for ((i=0; i < n_categories; i++)) { From 5906268d6f366c1462e6fc61b3634b76df35f115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 21 Aug 2024 05:22:38 -0300 Subject: [PATCH 073/128] chore: shfmt'ed download_sources.ksh 3 years later --- cmd/download_sources.ksh | 122 ++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index 37db1b2..b71e74c 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh93 +#!/usr/bin/env ksh93 # Simple shell hack to download and SHA256 check source tarballs. # # Copyright 2021 - 2024 Luiz Antônio Rangel (takusuman). @@ -24,83 +24,89 @@ umask 0022 # If we're running from the Copacabana build system, use # internal sha256sum(1) implementation. if $BUILD_KSH; then - build_kshdir="$(cd "$(dirname "${0##*/}")"; pwd -P)" - sha256sum() { "$build_kshdir/cmd/sha256sum.ksh" "$@"; } + build_kshdir="$( + cd "$(dirname "${0##*/}")" + pwd -P + )" + sha256sum() { "$build_kshdir/cmd/sha256sum.ksh" "$@"; } fi # Workaround to the # macro in arrays # which doesn't work properly in bash 4.3 for some reason. n() { - # ambiguous redirect? pipe it. - echo "${@}" | wc -w + # ambiguous redirect? pipe it. + echo "${@}" | wc -w } realpath() { - file_basename=`basename $1` - file_dirname=`dirname $1` + file_basename=$(basename "$1") + file_dirname=$(dirname "$1") # get the absolute directory name # example: ./sources.txt -> /usr/src/copacabana-repo/sources.txt - echo "`cd "${file_dirname}"; pwd`/${file_basename}" + echo "$( + cd "$file_dirname" + pwd + )/$file_basename" } # Drop-in replacement to GNU nproc. nproc() { - case "`uname -s`" in - Darwin | Linux) getconf '_NPROCESSORS_ONLN';; - FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN';; - SunOS) echo "`ksh93 -c 'getconf NPROCESSORS_ONLN'`" ;; - *) echo 1 ;; - esac + case "$(uname -s)" in + Darwin | Linux) getconf '_NPROCESSORS_ONLN' ;; + FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN' ;; + SunOS) echo "$(ksh93 -c 'getconf NPROCESSORS_ONLN')" ;; + *) echo 1 ;; + esac } main() { - sources_file="`realpath "$1"`" - sources_directory="`realpath "$SRCDIR"`" - test -n "$2" && hashsum_file="`realpath "$2"`" - mkdir -p "$sources_directory" - categories=(`nawk '/#>/{$1=""; sub(/^ /,"", $0); print $0 }' \ - "$sources_file"`) - n_categories="`n ${categories[*]}`" + sources_file="$(realpath "$1")" + sources_directory="$(realpath "$SRCDIR")" + test -n "$2" && hashsum_file="$(realpath "$2")" + mkdir -p "$sources_directory" + categories=($(nawk '/#>/{$1=""; sub(/^ /,"", $0); print $0 }' \ + "$sources_file")) + n_categories="$(n ${categories[*]})" - for ((i=0; i < n_categories; i++)) { - # foo/var => foo\/var - category_id="`echo ${categories[${i}]} | sed 's~\/~\\\/~g'`" - printf '==> %s\n' "${categories[${i}]}" - # AWK: Matches #> $category_id | - # counts until the next and last match | - # matches #< $category_id | - # then removes comments (lines starting with %%) - urls=(`nawk "/^#> $category_id$/{ flag=1; next } - /^#< $category_id$/{ flag=0 } flag && !/^%%/" \ - "$sources_file"`) - n_urls="`n ${urls[*]}`" + for ((i=0; i < n_categories; i++)); do + # foo/var => foo\/var + category_id="$(echo ${categories[${i}]} | sed 's~\/~\\/~g')" + printf '==> %s\n' "${categories[${i}]}" + # AWK: Matches #> $category_id | + # counts until the next and last match | + # matches #< $category_id | + # then removes comments (lines starting with %%) + urls=($(nawk "/^#> $category_id$/{ flag=1; next } + /^#< $category_id$/{ flag=0 } flag && !/^%%/" \ + "$sources_file")) + n_urls="$(n ${urls[*]})" - category_dir="$sources_directory/${categories[${i}]}" - mkdir -p "$category_dir" + category_dir="$sources_directory/${categories[${i}]}" + mkdir -p "$category_dir" - # cURL is slower, but it's present on more systems per default than aria2c, - # so we're going with it. - if ! $USE_ARIA2C; then - cd "$category_dir" || exit 2 - for ((j=0; j < n_urls; j++)) { - printf 'Downloading %s\n' "${urls[$j]##*/}" - curl -LO "${urls[${j}]}" - } - else - # Hell yeah, speed. - ( for ((j=0; j < n_urls; j++)) { - printf '%s\n\tout=%s\n' \ - "${urls[$j]}" "${urls[$j]##*/}" - } ) \ - | aria2c -q -j `nproc` -x `nproc` -d "$category_dir" -i - - fi - } - if `echo ${SHA256CHECK} | grep -i '^y' &>/dev/null` \ - && `test -n "$hashsum_file"`; then - cd "$sources_directory" - sha256sum -c "$hashsum_file" \ - && cd "$OLDPWD" - fi + # cURL is slower, but it's present on more systems per default than aria2c, + # so we're going with it. + if ! $USE_ARIA2C; then + cd "$category_dir" || exit 2 + for ((j=0; j < n_urls; j++)); do + printf 'Downloading %s\n' "${urls[$j]##*/}" + curl -LO "${urls[${j}]}" + done + else + # Hell yeah, speed. + (for ((j=0; j < n_urls; j++)); do + printf '%s\n\tout=%s\n' \ + "${urls[$j]}" "${urls[$j]##*/}" + done) | + aria2c -q -j $(nproc) -x $(nproc) -d "$category_dir" -i - + fi + done + if $(echo $SHA256CHECK | grep -i '^y' &>/dev/null) && + $(test -n "$hashsum_file"); then + cd "$sources_directory" + sha256sum -c "$hashsum_file" && + cd "$OLDPWD" + fi } main "$@" From 2648006a56c4020d38f855f9aaff70a8f090f144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 22 Aug 2024 23:50:56 -0300 Subject: [PATCH 074/128] chore: shfmt'ed some internal code. --- build-system/internals/disks.shi | 23 ++-- build-system/internals/helpers.shi | 183 +++++++++++++++-------------- build-system/internals/rconfig.shi | 82 ++++++------- 3 files changed, 147 insertions(+), 141 deletions(-) diff --git a/build-system/internals/disks.shi b/build-system/internals/disks.shi index a3865de..0c41ba3 100644 --- a/build-system/internals/disks.shi +++ b/build-system/internals/disks.shi @@ -13,20 +13,20 @@ function get_size_blocks { # The minimum size for a block is 512KiB, not less. # This identifier may sound a little bit erred. readonly blocks_per_kib=512 - - disk_size=( $(elevate fdisk -x "$disk_block" \ - | sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q') ) + + disk_size=($(elevate fdisk -x "$disk_block" | + sed '1 s/Disk .*: \(.*\),.*,.*/\1/; 1q')) size=${disk_size[0]} sizeunit=${disk_size[1]} unset disk_size case $sizeunit in - 'TiB') ((blocks= size * (blocks_per_kib * 4194304) )) ;; - 'GiB') ((blocks= size * (blocks_per_kib * 4096) )) ;; - 'MiB') ((blocks= size * (blocks_per_kib * 4) )) ;; - 'KiB') ((blocks= size / blocks_per_kib )) ;; - esac + 'TiB') ((blocks = size * (blocks_per_kib * 4194304))) ;; + 'GiB') ((blocks = size * (blocks_per_kib * 4096))) ;; + 'MiB') ((blocks = size * (blocks_per_kib * 4))) ;; + 'KiB') ((blocks = size / blocks_per_kib)) ;; + esac unset size sizeunit printf '%d' $blocks @@ -42,8 +42,11 @@ function check_linuxfs { err=0 case $fs in - btrfs|ext4) break ;; - default) err=1; break ;; + btrfs | ext4) break ;; + default) + err=1 + break + ;; esac return $err diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 40e6db2..197389f 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -1,5 +1,5 @@ # vim: set filetype=sh : -# Internal helper library for the Copacabana build system. +# General helper library for the Copacabana build system. # Meant to be used with Korn Shell 93. # # Copyright (c) 2023-2024 Pindorama @@ -12,8 +12,8 @@ # Make everyone aware we're running from BUILD_KSH. readonly BUILD_KSH=true -readonly KSH93_RELEASE=$(printf '%s' "${KSH_VERSION:-0}" \ - | nawk '{ gsub("-", ""); print $NF; }') +readonly KSH93_RELEASE=$(printf '%s' "${KSH_VERSION:-0}" | + nawk '{ gsub("-", ""); print $NF; }') export BUILD_KSH KSH93_RELEASE # map() and record() functions below. @@ -46,8 +46,8 @@ function record { # record() shall not be supported as is, because # compound variables are not supported on Bash. if [[ -n $BASH ]]; then - bash_supports_compound=false - export bash_supports_compound + bash_supports_compound=false + export bash_supports_compound fi eval $(__record "$identifier" "$variable" "$value") @@ -68,32 +68,32 @@ __record() { variable="$2" value="$3" - if [[ -z "$BASH" ]]; then # This is for KornShell 93 - # The only thing that changes between record() and map() is the printf - # format before evaluating it into the script. - if [[ "$whos_calling" == 'record' ]]; then - format='%s+=(%s="%s")' - elif [[ "$whos_calling" == 'map' ]]; then - format='%s+=([%s]="%s")' - else - panic '%s: invalid caller '%s'.\n' \ - 'record()/map() backend' "$whos_calling" - fi + if [[ -z $BASH ]]; then # This is for KornShell 93 + # The only thing that changes between record() and map() is the printf + # format before evaluating it into the script. + if [[ $whos_calling == 'record' ]]; then + format='%s+=(%s="%s")' + elif [[ $whos_calling == 'map' ]]; then + format='%s+=([%s]="%s")' + else + panic '%s: invalid caller '%s'.\n' \ + 'record()/map() backend' "$whos_calling" + fi else # Broken-Again - if ! $bash_supports_compound; then - panic \ - '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.\n' \ - 'record()/map() backend' - # Basic sanitizing in case of panic() does - # not quitting the program as intended. - unset bash_supports_compound - fi - format='%s['%s']="%s"' + if ! $bash_supports_compound; then + panic \ + '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.\n' \ + 'record()/map() backend' + # Basic sanitizing in case of panic() does + # not quitting the program as intended. + unset bash_supports_compound + fi + format='%s['%s']="%s"' fi - if [[ -n "$BASH" ]]; then - # Declare a global, associative array. - printf 'declare -gA %s\n' "$identifier" + if [[ -n $BASH ]]; then + # Declare a global, associative array. + printf 'declare -gA %s\n' "$identifier" fi # Hope this works. @@ -109,15 +109,15 @@ function rematch { s="$1" # Regular expression "rule", as a filter. - re="$2" + re="$2" # If $re is empty, just exit without questions. - [[ ! -n "$re" ]] && return 0 + [[ -z $re ]] && return 0 # This gets rid of the capture group syntax that we will be using again # on sed. egrep(1) could also be used, but I opted for shell built-ins # since we're already on Korn Shell. - [[ "$s" =~ $(printf '%s' "$re" | sed 's/\\(//; s/\\)//') ]] || return 1 + [[ $s =~ $(printf '%s' "$re" | sed 's/\\(//; s/\\)//') ]] || return 1 printf '%s' "$s" | sed "s/$re/\1/" } @@ -126,27 +126,27 @@ function rematch { # on purpose to the C preprocessor special operator defined(), meant for being # used in if conditions. function defined { - set -x - # First it will check if it's a function defined on the environment and/or in - # a sourced file, if it's not, then it will check if it is a variable. - { - # 'type -t' first appeared in KornShell 93 1.0.0. release - # as a reimplementation of the GNU Broken-Again extension, - # earlier versions do not have it present. - { (test $KSH93_RELEASE -ge 20220801 || test -n "$BASH") \ - && type -t "$1" \ - || type -v "$1"; } \ - | grep 'function' 2>&1 > /dev/null \ - || test ! -z "$(eval "echo \$$1")" - } \ - || return 1 + set -x + # First it will check if it's a function defined on the environment and/or in + # a sourced file, if it's not, then it will check if it is a variable. + { + # 'type -t' first appeared in KornShell 93 1.0.0. release + # as a reimplementation of the GNU Broken-Again extension, + # earlier versions do not have it present. + { (test $KSH93_RELEASE -ge 20220801 || test -n "$BASH") && + type -t "$1" || + type -v "$1"; } | + grep 'function' 2>&1 >/dev/null || + test ! -z "$(eval "echo \$$1")" + } || + return 1 } # Multiple file input support for realpath(1) # Basically a boilerplate. function realpaths { - files=( ${@} ) - for (( count=0; count < ${#files[@]}; count++ )); do + files=(${@}) + for ((count=0; count < ${#files[@]}; count++)); do realpath "${files[$count]}" done unset count files @@ -158,56 +158,59 @@ function chdir { cd "$1"; } # Just a wrapper to a decompressor such as gzip, xz, bzip2 etc. # Derived from copy2prefix() at https://git.io/mitzune function c { - tarball="$2" + tarball="$2" # First, cut the absolute path off - tarball_ext="${tarball##*/}" + tarball_ext="${tarball##*/}" # Then, the filename itself, # we just want the extension. - tarball_ext="${tarball_ext##*.}" - case "$tarball_ext" in - gz|tgz) { gzip "$@"; } ;; - xz|txz) { xz "$@"; } ;; - bz2|tbz) { bzip2 "$@"; } ;; - tar) { shift; cat "$@"; } ;; - *) printerr "$0: File format not recognized." ;; - esac + tarball_ext="${tarball_ext##*.}" + case "$tarball_ext" in + gz | tgz) { gzip "$@"; } ;; + xz | txz) { xz "$@"; } ;; + bz2 | tbz) { bzip2 "$@"; } ;; + tar) { + shift + cat "$@" + } ;; + *) printerr "$0: File format not recognized." ;; + esac } # This "generates" wrappers for elevating permissions when needed. # Be careful. # Derived from check_doas() at https://git.io/mitzune function check_elevate_method { - # Clever way to get UID without having to use id(1) or $UID itself. - # Check if UID is defined; small fix for using GNU Broken-Again Shell - # instead of Korn Shell 93, since $UID is read-only on GNU's Shell. - # We'll be making it public because many scripts will use it later. - # Using export directly on variable declaration since it would require to - # use another comparison for knowing if UID is available if we export just - # at the end. - [[ -z $UID ]] && export UID="$(grep $(whoami) /etc/passwd | cut -d: -f3)" - - # Cache the user name from whoami(1) and, unlike $USER, made it read-only - # to prevent manipulation from overwriting. - readonly user="$(whoami)" - - if $(grep "$user" /etc/doas.conf &>/dev/null); then - function elevate { doas -- "$@"; } - typeset -fx elevate - elif $(sudo -v 2>/dev/null); then - function elevate { sudo -- "$@"; } - typeset -fx elevate - elif [[ $UID == 0 ]]; then - printerr 'Warning: running as root. This isn'\''t recommended.\n' - elif $(groups $user | grep 'wheel' >/dev/null); then - printerr \ - 'Warning: %s can log directly as root, although using sudo/doas is preferable.\n' \ - "$user" - function elevate { su -c "$@"; } - typeset -fx elevate - else - printerr 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' - exit 10 - fi - - export user + # Clever way to get UID without having to use id(1) or $UID itself. + # Check if UID is defined; small fix for using GNU Broken-Again Shell + # instead of Korn Shell 93, since $UID is read-only on GNU's Shell. + # We'll be making it public because many scripts will use it later. + # Using export directly on variable declaration since it would require to + # use another comparison for knowing if UID is available if we export just + # at the end. + [[ -z $UID ]] && export UID="$(grep $(whoami) /etc/passwd | cut -d: -f3)" + + # Cache the user name from whoami(1) and, unlike $USER, made it read-only + # to prevent manipulation from overwriting. + readonly user="$(whoami)" + + if $(grep "$user" /etc/doas.conf &>/dev/null); then + function elevate { doas -- "$@"; } + typeset -fx elevate + elif $(sudo -v 2>/dev/null); then + function elevate { sudo -- "$@"; } + typeset -fx elevate + elif [[ $UID == 0 ]]; then + printerr 'Warning: running as root. This isn'\''t recommended.\n' + elif $(groups $user | grep 'wheel' >/dev/null); then + printerr \ + 'Warning: %s can log directly as root, although using sudo/doas is preferable.\n' \ + "$user" + function elevate { su -c "$@"; } + typeset -fx elevate + else + printerr 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' + exit 10 + fi + + export user } diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi index 30444ec..6bca687 100644 --- a/build-system/internals/rconfig.shi +++ b/build-system/internals/rconfig.shi @@ -11,7 +11,7 @@ # to dotini/inicompat --- and, in case of using # GNU's Broken-Again Shell, it does a coarse conversion of # the INI file to a simple Shell-based configuration file -# format. +# format. function rconfig { file="$1" @@ -22,24 +22,24 @@ function rconfig { eval conf=$(dotini "$file") inicompat conf elif [[ -n $BASH ]]; then # BASH - cat "$1" | \ - for (( ;; )); do - if read line; then - if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] \ - || [[ "$line" =~ '^[#;].*$' ]]; then - continue + cat "$1" | + for ((;;)); do + if read line; then + if [[ "$line" =~ \[.*\] ]] || [[ "$line" =~ ^$ ]] || + [[ "$line" =~ '^[#;].*$' ]]; then + continue + else + keyval="$(printf '%s' "$line" | + sed 's/^\(.*\)[#;].*/\1/;')" + identifier="${keyval%%=*}" + value="${keyval##*=}" + [[ "$keyval" =~ ^$ ]] && continue + eval $(printf '%s='\''%s'\''' $identifier "$value") + fi else - keyval="$(printf '%s' "$line" \ - | sed 's/^\(.*\)[#;].*/\1/;')" - identifier="${keyval%%=*}" - value="${keyval##*=}" - [[ "$keyval" =~ ^$ ]] && continue - eval $(printf '%s='\''%s'\''' $identifier "$value") + break fi - else - break - fi - done + done fi } @@ -71,14 +71,14 @@ function dotini { # First of all, we shall remove comments. # I know this could be done manually using a for-loop, # but I think sed can be more reliable. - (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | \ - for ((nl=0 ;; nl++)); do - if read line; then - inibuf[$nl]="$line" - else - break - fi - done + (sed 's/^\(.*\)[#;].*/\1/; /^[#;].*$/d; /^$/d' "$file") | + for ((nl=0;; nl++)); do + if read line; then + inibuf[$nl]="$line" + else + break + fi + done # Open compound variable syntax. printf '%c' '(' @@ -88,10 +88,10 @@ function dotini { line="${inibuf[l]}" # This gets the INI section. - if section_title="$(rematch "$line" '\[\(.*\)\]')"; then + if section_title="$(rematch "$line" '\[\(.*\)\]')"; then # The formatted section title. - formatted_section="$(printf '%s' "$section_title" \ - | nawk '{ gsub(" ", "_"); print(tolower($0)) }')" + formatted_section="$(printf '%s' "$section_title" | + nawk '{ gsub(" ", "_"); print(tolower($0)) }')" # We can procceed to the next line. continue fi @@ -138,7 +138,7 @@ function dotini { # Close compound variable. printf '%c' ')' - # Remove the section name from the memory, + # Remove the section name from the memory, # since it can cause fuss later. unset formatted_section } @@ -155,25 +155,25 @@ function inicompat { integer s k typeset -a sections fmt='%s='\''%s'\''' - sections=( ${!inirecord[@]} ) - for ((s=0; s<${#sections[@]}; s++ )); do + sections=(${!inirecord[@]}) + for ((s=0; s < ${#sections[@]}; s++)); do typeset -a confkeys section=${sections[s]} confkeys=( ${!inirecord[$section][@]} ) case "${confkeys[0]}" in - 0) # If dealing with section-less file. - eval $(printf "$fmt" \ + 0) # If dealing with section-less file. + eval $(printf "$fmt" \ $section "${inirecord[$section]}") ;; - *) # Default... Or dealing with sections. - for (( k=0; k < ${#confkeys[@]}; k++ )); do - confkey=${confkeys[$k]} - confval="${inirecord[$section][$confkey]}" - eval $(printf "$fmt" \ - $confkey "$confval") - unset confkey confval - done ;; + *) # Default... Or dealing with sections. + for ((k=0; k < ${#confkeys[@]}; k++)); do + confkey=${confkeys[$k]} + confval="${inirecord[$section][$confkey]}" + eval $(printf "$fmt" \ + $confkey "$confval") + unset confkey confval + done ;; esac unset section confkeys confkey confval done From 45daf431340892e8ea3147404e3fcd1ea151835b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 23 Aug 2024 00:19:29 -0300 Subject: [PATCH 075/128] fix: Initial quoting fix at rconfig.shi (INI parser). --- build-system/internals/rconfig.shi | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi index 6bca687..fea9c64 100644 --- a/build-system/internals/rconfig.shi +++ b/build-system/internals/rconfig.shi @@ -53,6 +53,7 @@ function rconfig { # It does not outsource record() or map(), so there's more independence # and flexibility on choosing identifiers for your INI file configuration. function dotini { + set -x file="$1" # The function shall fail before "allocating" anything in memory. @@ -104,7 +105,8 @@ function dotini { # confline[2]=value confline[0]="${line%%=*}" # Bullet-proofing against subshells. - confline[1]="$(printf '%q' "${line#*=}")" + confline[1]="$(echo -n "${line#*=}" \ + | nawk '{gsub("\"", "'\''"); gsub("'\''", "'\'''\'''\''"); print $0 }')" # If there is not a section, it will only declare the INI # variable and its value on the compound variable. @@ -130,7 +132,8 @@ function dotini { # already parsed, return it as a associative array declaration. printf '[%s]+=([%s]=%s) ' \ $formatted_section "${confline[0]}" "${confline[1]}" - + + print -C confline 1>&2 # Clean confline[] array. unset confline[0] confline[1] done @@ -151,10 +154,11 @@ function dotini { # # inicompat conf function inicompat { + set -x nameref inirecord=$1 integer s k typeset -a sections - fmt='%s='\''%s'\''' + fmt='%s=%q' sections=(${!inirecord[@]}) for ((s=0; s < ${#sections[@]}; s++)); do typeset -a confkeys From d8dc494e12de58eb21457fbf0d487c1495c34240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 23 Aug 2024 00:37:17 -0300 Subject: [PATCH 076/128] fix: Definitive security patch for rconfig.shi Fixes error presented at https://github.com/Projeto-Pindorama/copacabana/issues/8#issuecomment-2306294875 --- build-system/internals/rconfig.shi | 6 +----- build-system/test.ini | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 build-system/test.ini diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi index fea9c64..bbeae3f 100644 --- a/build-system/internals/rconfig.shi +++ b/build-system/internals/rconfig.shi @@ -53,7 +53,6 @@ function rconfig { # It does not outsource record() or map(), so there's more independence # and flexibility on choosing identifiers for your INI file configuration. function dotini { - set -x file="$1" # The function shall fail before "allocating" anything in memory. @@ -105,8 +104,7 @@ function dotini { # confline[2]=value confline[0]="${line%%=*}" # Bullet-proofing against subshells. - confline[1]="$(echo -n "${line#*=}" \ - | nawk '{gsub("\"", "'\''"); gsub("'\''", "'\'''\'''\''"); print $0 }')" + confline[1]="$(echo -n "${line#*=}" | sed 's/\$/\\\$/g; s/\`/\\`/g')" # If there is not a section, it will only declare the INI # variable and its value on the compound variable. @@ -133,7 +131,6 @@ function dotini { printf '[%s]+=([%s]=%s) ' \ $formatted_section "${confline[0]}" "${confline[1]}" - print -C confline 1>&2 # Clean confline[] array. unset confline[0] confline[1] done @@ -154,7 +151,6 @@ function dotini { # # inicompat conf function inicompat { - set -x nameref inirecord=$1 integer s k typeset -a sections diff --git a/build-system/test.ini b/build-system/test.ini new file mode 100644 index 0000000..8b27ff7 --- /dev/null +++ b/build-system/test.ini @@ -0,0 +1,3 @@ +[Testando um dois três] +WHOAMI="$(whoami)" +CALÇA="`echo Camisa verde-claro, calça saint-tropez`" From 0e7756b96910095704ddc9641375c4ba79d4ee79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 23 Aug 2024 00:38:59 -0300 Subject: [PATCH 077/128] chore: Removed temporary test files. --- build-system/test.ini | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 build-system/test.ini diff --git a/build-system/test.ini b/build-system/test.ini deleted file mode 100644 index 8b27ff7..0000000 --- a/build-system/test.ini +++ /dev/null @@ -1,3 +0,0 @@ -[Testando um dois três] -WHOAMI="$(whoami)" -CALÇA="`echo Camisa verde-claro, calça saint-tropez`" From 6ab0fcdcbf4f7d65055700e08723ccb087b591b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 25 Aug 2024 02:11:49 -0300 Subject: [PATCH 078/128] chore: refactor sha256sum.ksh --- cmd/sha256sum.ksh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/cmd/sha256sum.ksh b/cmd/sha256sum.ksh index 9a015a6..7acd61e 100755 --- a/cmd/sha256sum.ksh +++ b/cmd/sha256sum.ksh @@ -1,5 +1,5 @@ #!/usr/bin/env ksh93 -# sha256sum.ksh - Generate SHA256 hashes for a file using Open/LibreSSL. +# sha256sum.ksh - Generate SHA256 hashes for a file using Open/LibreSSL. # Can be extended to more digest formats later, the code is pretty maleable. # # Copyright (c) 2023-2024 Pindorama @@ -18,13 +18,13 @@ CLASSIC=false function main { while getopts ":oC:c:h:" options; do case "$options" in - C|c) check "$OPTARG" ;; - h) hashfile="$OPTARG" ;; - o) CLASSIC=true ;; - \?|*) print_help ;; + C | c) check "$OPTARG" ;; + h) hashfile="$OPTARG" ;; + o) CLASSIC=true ;; + \? | *) print_help ;; esac done - shift $(( OPTIND - 1 )) + shift $((OPTIND - 1)) # As done later, for the sake of readability. # Nobody knows exactly what "$1" means without having to read the entire @@ -46,16 +46,16 @@ function get_checksum { # $CLASSIC is a boolean-type value (true or false), and determines if # you're getting the old/classic OpenSSL shell API output or you're # getting a more cksum(1)-style output. - - sslcmd dgst -sha256 "$1" | \ - if ! $CLASSIC; then - nawk_ssl_to_cksum - else - cat - fi + + sslcmd dgst -sha256 "$1" | + if ! $CLASSIC; then + nawk_ssl_to_cksum + else + cat + fi } -# This checks if the checksum inside a file matches with the file in the disk. +# This checks if the checksum inside a file matches with the file in the disk. function check { # Just for the sake of readability, as in main. hashfile="$1" @@ -76,10 +76,10 @@ function check { fi file_to_check="${cksum_line#* }" file_alleged_hash="${cksum_line%% *}" - + # Setting $CLASSIC as "false", since we're going to only use # cksum-like syntax. - export CLASSIC="false" + export CLASSIC=false # Same thing from before, but now with the newly generated digest. actual_file_cksum="$(get_checksum "${file_to_check}")" @@ -93,16 +93,16 @@ function check { printmsg "%s: WARNING: %s computed checksum did NOT match\n" \ "$progname" "$actual_file_name" fi - + # Clean variables from the memory unset cksum_line actual_file_cksum file_to_check \ - file_alleged_hash actual_file_name actual_file_hash - done < "$hashfile" + file_alleged_hash actual_file_name actual_file_hash + done <"$hashfile" exit 0 } # Boilerplate to OpenSSL-compatible shell API. -function sslcmd { +function sslcmd { "$(type -p $SSL_CMD)" "$@" } @@ -122,8 +122,8 @@ function printmsg { function print_help { printmsg \ - 'usage: %s: [-o] [-C hashfile to read] [-h hashfile to record] [file to hash]\n' \ - "$progname" + 'usage: %s: [-o] [-C hashfile to read] [-h hashfile to record] [file to hash]\n' \ + "$progname" exit 1 } From a4667330ec45006ec572866e0cce57769258e8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 25 Aug 2024 02:31:44 -0300 Subject: [PATCH 079/128] chore: shfmt'ed checks/dependencies.ksh --- build-system/tasks/checks/dependencies.ksh | 214 ++++++++++++--------- 1 file changed, 118 insertions(+), 96 deletions(-) diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index 1950310..8b2c75d 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -19,23 +19,23 @@ cxx_sanity_test="$trash/sanity.cxx" archiver_sanity="$trash/archiver_sanity" # Internal helper scripts (at cmd/) -internal_scripts=( 'cmd/download_sources.ksh' 'cmd/populate_fhs.sh' \ - 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh' ) +internal_scripts=('cmd/download_sources.ksh' 'cmd/populate_fhs.sh' + 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh') # GNU auto*conf commands -GNUAutoconf_commands=( 'aclocal' 'automake' 'autoconf' 'autoscan' \ - 'autoreconf' 'ifnames' 'autoheader' 'autom4te' 'autoupdate' \ - 'libtool' 'libtoolize' ) +GNUAutoconf_commands=('aclocal' 'automake' 'autoconf' 'autoscan' + 'autoreconf' 'ifnames' 'autoheader' 'autom4te' 'autoupdate' + 'libtool' 'libtoolize') # GNU Binutils commands -GNUBinutils_commands=( 'addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' \ - 'gprof' ld{,.bfd} 'nm' 'objcopy' 'objdump' 'ranlib' 'readelf' \ - 'size' 'strings' 'strip' ) +GNUBinutils_commands=('addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' + 'gprof' ld{,.bfd} 'nm' 'objcopy' 'objdump' 'ranlib' 'readelf' + 'size' 'strings' 'strip') # General commands -general_commands=( 'cmp' 'curl' diff{,3} 'sdiff' 'ed' 'file' \ - 'patch' 'find' 'grep' 'lemount' 'm4' 'mitzune' \ - ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) +general_commands=('cmp' 'curl' diff{,3} 'sdiff' 'ed' 'file' + 'patch' 'find' 'grep' 'lemount' 'm4' 'mitzune' + ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]}) # General compressing tools archivers=('tar' 'bzip2' 'gzip' 'xz') @@ -43,43 +43,56 @@ archivers=('tar' 'bzip2' 'gzip' 'xz') # Check for aria2c if $USE_ARIA2C; then general_commands[1]='aria2c' -fi +fi -for (( g=0; g < $(n ${general_commands[@]}); g++ )); do +for ((g=0; g < $(n ${general_commands[@]}); g++)); do printerr 'Searching for %s at PATH (%s)... ' \ "${general_commands[$g]}" "$PATH" - type -p "${general_commands[$g]}" \ - || { printerr 'Not found.\n'; return 1; } + if ! type -p "${general_commands[$g]}"; then + case "${general_commands[$g]}" in + sha256sum) + # Use internal sha256sum implementation + function sha256sum { + "$build_kshdir/cmd/sha256sum.ksh" "$@" + } + typeset -xf sha256sum + ;; + *) + printerr 'Not found.\n' + return 1 + ;; + esac + fi done -for (( h=0; h < $(n ${archivers[@]}); h++ )); do +for ((h=0; h < $(n ${archivers[@]}); h++)); do printerr 'Does %s work for what we want? ' "${archivers[$h]}" - if [ "${archivers[$h]}" == 'tar' ]; then # TAR-specific tests + if [ "${archivers[$h]}" == 'tar' ]; then # TAR-specific tests tarpath="$(realpath $(type -p tar))" - if (strings "$tarpath" | grep '@(#)tar.*\(gritter\)' \ - && getconf HEIRLOOM_TOOLCHEST_VERSION) 2>&1 >/dev/null; then + if (strings "$tarpath" | grep '@(#)tar.*\(gritter\)' && + getconf HEIRLOOM_TOOLCHEST_VERSION) 2>&1 >/dev/null; then printerr '\nI'\''m almost certain that %s is from the Heirloom Toolchest...\n' \ "$(type -p tar)" - printerr 'Heirloom Toolchest'\''s tar is broken since at least 2007 for some reason.\n' + printerr 'Heirloom Toolchest'\''s tar is broken since at least 2007 for some reason.\n' printerr \ - 'Until this is hopefully fixed, I'\''ll be searching for another tar at PATH.\n' - - printf '%s' "$PATH" \ - | nawk '{ gsub(":", "\n"); print $0; }' \ - | for ((;;)); do - if read -r d; then - tar_cmd="$d/tar" - if [[ ! -e "$tar_cmd" || "$d" == "${tarpath%/*}" ]]; then - continue - elif ($tar_cmd --help 2>&1| egrep 'star|bsdtar|GNU' 2>&1 >/dev/null); then - new_tarpath="$(realpath $d)" - tmpPATH="$new_tarpath:$PATH" - # This big chunk of code works as a 'uniq' - # for the PATH variable because, since - # $new_tarpath was already in PATH, it - # would be repeated in the new PATH. - PATH="$(printf '%s' "$tmpPATH" \ - | nawk '{ np=split($0, p, ":"); + 'Until this is hopefully fixed, I'\''ll be searching for another tar at PATH.\n' + + printf '%s' "$PATH" | + nawk '{ gsub(":", "\n"); print $0; }' | + for ((;;)); do + if read -r d; then + tar_cmd="$d/tar" + if [[ ! -e "$tar_cmd" || "$d" == "${tarpath%/*}" ]]; then + continue + elif ($tar_cmd --help 2>&1 | egrep 'star|bsdtar|GNU' 2>&1 >/dev/null); then + new_tarpath="$(realpath $d)" + tmpPATH="$new_tarpath:$PATH" + # This big chunk of code works as a 'uniq' + # for the PATH variable because, since + # $new_tarpath was already in PATH, it + # would be repeated in the new PATH. + PATH="$(printf '%s' "$tmpPATH" | + nawk '{ np=split($0, p, ":"); for (n = 1; n <= np; n++) { if ((n + 1) >= np) { separator="" @@ -93,28 +106,28 @@ for (( h=0; h < $(n ${archivers[@]}); h++ )); do } } }')" - printerr 'Info: Found suitable tar at %s\n' $new_tarpath - printerr 'Info: New PATH: %s\n' $PATH - export PATH - unset new_tarpath tmpPATH - break + printerr 'Info: Found suitable tar at %s\n' $new_tarpath + printerr 'Info: New PATH: %s\n' $PATH + export PATH + unset new_tarpath tmpPATH + break + fi + unset tar_cmd + else + panic 'Error: Couldn'\''t find a suitable tar implementation.\n' + break # Une pure formalité. fi - unset tar_cmd - else - panic 'Error: Couldn'\''t find a suitable tar implementation.\n' - break # Une pure formalité. - fi - done + done fi - if [[ "$tarpath" =~ (star) ]] \ - || (tar -h 2>&1| grep 'star' 2>&1 >/dev/null); then + if [[ "$tarpath" =~ (star) ]] || + (tar -h 2>&1 | grep 'star' 2>&1 >/dev/null); then printerr '\nI'\''m almost certain that %s is Schily tar...\n' \ "$(type -p tar)" printerr \ - 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' + 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' printerr \ - 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).\n' + 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).\n' function tar { "$(type -p tar)" "$@" \ --no-secure-links --artype=xustar @@ -124,49 +137,55 @@ for (( h=0; h < $(n ${archivers[@]}); h++ )); do unset tarpath { - ( mkdir -p "$archiver_sanity"{,_results} - cd "$archiver_sanity" - > vulgar_file - mkfifo pipe_test - ln -sf "$(readlink -f "$archiver_sanity")" potentially_unsafe_link - ln -f vulgar_file hard_link - # We already expect an error/warning - ln -f not_a_vulgar_file broken_link 2>/dev/null - ) - ( cd "$archiver_sanity" - tar -cf - . ) | tar -xf - -C "${archiver_sanity}_results" + ( + mkdir -p "$archiver_sanity"{,_results} + cd "$archiver_sanity" + >vulgar_file + mkfifo pipe_test + ln -sf "$(readlink -f "$archiver_sanity")" potentially_unsafe_link + ln -f vulgar_file hard_link + # We already expect an error/warning + ln -f not_a_vulgar_file broken_link 2>/dev/null + ) + ( + cd "$archiver_sanity" + tar -cf - . + ) | tar -xf - -C "${archiver_sanity}_results" } && rm -rf "${archiver_sanity}_results" else # Bzip2, Gzip or Xz tests - for (( l=1; l <= 9; l++ )); do + for ((l=1; l <= 9; l++)); do printerr 'With compression level %s? ' $l - + # Test the alphabet string can be compressed # without being corrupted, then, do a more # "difficult" test using the main build.ksh # script file. - { printf '%s' {a..z} | "${archivers[$h]}" -"$l" -cf \ - | "${archivers[$h]}" -dcf | wc -m | tr -d '[:space:]' \ - | test `cat` -eq 26 ; } \ - && { cat "$progdir/$progname" | "${archivers[$h]}" -"$l" -cf \ - | "${archivers[$h]}" -dcf \ - | cmp - "$progdir/$progname"; } - printerr 'Ok...\n' + { printf '%s' {a..z} | "${archivers[$h]}" -"$l" -cf | + "${archivers[$h]}" -dcf | wc -m | tr -d '[:space:]' | + test $(cat) -eq 26; } && + { cat "$progdir/$progname" | "${archivers[$h]}" -"$l" -cf | + "${archivers[$h]}" -dcf | + cmp - "$progdir/$progname"; } + printerr 'Ok...\n' done fi - printerr 'Sounds like a yes.\n' + printerr 'Sounds like a yes.\n' done -for (( i=0; i < $(n ${utils[@]}); i++ )); do +for ((i=0; i < $(n ${utils[@]}); i++)); do printerr 'Is %s present on this system? ' "${utils[$i]}" - command -v ${utils[$i]} 2>&1 > /dev/null && printerr 'Sounds like a yes.\n' \ - || { printerr '%s not found.\n' ${utils[$i]}; return 1; } + command -v ${utils[$i]} 2>&1 >/dev/null && printerr 'Sounds like a yes.\n' || + { + printerr '%s not found.\n' ${utils[$i]} + return 1 + } done -for (( k=0; k < $(n ${internal_scripts[@]}); k++ )); do +for ((k=0; k < $(n ${internal_scripts[@]}); k++)); do printerr 'Info: Searching for independent script %s at %s... ' \ "${internal_scripts[$k]}" "$progdir" - if [ -e "$progdir/${internal_scripts[$k]}" ] \ - && [ ! -z "$(cat "$progdir/${internal_scripts[$k]}")" ]; then + if [ -e "$progdir/${internal_scripts[$k]}" ] && + [ ! -z "$(cat "$progdir/${internal_scripts[$k]}")" ]; then printerr 'Found!\n' else printerr '%s not found...\n' @@ -184,7 +203,7 @@ printerr 'Does the running shell (%s) work for what we need?\n' "$run_shell" # since we expect it to run as a new process, so as a new P.ID. and as a new # "folder" at /proc, explaining in a extremely simplistic way. -cat > "$ksh_sanity_test" << 'EO_KSHSANITY' +cat >"$ksh_sanity_test" <<'EO_KSHSANITY' #!/usr/bin/env ksh interpreter="$(readlink -f /proc/$$/exe)" @@ -207,9 +226,9 @@ fi EO_KSHSANITY "$run_shell" "$ksh_sanity_test" -printerr 'Does the C/C++ compiler work for what we need?\n' +printerr 'Does the C/C++ compiler work for what we need?\n' -cat > "$c_sanity_test" << 'EO_CSANITY' +cat >"$c_sanity_test" <<'EO_CSANITY' #include #if defined(__GNUC__) || defined(__clang__) @@ -228,7 +247,7 @@ return RETURN; } EO_CSANITY -cat > "$cxx_sanity_test" << 'EO_C++SANITY' +cat >"$cxx_sanity_test" <<'EO_C++SANITY' #include using std::cout; @@ -248,24 +267,27 @@ return RETURN; } EO_C++SANITY -{ "$CC" -o"$trash/c_sanity" "$c_sanity_test"; "$trash/c_sanity" \ -&& "$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test" && "$trash/cxx_sanity"; } \ -|| exit $? +{ + "$CC" -o"$trash/c_sanity" "$c_sanity_test" + "$trash/c_sanity" && + "$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test" && "$trash/cxx_sanity" +} || + exit $? printerr 'Info: Generating our cross-compiling host based on this machine'\''s type...\n' printerr 'Does this system have GNU Broken-Again Shell for $MACHTYPE or we'\''ll be depending on %s? ' \ -"$CC" -if ! type -p bash 2>&1 > /dev/null; then -printerr 'Nah, it'\''s clean.\n' -has_bash=false + "$CC" +if ! type -p bash 2>&1 >/dev/null; then + printerr 'Nah, it'\''s clean.\n' + has_bash=false else -printerr 'It does, we'\''re going with it.\n' -has_bash=true + printerr 'It does, we'\''re going with it.\n' + has_bash=true fi -COPA_HOST="$( ( ($has_bash && bash -c 'echo $MACHTYPE') \ -|| (gcc -v 2>&1 | nawk '/Target/{ sub(/.*Target:/, "", $0); printf("%s", $1); }') ) \ -| nawk '{ split($0, host, "-"); sub(host[2], "crossCOPACABANA", $0); printf("%s\n", $0); }')" +COPA_HOST="$( ( ($has_bash && bash -c 'echo $MACHTYPE') || + (gcc -v 2>&1 | nawk '/Target/{ sub(/.*Target:/, "", $0); printf("%s", $1); }')) | + nawk '{ split($0, host, "-"); sub(host[2], "crossCOPACABANA", $0); printf("%s\n", $0); }')" unset has_bash printerr 'Info: COPA_HOST will be "%s".\n' "$COPA_HOST" From ca3dd5a8af617e7f7d0b10951ad63ec902d87102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 25 Aug 2024 21:47:12 -0300 Subject: [PATCH 080/128] fix: Return an error code if SHA256 hash doesn't match at cmd/sha256sum.ksh --- cmd/sha256sum.ksh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/sha256sum.ksh b/cmd/sha256sum.ksh index 7acd61e..93ed9f8 100755 --- a/cmd/sha256sum.ksh +++ b/cmd/sha256sum.ksh @@ -38,6 +38,8 @@ function main { output_hashfile="${hashfile:-/dev/null}" get_checksum "$file" | tee -a "${output_hashfile}" + + exit $err } function get_checksum { @@ -57,6 +59,7 @@ function get_checksum { # This checks if the checksum inside a file matches with the file in the disk. function check { + err=0 # Just for the sake of readability, as in main. hashfile="$1" @@ -92,13 +95,15 @@ function check { printmsg "(SHA256) %s: FAILED\n" "$actual_file_name" printmsg "%s: WARNING: %s computed checksum did NOT match\n" \ "$progname" "$actual_file_name" + err=1 fi # Clean variables from the memory unset cksum_line actual_file_cksum file_to_check \ file_alleged_hash actual_file_name actual_file_hash done <"$hashfile" - exit 0 + + export err } # Boilerplate to OpenSSL-compatible shell API. From 9a0ecdd213132ad8cabc212e0d36212ffce74793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 26 Aug 2024 02:11:33 -0300 Subject: [PATCH 081/128] chore: yes2bool function --- build-system/internals/helpers.shi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 197389f..650296b 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -214,3 +214,8 @@ function check_elevate_method { export user } + +# Converts a 'yes/no' variable to a boolean. +function yes2bool { + (echo $1 | grep -i '^y' &>/dev/null) || false +} From e2daf4da3dea4c08a2426de50d04902e026b8976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 26 Aug 2024 02:11:56 -0300 Subject: [PATCH 082/128] feat: Start from where it stopped at tasks/get_sources --- build-system/tasks/get_sources.ksh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build-system/tasks/get_sources.ksh b/build-system/tasks/get_sources.ksh index d69f3dd..d4d0a61 100644 --- a/build-system/tasks/get_sources.ksh +++ b/build-system/tasks/get_sources.ksh @@ -22,14 +22,16 @@ source_list="$(readlink -f "$1")" source_hash="$(readlink -f "$2")" -SHA256CHECK="$SHA256CHECK" -SRCDIR="$SRCDIR" -USE_ARIA2C="$USE_ARIA2C" export USE_ARIA2C SHA256CHECK SRCDIR printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ "$source_list" -"$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" +if [[ -z $(ls "$SRCDIR" 2>/dev/null) ]] || $(yes2bool "SHA256CHECK" && \ + (cd "$SRCDIR" && sha256sum -c "$source_hash")); then + "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" +else + printerr 'Info: Sources already downloaded and validated, good to go.' +fi unset SHA256CHECK USE_ARIA2C From 3f55f23965384647b8fa6669888576792780fe6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 26 Aug 2024 02:12:48 -0300 Subject: [PATCH 083/128] feat: Implement method to keep track of tasks already ran at makier.ksh. --- build-system/internals/makier.ksh | 23 ++++++++++++++++++++--- build-system/tasks/get_sources.ksh | 7 +------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 7114e6d..6df7fa4 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -1,10 +1,27 @@ +# vim: set filetype=sh : # Boilerplate for running tasks. +# +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA _make(){ + set -e lang='.ksh' tasks="${tasks:?"task directory not defined"}" + made="$tasks/made.txt" tak="$1" - - shift # Remove '$1' - . "$(printf '%s/%s%s' "$tasks" "$tak" "$lang")" "${@:-''}" + + # Since having access to the date of the last + # change done to a file in the UNIX format is + # hard without stat(1) or even strace(1)ng the + # ls(1) program, we will use a rudimentary + # technique to keep track of tasks that had + # already being ran. + if grep -v "$tak" "$made"; then + shift # Remove '$1' + . "$(printf '%s/%s%s' "$tasks" "$tak" "$lang")" "${@:-''}" + # Write task name to a list of done tasks. + echo $tak >> "$tasks/made.txt" + fi } diff --git a/build-system/tasks/get_sources.ksh b/build-system/tasks/get_sources.ksh index d4d0a61..4d4ff28 100644 --- a/build-system/tasks/get_sources.ksh +++ b/build-system/tasks/get_sources.ksh @@ -27,11 +27,6 @@ export USE_ARIA2C SHA256CHECK SRCDIR printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ "$source_list" -if [[ -z $(ls "$SRCDIR" 2>/dev/null) ]] || $(yes2bool "SHA256CHECK" && \ - (cd "$SRCDIR" && sha256sum -c "$source_hash")); then - "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" -else - printerr 'Info: Sources already downloaded and validated, good to go.' -fi +"$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" unset SHA256CHECK USE_ARIA2C From edbfafa1fb81af0ffb36cf6f60f4d4e3fff24234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 29 Aug 2024 23:21:42 -0300 Subject: [PATCH 084/128] fix: unmount_and_detach as a task. --- build-system/tasks/disk/unmount_and_detach.ksh | 8 ++++++++ build-system/tasks/finish.ksh | 2 +- build-system/work.ini | 3 +++ build.ksh | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 build-system/tasks/disk/unmount_and_detach.ksh diff --git a/build-system/tasks/disk/unmount_and_detach.ksh b/build-system/tasks/disk/unmount_and_detach.ksh new file mode 100644 index 0000000..3baf2be --- /dev/null +++ b/build-system/tasks/disk/unmount_and_detach.ksh @@ -0,0 +1,8 @@ +mount_point="$1" +disk_block="$2" + +elevate "$run_shell" -c \ + "umount -R '"$mount_point"' '"/mnt/`echo "$mount_point" | sed 's@/@@g'`"'" +if $VIRTUAL_DISK; then + elevate losetup -D "${disk_block%%*p?}" +fi diff --git a/build-system/tasks/finish.ksh b/build-system/tasks/finish.ksh index 2a42ba1..9e1ca52 100644 --- a/build-system/tasks/finish.ksh +++ b/build-system/tasks/finish.ksh @@ -1,5 +1,5 @@ if $UMOUNT_ON_EXIT; then - unmount_and_detach "$COPA" "$disk_block" + _make 'disk/unmount_and_detach' "$COPA" "$disk_block" fi # Remove the trash directory with sanity tests diff --git a/build-system/work.ini b/build-system/work.ini index 5526926..5f76e2c 100644 --- a/build-system/work.ini +++ b/build-system/work.ini @@ -19,3 +19,6 @@ TRASH_PREFIX="/tmp" ; PKGDIR="" ; OBJDIR="" + +; This contains tasks that will be re-run even on start-over. +FORGO_TASKS="checks/dependencies disk/create_disk disk/unmount_and_detach" diff --git a/build.ksh b/build.ksh index f9a38cd..29086f6 100755 --- a/build.ksh +++ b/build.ksh @@ -4,6 +4,7 @@ # SPDX-Licence-Identifier: NCSA set -e +trap '_make finish' ERR EXIT progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" @@ -34,7 +35,7 @@ _make 'checks/dependencies' _make 'disk/create_disk' "$DISK_BLOCK" _make 'disk/populate' _make get_sources sources.txt sources.sha256 +_make build cross-tools #build cross-tools "base/kernel-headers" "dev/GNUBinutils" \ # "dev/GNUcc" "base/LibC" "dev/GNUcc" - _make finish From b96991afb4747438d3fd676a7ec7c52dc9668da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 30 Aug 2024 03:15:39 -0300 Subject: [PATCH 085/128] feat!: Made task history file location customizable. --- build-system/internals/makier.ksh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 6df7fa4..7b0704a 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -5,23 +5,28 @@ # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA -_make(){ +_make() { set -e lang='.ksh' tasks="${tasks:?"task directory not defined"}" - made="$tasks/made.txt" + made="${made:?"task history file not defined. +To disable it, define as the null character device."}" tak="$1" + # Create the file if it does not exist yet. + [[ ! -e "$made" ]] && echo -n >"$made" + # Since having access to the date of the last # change done to a file in the UNIX format is # hard without stat(1) or even strace(1)ng the # ls(1) program, we will use a rudimentary # technique to keep track of tasks that had # already being ran. - if grep -v "$tak" "$made"; then + if ! grep "$tak" "$made" >/dev/null; then shift # Remove '$1' . "$(printf '%s/%s%s' "$tasks" "$tak" "$lang")" "${@:-''}" # Write task name to a list of done tasks. - echo $tak >> "$tasks/made.txt" + [[ "$FORGO_TASKS" == *"$tak"* ]] || + echo $tak >>"$tasks/made.txt" fi } From f945b8b41b35e20183b32db720b0d0f43f827f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 30 Aug 2024 22:38:26 -0300 Subject: [PATCH 086/128] chore: Made aria2c verbose again and do 2 jobs per processor. --- cmd/download_sources.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index b71e74c..a165980 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -98,7 +98,7 @@ main() { printf '%s\n\tout=%s\n' \ "${urls[$j]}" "${urls[$j]##*/}" done) | - aria2c -q -j $(nproc) -x $(nproc) -d "$category_dir" -i - + aria2c -j $(( $(nproc) * 2 )) -x $(nproc) -d "$category_dir" -i - fi done if $(echo $SHA256CHECK | grep -i '^y' &>/dev/null) && From 86a90b531dd4f2c4c5696a4e818098571ba5e8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 30 Aug 2024 22:40:20 -0300 Subject: [PATCH 087/128] fix: clean $made file when starting over. --- build-system/tasks/disk/create_disk.ksh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-system/tasks/disk/create_disk.ksh b/build-system/tasks/disk/create_disk.ksh index 4acc413..7a80ede 100644 --- a/build-system/tasks/disk/create_disk.ksh +++ b/build-system/tasks/disk/create_disk.ksh @@ -137,6 +137,7 @@ if "$VIRTUAL_DISK"; then unset disk_block; export disk_block="${loop_disk_block}p1" fi if ( $first_time || $start_over ); then + echo -n > "$made" # Formats the disk block as Ext4 and label it as our defined disk label. elevate "$run_shell" -c "mkfs -V -t ext4 '$disk_block' && e2label '$disk_block' '$disk_label'" fi From c8aedb2f6cb03906eccfdc8fb119837af4f74ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 30 Aug 2024 22:43:21 -0300 Subject: [PATCH 088/128] fix: Deal with different $made file locations at _make() --- build-system/internals/makier.ksh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 7b0704a..e042b6e 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -9,8 +9,7 @@ _make() { set -e lang='.ksh' tasks="${tasks:?"task directory not defined"}" - made="${made:?"task history file not defined. -To disable it, define as the null character device."}" + made="${made:?"task history file not defined"}" tak="$1" # Create the file if it does not exist yet. @@ -27,6 +26,6 @@ To disable it, define as the null character device."}" . "$(printf '%s/%s%s' "$tasks" "$tak" "$lang")" "${@:-''}" # Write task name to a list of done tasks. [[ "$FORGO_TASKS" == *"$tak"* ]] || - echo $tak >>"$tasks/made.txt" + echo $tak >>"$made" fi } From af90a989abf7a13b2e6e06b60f3671709309eaf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 2 Sep 2024 03:06:46 -0300 Subject: [PATCH 089/128] feat!: Use new log() function based on @xplshn's work. With a little bit of code copi... I mean, inspiration from herbiec's printlog(), (ab)using some KornShell 93/GNU Bash features and using the "I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR" preference from machine.ini; also with rigorous checks for colour support in the terminal being used and a more pfmt(3C)-esque approach instead of the '--flag' one, besides some inspiration also drawn from Google Go's stdlib log package. This was suggested at https://github.com/Projeto-Pindorama/copacabana/issues/8#issuecomment-2263609139 Not necessarily related to this commit, but, if you please, take a listen to Astrud Gilberto's cover of a Jorge Ben song: https://youtu.be/EWv4mLbh8xo --- build-system/internals/helpers.shi | 88 +++++++++++++-- build-system/internals/log.shi | 87 +++++++++++---- build-system/tasks/checks/dependencies.ksh | 106 +++++++++--------- build-system/tasks/disk/create_disk.ksh | 118 +++++++++++---------- build-system/tasks/disk/populate.ksh | 10 +- build-system/tasks/get_sources.ksh | 5 +- build.ksh | 10 +- 7 files changed, 275 insertions(+), 149 deletions(-) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 650296b..deff271 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -6,6 +6,13 @@ # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA # +# 'check_for_colour_support', 'isatty', 'isdigit' and sections +# of 'map'/'record' and '__record' borrowed from Luiz Antônio's +# herbiec. As per the copyright header on herbiec.ksh: +# Copyright (c) 2023 Luiz Antônio Rangel +# +# SPDX-Licence-Identifier: ISC +# # "'Liberdade, Igualdade, Fraternidade', # é o seguinte: se tem Liberdade, tem que # ter Igualdade, Amor e Fraternidade [...]" @@ -165,14 +172,14 @@ function c { # we just want the extension. tarball_ext="${tarball_ext##*.}" case "$tarball_ext" in - gz | tgz) { gzip "$@"; } ;; - xz | txz) { xz "$@"; } ;; - bz2 | tbz) { bzip2 "$@"; } ;; - tar) { - shift - cat "$@" - } ;; - *) printerr "$0: File format not recognized." ;; + gz | tgz) { gzip "$@"; } ;; + xz | txz) { xz "$@"; } ;; + bz2 | tbz) { bzip2 "$@"; } ;; + tar) { + shift + cat "$@" + } ;; + *) log PANE "%s: File format not recognized." $0 ;; esac } @@ -219,3 +226,68 @@ function check_elevate_method { function yes2bool { (echo $1 | grep -i '^y' &>/dev/null) || false } + +# Just as the name says. +function check_for_colour_support { + # Get the terminal program, if it + # is a terminal emulator, so we can + # check if it supports ANSI escape + # codes. + termppath="$(ps -p $PPID -o comm=)" + termprog="${termppath##*/}" + + # Presumption of innocence about ANSI + # escape codes on the terminal. + itsANSIcap=true + + # Colour table. + map colours red '\033[91m' + map colours green '\033[92m' + map colours azure '\033[34m' + map colours yellow '\033[93m' + map colours purple '\033[35m' + map colours close '\033[m' + + # Is our terminal capable of processing + # ANSI escape codes? This list is just + # a sketch, you can expand it per sending + # a patch. + case "$termprog" in + # Found guilty! + 9term) itsANSIcap=false ;; + *) break ;; + esac + + if ! isatty 2 && ! $itsANSIcap && (($(tput colors) < 8)); then + unset colours + fi +} + +# Checks if the informed f.d. is a valid teletype device. +# Boilerplate for the shell built-in 'test' with the '-t' +# option and basic error handling for erred usage. +# Analogous to its homonymous in the C programming +# language (isatty(3)). +function isatty { + if ! isdigit $1; then + log ERRORF "%s: '%s' is not a valid tty." $0 $1 + return 2 + fi + + { test -t $1; } || return 1 +} + +# Checks if the informed character is a digit. It uses +# printf(1) along with KornShell 93/GNU Bash built-in +# regex for checking if it's actually a digit. +# Just like the latter, it's analogous to its homonymous +# in the C programming language (isdigit(3)). +function isdigit { + digit=$1 + shift + errstring="$@" + + if [[ $(printf '%d' $digit) != $digit && $digit == +([0-9]) ]]; then + false + fi +} diff --git a/build-system/internals/log.shi b/build-system/internals/log.shi index c2da47d..3dd6f25 100644 --- a/build-system/internals/log.shi +++ b/build-system/internals/log.shi @@ -1,31 +1,76 @@ # vim: set filetype=sh : -# Error handling and logging in general. +# Error handling and logging in general. # Copyright (c) 2023-2024 Pindorama -# Luiz Antônio Rangel +# Copyright (c) 2024 xplshn +# Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA - -# Use this function both for errors and warnings -function printerr { - printf "$@" 1>&2 -} +# +# Rewritten using xplshn's Andes /etc/profile.d/std.sh +# as the base. # And use this for fatal errors, it will exit the script. function panic { - msgbuf="$(printf "$@")" - printerr 'panic: %s' "$msgbuf" - - exit 255 + log PANE "$@" } -# This function writes everything in a program output to a file passed as a -# parameter, else it also writes it to the standard output using tee(1). -# Sure thing you still need to pass 2>&1 before the pipe to 'logto [file]'. -function logto { - file="$1" - # Do not be scared, just a boolean having a rendezvous with a - # more compact alternative to if-else statements. - c29waGlhZmljYWNvbWlnbwo=$I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR - { $c29waGlhZmljYWNvbWlnbwo && tee "$file"; } \ - || { cat - >> "$file"; } +# Function to log to stdout with optional color +function log { + # Default format and function return (none, true). + fmt="" + _defer='return 0' + + # Check if the first argument is a valid level of logging + # and, if it is, which it is. + # It will set the colour code from these. + level="$1" + # Shift past the level argument. + shift + case "$level" in + 'PANE') + printf 'panic: %%s\\n\\n' + _defer='exit 255' + ;; + 'ERROR' | 'WARN' | 'INFO' | 'DEBUG') + case "$level" in + 'ERROR') + colour=${colours[red]} + _defer='return 1' + ;; + 'WARN') colour=${colours[yellow]} ;; + 'INFO') colour=${colours[green]} ;; + 'DEBUG') colour=${colours[purple]} ;; + esac + + fmt="$(printf '%b%s%b: %%s\\n' \ + "$colour" $level "${colours[close]}")" + + case $I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR in + 'true') break ;; + *) + case $level in + 'INFO' | 'DEBUG') fmt='' ;; + esac + ;; + esac + ;; + 'PROGOUT') + colour="${colours[azure]}" + program="$1" + shift + fmt="$(printf '(program) %b%s%b: %%s\\n' \ + "$colour" "$(realpath "$program")" "${colours[close]}")" + ;; + # Work just as 'printf [...] 1>&2' --- maybe + # a little slower because of the switches + 'STD') ;; + *) log ERROR 'Invalid level.' ;; + esac + + # Print the message with or without color, + # pre-formatting the output before, of course + [[ -n $@ ]] && msgbuf="$(printf "$@")" + printf "$fmt" "$msgbuf" 1>&2 + + $_defer } diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index 8b2c75d..ba6456d 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -46,43 +46,42 @@ if $USE_ARIA2C; then fi for ((g=0; g < $(n ${general_commands[@]}); g++)); do - printerr 'Searching for %s at PATH (%s)... ' \ + log INFO 'Searching for %s at PATH (%s)... ' \ "${general_commands[$g]}" "$PATH" - if ! type -p "${general_commands[$g]}"; then + if ! type -p "${general_commands[$g]}" 2>&1 >/dev/null; then case "${general_commands[$g]}" in - sha256sum) - # Use internal sha256sum implementation - function sha256sum { - "$build_kshdir/cmd/sha256sum.ksh" "$@" - } - typeset -xf sha256sum - ;; - *) - printerr 'Not found.\n' - return 1 - ;; + sha256sum) + # Use internal sha256sum implementation + function sha256sum { + "$build_kshdir/cmd/sha256sum.ksh" "$@" + } + typeset -xf sha256sum + ;; + *) + log ERROR '%s not found.' "${general_commands[$g]}" + ;; esac fi done for ((h=0; h < $(n ${archivers[@]}); h++)); do - printerr 'Does %s work for what we want? ' "${archivers[$h]}" + log INFO 'Does %s work for what we want? ' "${archivers[$h]}" if [ "${archivers[$h]}" == 'tar' ]; then # TAR-specific tests tarpath="$(realpath $(type -p tar))" if (strings "$tarpath" | grep '@(#)tar.*\(gritter\)' && getconf HEIRLOOM_TOOLCHEST_VERSION) 2>&1 >/dev/null; then - printerr '\nI'\''m almost certain that %s is from the Heirloom Toolchest...\n' \ + log WARN 'I'\''m almost certain that %s is from the Heirloom Toolchest...' \ "$(type -p tar)" - printerr 'Heirloom Toolchest'\''s tar is broken since at least 2007 for some reason.\n' - printerr \ - 'Until this is hopefully fixed, I'\''ll be searching for another tar at PATH.\n' + log WARN 'Heirloom Toolchest'\''s tar is broken since at least 2007 for some reason.' + log WARN \ + 'Until this is hopefully fixed, I'\''ll be searching for another tar at PATH.' printf '%s' "$PATH" | nawk '{ gsub(":", "\n"); print $0; }' | for ((;;)); do if read -r d; then tar_cmd="$d/tar" - if [[ ! -e "$tar_cmd" || "$d" == "${tarpath%/*}" ]]; then + if [[ ! -e $tar_cmd || $d == "${tarpath%/*}" ]]; then continue elif ($tar_cmd --help 2>&1 | egrep 'star|bsdtar|GNU' 2>&1 >/dev/null); then new_tarpath="$(realpath $d)" @@ -106,8 +105,8 @@ for ((h=0; h < $(n ${archivers[@]}); h++)); do } } }')" - printerr 'Info: Found suitable tar at %s\n' $new_tarpath - printerr 'Info: New PATH: %s\n' $PATH + log INFO 'Found suitable tar at %s\n' $new_tarpath + log INFO 'New PATH: %s\n' $PATH export PATH unset new_tarpath tmpPATH break @@ -120,14 +119,14 @@ for ((h=0; h < $(n ${archivers[@]}); h++)); do done fi - if [[ "$tarpath" =~ (star) ]] || + if [[ $tarpath =~ (star) ]] || (tar -h 2>&1 | grep 'star' 2>&1 >/dev/null); then - printerr '\nI'\''m almost certain that %s is Schily tar...\n' \ + log INFO 'I'\''m almost certain that %s is Schily tar...' \ "$(type -p tar)" - printerr \ - 'I'\''ll disable the secure symbolic links function, for avoiding problems later.\n' - printerr \ - 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).\n' + log INFO \ + 'I'\''ll disable the secure symbolic links function, for avoiding problems later.' + log INFO \ + 'Also setting archive type as "xustar" for unlimited file size (grander than 8192 MiB).' function tar { "$(type -p tar)" "$@" \ --no-secure-links --artype=xustar @@ -154,7 +153,7 @@ for ((h=0; h < $(n ${archivers[@]}); h++)); do } && rm -rf "${archiver_sanity}_results" else # Bzip2, Gzip or Xz tests for ((l=1; l <= 9; l++)); do - printerr 'With compression level %s? ' $l + log INFO 'With compression level %s? ' $l # Test the alphabet string can be compressed # without being corrupted, then, do a more @@ -166,38 +165,35 @@ for ((h=0; h < $(n ${archivers[@]}); h++)); do { cat "$progdir/$progname" | "${archivers[$h]}" -"$l" -cf | "${archivers[$h]}" -dcf | cmp - "$progdir/$progname"; } - printerr 'Ok...\n' + log INFO 'Ok...' done fi - printerr 'Sounds like a yes.\n' + log INFO 'Sounds like a yes.' done for ((i=0; i < $(n ${utils[@]}); i++)); do - printerr 'Is %s present on this system? ' "${utils[$i]}" - command -v ${utils[$i]} 2>&1 >/dev/null && printerr 'Sounds like a yes.\n' || - { - printerr '%s not found.\n' ${utils[$i]} - return 1 - } + log INFO 'Is %s present on this system? ' "${utils[$i]}" + command -v ${utils[$i]} 2>&1 >/dev/null && + log INFO 'Sounds like a yes.' || + log ERROR '%s not found.' ${utils[$i]} done for ((k=0; k < $(n ${internal_scripts[@]}); k++)); do - printerr 'Info: Searching for independent script %s at %s... ' \ + log INFO 'Searching for independent script %s at %s... ' \ "${internal_scripts[$k]}" "$progdir" if [ -e "$progdir/${internal_scripts[$k]}" ] && [ ! -z "$(cat "$progdir/${internal_scripts[$k]}")" ]; then - printerr 'Found!\n' + log INFO 'Found!' else - printerr '%s not found...\n' - panic 'Error: It seems like your Copacabana repository clone is incomplete.\n' - return 1 + log WARN '%s not found...' "${internal_scripts[$k]}" + panic 'It seems like your Copacabana repository clone is incomplete.' fi done # Programming language interpreters/compilers sanity checks. run_shell="$(readlink -f /proc/$$/exe)" -printerr 'Does the running shell (%s) work for what we need?\n' "$run_shell" +log INFO 'Does the running shell (%s) work for what we need?' "$run_shell" # Not caching "$(readlink -f /proc/$$/exe)" via $run_shell on the sanity test, # since we expect it to run as a new process, so as a new P.ID. and as a new @@ -224,9 +220,10 @@ Please, report this at https://github.com/Projeto-Pindorama/copacabana.\n' "$int return 1 fi EO_KSHSANITY +log PROGOUT "$ksh_sanity_test" "$run_shell" "$ksh_sanity_test" -printerr 'Does the C/C++ compiler work for what we need?\n' +log INFO 'Does the C/C++ compiler work for what we need?' cat >"$c_sanity_test" <<'EO_CSANITY' #include @@ -267,21 +264,22 @@ return RETURN; } EO_C++SANITY -{ - "$CC" -o"$trash/c_sanity" "$c_sanity_test" - "$trash/c_sanity" && - "$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test" && "$trash/cxx_sanity" -} || - exit $? +log PROGOUT "$CC" "$("$CC" -o"$trash/c_sanity" "$c_sanity_test")" +log PROGOUT "$trash/c_sanity" "$($trash/c_sanity)" +log PROGOUT "$CXX" "$("$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test")" +log PROGOUT "$trash/cxx_sanity" "$($trash/cxx_sanity)" +if ! ("$trash/c_sanity" || "$trash/cxx_sanity") 2>&1 >/dev/null; then + log ERROR 'Error at the C/C++ compiler sanity tests.' +fi -printerr 'Info: Generating our cross-compiling host based on this machine'\''s type...\n' -printerr 'Does this system have GNU Broken-Again Shell for $MACHTYPE or we'\''ll be depending on %s? ' \ +log INFO 'Generating our cross-compiling host based on this machine'\''s type...' +log DEBUG 'Does this system have GNU Broken-Again Shell for $MACHTYPE or we'\''ll be depending on %s?' \ "$CC" if ! type -p bash 2>&1 >/dev/null; then - printerr 'Nah, it'\''s clean.\n' + log DEBUG 'Nah, it'\''s clean.' has_bash=false else - printerr 'It does, we'\''re going with it.\n' + log DEBUG 'It does, we'\''re going with it.' has_bash=true fi @@ -290,7 +288,7 @@ COPA_HOST="$( ( ($has_bash && bash -c 'echo $MACHTYPE') || nawk '{ split($0, host, "-"); sub(host[2], "crossCOPACABANA", $0); printf("%s\n", $0); }')" unset has_bash -printerr 'Info: COPA_HOST will be "%s".\n' "$COPA_HOST" +log INFO 'COPA_HOST will be "%s".' "$COPA_HOST" # Exporting our running Shell for using later in other tasks and also the # $COPA_HOST, that will be used when building the cross-compiler. diff --git a/build-system/tasks/disk/create_disk.ksh b/build-system/tasks/disk/create_disk.ksh index 7a80ede..97dcaec 100644 --- a/build-system/tasks/disk/create_disk.ksh +++ b/build-system/tasks/disk/create_disk.ksh @@ -1,9 +1,9 @@ -# STEP 1: "Pindorama presents: Fubá Cake" +# STEP 1: "Pindorama presents: Fubá Cake" # In this step, we will create and format a disk, virtual or physical. disk_block="$1" # Set first_time flag to indicate that it's the first time building the -# system. +# system. first_time=true # Estabilish a default size of 20 GB for a virtual disk @@ -19,50 +19,53 @@ disk_label=${DISK_LABEL:-'Copacabana'} # t = Use a type # 83 = Linux partition type # w = Write 'n quit -fdisk_steps=( 'o' 'n' 'p' '1' ' ' ' ' 't' '83' 'w' ) - -if (( ${#disk_label} > 16 )); then - printerr \ - 'Warning: This disk label ("%s") exceeds e2label'\''s VOLNAMSZ (%d) in %d characters.\n' \ - "$disk_label" 16 $(( ${#disk_label} - 16 )) - printerr \ - 'Warning: Falling back to the default value so we does not get any warnings from e2label.\n' - unset disk_label; disk_label='Copacabana' +fdisk_steps=('o' 'n' 'p' '1' ' ' ' ' 't' '83' 'w') + +if ((${#disk_label} > 16)); then + log WARN \ + 'This disk label ("%s") exceeds e2label'\''s VOLNAMSZ (%d) in %d characters.' \ + "$disk_label" 16 $((${#disk_label} - 16)) + log WARN \ + 'Falling back to the default value so we does not get any warnings from e2label.' + unset disk_label + disk_label='Copacabana' fi -printerr 'Info: %s only creates a plain disk, without partitions for /boot, /usr, etc.\n' $0 -if [[ ! "$VIRTUAL_DISK" ]] && [[ -b "$disk_block" ]] \ - || ( [[ "$(uname -s)" == "Linux" ]] && (( KSH93_RELEASE <= 20211217 )) \ - && (grep "${disk_block##*/}" /proc/partitions 2>&1 > /dev/null \ - && [[ "$(file "$disk_block")" =~ (.*[\t ]block special.*) ]]) ); then +log WARN '%s only creates a plain disk, without partitions for /boot, /usr, etc.' $0 +if [[ ! $VIRTUAL_DISK ]] && [[ -b $disk_block ]] || + ([[ "$(uname -s)" == "Linux" ]] && ((KSH93_RELEASE <= 20211217)) && + (grep "${disk_block##*/}" /proc/partitions 2>&1 >/dev/null && + [[ "$(file "$disk_block")" =~ (.*[\t ]block special.*) ]])); then # Get the disk size from /proc/partitions, pretty # self-explanatory. - disk_size="$(grep "${disk_block##*/}\$" /proc/partitions \ - | nawk '{ printf "%0.1f\n", ($(NF -1) / 1024); }')" + disk_size="$(grep "${disk_block##*/}\$" /proc/partitions | + nawk '{ printf "%0.1f\n", ($(NF -1) / 1024); }')" - printerr 'Info: Using a physical disk, present at %s with size of %d MB.\n' \ + log INFO 'Using a physical disk, present at %s with size of %d MB.' \ "$disk_block" "$disk_size" - if (( disk_size < (10 * 1024) )); then + if ((disk_size < (10 * 1024))); then panic \ - 'Disk %s is too small (%d MB). %d MB is the recommended capacity for building Copacabana.\n' \ - "$disk_block" "$disk_size" $(( 10 * 1024 )) + 'Disk %s is too small (%d MB). %d MB is the recommended capacity for building Copacabana.' \ + "$disk_block" "$disk_size" $((10 * 1024)) # Do not accept disks/disk partitions larger than 50GB. - elif (( disk_size > (50 * 1024) )); then + elif ((disk_size > (50 * 1024))); then panic \ - 'Disk %s is too large. Create a partition and/or use a virtual disk smaller than %d MB.\n' \ - "$disk_block" $(( 50 * 1024 )) + 'Disk %s is too large. Create a partition and/or use a virtual disk smaller than %d MB.' \ + "$disk_block" $((50 * 1024)) fi # Check if disk is already initialized. if $(elevate fdisk -x "${disk_block%%[0-9]}" | grep "$disk_block" &>/dev/null); then - filesystem=$(eval $(blkid -o udev "$disk_block"); - printf '%s\n' "$ID_FS_TYPE") + filesystem=$( + eval $(blkid -o udev "$disk_block") + printf '%s\n' "$ID_FS_TYPE" + ) if ! check_linuxfs $filesystem; then panic \ - '%s is not intended for containing a Linux system.\nDid you mean creating a virtual disk image inside %s?\n' \ - $filesystem "$disk_block" + '%s is not intended for containing a Linux system.\nDid you mean creating a virtual disk image inside %s?' \ + $filesystem "$disk_block" fi # If we have a compatible file system on the disk, we @@ -73,14 +76,17 @@ elif [[ "$VIRTUAL_DISK" ]]; then # This would be the equivalent of the old realpath() builtin # at posix-alt.shi, it gets $disk_block's directory location # and then contatenates it with its name. - virtuadisk_path="$(cd "${disk_block%/*}"; pwd -P)/${disk_block##*/}" - printerr 'Info: Using a virtual disk, located at %s, with a pre-determined size of %d MB.\n' \ - "$virtuadisk_path" $(( virtuadisk_size * 1024 )) - - if [[ ! -e "$virtuadisk_path" ]]; then - printerr 'Info: Inexistent disk image, creating it...\n' - elif [[ -e "$virtuadisk_path" && ! -b "$virtuadisk_path" ]]; then - printerr 'Info: A disk image already exists at %s, do you wish to continue or clean it up and start over?\n' \ + virtuadisk_path="$( + cd "${disk_block%/*}" + pwd -P + )/${disk_block##*/}" + log WARN 'Using a virtual disk, located at %s, with a pre-determined size of %d MB.' \ + "$virtuadisk_path" $((virtuadisk_size * 1024)) + + if [[ ! -e $virtuadisk_path ]]; then + log WARN 'Inexistent disk image, creating it...' + elif [[ -e $virtuadisk_path && ! -b $virtuadisk_path ]]; then + log WARN 'A disk image already exists at %s, do you wish to continue or clean it up and start over?' \ "$virtuadisk_path" first_time=false fi @@ -94,35 +100,36 @@ if ! $first_time; then # This will (L.E.)mount the disk and view if # there is something that can be done. yes) break ;; - no) start_over=true; - break ;; - quit|*) return 1 ;; + no) + start_over=true + break + ;; + quit | *) return 1 ;; esac done fi if "$VIRTUAL_DISK"; then - if ( $first_time || $start_over ); then - printerr 'Info: Creating a virtual disk image at %s, with size of %d MB.\n' \ - "$virtuadisk_path" $(( virtuadisk_size * 1024 )) + if ($first_time || $start_over); then + log WARN 'Creating a virtual disk image at %s, with size of %d MB.' \ + "$virtuadisk_path" $((virtuadisk_size * 1024)) # 1 GB is equal to 2.097.152 blocks. # In other words, use: # X GB = X * [(1024^2) * 2] blocks - virtuadisk_blksize="$(( virtuadisk_size * ((1024 ** 2) * 2) ))" + virtuadisk_blksize="$((virtuadisk_size * ((1024 ** 2) * 2)))" dd if=/dev/zero of="$virtuadisk_path" bs=512 count=$virtuadisk_blksize # Does the size in blocks matches with what du(1)'s getting? virtuadisk_reported_size=$(du -s "$virtuadisk_path" | nawk '{ printf("%d", $1); }') - - if (( virtuadisk_blksize == virtuadisk_reported_size )); then - printerr 'Info: %s is o.k. Proceeding.\n' "$virtuadisk_path" + + if ((virtuadisk_blksize == virtuadisk_reported_size)); then + log INFO '%s is o.k. Proceeding.' "$virtuadisk_path" else - printerr 'Error: dd failed to write %d blocks to %s.\n' \ + log WARN 'dd failed to write %d blocks to %s.' \ $virtuadisk_blksize "$virtuadisk_path" - printerr 'Error: It possible reported an error and/or an interruption signal before this message.\n' - printerr 'Error: Please, check. Stopping the build process.\n' - return 1 + log WARN 'It possible reported an error and/or an interruption signal before this message.' + log ERROR 'Please, check. Stopping the build process.' fi # For some reason, echo won't be working for this, so let be @@ -134,10 +141,11 @@ if "$VIRTUAL_DISK"; then loop_disk_block="$(elevate losetup --show -P -f "$virtuadisk_path")" # That's why we hardcoded the partition to be the first. - unset disk_block; export disk_block="${loop_disk_block}p1" + unset disk_block + export disk_block="${loop_disk_block}p1" fi -if ( $first_time || $start_over ); then - echo -n > "$made" +if ($first_time || $start_over); then + echo -n >"$made" # Formats the disk block as Ext4 and label it as our defined disk label. elevate "$run_shell" -c "mkfs -V -t ext4 '$disk_block' && e2label '$disk_block' '$disk_label'" fi @@ -152,4 +160,4 @@ printf '%s\n' "$disk_block" 1 | eval $(elevate lemount) # overwritten by a "non-build.ksh aware" script later. export readonly COPA="$ledisk" -printerr 'Info: Copacabana disk %s mounted at %s.\n' "$disk_block" "$COPA" +log INFO 'Copacabana disk %s mounted at %s.' "$disk_block" "$COPA" diff --git a/build-system/tasks/disk/populate.ksh b/build-system/tasks/disk/populate.ksh index b07fc17..4111074 100644 --- a/build-system/tasks/disk/populate.ksh +++ b/build-system/tasks/disk/populate.ksh @@ -11,7 +11,7 @@ blackbox="$COPA/build.log.$CPU" # Self-explanatory, just create the directories for the initial # toolchain and intermediary chroot toolchain. -printerr 'Info: Making directories in %s for the building toolchains.\n' \ +log INFO 'Making directories in %s for the building toolchains.' \ "$COPA" elevate mkdir -p "$COPA/"{cgnu,llvm}tools "$OBJDIR" "$PKGDIR" (cd "$COPA"; ls -lah .) @@ -22,7 +22,7 @@ elevate mkdir -p "$COPA/"{cgnu,llvm}tools "$OBJDIR" "$PKGDIR" # {"$COPA/",/}cgnutools expands to $COPA/cgnutools /cgnutools, # which is the input that we'd need to ln(1). if [[ -d "$COPA/cgnutools" && -d "$COPA/llvmtools" ]]; then - printerr 'Info: Symbolic linking %s to %s...\n' \ + log INFO 'Symbolic linking %s to %s...' \ {"$COPA/",/}cgnutools {"$COPA/",/}llvmtools # If /cgnutools is already a symbolic link to @@ -46,15 +46,15 @@ if [[ -d "$COPA/cgnutools" && -d "$COPA/llvmtools" ]]; then (cd /; ls -l ./{cgnu,llvm}tools) fi -printerr 'Info: Making directories in %s for populating the file system.\n' \ +log INFO 'Making directories in %s for populating the file system.' \ "$COPA" elevate $run_shell -c "COPA=$COPA BUILD_KSH=$BUILD_KSH $progdir/cmd/populate_fhs.sh; mkdir -p "$SRCDIR"" -printerr 'Info: Initializing blackbox file (%s) for the build.\n' \ +log INFO 'Initializing blackbox file (%s) for the build.' \ "$blackbox" ( cd "$COPA"; elevate sh -c "> $blackbox; chown $user $blackbox" ) -printerr 'Info: Making %s, %s, %s, %s and %s writable by the current user.\n' \ +log INFO 'Making %s, %s, %s, %s and %s writable by the current user.' \ $(realpaths /{cgnu,llvm}tools) "$SRCDIR" "$OBJDIR" "$PKGDIR" elevate chown -RH "$user" /{cgnu,llvm}tools "$SRCDIR" "$OBJDIR" "$PKGDIR" export blackbox SRCDIR diff --git a/build-system/tasks/get_sources.ksh b/build-system/tasks/get_sources.ksh index 4d4ff28..727ec7f 100644 --- a/build-system/tasks/get_sources.ksh +++ b/build-system/tasks/get_sources.ksh @@ -22,9 +22,12 @@ source_list="$(readlink -f "$1")" source_hash="$(readlink -f "$2")" +# Ratify since it may not be defined on a second +# run after disk/populate has been run. +SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" export USE_ARIA2C SHA256CHECK SRCDIR -printerr 'Info: Downloading sources for building Copacabana using %s as the list.\n' \ +log INFO 'Downloading sources for building Copacabana using %s as the list.\n' \ "$source_list" "$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" diff --git a/build.ksh b/build.ksh index 29086f6..8d5aafa 100755 --- a/build.ksh +++ b/build.ksh @@ -4,13 +4,13 @@ # SPDX-Licence-Identifier: NCSA set -e -trap '_make finish' ERR EXIT progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" # _make tasks="$progdir/build-system/tasks" +made="$progdir/_made" . "$progdir/build-system/internals/makier.ksh" # Immediatly source and run the platform @@ -18,8 +18,8 @@ tasks="$progdir/build-system/tasks" _make 'checks/platform' . "$progdir/build-system/internals/posix-alt.shi" -. "$progdir/build-system/internals/log.shi" . "$progdir/build-system/internals/helpers.shi" +. "$progdir/build-system/internals/log.shi" . "$progdir/build-system/internals/rconfig.shi" . "$progdir/build-system/internals/disks.shi" @@ -29,13 +29,13 @@ rconfig "$progdir/build-system/fhs.ini" trash="$(mktemp -d "$TRASH_PREFIX/CopaBuild.XXXXXX")" map dtime initial "$(date +'%Hh%Mmin on %B %d, %Y')" +check_for_colour_support check_elevate_method _make 'checks/dependencies' _make 'disk/create_disk' "$DISK_BLOCK" _make 'disk/populate' _make get_sources sources.txt sources.sha256 -_make build cross-tools -#build cross-tools "base/kernel-headers" "dev/GNUBinutils" \ -# "dev/GNUcc" "base/LibC" "dev/GNUcc" +_make build_set cross-tools +_make build_set base _make finish From e5af04e6b490864d4eb503685379eac782ec3d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 3 Sep 2024 13:04:32 -0300 Subject: [PATCH 090/128] fix: Terminal detection at check_for_colour_support() and better verbose at log() and _make(). --- build-system/internals/helpers.shi | 5 +++-- build-system/internals/log.shi | 12 ++++++------ build-system/internals/makier.ksh | 5 +++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index deff271..739e883 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -233,7 +233,8 @@ function check_for_colour_support { # is a terminal emulator, so we can # check if it supports ANSI escape # codes. - termppath="$(ps -p $PPID -o comm=)" + kshpid="$(ps -p $PPID -o ppid=)" + termppath="$(ps -p $kshpid -o comm=)" termprog="${termppath##*/}" # Presumption of innocence about ANSI @@ -258,7 +259,7 @@ function check_for_colour_support { *) break ;; esac - if ! isatty 2 && ! $itsANSIcap && (($(tput colors) < 8)); then + if ! isatty 2 || ! $itsANSIcap || (($(tput colors) < 8)); then unset colours fi } diff --git a/build-system/internals/log.shi b/build-system/internals/log.shi index 3dd6f25..402f631 100644 --- a/build-system/internals/log.shi +++ b/build-system/internals/log.shi @@ -9,22 +9,22 @@ # Rewritten using xplshn's Andes /etc/profile.d/std.sh # as the base. -# And use this for fatal errors, it will exit the script. +# And use this for fatal errors, it will exit the script function panic { log PANE "$@" } # Function to log to stdout with optional color function log { - # Default format and function return (none, true). + # Default format and function return (none, true) fmt="" _defer='return 0' # Check if the first argument is a valid level of logging - # and, if it is, which it is. - # It will set the colour code from these. + # and, if it is, which it is + # It will set the colour code from these level="$1" - # Shift past the level argument. + # Shift past the level argument shift case "$level" in 'PANE') @@ -64,7 +64,7 @@ function log { # Work just as 'printf [...] 1>&2' --- maybe # a little slower because of the switches 'STD') ;; - *) log ERROR 'Invalid level.' ;; + *) log ERROR 'Invalid level '\''%s'\''' $level;; esac # Print the message with or without color, diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index e042b6e..9c8b2a4 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -7,6 +7,7 @@ _make() { set -e + funcname=$0 lang='.ksh' tasks="${tasks:?"task directory not defined"}" made="${made:?"task history file not defined"}" @@ -23,7 +24,11 @@ _make() { # already being ran. if ! grep "$tak" "$made" >/dev/null; then shift # Remove '$1' + printf '%s: running task '\''%s'\''\n' \ + $funcname "$tak" 1>&2 . "$(printf '%s/%s%s' "$tasks" "$tak" "$lang")" "${@:-''}" + printf '%s: task done\n' \ + "$funcname" 1>&2 # Write task name to a list of done tasks. [[ "$FORGO_TASKS" == *"$tak"* ]] || echo $tak >>"$made" From b99ee6541306e87eb5758bb77b8b16faf53210af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 3 Sep 2024 21:25:53 -0300 Subject: [PATCH 091/128] chore: Change log INFO to log WARN at tar check on checks/dependencies. --- build-system/tasks/checks/dependencies.ksh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index ba6456d..f2be9bb 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -105,7 +105,7 @@ for ((h=0; h < $(n ${archivers[@]}); h++)); do } } }')" - log INFO 'Found suitable tar at %s\n' $new_tarpath + log WARN 'Found suitable tar at %s\n' $new_tarpath log INFO 'New PATH: %s\n' $PATH export PATH unset new_tarpath tmpPATH @@ -264,9 +264,9 @@ return RETURN; } EO_C++SANITY -log PROGOUT "$CC" "$("$CC" -o"$trash/c_sanity" "$c_sanity_test")" +log PROGOUT "$CC" "$("$CC" -o"$trash/c_sanity" "$c_sanity_test")\n" log PROGOUT "$trash/c_sanity" "$($trash/c_sanity)" -log PROGOUT "$CXX" "$("$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test")" +log PROGOUT "$CXX" "$("$CXX" -o"$trash/cxx_sanity" "$cxx_sanity_test")\n" log PROGOUT "$trash/cxx_sanity" "$($trash/cxx_sanity)" if ! ("$trash/c_sanity" || "$trash/cxx_sanity") 2>&1 >/dev/null; then log ERROR 'Error at the C/C++ compiler sanity tests.' From 43e5a932cc799e77bd95ad6bb80bd3db11a2749f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 5 Sep 2024 21:55:16 -0300 Subject: [PATCH 092/128] chore: Include log.shi before helpers.shi at build.ksh --- build.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ksh b/build.ksh index 8d5aafa..05f4086 100755 --- a/build.ksh +++ b/build.ksh @@ -17,9 +17,9 @@ made="$progdir/_made" # checks before doing anything else. _make 'checks/platform' +. "$progdir/build-system/internals/log.shi" . "$progdir/build-system/internals/posix-alt.shi" . "$progdir/build-system/internals/helpers.shi" -. "$progdir/build-system/internals/log.shi" . "$progdir/build-system/internals/rconfig.shi" . "$progdir/build-system/internals/disks.shi" From 6e823d487f12073260c014d49c8faf6e25ec06fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 5 Sep 2024 21:57:20 -0300 Subject: [PATCH 093/128] chore: Do not format panic() error messages. --- build-system/internals/helpers.shi | 9 +++++---- build-system/internals/rconfig.shi | 2 +- build-system/tasks/checks/dependencies.ksh | 2 +- build.ksh | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 739e883..50b12b2 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -67,6 +67,7 @@ function record { # is no problem for now since Bash doesn't support compound variables, # just associative arrays, so both "map" and "record" can be the same to Bash. __record() { + backend_name='record()/map() backend' # "London calling to the faraway towns... # But it wasn't my love... # Is she still upset with me?" @@ -83,14 +84,14 @@ __record() { elif [[ $whos_calling == 'map' ]]; then format='%s+=([%s]="%s")' else - panic '%s: invalid caller '%s'.\n' \ - 'record()/map() backend' "$whos_calling" + panic '%s: invalid caller '\''%s'\''.' \ + "$backend_name" "$whos_calling" fi else # Broken-Again if ! $bash_supports_compound; then panic \ - '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.\n' \ - 'record()/map() backend' + '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.' \ + "$backend_name" # Basic sanitizing in case of panic() does # not quitting the program as intended. unset bash_supports_compound diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi index bbeae3f..d540cf8 100644 --- a/build-system/internals/rconfig.shi +++ b/build-system/internals/rconfig.shi @@ -60,7 +60,7 @@ function dotini { # it's just a formality when the topic are ksh-ish languages such # as GNU's Bash or even ksh93 itself. if [[ ! -e "$file" ]]; then - panic '%s: file %s does not exist.\n' $0 "$file" + panic '%s: file %s does not exist.' $0 "$file" fi # Allocate an array for recording the file and declarate diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index f2be9bb..9e9465e 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -113,7 +113,7 @@ for ((h=0; h < $(n ${archivers[@]}); h++)); do fi unset tar_cmd else - panic 'Error: Couldn'\''t find a suitable tar implementation.\n' + panic 'Couldn'\''t find a suitable tar implementation.' break # Une pure formalité. fi done diff --git a/build.ksh b/build.ksh index 05f4086..2fd7a6d 100755 --- a/build.ksh +++ b/build.ksh @@ -17,8 +17,8 @@ made="$progdir/_made" # checks before doing anything else. _make 'checks/platform' -. "$progdir/build-system/internals/log.shi" . "$progdir/build-system/internals/posix-alt.shi" +. "$progdir/build-system/internals/log.shi" . "$progdir/build-system/internals/helpers.shi" . "$progdir/build-system/internals/rconfig.shi" . "$progdir/build-system/internals/disks.shi" From 17e4a72a28a751adda09f438b890ad21d3aae576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 13 Sep 2024 00:17:53 -0300 Subject: [PATCH 094/128] fix: log STD and log PANE I swear this may be the last time I work on the helper functions, now it's time for Copacabana building itself. --- build-system/internals/log.shi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/internals/log.shi b/build-system/internals/log.shi index 402f631..6873e48 100644 --- a/build-system/internals/log.shi +++ b/build-system/internals/log.shi @@ -28,7 +28,7 @@ function log { shift case "$level" in 'PANE') - printf 'panic: %%s\\n\\n' + fmt='panic: %s\n' _defer='exit 255' ;; 'ERROR' | 'WARN' | 'INFO' | 'DEBUG') @@ -63,7 +63,7 @@ function log { ;; # Work just as 'printf [...] 1>&2' --- maybe # a little slower because of the switches - 'STD') ;; + 'STD') fmt='%s' ;; *) log ERROR 'Invalid level '\''%s'\''' $level;; esac From becb4b40bed2084768a936183fd5097ccfc592c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 13 Sep 2024 10:16:11 -0300 Subject: [PATCH 095/128] fix: log STD --- build-system/internals/log.shi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build-system/internals/log.shi b/build-system/internals/log.shi index 6873e48..e1d2a8d 100644 --- a/build-system/internals/log.shi +++ b/build-system/internals/log.shi @@ -61,10 +61,11 @@ function log { fmt="$(printf '(program) %b%s%b: %%s\\n' \ "$colour" "$(realpath "$program")" "${colours[close]}")" ;; - # Work just as 'printf [...] 1>&2' --- maybe - # a little slower because of the switches - 'STD') fmt='%s' ;; - *) log ERROR 'Invalid level '\''%s'\''' $level;; + 'STD') # Works just as 'printf [...] 1>&2'. + fmt="$1" + shift + ;; + *) log ERROR 'Invalid level '\''%s'\''' $level ;; esac # Print the message with or without color, From d7229d8935b25004e9e2689f8b4deb6660e7eea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 19 Sep 2024 07:23:30 -0300 Subject: [PATCH 096/128] feat: Writing part for building packages and sets --- build-system/internals/makier.ksh | 33 +++++++++++- build-system/tasks/build_all.ksh | 76 ---------------------------- build-system/tasks/build_set.ksh | 56 ++++++++++++++++++++ build-system/tasks/disk/populate.ksh | 4 -- build-system/tasks/get_sources.ksh | 3 -- build-system/work.ini | 2 +- packages | 2 +- 7 files changed, 89 insertions(+), 87 deletions(-) delete mode 100644 build-system/tasks/build_all.ksh create mode 100644 build-system/tasks/build_set.ksh diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 9c8b2a4..7a89d33 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -14,7 +14,7 @@ _make() { tak="$1" # Create the file if it does not exist yet. - [[ ! -e "$made" ]] && echo -n >"$made" + [[ ! -e $made ]] && echo -n >"$made" # Since having access to the date of the last # change done to a file in the UNIX format is @@ -30,7 +30,36 @@ _make() { printf '%s: task done\n' \ "$funcname" 1>&2 # Write task name to a list of done tasks. - [[ "$FORGO_TASKS" == *"$tak"* ]] || + [[ $FORGO_TASKS == *"$tak"* ]] || echo $tak >>"$made" fi } + +_build_package() { + unset nonsetted + packagedir="$progdir/packages" + top_tasks="$tasks" + unset tasks + tasks="$packagedir" + package="$1" + packinfo="$packagedir/$package/info.ini" + Destdir="${nonsetted:-"$OBJDIR/$package"}" + + echo $OBJDIR + + # Get package information: + rconfig "$packinfo" + cd "${nonsetted:-$SRCDIR}" + _make "$package/pkgbuild" + cd - + + cd "$Destdir" + find . -type f -print >pkgproto.txt + log WARN 'Copying %s contents to %s' "$package" "$COPA" + tar -cvf - . | tar -xvf - -C "$COPA" + cd - + + # Restore global tasks directory location. + unset tasks + tasks="$top_tasks" +} diff --git a/build-system/tasks/build_all.ksh b/build-system/tasks/build_all.ksh deleted file mode 100644 index 842dfb2..0000000 --- a/build-system/tasks/build_all.ksh +++ /dev/null @@ -1,76 +0,0 @@ -# This task script is part of Copacabana's build system. -# -# Copyright (c) 2023-2024: Pindorama -# SPDX-Licence-Identifier: NCSA - -# STEP 3: Build -# "Around 3 a.m., the colonel pushed a bunch of papers that were on his front at -# his table. He strected his arms and leaned his head on the cold glass tabletop. -# - 'I need to cool down my head. It looks like it's on fire.' -# Soon after, the red telephone rang. The head of the Agency was calling and he -# wanted to know how the operation was going. -# - 'Yellow Cake already got started, General. So far, so good', Ary responded." -# -- Alexandre Von Baumgarten's "Yellow Cake" -# -# In this step, there will be the definition of functions to create and format a -# disk, populate it with directories and then, at the end of the build, unmount -# it, respectively. - -# And this will be used inside driver.ksh to find where packages/ is. -export progdir trash - -# Syntax: build [stage_name] packages ... -function build { - case $1 in - cross-tools) shift; build_xtools "$@" ;; - tools) shift; build_tools "$@" ;; - base) shift; build_base "$@" ;; - close) shift; close_build ;; - esac -} - -function build_xtools { - packages=( "$@" ) - n_packages=$(n "${packages[@]}") - - for (( n=0; n < n_packages; n++ )); do - "$progdir/build-system/internals/cmd/driver.ksh" -Dcross "${packages[$n]}" \ - || { $I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR \ - || printerr 'Error: Failed to build %s, please check log (%s) for more details.\n' \ - "${packages[$n]}" "$blackbox"; } - done -} - -function build_tools { - return 0 -} - -function build_base { - return 0 -} - -# Note: the titles shall change insofar the script is written. -# STEP 4: Closing the build -# This function will just write the "/etc/copacabana-release" file on -# the final system, closing the build process. -function close_build { - version="$progdir/version" - release_file="$COPA/etc/copacabana-release" - if [[ ! -s "$version" ]]; then - printf '%.1f' 0.0 > "$version" - fi - map dtime final "$(date +'%Hh%Mmin on %B %d, %Y')" - - printf > "$release_file" \ - 'Copacabana %.1f/%s\nCopyright (c) %d-%d Pindorama. All rights reserved.\n\nDesigned between %s and %s. Built from %s until %s (UTC %s).\n' \ - "$(cat $version)" "$CPU" '2019' "$(date +"%Y")" \ - 'February 2021' "$(date +'%B %Y')" \ - "${dtime[initial]}" "${dtime[final]}" "$(date +%Z)" - - printerr 'Info: Build done at %s.\n' \ - "${dtime[final]}" | tee "$blackbox" - - return 0 -} - -build "$@" diff --git a/build-system/tasks/build_set.ksh b/build-system/tasks/build_set.ksh new file mode 100644 index 0000000..a97ed54 --- /dev/null +++ b/build-system/tasks/build_set.ksh @@ -0,0 +1,56 @@ +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023-2024: Pindorama +# SPDX-Licence-Identifier: NCSA + +# STEP 3: Build +# "Around 3 a.m., the colonel pushed a bunch of papers that were on his front at +# his table. He strected his arms and leaned his head on the cold glass tabletop. +# - 'I need to cool down my head. It looks like it's on fire.' +# Soon after, the red telephone rang. The head of the Agency was calling and he +# wanted to know how the operation was going. +# - 'Yellow Cake already got started, General. So far, so good', Ary responded." +# -- Alexandre Von Baumgarten's "Yellow Cake" +# +# In this step, there will be the definition of functions to create and format a +# disk, populate it with directories and then, at the end of the build, unmount +# it, respectively. + +set="$1" +shift + +case $set in +cross-tools) + _build_package cross/mussel + + # Enter set directory + cd "$OBJDIR/cross" + ;; +tools) + ;; +base) + ;; +close) + # STEP 4: Closing the build + # This function will just write the "/etc/copacabana-release" + # file on the final system, closing the build process. + version="$progdir/version" + release_file="$COPA/etc/copacabana-release" + if [[ ! -s $version ]]; then + printf '%.1f' 0.0 >"$version" + fi + map dtime final "$(date +'%Hh%Mmin on %B %d, %Y')" + + printf >"$release_file" \ + 'Copacabana %.1f/%s\nCopyright (c) %d-%d Pindorama. All rights reserved.\n\nDesigned between %s and %s. Built from %s until %s (UTC %s).\n' \ + "$(cat $version)" "$CPU" '2019' "$(date +"%Y")" \ + 'February 2021' "$(date +'%B %Y')" \ + "${dtime[initial]}" "${dtime[final]}" "$(date +%Z)" + + printerr 'Info: Build done at %s.\n' \ + "${dtime[final]}" | tee "$blackbox" ;; +esac + +for d in *; do + ls -1 "$d" +done diff --git a/build-system/tasks/disk/populate.ksh b/build-system/tasks/disk/populate.ksh index 4111074..cf690e6 100644 --- a/build-system/tasks/disk/populate.ksh +++ b/build-system/tasks/disk/populate.ksh @@ -1,10 +1,6 @@ # STEP 1.5: Populate the file system # This function will run the cmd/populate_fhs.sh script and create directories # for the toolchains that will be built. -set -x -SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" -PKGDIR="${PKGDIR:-"$COPA/usr/tmp/plaza"}" -OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" # Also declare who will be our log file. blackbox="$COPA/build.log.$CPU" diff --git a/build-system/tasks/get_sources.ksh b/build-system/tasks/get_sources.ksh index 727ec7f..5f6a410 100644 --- a/build-system/tasks/get_sources.ksh +++ b/build-system/tasks/get_sources.ksh @@ -22,9 +22,6 @@ source_list="$(readlink -f "$1")" source_hash="$(readlink -f "$2")" -# Ratify since it may not be defined on a second -# run after disk/populate has been run. -SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" export USE_ARIA2C SHA256CHECK SRCDIR log INFO 'Downloading sources for building Copacabana using %s as the list.\n' \ diff --git a/build-system/work.ini b/build-system/work.ini index 5f76e2c..bf556a7 100644 --- a/build-system/work.ini +++ b/build-system/work.ini @@ -21,4 +21,4 @@ TRASH_PREFIX="/tmp" ; OBJDIR="" ; This contains tasks that will be re-run even on start-over. -FORGO_TASKS="checks/dependencies disk/create_disk disk/unmount_and_detach" +FORGO_TASKS="build_set checks/dependencies disk/create_disk disk/unmount_and_detach set_dirs" diff --git a/packages b/packages index 97f5592..a11caac 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit 97f5592f3e815e832621fbd4117f61cc74aecacd +Subproject commit a11caac58951fdeaa75d9470ea5c3cc0b432d189 From 8015c0da0d5a3d9797992e25260c8c534e680220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 19 Sep 2024 10:13:55 -0300 Subject: [PATCH 097/128] chore!: Remove debug echo and enter pkgs/ directory --- build-system/internals/makier.ksh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 7a89d33..187abd0 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -45,11 +45,9 @@ _build_package() { packinfo="$packagedir/$package/info.ini" Destdir="${nonsetted:-"$OBJDIR/$package"}" - echo $OBJDIR - # Get package information: rconfig "$packinfo" - cd "${nonsetted:-$SRCDIR}" + cd "${nonsetted:-"$SRCDIR/pkgs"}" _make "$package/pkgbuild" cd - From b4e638ab7c4aec09411085e6039a14a38c74891c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 19 Sep 2024 10:48:14 -0300 Subject: [PATCH 098/128] feat!: FORGO_TASKS as a header. --- build-system/internals/makier.ksh | 4 +++- build-system/tasks/build_set.ksh | 1 + build-system/tasks/checks/dependencies.ksh | 1 + build-system/tasks/disk/create_disk.ksh | 1 + .../tasks/disk/unmount_and_detach.ksh | 1 + build-system/tasks/made.txt | 20 +++++++++++++++++++ build-system/tasks/set_dirs.ksh | 6 ++++++ build-system/work.ini | 3 --- 8 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 build-system/tasks/made.txt create mode 100644 build-system/tasks/set_dirs.ksh diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 187abd0..d4780a9 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -6,13 +6,15 @@ # SPDX-Licence-Identifier: NCSA _make() { - set -e funcname=$0 lang='.ksh' tasks="${tasks:?"task directory not defined"}" made="${made:?"task history file not defined"}" tak="$1" + # This contains tasks that will be re-run even on start-over. + FORGO_TASKS="$(grep -rl '^: forgo$' "$tasks")" + # Create the file if it does not exist yet. [[ ! -e $made ]] && echo -n >"$made" diff --git a/build-system/tasks/build_set.ksh b/build-system/tasks/build_set.ksh index a97ed54..96ab75c 100644 --- a/build-system/tasks/build_set.ksh +++ b/build-system/tasks/build_set.ksh @@ -1,3 +1,4 @@ +: forgo # This task script is part of Copacabana's build system. # # Copyright (c) 2023-2024: Pindorama diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index 9e9465e..a2e94e3 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -1,3 +1,4 @@ +: forgo # This task script is part of Copacabana's build system. # # Copyright (c) 2023-2024: Pindorama diff --git a/build-system/tasks/disk/create_disk.ksh b/build-system/tasks/disk/create_disk.ksh index 97dcaec..892d691 100644 --- a/build-system/tasks/disk/create_disk.ksh +++ b/build-system/tasks/disk/create_disk.ksh @@ -1,3 +1,4 @@ +: forgo # STEP 1: "Pindorama presents: Fubá Cake" # In this step, we will create and format a disk, virtual or physical. disk_block="$1" diff --git a/build-system/tasks/disk/unmount_and_detach.ksh b/build-system/tasks/disk/unmount_and_detach.ksh index 3baf2be..116ebec 100644 --- a/build-system/tasks/disk/unmount_and_detach.ksh +++ b/build-system/tasks/disk/unmount_and_detach.ksh @@ -1,3 +1,4 @@ +: forgo mount_point="$1" disk_block="$2" diff --git a/build-system/tasks/made.txt b/build-system/tasks/made.txt new file mode 100644 index 0000000..fa43d81 --- /dev/null +++ b/build-system/tasks/made.txt @@ -0,0 +1,20 @@ +disk/populate +get_sources +checks/platform +disk/unmount_and_detach +disk/unmount_and_detach +checks/platform +disk/populate +checks/platform +checks/platform +checks/platform +disk/populate +get_sources +checks/platform +disk/populate +checks/platform +disk/populate +get_sources +checks/platform +disk/populate +get_sources diff --git a/build-system/tasks/set_dirs.ksh b/build-system/tasks/set_dirs.ksh new file mode 100644 index 0000000..8e7e6f6 --- /dev/null +++ b/build-system/tasks/set_dirs.ksh @@ -0,0 +1,6 @@ +: forgo +# Set directories for the next tasks. + +SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" +PKGDIR="${PKGDIR:-"$COPA/usr/tmp/plaza"}" +OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" diff --git a/build-system/work.ini b/build-system/work.ini index bf556a7..5526926 100644 --- a/build-system/work.ini +++ b/build-system/work.ini @@ -19,6 +19,3 @@ TRASH_PREFIX="/tmp" ; PKGDIR="" ; OBJDIR="" - -; This contains tasks that will be re-run even on start-over. -FORGO_TASKS="build_set checks/dependencies disk/create_disk disk/unmount_and_detach set_dirs" From 5e97cd013aae66eaaf0ec174d47800128cfd17f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Thu, 19 Sep 2024 10:49:47 -0300 Subject: [PATCH 099/128] chore: Added _made to .gitignore --- .gitignore | 4 ++++ build-system/tasks/made.txt | 20 -------------------- 2 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 build-system/tasks/made.txt diff --git a/.gitignore b/.gitignore index 6d70be0..939e10b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ *~ .*~ .*.swp + +# Don't store build.ksh history +build-system/tasks/made.txt +_made diff --git a/build-system/tasks/made.txt b/build-system/tasks/made.txt deleted file mode 100644 index fa43d81..0000000 --- a/build-system/tasks/made.txt +++ /dev/null @@ -1,20 +0,0 @@ -disk/populate -get_sources -checks/platform -disk/unmount_and_detach -disk/unmount_and_detach -checks/platform -disk/populate -checks/platform -checks/platform -checks/platform -disk/populate -get_sources -checks/platform -disk/populate -checks/platform -disk/populate -get_sources -checks/platform -disk/populate -get_sources From cad8251a3fc5c424cd9318539b5cf74a932534b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 20 Sep 2024 22:34:08 -0300 Subject: [PATCH 100/128] chore: shfmt'ed cmd/populate_fhs.sh --- cmd/populate_fhs.sh | 55 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/cmd/populate_fhs.sh b/cmd/populate_fhs.sh index 6195b3c..6ce8554 100755 --- a/cmd/populate_fhs.sh +++ b/cmd/populate_fhs.sh @@ -4,52 +4,53 @@ # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA -set -x - progname="${0##*/}" COPA=${COPA:-/dsk/0v} mtab='/etc/mtab' -fhs_spec="$(cd "$(dirname build.ksh)"; pwd -P)/build-system/fhs.ini" +fhs_spec="$( + cd "$(dirname build.ksh)" + pwd -P +)/build-system/fhs.ini" BUILD_KSH=${BUILD_KSH:-false} F=${F:-$(sed '/.*DIRS=".*"/!d; s/.*DIRS="\(.*\)"/\1/g' "$fhs_spec")} # Considering that directories were not defined by build.ksh if ! $BUILD_KSH; then { - printf 1>&2 \ - '%s is not intended to be run outside Copacabana'\''s build system.\n' \ - "$progname" - exit 2 + printf 1>&2 \ + '%s is not intended to be run outside Copacabana'\''s build system.\n' \ + "$progname" + exit 2 } fi if [ "$(whoami)" != 'root' ]; then # panic { - printf 1>&2 'You must be '\''root'\'' to run %s.\n' "$progname" - exit 126 + printf 1>&2 'You must be '\''root'\'' to run %s.\n' "$progname" + exit 126 } fi # Is the Copacabana build disk mounted? printf 1>&2 'Checking if %s is a mountpoint...\n' "$COPA" { -# Declare 'err' as being 1 since it will -# only be changed if a disk is mounted. -err=1 -while read line; do - disk="${line%%[[:space:]]*}" - dirtotest_=${line#*[[:space:]]} - dirtotest=${dirtotest_%%[[:space:]]*} - if [ "x$dirtotest" = "x$COPA" ]; then - printf 1>&2 'Found %s as a mountpoint for %s.\n' \ - "$COPA" "$disk" - err=0 - break - fi - unset disk dirtotest_ dirtotest - # Not mounted? -done < "$mtab" + # Declare 'err' as being 1 since it will + # only be changed if a disk is mounted. + err=1 + while read line; do + disk="${line%%[[:space:]]*}" + dirtotest_=${line#*[[:space:]]} + dirtotest=${dirtotest_%%[[:space:]]*} + if [ "x$dirtotest" = "x$COPA" ]; then + printf 1>&2 'Found %s as a mountpoint for %s.\n' \ + "$COPA" "$disk" + err=0 + break + fi + unset disk dirtotest_ dirtotest + # Not mounted? + done <"$mtab" } if [ $err != 0 ]; then printf 1>&2 '%s not mounted?\n' \ @@ -59,8 +60,8 @@ fi printf 1>&2 'Creating directories in '\''%s'\''.\n' $COPA ( -cd $COPA -eval $(printf 'for folder in %s; do mkdir -m 755 "./$folder"; done; err=$?' "$F") + cd $COPA + eval $(printf 'for folder in %s; do mkdir -m 755 "./$folder"; done; err=$?' "$F") ) exit $err From 504f96683636e3855ab1570b65807f7167129da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 20 Sep 2024 22:34:57 -0300 Subject: [PATCH 101/128] fix: Call tasks/set_dirs. --- build.ksh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.ksh b/build.ksh index 2fd7a6d..1d66ab8 100755 --- a/build.ksh +++ b/build.ksh @@ -34,6 +34,7 @@ check_elevate_method _make 'checks/dependencies' _make 'disk/create_disk' "$DISK_BLOCK" +_make set_dirs _make 'disk/populate' _make get_sources sources.txt sources.sha256 _make build_set cross-tools From de3da5f718f76525ba503a04940780110f0a4fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 20 Sep 2024 22:35:24 -0300 Subject: [PATCH 102/128] chore: Do not use tracing at defined() anymore. --- build-system/internals/helpers.shi | 1 - 1 file changed, 1 deletion(-) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 50b12b2..14e5404 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -134,7 +134,6 @@ function rematch { # on purpose to the C preprocessor special operator defined(), meant for being # used in if conditions. function defined { - set -x # First it will check if it's a function defined on the environment and/or in # a sourced file, if it's not, then it will check if it is a variable. { From 1fc1c3bd6f212ced9212d4528a0d6fa4592ee189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 20 Sep 2024 22:36:03 -0300 Subject: [PATCH 103/128] fix: $Destdir at $PKGDIR, "mkdir -p" the $Destdir before copying files. --- build-system/internals/makier.ksh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index d4780a9..091926f 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -13,7 +13,9 @@ _make() { tak="$1" # This contains tasks that will be re-run even on start-over. - FORGO_TASKS="$(grep -rl '^: forgo$' "$tasks")" + # Use '|| true' in case of none of the tasks containing the + # ': forgo' line. + FORGO_TASKS="$(grep -rl '^: forgo$' "$tasks" || true)" # Create the file if it does not exist yet. [[ ! -e $made ]] && echo -n >"$made" @@ -45,7 +47,7 @@ _build_package() { tasks="$packagedir" package="$1" packinfo="$packagedir/$package/info.ini" - Destdir="${nonsetted:-"$OBJDIR/$package"}" + Destdir="${nonsetted:-"$PKGDIR/$package"}" # Get package information: rconfig "$packinfo" @@ -53,6 +55,7 @@ _build_package() { _make "$package/pkgbuild" cd - + mkdir -p "$Destdir" cd "$Destdir" find . -type f -print >pkgproto.txt log WARN 'Copying %s contents to %s' "$package" "$COPA" From 6017512cb3cdc340000df6c18622d39a66f73cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 15 Oct 2024 20:21:11 -0300 Subject: [PATCH 104/128] fix: Create Destdir before running task --- build-system/internals/makier.ksh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 091926f..8883de0 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -49,13 +49,15 @@ _build_package() { packinfo="$packagedir/$package/info.ini" Destdir="${nonsetted:-"$PKGDIR/$package"}" + # Create $Destdir before running task. + mkdir -p "$Destdir" + # Get package information: rconfig "$packinfo" cd "${nonsetted:-"$SRCDIR/pkgs"}" _make "$package/pkgbuild" cd - - mkdir -p "$Destdir" cd "$Destdir" find . -type f -print >pkgproto.txt log WARN 'Copying %s contents to %s' "$package" "$COPA" From 9e4318fad1f525dbde9ed99aed781830cb46634e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 18 Oct 2024 20:39:00 -0300 Subject: [PATCH 105/128] fix: dotini() sanitising for GNU sed implementation. --- build-system/internals/rconfig.shi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi index d540cf8..525377e 100644 --- a/build-system/internals/rconfig.shi +++ b/build-system/internals/rconfig.shi @@ -104,7 +104,7 @@ function dotini { # confline[2]=value confline[0]="${line%%=*}" # Bullet-proofing against subshells. - confline[1]="$(echo -n "${line#*=}" | sed 's/\$/\\\$/g; s/\`/\\`/g')" + confline[1]="$(echo -n "${line#*=}" | sed 's/\$/\\\$/g; s/`/\\`/g')" # If there is not a section, it will only declare the INI # variable and its value on the compound variable. From f981dc27f4ca86505758c770afba8c3d7015605e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 18 Oct 2024 20:40:23 -0300 Subject: [PATCH 106/128] fix: x86_64-pc-linux-musl -> x86_64-linux-musl, UMOUNT_ON_EXIT -> true, etc. --- build-system/machine.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-system/machine.ini b/build-system/machine.ini index 922f0f7..a4d5433 100644 --- a/build-system/machine.ini +++ b/build-system/machine.ini @@ -1,6 +1,6 @@ [Machine] COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" -TARGET_TUPLE="x86_64-pc-linux-musl" +TARGET_TUPLE="x86_64-linux-musl" ARCH="x86" CPU="x86-64" @@ -10,10 +10,10 @@ I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" [Disk managenment] VIRTUAL_DISK="false" -DISK_BLOCK="/dev/sdb" +DISK_BLOCK="/dev/sda" VIRTUADISK_SIZE=10 ; DISK_LABEL="" -UMOUNT_ON_EXIT="false" +UMOUNT_ON_EXIT="true" [Download sources] ; SRCDIR_SUFFIX="" From cb3b5a9a8b55df25bc5c180c1a80decd8990c947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 25 Oct 2024 17:48:33 -0300 Subject: [PATCH 107/128] chore: first toolchain almost complete --- build-system/internals/makier.ksh | 16 +++++++++++++--- build-system/machine.ini | 2 +- build-system/tasks/build_set.ksh | 16 ++++++---------- build-system/tasks/checks/dependencies.ksh | 6 ++++-- build-system/tasks/set_dirs.ksh | 3 +++ build.ksh | 1 - packages | 2 +- sources.txt | 5 +++-- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 8883de0..4839a6d 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -47,7 +47,8 @@ _build_package() { tasks="$packagedir" package="$1" packinfo="$packagedir/$package/info.ini" - Destdir="${nonsetted:-"$PKGDIR/$package"}" + Destdir_suffix="${nonsetted:-"$Destdir_suffix"}" + Destdir="${nonsetted:-"$PKGDIR/$package/$Destdir_suffix"}" # Create $Destdir before running task. mkdir -p "$Destdir" @@ -58,13 +59,22 @@ _build_package() { _make "$package/pkgbuild" cd - - cd "$Destdir" + set -x + echo $Destdir + echo cd "${Destdir%/*}" + cd "${Destdir%/*}" find . -type f -print >pkgproto.txt log WARN 'Copying %s contents to %s' "$package" "$COPA" - tar -cvf - . | tar -xvf - -C "$COPA" + find . ! -name 'pkgproto.txt' -depth -print | elevate cpio -pdmu "$COPA" cd - # Restore global tasks directory location. unset tasks tasks="$top_tasks" } + +_build_packages() { + for pack do + _build_package "$pack" + done +} diff --git a/build-system/machine.ini b/build-system/machine.ini index a4d5433..180b936 100644 --- a/build-system/machine.ini +++ b/build-system/machine.ini @@ -10,7 +10,7 @@ I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" [Disk managenment] VIRTUAL_DISK="false" -DISK_BLOCK="/dev/sda" +DISK_BLOCK="/dev/sdb" VIRTUADISK_SIZE=10 ; DISK_LABEL="" UMOUNT_ON_EXIT="true" diff --git a/build-system/tasks/build_set.ksh b/build-system/tasks/build_set.ksh index 96ab75c..10b19bc 100644 --- a/build-system/tasks/build_set.ksh +++ b/build-system/tasks/build_set.ksh @@ -22,12 +22,12 @@ shift case $set in cross-tools) - _build_package cross/mussel - - # Enter set directory - cd "$OBJDIR/cross" - ;; -tools) + Destdir_suffix=cgnutools \ + _build_packages cross/mussel cross/kernel-headers + Destdir_suffix=llvmtools \ + _build_packages cross/LibC-musl cross/zlib cross/libatomic + Destdir_suffix=cgnutools \ + _build_packages cross/libunwind cross/LLVM ;; base) ;; @@ -51,7 +51,3 @@ close) printerr 'Info: Build done at %s.\n' \ "${dtime[final]}" | tee "$blackbox" ;; esac - -for d in *; do - ls -1 "$d" -done diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index a2e94e3..35e1c19 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -23,8 +23,8 @@ archiver_sanity="$trash/archiver_sanity" internal_scripts=('cmd/download_sources.ksh' 'cmd/populate_fhs.sh' 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh') -# GNU auto*conf commands -GNUAutoconf_commands=('aclocal' 'automake' 'autoconf' 'autoscan' +# GNU auto*hell commands +GNUAutohell_commands=('aclocal' 'automake' 'autoconf' 'autoscan' 'autoreconf' 'ifnames' 'autoheader' 'autom4te' 'autoupdate' 'libtool' 'libtoolize') @@ -33,6 +33,8 @@ GNUBinutils_commands=('addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' 'gprof' ld{,.bfd} 'nm' 'objcopy' 'objdump' 'ranlib' 'readelf' 'size' 'strings' 'strip') +Devtools_commands=('cmake') + # General commands general_commands=('cmp' 'curl' diff{,3} 'sdiff' 'ed' 'file' 'patch' 'find' 'grep' 'lemount' 'm4' 'mitzune' diff --git a/build-system/tasks/set_dirs.ksh b/build-system/tasks/set_dirs.ksh index 8e7e6f6..e97cb60 100644 --- a/build-system/tasks/set_dirs.ksh +++ b/build-system/tasks/set_dirs.ksh @@ -4,3 +4,6 @@ SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" PKGDIR="${PKGDIR:-"$COPA/usr/tmp/plaza"}" OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" + +# Amend /cgnutools/bin and /llvmtools/bin to PATH +PATH="/cgnutools/bin:/llvmtools/bin:$PATH" diff --git a/build.ksh b/build.ksh index 1d66ab8..4a912d9 100755 --- a/build.ksh +++ b/build.ksh @@ -4,7 +4,6 @@ # SPDX-Licence-Identifier: NCSA set -e - progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" diff --git a/packages b/packages index a11caac..854a487 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit a11caac58951fdeaa75d9470ea5c3cc0b432d189 +Subproject commit 854a487e35d37e609edd67331db52f39fcd7786e diff --git a/sources.txt b/sources.txt index 89785f4..a7ca5a4 100644 --- a/sources.txt +++ b/sources.txt @@ -51,7 +51,7 @@ https://download.savannah.nongnu.org/releases/attr/attr-2.5.1.tar.xz https://master.dl.sourceforge.net/project/openpam/openpam/Tabebuia/openpam-20190224.tar.gz https://master.dl.sourceforge.net/project/s-tar/star-1.6.tar.bz2 https://zlib.net/pigz/pigz-2.8.tar.gz -https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.tar.gz +https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.2.2.tar.gz https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz https://tukaani.org/xz/xz-5.4.2.tar.xz http://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz @@ -78,10 +78,11 @@ https://downloads.sourceforge.net/tcl/tcl8.6.10-html.tar.gz https://github.com/michaelforney/samurai/releases/download/1.2/samurai-1.2.tar.gz https://github.com/Kitware/CMake/releases/download/v3.28.0-rc1/cmake-3.28.0-rc1.tar.gz https://github.com/mesonbuild/meson/releases/download/0.55.0/meson-0.55.0.tar.gz -https://invisible-island.net/datafiles/release/byacc.tar.gz +https://invisible-island.net/archives/byacc/byacc-20240109.tgz https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz https://downloads.sourceforge.net/project/expat/expat/2.5.0/expat-2.5.0.tar.xz https://downloads.sourceforge.net/project/expect/Expect/5.45.4/expect5.45.4.tar.gz +https://github.com/Projeto-Pindorama/libreatomic/archive/refs/tags/221212.tar.gz #< pkgs/dev #> pkgs/extra From afe34626ef6f1561e91ada0c08eb43e9dd545e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 26 Oct 2024 15:45:55 -0300 Subject: [PATCH 108/128] fix: pass CFLAGS to CMake at cross/LLVM --- build-system/internals/makier.ksh | 16 +++++++++++++--- build-system/machine.ini | 2 +- build-system/tasks/build_set.ksh | 16 ++++++---------- build-system/tasks/checks/dependencies.ksh | 6 ++++-- build-system/tasks/set_dirs.ksh | 3 +++ build.ksh | 1 - packages | 2 +- sources.txt | 5 +++-- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 8883de0..4839a6d 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -47,7 +47,8 @@ _build_package() { tasks="$packagedir" package="$1" packinfo="$packagedir/$package/info.ini" - Destdir="${nonsetted:-"$PKGDIR/$package"}" + Destdir_suffix="${nonsetted:-"$Destdir_suffix"}" + Destdir="${nonsetted:-"$PKGDIR/$package/$Destdir_suffix"}" # Create $Destdir before running task. mkdir -p "$Destdir" @@ -58,13 +59,22 @@ _build_package() { _make "$package/pkgbuild" cd - - cd "$Destdir" + set -x + echo $Destdir + echo cd "${Destdir%/*}" + cd "${Destdir%/*}" find . -type f -print >pkgproto.txt log WARN 'Copying %s contents to %s' "$package" "$COPA" - tar -cvf - . | tar -xvf - -C "$COPA" + find . ! -name 'pkgproto.txt' -depth -print | elevate cpio -pdmu "$COPA" cd - # Restore global tasks directory location. unset tasks tasks="$top_tasks" } + +_build_packages() { + for pack do + _build_package "$pack" + done +} diff --git a/build-system/machine.ini b/build-system/machine.ini index a4d5433..180b936 100644 --- a/build-system/machine.ini +++ b/build-system/machine.ini @@ -10,7 +10,7 @@ I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" [Disk managenment] VIRTUAL_DISK="false" -DISK_BLOCK="/dev/sda" +DISK_BLOCK="/dev/sdb" VIRTUADISK_SIZE=10 ; DISK_LABEL="" UMOUNT_ON_EXIT="true" diff --git a/build-system/tasks/build_set.ksh b/build-system/tasks/build_set.ksh index 96ab75c..10b19bc 100644 --- a/build-system/tasks/build_set.ksh +++ b/build-system/tasks/build_set.ksh @@ -22,12 +22,12 @@ shift case $set in cross-tools) - _build_package cross/mussel - - # Enter set directory - cd "$OBJDIR/cross" - ;; -tools) + Destdir_suffix=cgnutools \ + _build_packages cross/mussel cross/kernel-headers + Destdir_suffix=llvmtools \ + _build_packages cross/LibC-musl cross/zlib cross/libatomic + Destdir_suffix=cgnutools \ + _build_packages cross/libunwind cross/LLVM ;; base) ;; @@ -51,7 +51,3 @@ close) printerr 'Info: Build done at %s.\n' \ "${dtime[final]}" | tee "$blackbox" ;; esac - -for d in *; do - ls -1 "$d" -done diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index a2e94e3..35e1c19 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -23,8 +23,8 @@ archiver_sanity="$trash/archiver_sanity" internal_scripts=('cmd/download_sources.ksh' 'cmd/populate_fhs.sh' 'cmd/sha256sum.ksh' 'cmd/snapshot_stage.ksh') -# GNU auto*conf commands -GNUAutoconf_commands=('aclocal' 'automake' 'autoconf' 'autoscan' +# GNU auto*hell commands +GNUAutohell_commands=('aclocal' 'automake' 'autoconf' 'autoscan' 'autoreconf' 'ifnames' 'autoheader' 'autom4te' 'autoupdate' 'libtool' 'libtoolize') @@ -33,6 +33,8 @@ GNUBinutils_commands=('addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' 'gprof' ld{,.bfd} 'nm' 'objcopy' 'objdump' 'ranlib' 'readelf' 'size' 'strings' 'strip') +Devtools_commands=('cmake') + # General commands general_commands=('cmp' 'curl' diff{,3} 'sdiff' 'ed' 'file' 'patch' 'find' 'grep' 'lemount' 'm4' 'mitzune' diff --git a/build-system/tasks/set_dirs.ksh b/build-system/tasks/set_dirs.ksh index 8e7e6f6..e97cb60 100644 --- a/build-system/tasks/set_dirs.ksh +++ b/build-system/tasks/set_dirs.ksh @@ -4,3 +4,6 @@ SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" PKGDIR="${PKGDIR:-"$COPA/usr/tmp/plaza"}" OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" + +# Amend /cgnutools/bin and /llvmtools/bin to PATH +PATH="/cgnutools/bin:/llvmtools/bin:$PATH" diff --git a/build.ksh b/build.ksh index 1d66ab8..4a912d9 100755 --- a/build.ksh +++ b/build.ksh @@ -4,7 +4,6 @@ # SPDX-Licence-Identifier: NCSA set -e - progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" diff --git a/packages b/packages index a11caac..6b1deea 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit a11caac58951fdeaa75d9470ea5c3cc0b432d189 +Subproject commit 6b1deeac25251cf0f668a724c55d99315aafa97b diff --git a/sources.txt b/sources.txt index 89785f4..a7ca5a4 100644 --- a/sources.txt +++ b/sources.txt @@ -51,7 +51,7 @@ https://download.savannah.nongnu.org/releases/attr/attr-2.5.1.tar.xz https://master.dl.sourceforge.net/project/openpam/openpam/Tabebuia/openpam-20190224.tar.gz https://master.dl.sourceforge.net/project/s-tar/star-1.6.tar.bz2 https://zlib.net/pigz/pigz-2.8.tar.gz -https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.tar.gz +https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.2.2.tar.gz https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz https://tukaani.org/xz/xz-5.4.2.tar.xz http://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz @@ -78,10 +78,11 @@ https://downloads.sourceforge.net/tcl/tcl8.6.10-html.tar.gz https://github.com/michaelforney/samurai/releases/download/1.2/samurai-1.2.tar.gz https://github.com/Kitware/CMake/releases/download/v3.28.0-rc1/cmake-3.28.0-rc1.tar.gz https://github.com/mesonbuild/meson/releases/download/0.55.0/meson-0.55.0.tar.gz -https://invisible-island.net/datafiles/release/byacc.tar.gz +https://invisible-island.net/archives/byacc/byacc-20240109.tgz https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz https://downloads.sourceforge.net/project/expat/expat/2.5.0/expat-2.5.0.tar.xz https://downloads.sourceforge.net/project/expect/Expect/5.45.4/expect5.45.4.tar.gz +https://github.com/Projeto-Pindorama/libreatomic/archive/refs/tags/221212.tar.gz #< pkgs/dev #> pkgs/extra From 00808af93939234b93f14cc340622cec00bde432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 11 Nov 2024 01:29:59 -0300 Subject: [PATCH 109/128] chore: bump LLVM to 17.0.5 --- packages | 2 +- sources.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages b/packages index 6b1deea..8116ac3 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit 6b1deeac25251cf0f668a724c55d99315aafa97b +Subproject commit 8116ac35b24c02d6618083adc3331b697dba7a20 diff --git a/sources.txt b/sources.txt index a7ca5a4..f559a35 100644 --- a/sources.txt +++ b/sources.txt @@ -60,7 +60,7 @@ https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #> pkgs/dev https://github.com/firasuke/mussel/archive/refs/heads/main.tar.gz -https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.1/llvm-project-17.0.1.src.tar.xz +https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.6.tar.xz https://mirrors.edge.kernel.org/pub/software/scm/git/git-manpages-2.36.6.tar.xz From ed4b385e2617caff759a32a4c6a9f4c9c6c44893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Mon, 11 Nov 2024 01:30:35 -0300 Subject: [PATCH 110/128] fix: Do not create '.N' files when downloading with aria2c. --- cmd/download_sources.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index a165980..d9962ea 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -98,7 +98,7 @@ main() { printf '%s\n\tout=%s\n' \ "${urls[$j]}" "${urls[$j]##*/}" done) | - aria2c -j $(( $(nproc) * 2 )) -x $(nproc) -d "$category_dir" -i - + aria2c --continue=true -j $(( $(nproc) * 2 )) -x $(nproc) -d "$category_dir" -i - fi done if $(echo $SHA256CHECK | grep -i '^y' &>/dev/null) && From 1e25c1331aa4b6fdf4d480aba2d517758457784a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 24 Dec 2024 06:55:05 -0300 Subject: [PATCH 111/128] chore: Short change --- build-system/machine.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-system/machine.ini b/build-system/machine.ini index 180b936..1469d78 100644 --- a/build-system/machine.ini +++ b/build-system/machine.ini @@ -9,9 +9,9 @@ BINARY_CACHE="false" I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" [Disk managenment] -VIRTUAL_DISK="false" -DISK_BLOCK="/dev/sdb" -VIRTUADISK_SIZE=10 +VIRTUAL_DISK="true" +DISK_BLOCK="/run/media/luiz/Novo Volume/Copacabana.img" +VIRTUADISK_SIZE=20 ; DISK_LABEL="" UMOUNT_ON_EXIT="true" From 7bf24ae911051dc7a6679e7b2014e00d044195f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 24 Dec 2024 06:55:47 -0300 Subject: [PATCH 112/128] fix: Use 'log WARN' instead of 'printerr'. --- build-system/internals/helpers.shi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 14e5404..2841259 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -207,15 +207,15 @@ function check_elevate_method { function elevate { sudo -- "$@"; } typeset -fx elevate elif [[ $UID == 0 ]]; then - printerr 'Warning: running as root. This isn'\''t recommended.\n' + log WARN 'Warning: running as root. This isn'\''t recommended.\n' elif $(groups $user | grep 'wheel' >/dev/null); then - printerr \ + log WARN \ 'Warning: %s can log directly as root, although using sudo/doas is preferable.\n' \ "$user" function elevate { su -c "$@"; } typeset -fx elevate else - printerr 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' + log ERROR 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' exit 10 fi From 2e6e4580af99164781ef240e40d343c66934782d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 24 Dec 2024 06:56:21 -0300 Subject: [PATCH 113/128] fix: Test if link exists before creating it. --- build-system/tasks/disk/populate.ksh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-system/tasks/disk/populate.ksh b/build-system/tasks/disk/populate.ksh index cf690e6..76bbd3a 100644 --- a/build-system/tasks/disk/populate.ksh +++ b/build-system/tasks/disk/populate.ksh @@ -27,14 +27,14 @@ if [[ -d "$COPA/cgnutools" && -d "$COPA/llvmtools" ]]; then # re-do it. # The same applies to /llvmtools. [[ $(realpath /cgnutools) != "$COPA/cgnutools" ]] \ - && elevate rm /cgnutools + && test -e /cgnutools && elevate rm /cgnutools ( test -L /cgnutools \ && [[ $(realpath /cgnutools) == "$COPA/cgnutools" ]] ) \ || elevate ln -s {"$COPA/",/}cgnutools [[ $(realpath /llvmtools) != "$COPA/llvmtools" ]] \ - && elevate rm /llvmtools + && test -e /llvmtools && elevate rm /llvmtools ( test -L /llvmtools \ && [[ $(realpath /llvmtools) == "$COPA/llvmtools" ]] ) \ || elevate ln -s {"$COPA/",/}llvmtools From 4e6c88af45b1daa29d476cc86981ca0e23165caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 29 Dec 2024 00:13:38 -0300 Subject: [PATCH 114/128] fix: Check if file exists at rconfig function. --- build-system/internals/rconfig.shi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi index 525377e..b6b5b5f 100644 --- a/build-system/internals/rconfig.shi +++ b/build-system/internals/rconfig.shi @@ -15,6 +15,10 @@ function rconfig { file="$1" + if [[ ! -e "$file" ]]; then + panic '%s: file %s does not exist.' $0 "$file" + fi + if [[ -z $BASH && -n $KSH_VERSION ]]; then # Load the .ini configuration file as # a compound variable to the memory. From 0bb39f7d46e177d2b9dfeb2f59f39dfc7d100768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 29 Dec 2024 00:13:57 -0300 Subject: [PATCH 115/128] chore: Use temporary mussel fork that implements a --custom-vendor option. --- sources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources.txt b/sources.txt index f559a35..e66ad23 100644 --- a/sources.txt +++ b/sources.txt @@ -59,7 +59,7 @@ https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #< pkgs #> pkgs/dev -https://github.com/firasuke/mussel/archive/refs/heads/main.tar.gz +https://github.com/firasuke/mussel/archive/refs/heads/copaclang-temp.tar.gz https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.6.tar.xz From 8084dac31b74dd3513e1efce55d97ab264ba5d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 29 Dec 2024 02:46:16 -0300 Subject: [PATCH 116/128] fix: mussel copaclang-temp is at our repo fork (Projeto-Pindorama/mussel), not at firasuke's. --- sources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources.txt b/sources.txt index e66ad23..15e7d86 100644 --- a/sources.txt +++ b/sources.txt @@ -59,7 +59,7 @@ https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #< pkgs #> pkgs/dev -https://github.com/firasuke/mussel/archive/refs/heads/copaclang-temp.tar.gz +https://github.com/Projeto-Pindorama/mussel/archive/refs/heads/copaclang-temp.tar.gz https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.6.tar.xz From 72b3e85fb208d65199bd40f65b1f2538d458e990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 03:08:08 -0300 Subject: [PATCH 117/128] feat: Bump xz to 5.6.3, add libarchive 3.7.7. --- sources.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources.txt b/sources.txt index 15e7d86..52926fb 100644 --- a/sources.txt +++ b/sources.txt @@ -53,7 +53,8 @@ https://master.dl.sourceforge.net/project/s-tar/star-1.6.tar.bz2 https://zlib.net/pigz/pigz-2.8.tar.gz https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.2.2.tar.gz https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz -https://tukaani.org/xz/xz-5.4.2.tar.xz +https://tukaani.org/xz/xz-5.6.3.tar.gz +https://github.com/libarchive/libarchive/releases/download/v3.7.7/libarchive-3.7.7.tar.xz http://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #< pkgs From 86426f90046f39d328622d7778d03fd586616f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 03:09:20 -0300 Subject: [PATCH 118/128] feat: Add check for GNU du. --- build-system/tasks/checks/dependencies.ksh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/build-system/tasks/checks/dependencies.ksh b/build-system/tasks/checks/dependencies.ksh index 35e1c19..ab6f52d 100644 --- a/build-system/tasks/checks/dependencies.ksh +++ b/build-system/tasks/checks/dependencies.ksh @@ -36,7 +36,7 @@ GNUBinutils_commands=('addr2line' 'ar' 'as' 'c++filt' 'dwp' 'elfedit' Devtools_commands=('cmake') # General commands -general_commands=('cmp' 'curl' diff{,3} 'sdiff' 'ed' 'file' +general_commands=('cmp' 'curl' diff{,3} 'du' 'sdiff' 'ed' 'file' 'patch' 'find' 'grep' 'lemount' 'm4' 'mitzune' ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]}) @@ -53,7 +53,7 @@ for ((g=0; g < $(n ${general_commands[@]}); g++)); do "${general_commands[$g]}" "$PATH" if ! type -p "${general_commands[$g]}" 2>&1 >/dev/null; then case "${general_commands[$g]}" in - sha256sum) + 'sha256sum') # Use internal sha256sum implementation function sha256sum { "$build_kshdir/cmd/sha256sum.ksh" "$@" @@ -64,6 +64,18 @@ for ((g=0; g < $(n ${general_commands[@]}); g++)); do log ERROR '%s not found.' "${general_commands[$g]}" ;; esac + else + case "${general_commands[$g]}" in + 'du') + log INFO 'Is %s GNU? ' "$(type -p du)" + if (du --help 2>&1 \ + | egrep 'POSIXLY_CORRECT|GNU' 2>&1 >/dev/null); then + log INFO 'Certes, it is.\n' + POSIXLY_CORRECT=true + export POSIXLY_CORRECT + fi ;; + *) continue ;; + esac fi done From b2be8112dbeb1d1ca2b992207cd06c137d5468e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 03:12:00 -0300 Subject: [PATCH 119/128] fix: Set $PATH for /llvmtools and /cgnutools at the build_set task. --- build-system/tasks/build_set.ksh | 13 +++++++++++-- build-system/tasks/set_dirs.ksh | 4 ++-- build.ksh | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build-system/tasks/build_set.ksh b/build-system/tasks/build_set.ksh index 10b19bc..c372f2c 100644 --- a/build-system/tasks/build_set.ksh +++ b/build-system/tasks/build_set.ksh @@ -21,13 +21,22 @@ set="$1" shift case $set in -cross-tools) +toolchain) + PATH="/cgnutools/bin:$OLD_PATH" Destdir_suffix=cgnutools \ _build_packages cross/mussel cross/kernel-headers Destdir_suffix=llvmtools \ _build_packages cross/LibC-musl cross/zlib cross/libatomic Destdir_suffix=cgnutools \ - _build_packages cross/libunwind cross/LLVM + _build_packages cross/libunwind cross/LLVM-st1 + Destdir_suffix=llvmtools \ + _build_packages cross/LLVM-st2 + PATH="/llvmtools/bin:$OLD_PATH" + Destdir_suffix=llvmtools _build_packages cross/byacc cross/flex \ + cross/GNUncurses cross/sh cross/bzip2 cross/pigz cross/xz-utils \ + cross/gettext-tiny cross/heirloom cross/mico cross/GNUm4 \ + cross/GNUmake cross/libarchive cross/star cross/GNUsed + ;; base) ;; diff --git a/build-system/tasks/set_dirs.ksh b/build-system/tasks/set_dirs.ksh index e97cb60..e586d89 100644 --- a/build-system/tasks/set_dirs.ksh +++ b/build-system/tasks/set_dirs.ksh @@ -5,5 +5,5 @@ SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/tmp/src}" PKGDIR="${PKGDIR:-"$COPA/usr/tmp/plaza"}" OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" -# Amend /cgnutools/bin and /llvmtools/bin to PATH -PATH="/cgnutools/bin:/llvmtools/bin:$PATH" +# Make a backup of the PATH. +OLD_PATH="$PATH" diff --git a/build.ksh b/build.ksh index 4a912d9..307f353 100755 --- a/build.ksh +++ b/build.ksh @@ -36,6 +36,6 @@ _make 'disk/create_disk' "$DISK_BLOCK" _make set_dirs _make 'disk/populate' _make get_sources sources.txt sources.sha256 -_make build_set cross-tools +_make build_set toolchain _make build_set base _make finish From ca61251193731198f937466e0d56e6c3abcf2401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 15:29:10 -0300 Subject: [PATCH 120/128] feat!: Refactor cmd/snapshot_stage.ksh; support "bad" directory names. --- cmd/snapshot_stage.ksh | 50 +++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/cmd/snapshot_stage.ksh b/cmd/snapshot_stage.ksh index f1acd77..3e14377 100755 --- a/cmd/snapshot_stage.ksh +++ b/cmd/snapshot_stage.ksh @@ -1,58 +1,44 @@ #!/usr/bin/env ksh93 -# Simple shell hack to snapshot a Copacabana stage. -# Copyright 2022-2024: Luiz Antônio (takusuman). +# Simple shell hack to snapshot a Copacabana stage. +# Copyright 2022-2025: Luiz Antônio Rangel (takusuman). # This script is licensed under UUIC/NCSA (as Copacabana work itself). # PS: It can also be run in GNU Broken... eh, I mean BOURNE-Again Shell -# if you don't have AT&T's ksh93 installed. +# if you don't have AT&T's ksh93 installed. program=$0 COPA=${COPA:-/dsk/0v} function main { - options=':S:d:h' - while getopts "$options" OPT; do - case $OPT in - S) stage=$OPTARG ;; - d) directory="$OPTARG" ;; - :|*|?|h) print_help $OPT ;; - esac - done - ## May I have to handle this manually - ## Seriously? - if [ -z $stage ] || [ -z "$directory" ]; then - print_help $OPT + if (($# < 2)); then + print_help fi - snapshot $stage "$directory" -} -function snapshot { stage=$1 - directory="$(realpath "$2")" + directory="$(readlink -f "$2")" + filename="${stage}_$(date +%Y-%m-%d_%H-%M-%S)" # This is meant to be used with our Copacabana stages # In other words, we will always be looking for stages on $COPA, not # elsewhere - # Of course, you can change this with some Shell hacking + # Of course, you can change this with some Shell hacking case $stage in - base) stage_dir="." ;; # This is kind of a shoot in the dark, - # since we're considering "." is - # $COPA's root just because we cd'd on - # it. - *) stage_dir=$stage ;; + base) stage_dir="." ;; # This is kind of a shoot in the dark, + # since we're considering "." is + # $COPA's root just because we cd'd on + # it. + *) stage_dir=$stage ;; esac - printf 'Creating snapshot a snapshot of %s on "%s"\nSaving on %s\n' \ + printf 1>&2 'Creating snapshot a snapshot of %s on "%s"\nSaving on %s\n' \ $stage $filename "$directory" - sleep 2 \ - && cd $COPA \ - && tar -cvf - "$stage_dir" | xz -${XZ_COMPRESSION_LEVEL:-7}e \ - > "$directory/$filename.tar.xz" + cd "$COPA" && (tar -cf - "$stage_dir" | + xz -${XZ_COMPRESSION_LEVEL:-7}e) >"$directory/$filename.tar.xz" return 0 } function print_help { - printf '%s: illegal option "%s"\n[usage]: %s -S stage -d /dsk/0/copa_snapshots\n' "$program" "$1" "$program" + printf 1>&2 '[usage]: %s stage /dsk/0/copa_snapshots\n' "$program" exit 1 } -main $@ +main "$@" From 3c3df15132b06b5bfd8ba805993f0fe6510b2f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 16:17:58 -0300 Subject: [PATCH 121/128] feat: Implement strsplit() at helpers.shi. --- build-system/internals/helpers.shi | 56 +++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/build-system/internals/helpers.shi b/build-system/internals/helpers.shi index 2841259..d1bf9b6 100644 --- a/build-system/internals/helpers.shi +++ b/build-system/internals/helpers.shi @@ -2,7 +2,7 @@ # General helper library for the Copacabana build system. # Meant to be used with Korn Shell 93. # -# Copyright (c) 2023-2024 Pindorama +# Copyright (c) 2023-2025 Pindorama # Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA # @@ -85,13 +85,13 @@ __record() { format='%s+=([%s]="%s")' else panic '%s: invalid caller '\''%s'\''.' \ - "$backend_name" "$whos_calling" + "$backend_name" "$whos_calling" fi else # Broken-Again if ! $bash_supports_compound; then panic \ - '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.' \ - "$backend_name" + '%s: GNU Broken-Again Shell does not support compound variables, a.k.a. '\''record()'\''.' \ + "$backend_name" # Basic sanitizing in case of panic() does # not quitting the program as intended. unset bash_supports_compound @@ -130,6 +130,36 @@ function rematch { printf '%s' "$s" | sed "s/$re/\1/" } +# Luiz' (not-so) stupid split. +# It "returns" an array that shall be eval'ed into the script. +function strsplit { + # Input string. + s="$1" + # Character to split. + ccut="$2" + # Number of substrings + nsubs=0 + + for ((c = 0; c < ${#s}; c++)); do + chr="${s:c:1}" + if [[ $chr == "$ccut" ]]; then + nsubs=$((nsubs + 1)) + continue + fi + substrs[nsubs]+="$chr" + done + + # Reformat it. + printf '%c' '(' + for ((nsub = 0; nsub < ${#substrs[@]}; nsub++)); do + printf ''\''%s'\'' ' "${substrs[$nsub]}" + done + printf '%c' ')' + + # Clean the memory. + unset substrs s c nsubs +} + # Checks if a function or a variable is defined via its identifier. Analogous # on purpose to the C preprocessor special operator defined(), meant for being # used in if conditions. @@ -153,7 +183,7 @@ function defined { # Basically a boilerplate. function realpaths { files=(${@}) - for ((count=0; count < ${#files[@]}; count++)); do + for ((count = 0; count < ${#files[@]}; count++)); do realpath "${files[$count]}" done unset count files @@ -172,14 +202,14 @@ function c { # we just want the extension. tarball_ext="${tarball_ext##*.}" case "$tarball_ext" in - gz | tgz) { gzip "$@"; } ;; - xz | txz) { xz "$@"; } ;; - bz2 | tbz) { bzip2 "$@"; } ;; - tar) { - shift - cat "$@" - } ;; - *) log PANE "%s: File format not recognized." $0 ;; + gz | tgz) { gzip "$@"; } ;; + xz | txz) { xz "$@"; } ;; + bz2 | tbz) { bzip2 "$@"; } ;; + tar) { + shift + cat "$@" + } ;; + *) log PANE "%s: File format not recognized." $0 ;; esac } From 00611531b50edba8c2dfa8cc3f0d8f15d467ae68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 16:20:21 -0300 Subject: [PATCH 122/128] chore: Remove dotfiles/bashrc No need to do it since the build system is already automated. --- dotfiles/bashrc | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 dotfiles/bashrc diff --git a/dotfiles/bashrc b/dotfiles/bashrc deleted file mode 100644 index d3543c1..0000000 --- a/dotfiles/bashrc +++ /dev/null @@ -1,49 +0,0 @@ -# development .bashrc - -# If not running interactively, don't do anything -[[ $- != *i* ]] && return - -alias ls='ls -lah' -PS1='[\u@\h \W]\$ ' -LANG=POSIX -LC_ALL="${LANG}" - -# directories -COPA='/dsk/0v' -XTOOLS=/cross-tools -TOOLS=/tools -LFS="${COPA}" - -# PATH -PATH="${XTOOLS}/bin:${TOOLS}/bin:/bin:/usr/bin" - -# autoconf/configure doesn't like Heirloom that much... -ACCEPT_INFERIOR_RM_PROGRAM='yes' - -# target -COPA_TARGET="$(uname -m)-pindoramaCOPACABANA-linux-musl" -LFS_TARGET="${COPA_TARGET}" - -# host -COPA_HOST="$(echo ${MACHTYPE} | sed "s/$(echo $MACHTYPE | cut -d- -f2)/crossCOPACABANA/")" -LFS_HOST="${COPA_HOST}" - -# CPU information -ARCH='x86' -CPU='x86-64' -## generic x86_64 CFLAGS -CFLAGS="-Os -march=nocona -mtune=$CPU -pipe" - -# compiler tools -CC="${COPA_TARGET}-gcc" -CXX="${COPA_TARGET}-g++" -AR="${COPA_TARGET}-ar" -AS="${COPA_TARGET}-as" -RANLIB="${COPA_TARGET}-ranlib" -LD="${COPA_TARGET}-ld" -STRIP="${COPA_TARGET}-strip" -export COPA LFS PATH COPA_TARGET LFS_TARGET COPA_HOST LFS_HOST ARCH CPU - -# export compiler tools -export CC CXX AR AS RANLIB LD STRIP -#unset CC CXX AR AS RANLIB LD STRIP From 4f1146452924c4e1e46d9b393d0d99a543f042d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 17:04:09 -0300 Subject: [PATCH 123/128] feat: Implement multiple architecture support. --- build-system/machine.ini | 4 +--- build-system/tasks/set_dirs.ksh | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/build-system/machine.ini b/build-system/machine.ini index 1469d78..584c400 100644 --- a/build-system/machine.ini +++ b/build-system/machine.ini @@ -1,8 +1,6 @@ [Machine] COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" -TARGET_TUPLE="x86_64-linux-musl" -ARCH="x86" -CPU="x86-64" +TARGET_TUPLE="x86_64-crossCOPACABANA-linux-musl" [Build] BINARY_CACHE="false" diff --git a/build-system/tasks/set_dirs.ksh b/build-system/tasks/set_dirs.ksh index e586d89..f6c15b2 100644 --- a/build-system/tasks/set_dirs.ksh +++ b/build-system/tasks/set_dirs.ksh @@ -7,3 +7,44 @@ OBJDIR="${OBJDIR:-"$COPA/usr/tmp/obj"}" # Make a backup of the PATH. OLD_PATH="$PATH" + +# Set architecture to compile for. +eval cross_tuple=$(strsplit "$TARGET_TUPLE" '-') +eval target_tuple=$(strsplit "$COPA_TARGET" '-') + +if [[ ${target_tuple[0]} != ${cross_tuple[0]} ]]; then + panic 'Target and cross-toolchain architectures can not differ.' +fi + +CROSS_VENDOR=${cross_tuple[1]} +COPA_VENDOR=${target_tuple[1]} +MARCH="${target_tuple[0]}" +case "$MARCH" in + x86_64) + ARCH='x86' + CPU='x86-64' + MUSL_ARCH=$MARCH + ;; + i686) + ARCH='x86' + CPU=$MARCH # i686 + MUSL_ARCH='i386' + ;; + aarch64) + ARCH='arm64' + CPU='armv8-a' + MUSL_ARCH=$MARCH + ;; + arm7*) + ARCH='arm' + CPU='armv7-a' + MUSL_ARCH=$CMLFS_ARCH + ;; + arm6*) + ARCH='arm' + CPU='armv6zk' + MUSL_ARCH=$CMLFS_ARCH + ;; + *) panic 'Architecture not supported: %s' "$MARCH" ;; +esac +export CROSS_VENDOR COPA_VENDOR MARCH ARCH CPU MUSL_ARCH From c81b38788f869b0f9ba7497820743d216bfab795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Tue, 31 Dec 2024 17:42:20 -0300 Subject: [PATCH 124/128] feat: Update packages/ --- build-system/internals/makier.ksh | 3 +-- packages | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build-system/internals/makier.ksh b/build-system/internals/makier.ksh index 4839a6d..6b4b6bd 100644 --- a/build-system/internals/makier.ksh +++ b/build-system/internals/makier.ksh @@ -59,13 +59,12 @@ _build_package() { _make "$package/pkgbuild" cd - - set -x echo $Destdir echo cd "${Destdir%/*}" cd "${Destdir%/*}" find . -type f -print >pkgproto.txt log WARN 'Copying %s contents to %s' "$package" "$COPA" - find . ! -name 'pkgproto.txt' -depth -print | elevate cpio -pdmu "$COPA" + find . ! -name 'pkgproto.txt' -depth -print | elevate cpio -v -pdmu "$COPA" cd - # Restore global tasks directory location. diff --git a/packages b/packages index 8116ac3..31450d5 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit 8116ac35b24c02d6618083adc3331b697dba7a20 +Subproject commit 31450d539225445b6d4a0ff7a68e3f090382fca5 From 6fd6bb96011b7f3a550c9157d5696b0549c716c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Wed, 1 Jan 2025 17:15:07 -0300 Subject: [PATCH 125/128] chore: Moved back to firasuke's main repository for mussel. --- sources.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources.txt b/sources.txt index 52926fb..1e2ca66 100644 --- a/sources.txt +++ b/sources.txt @@ -60,7 +60,7 @@ https://distfiles.dereferenced.org/pkgconf/pkgconf-1.9.2.tar.xz #< pkgs #> pkgs/dev -https://github.com/Projeto-Pindorama/mussel/archive/refs/heads/copaclang-temp.tar.gz +https://github.com/firasuke/mussel/archive/refs/heads/main.tar.gz https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.5/llvm-project-17.0.5.src.tar.xz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0.tar.bz2 https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.6.tar.xz From eef2511046edeefd63a293b4fe05f31f034904d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 3 Jan 2025 20:06:28 -0300 Subject: [PATCH 126/128] Update packages/ --- packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages b/packages index 31450d5..4d04adc 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit 31450d539225445b6d4a0ff7a68e3f090382fca5 +Subproject commit 4d04adca61f636bea1f6167bbb4ec18e1d8dd64e From 2dc5eba31dc15fdfcab4cf070ca167099d3f149b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Fri, 3 Jan 2025 20:30:43 -0300 Subject: [PATCH 127/128] Merry (late) Christmas! And a happy 2025! --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 4ab0681..06f026e 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ University of Illinois/NCSA Open Source License -Copyright (c) 2019-2024 Pindorama. All rights reserved. +Copyright (c) 2019-2025 Pindorama. All rights reserved. Developed by: Pindorama Caio Novais (caioyoshimura) From 33487d85367d86ac157178372f5d760c4577a2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sat, 4 Jan 2025 09:27:18 -0300 Subject: [PATCH 128/128] chore: Update packages --- packages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages b/packages index 4d04adc..2c467d6 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit 4d04adca61f636bea1f6167bbb4ec18e1d8dd64e +Subproject commit 2c467d694f748164ce25c344576624c68dca7dd2