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/.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 diff --git a/LICENSE.txt b/LICENSE.txt index 86174e9..06f026e 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-2025 Pindorama. All rights reserved. Developed by: Pindorama Caio Novais (caioyoshimura) diff --git a/README.md b/README.md index 85939bb..5434dbf 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 @@ -25,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); 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 deleted file mode 100755 index 918d8c1..0000000 --- a/build-system/internals/cmd/driver.ksh +++ /dev/null @@ -1,143 +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 -set -x - -set -e - -# shellcheck disable=SC2068 - -drvname="$1" - -# 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" - -# 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 { - if (( $# == 0 )); then - print_help - fi - - 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 )) - - [ $info_flag ] \ - && print_pkgbuild_info "$1" - - 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 { - # 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") - - # 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="$(eval_pkgbuild_path "$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="$(eval_pkgbuild_path "$1")" - - # This will read the pkgbuild functions until the end of the file. - nawk '/.\(\)/, !/./' "$package_recipe" -} - -function transmutacio { - set -x - 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="$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 -} - -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/disks.shi b/build-system/internals/disks.shi new file mode 100644 index 0000000..0c41ba3 --- /dev/null +++ b/build-system/internals/disks.shi @@ -0,0 +1,53 @@ +# 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 { + 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.shi b/build-system/internals/helpers.shi new file mode 100644 index 0000000..d1bf9b6 --- /dev/null +++ b/build-system/internals/helpers.shi @@ -0,0 +1,324 @@ +# vim: set filetype=sh : +# General helper library for the Copacabana build system. +# Meant to be used with Korn Shell 93. +# +# Copyright (c) 2023-2025 Pindorama +# 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 [...]" + +# 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; }') +export BUILD_KSH KSH93_RELEASE + +# 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" + + # 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_supports_compound=false + export bash_supports_compound + 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() { + backend_name='record()/map() backend' + # "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" + + 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'\''.' \ + "$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" + # 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" + 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. + [[ -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 + + 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. +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' 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 + 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 "$@" + } ;; + *) log PANE "%s: File format not recognized." $0 ;; + 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 + log WARN 'Warning: running as root. This isn'\''t recommended.\n' + elif $(groups $user | grep 'wheel' >/dev/null); then + 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 + log ERROR 'Fatal: It appears your user doesn'\''t have superuser privileges.\n' + exit 10 + fi + + export user +} + +# Converts a 'yes/no' variable to a boolean. +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. + kshpid="$(ps -p $PPID -o ppid=)" + termppath="$(ps -p $kshpid -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/helpers/helpers.shi b/build-system/internals/helpers/helpers.shi deleted file mode 100644 index 6baac09..0000000 --- a/build-system/internals/helpers/helpers.shi +++ /dev/null @@ -1,116 +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 - -# Make everyone aware we're running from BUILD_KSH. -export readonly BUILD_KSH=true - -# Reads simple Shell-based configuration files. -# "#" is used for comments, and white spaces are ignored for read(1). -function rconfig { - (sed '/#/d; /^$/d' "$1") \ - | while IFS='=' read identifier value; do - eval $identifier=$value - done -} - -# 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 -} - -# 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=( "$@" ) - /bin/sh -c "$command "${command_args[@]}"" -} - -# 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 -} diff --git a/build-system/internals/helpers/posix-alt.shi b/build-system/internals/helpers/posix-alt.shi deleted file mode 100644 index 699d3b7..0000000 --- a/build-system/internals/helpers/posix-alt.shi +++ /dev/null @@ -1,79 +0,0 @@ -# vim: set filetype=sh : -# POSIX shell alternatives for external processes, in a single libary. -# Copied from Mitzune's lib/ directory, with just the removal of the "local" -# keyword at timeout(), which isn't available on Korn Shell 93 since the -# 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 -# SPDX-Licence-Identifier: Caldera - -# Include dirs(), pushd() and popd() -. "$progdir/build-system/internals/helpers/dirs.shi" - -# vim: filetype=sh : - -# basename -basename(){ - DIR=${1%${1##*[!/]}} - DIR=${DIR##*/} - DIR=${DIR%"$2"} - printf '%s\n' "${DIR:-/}" -} - -# 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}" -} - -# wc -l -lines(){ - while IFS= read -r LINE || [ -n "${LINE}" ]; do - LINES=$[ ${LINES} + 1 ] - done < "${1}" - printf '%s\n' "$LINES" - unset LINES -} - -# timeout -timeout(){ - "${2}" & PID="${!}"; sleep "${1}" && kill "${PID}" -} - -# nproc -nproc(){ - case "`uname -s`" in - Darwin | Linux) getconf '_NPROCESSORS_ONLN';; - FreeBSD | OpenBSD | NetBSD) getconf 'NPROCESSORS_ONLN';; - SunOS) echo "`ksh93 -c 'getconf NPROCESSORS_ONLN'`" ;; - esac -} - -# The # macro for arrays. -n(){ - # based on what Caio did on - # Copacabana's cmd/download_sources.sh - echo ${@} | wc -w -} - -trim_home_path(){ - echo ${@} | sed 's@.*/home/@~@' -} - -# More powerful "source" macro for Korn Shell 93, -# which can't source a file from the current -# directory. -source(){ - { [ -e "$1" ] && [ -r "$1" ] \ - && . "$(realpath "$1")"; } \ - || return 1 -} - -##End of alternatives section diff --git a/build-system/internals/ini-test/php.ini b/build-system/internals/ini-test/php.ini new file mode 100644 index 0000000..349df05 --- /dev/null +++ b/build-system/internals/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/ini-test/test2.ini b/build-system/internals/ini-test/test2.ini new file mode 100644 index 0000000..78349e0 --- /dev/null +++ b/build-system/internals/ini-test/test2.ini @@ -0,0 +1,11 @@ +test1a=b +test1b="b" +[test1sectionA] +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/log.shi b/build-system/internals/log.shi new file mode 100644 index 0000000..e1d2a8d --- /dev/null +++ b/build-system/internals/log.shi @@ -0,0 +1,77 @@ +# vim: set filetype=sh : +# Error handling and logging in general. + +# Copyright (c) 2023-2024 Pindorama +# Copyright (c) 2024 xplshn +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA +# +# 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 { + log PANE "$@" +} + +# 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') + fmt='panic: %s\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]}")" + ;; + 'STD') # Works just as 'printf [...] 1>&2'. + fmt="$1" + shift + ;; + *) log ERROR 'Invalid level '\''%s'\''' $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/internals/makier.ksh b/build-system/internals/makier.ksh new file mode 100644 index 0000000..a762c6d --- /dev/null +++ b/build-system/internals/makier.ksh @@ -0,0 +1,100 @@ +# vim: set filetype=sh : +# Boilerplate for running tasks. +# +# Copyright (c) 2023-2025 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA +# +# 'mpatch' borrowed and adapted from firasuke's mussel. +# As per its copyright header: +# Copyright (c) 2020-2025, Firas Khalil Khana +# +# SPDX-Licence-Identifier: ISC +# + +_make() { + 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. + # 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" + + # 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 "$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" + fi +} + +_build_package() { + unset nonsetted + packagedir="$progdir/packages" + top_tasks="$tasks" + unset tasks + tasks="$packagedir" + package="$1" + packinfo="$packagedir/$package/info.ini" + Destdir_suffix="${nonsetted:-"$Destdir_suffix"}" + Destdir="${nonsetted:-"$PKGDIR/$package/$Destdir_suffix"}" + + # Backup $Destdir for pkgbuilds that may change it. + _Destdir="$Destdir" + + # Create $Destdir before running task. + mkdir -p "$Destdir" + + # Get package information: + rconfig "$packinfo" + cd "${nonsetted:-"$SRCDIR/pkgs"}" + _make "$package/pkgbuild" + cd - + + 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 -v -pdmu "$COPA" + cd - + + # Restore global tasks directory location. + unset tasks + tasks="$top_tasks" +} + +_build_packages() { + for pack do + _build_package "$pack" + done +} + +mpatch() { + level="$1" + patch_name="$2" + package_name="$(basename "$(pwd)")" + log INFO 'Applying patch '\''%s'\'' for %s...\n' \ + $patch_name "$package_name" + + # We're already inside the package directory, so + # no need for 'cd "$SRCDIR/$2/$2-$3"'. + patch -p"$level" -i "$PCHDIR/$package_name/${patch_name}.patch" 2>&1 + log INFO "%s patched with %s!\n" "$package_name" "$patch_name" +} diff --git a/build-system/internals/posix-alt.shi b/build-system/internals/posix-alt.shi new file mode 100644 index 0000000..71851f5 --- /dev/null +++ b/build-system/internals/posix-alt.shi @@ -0,0 +1,97 @@ +# vim: set filetype=sh : +# POSIX shell alternatives for external processes, in a single libary. +# Copied from Mitzune's lib/ directory, with just the removal of the "local" +# keyword at timeout(), which isn't available on Korn Shell 93 since the +# functions already have variables defined in local scopes. + +# Copyright (c) 2020-2021 Caio Novais and Luiz Antônio Rangel +# Copyright (c) 2020-2024 Luiz Antônio Rangel +# SPDX-Licence-Identifier: Caldera + +# Include dirs(), pushd() and popd() +#. "$progdir/build-system/internals/helpers/dirs.shi" + +# basename +basename(){ + DIR=${1%${1##*[!/]}} + DIR=${DIR##*/} + DIR=${DIR%"$2"} + printf '%s\n' "${DIR:-/}" +} + +# 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 +} + +# wc -l +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 + "$@" & PID="$!"; sleep "$time" && kill "$PID" + else + command timeout "$time" "$@" + fi +} + +# nproc +nproc(){ + 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. +n(){ + # based on what Caio did on + # Copacabana's cmd/download_sources.sh + echo ${@} | wc -w +} + +trim_home_path(){ + echo ${@} | sed 's@.*/home/@~@' +} + +# More powerful "source" macro for Korn Shell 93, +# which can't source a file from the current +# directory. +source(){ + { [ -e "$1" ] && [ -r "$1" ] \ + && . "$(realpath "$1")"; } \ + || return 1 +} + +##End of alternatives section diff --git a/build-system/internals/rconfig.shi b/build-system/internals/rconfig.shi new file mode 100644 index 0000000..b6b5b5f --- /dev/null +++ b/build-system/internals/rconfig.shi @@ -0,0 +1,184 @@ +# 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 [[ ! -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. + # 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. +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.' $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 + + # 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' '(' + + # 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. + formatted_section="$(printf '%s' "$section_title" | + nawk '{ gsub(" ", "_"); print(tolower($0)) }')" + # We can procceed to the next line. + continue + fi + + # A value declaration in INI follows the format: + # identifier = "value" + # Or + # identifier=value + # confline[1]=identifier + # confline[2]=value + confline[0]="${line%%=*}" + # Bullet-proofing against subshells. + 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. + 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' ')' + + # 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 +# 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 +function inicompat { + nameref inirecord=$1 + integer s k + typeset -a sections + fmt='%s=%q' + 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" \ + $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 ;; + esac + unset section confkeys confkey confval + done +} diff --git a/build-system/machine.ini b/build-system/machine.ini new file mode 100644 index 0000000..584c400 --- /dev/null +++ b/build-system/machine.ini @@ -0,0 +1,26 @@ +[Machine] +COPA_TARGET="x86_64-pindoramaCOPACABANA-linux-musl" +TARGET_TUPLE="x86_64-crossCOPACABANA-linux-musl" + +[Build] +BINARY_CACHE="false" +I_ENJOY_THAT_THINGS_ARE_REALLY_CLEAR="false" + +[Disk managenment] +VIRTUAL_DISK="true" +DISK_BLOCK="/run/media/luiz/Novo Volume/Copacabana.img" +VIRTUADISK_SIZE=20 +; DISK_LABEL="" +UMOUNT_ON_EXIT="true" + +[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 deleted file mode 100644 index bbbf8d7..0000000 --- a/build-system/tasks/build_all.ksh +++ /dev/null @@ -1,36 +0,0 @@ -# This will be used in Alambiko when installing the "packages" to a destination -# directory. -package_dir="$trash/pkg" - -# And this will be used inside driver.ksh to find where packages/ is. -export progdir - -# Syntax: build [stage_name] packages ... -function build { - case $1 in - cross-tools) shift; build_xtools "$@" ;; - tools) shift; build_tools "$@" ;; - base) shift; build_base "$@" ;; - esac -} - -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]} - done -} - -function build_tools { - return 0 -} - -function build_base { - 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..c372f2c --- /dev/null +++ b/build-system/tasks/build_set.ksh @@ -0,0 +1,62 @@ +: forgo +# 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 +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-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) + ;; +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 diff --git a/build-system/tasks/check_dependencies.ksh b/build-system/tasks/check_dependencies.ksh deleted file mode 100644 index 772c486..0000000 --- a/build-system/tasks/check_dependencies.ksh +++ /dev/null @@ -1,210 +0,0 @@ -# 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) - -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.ksh' \ - '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' 'patch' \ - 'find' 'grep' 'm4' 'mitzune' \ - ${GNUAutoconf_commands[@]} ${GNUBinutils_commands[@]} ) - - # General compressing tools - archivers=('tar' 'bzip2' 'gzip' 'xz') - - 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' - function tar { "$(readlink -f "$(type -p tar)")" --no-secure-links $@ ;} - 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..ab6f52d --- /dev/null +++ b/build-system/tasks/checks/dependencies.ksh @@ -0,0 +1,310 @@ +: forgo +# 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*hell commands +GNUAutohell_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') + +Devtools_commands=('cmake') + +# General commands +general_commands=('cmp' 'curl' diff{,3} 'du' 'sdiff' 'ed' 'file' + '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 + log INFO 'Searching for %s at PATH (%s)... ' \ + "${general_commands[$g]}" "$PATH" + 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 + ;; + *) + 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 + +for ((h=0; h < $(n ${archivers[@]}); h++)); do + 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 + log WARN 'I'\''m almost certain that %s is from the Heirloom Toolchest...' \ + "$(type -p tar)" + 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 + 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="" + } else { + separator=":" + } + # If not already present + # on the s[] array, print it. + if (!s[p[n]]++) { + printf("%s%c", p[n], separator); + } + } + }')" + log WARN 'Found suitable tar at %s\n' $new_tarpath + log INFO 'New PATH: %s\n' $PATH + export PATH + unset new_tarpath tmpPATH + break + fi + unset tar_cmd + else + panic 'Couldn'\''t find a suitable tar implementation.' + break # Une pure formalité. + fi + done + fi + + if [[ $tarpath =~ (star) ]] || + (tar -h 2>&1 | grep 'star' 2>&1 >/dev/null); then + log INFO 'I'\''m almost certain that %s is Schily tar...' \ + "$(type -p tar)" + 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 + } + typeset -xf tar + fi + 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" + } && rm -rf "${archiver_sanity}_results" + else # Bzip2, Gzip or Xz tests + for ((l=1; l <= 9; l++)); do + log INFO '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"; } + log INFO 'Ok...' + done + fi + log INFO 'Sounds like a yes.' +done + +for ((i=0; i < $(n ${utils[@]}); i++)); do + 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 + 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 + log INFO 'Found!' + else + 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)" +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 +# "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 +log PROGOUT "$ksh_sanity_test" +"$run_shell" "$ksh_sanity_test" + +log INFO 'Does the C/C++ compiler work for what we need?' + +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 + +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")\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.' +fi + +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 + log DEBUG 'Nah, it'\''s clean.' + has_bash=false +else + log DEBUG 'It does, we'\''re going with it.' + 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 + +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. +export run_shell COPA_HOST diff --git a/build-system/tasks/platform_checks.ksh b/build-system/tasks/checks/platform.ksh similarity index 79% rename from build-system/tasks/platform_checks.ksh rename to build-system/tasks/checks/platform.ksh index 904844f..866ebc2 100644 --- a/build-system/tasks/platform_checks.ksh +++ b/build-system/tasks/checks/platform.ksh @@ -1,3 +1,15 @@ +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023-2024: 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 diff --git a/build-system/tasks/disk/create_disk.ksh b/build-system/tasks/disk/create_disk.ksh new file mode 100644 index 0000000..892d691 --- /dev/null +++ b/build-system/tasks/disk/create_disk.ksh @@ -0,0 +1,164 @@ +: forgo +# 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 + 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 + +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); }')" + + log INFO 'Using a physical disk, present at %s with size of %d MB.' \ + "$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.' \ + "$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.' \ + "$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" + ) + + 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?' \ + $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 + # 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##*/}" + 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 +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 + break + ;; + quit | *) return 1 ;; + esac + done +fi + +if "$VIRTUAL_DISK"; then + 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)))" + 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 + log INFO '%s is o.k. Proceeding.' "$virtuadisk_path" + else + log WARN 'dd failed to write %d blocks to %s.' \ + $virtuadisk_blksize "$virtuadisk_path" + 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 + # 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 + 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 + +# 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" + +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 new file mode 100644 index 0000000..76bbd3a --- /dev/null +++ b/build-system/tasks/disk/populate.ksh @@ -0,0 +1,56 @@ +# 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. + +# 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. +log INFO 'Making directories in %s for the building toolchains.' \ + "$COPA" +elevate mkdir -p "$COPA/"{cgnu,llvm}tools "$OBJDIR" "$PKGDIR" +(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 + log INFO 'Symbolic linking %s to %s...' \ + {"$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" ]] \ + && test -e /cgnutools && elevate rm /cgnutools + ( test -L /cgnutools \ + && [[ $(realpath /cgnutools) == "$COPA/cgnutools" ]] ) \ + || elevate ln -s {"$COPA/",/}cgnutools + + + [[ $(realpath /llvmtools) != "$COPA/llvmtools" ]] \ + && test -e /llvmtools && elevate rm /llvmtools + ( test -L /llvmtools \ + && [[ $(realpath /llvmtools) == "$COPA/llvmtools" ]] ) \ + || elevate ln -s {"$COPA/",/}llvmtools + + (cd /; ls -l ./{cgnu,llvm}tools) +fi + +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"" + +log INFO 'Initializing blackbox file (%s) for the build.' \ + "$blackbox" +( cd "$COPA"; elevate sh -c "> $blackbox; chown $user $blackbox" ) + +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/disk/unmount_and_detach.ksh b/build-system/tasks/disk/unmount_and_detach.ksh new file mode 100644 index 0000000..116ebec --- /dev/null +++ b/build-system/tasks/disk/unmount_and_detach.ksh @@ -0,0 +1,9 @@ +: forgo +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/disk_managenment.ksh b/build-system/tasks/disk_managenment.ksh deleted file mode 100644 index 356677a..0000000 --- a/build-system/tasks/disk_managenment.ksh +++ /dev/null @@ -1,168 +0,0 @@ -function create_disk { - disk_block="$1" - - # 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 < (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 )) - 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 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 - fi - - 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" - 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'" - - # 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" -} - -function populate { - # 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/"{cross-,}tools - (cd "$COPA"; ls -lah .) - - # Make a symbolic link from $COPA/cross-tools to /cross-tools, the same - # for /tools. - # For instance: - # {"$COPA/",/}cross-tools expands to $COPA/cross-tools /cross-tools, - # which is the input that we'd need to ln(1). - if [[ -d "$COPA/cross-tools" && -d "$COPA/tools" ]]; then - printerr 'Info: Symbolic linking %s to %s...\n' \ - {"$COPA/",/}cross-tools {"$COPA/",/}tools - - # 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, - # 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 - - - [[ $(realpath /tools) != "$COPA/tools" ]] \ - && elevate rm /tools - ( test -L /tools \ - && [[ $(realpath /tools) == "$COPA/tools" ]] ) \ - || elevate ln -s {"$COPA/",/}tools - - (cd /; ls -l ./{cross-,}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" -} - -function unmount_and_detach { - # Korn Shell variables, unlike GNU Broken-Again Shell, are scoped to the - # function without the need to use the "local" keyword, so we mustn't - # worry about having another variable with the same "disk_block" - # identifier. - 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 070b629..9e1ca52 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 + _make 'disk/unmount_and_detach' "$COPA" "$disk_block" +fi - # Remove the trash directory with sanity tests - rm -r "$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_source-code.ksh deleted file mode 100644 index 731aac7..0000000 --- a/build-system/tasks/get_source-code.ksh +++ /dev/null @@ -1,17 +0,0 @@ -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")" - SRCDIR="$COPA/${SRCDIR_SUFFIX:-/usr/src}" - SHA256CHECK="$SHA256CHECK" - export 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" - - unset SHA256CHECK -} diff --git a/build-system/tasks/get_sources.ksh b/build-system/tasks/get_sources.ksh new file mode 100644 index 0000000..5f6a410 --- /dev/null +++ b/build-system/tasks/get_sources.ksh @@ -0,0 +1,32 @@ +# This task script is part of Copacabana's build system. +# +# Copyright (c) 2023-2024: 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. + +# 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")" + +export USE_ARIA2C SHA256CHECK SRCDIR + +log INFO 'Downloading sources for building Copacabana using %s as the list.\n' \ + "$source_list" + +"$progdir/cmd/download_sources.ksh" "$source_list" "$source_hash" + +unset SHA256CHECK USE_ARIA2C diff --git a/build-system/tasks/set_dirs.ksh b/build-system/tasks/set_dirs.ksh new file mode 100644 index 0000000..f6c15b2 --- /dev/null +++ b/build-system/tasks/set_dirs.ksh @@ -0,0 +1,50 @@ +: 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"}" + +# 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 diff --git a/build-system/work.ini b/build-system/work.ini new file mode 100644 index 0000000..5526926 --- /dev/null +++ b/build-system/work.ini @@ -0,0 +1,21 @@ +; 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. +; Per default, PKGDIR and OBJDIR are saved in the same disk in +; which Copacabana is going to be built. +; +TRASH_PREFIX="/tmp" +; PKGDIR="" +; OBJDIR="" diff --git a/build.ksh b/build.ksh index bc3a76b..307f353 100755 --- a/build.ksh +++ b/build.ksh @@ -1,43 +1,41 @@ #!/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 - progname="${0##*/}" progdir="$(cd "$(dirname "$progname")"; pwd -P)" -trash="$(mktemp -d /tmp/CopaBuild.XXXXXX)" -# Internal build system functions -. "$progdir/build-system/internals/helpers/helpers.shi" -. "$progdir/build-system/internals/helpers/posix-alt.shi" +# _make +tasks="$progdir/build-system/tasks" +made="$progdir/_made" +. "$progdir/build-system/internals/makier.ksh" -# 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" -. "$progdir/build-system/tasks/build_all.ksh" +# Immediatly source and run the platform +# checks before doing anything else. +_make 'checks/platform' -. "$progdir/build-system/tasks/finish.ksh" +. "$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.conf" -rconfig "$progdir/build-system/paths.conf" +rconfig "$progdir/build-system/machine.ini" +rconfig "$progdir/build-system/work.ini" +rconfig "$progdir/build-system/fhs.ini" -platform_checks +trash="$(mktemp -d "$TRASH_PREFIX/CopaBuild.XXXXXX")" +map dtime initial "$(date +'%Hh%Mmin on %B %d, %Y')" +check_for_colour_support 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 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" -finish +_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 toolchain +_make build_set base +_make finish diff --git a/cmd/download_sources.ksh b/cmd/download_sources.ksh index bfbdbc6..d9962ea 100755 --- a/cmd/download_sources.ksh +++ b/cmd/download_sources.ksh @@ -1,7 +1,7 @@ -#!/usr/bin/env ksh93 +#!/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 @@ -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 @@ -23,58 +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` +realpath() { + 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" } -main() { - 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 '#> '`) - n_categories="`n ${categories[*]}`" +# 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 +} - for ((i = 0; i < n_categories; i++)) { +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[*]})" - # 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"`) - 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}" - cd "${category_dir}" || exit 2 + category_dir="$sources_directory/${categories[${i}]}" + mkdir -p "$category_dir" - for ((j = 0; j < n_urls; j++)) { - printf 'Downloading %s\n' "`basename ${urls[${j}]}`" - curl -LO "${urls[${j}]}" - } - } - 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 --continue=true -j $(( $(nproc) * 2 )) -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 "$@" diff --git a/cmd/populate_fhs.ksh b/cmd/populate_fhs.ksh deleted file mode 100755 index 0f77a96..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,src,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..6ce8554 --- /dev/null +++ b/cmd/populate_fhs.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# Simple shell hack to populate Copacabana's FHS on a new disk +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel +# SPDX-Licence-Identifier: NCSA + +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" +{ + # 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' \ + "$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 diff --git a/cmd/sha256sum.ksh b/cmd/sha256sum.ksh index 4dcc233..93ed9f8 100755 --- a/cmd/sha256sum.ksh +++ b/cmd/sha256sum.ksh @@ -1,9 +1,9 @@ #!/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 Pindorama -# Luiz Antônio Rangel +# Copyright (c) 2023-2024 Pindorama +# Luiz Antônio Rangel # SPDX-Licence-Identifier: NCSA progname=${0##*/} @@ -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 @@ -38,6 +38,8 @@ function main { output_hashfile="${hashfile:-/dev/null}" get_checksum "$file" | tee -a "${output_hashfile}" + + exit $err } function get_checksum { @@ -46,17 +48,18 @@ 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 { + err=0 # Just for the sake of readability, as in main. hashfile="$1" @@ -76,10 +79,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}")" @@ -92,17 +95,19 @@ 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 + file_alleged_hash actual_file_name actual_file_hash + done <"$hashfile" + + export err } # Boilerplate to OpenSSL-compatible shell API. -function sslcmd { +function sslcmd { "$(type -p $SSL_CMD)" "$@" } @@ -122,8 +127,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 } diff --git a/cmd/snapshot_stage.ksh b/cmd/snapshot_stage.ksh index 5c1090e..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: 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 "$@" diff --git a/build-system/machine.conf b/docs/build-system/machine.md similarity index 52% rename from build-system/machine.conf rename to docs/build-system/machine.md index 2696e4e..f72cfa0 100644 --- a/build-system/machine.conf +++ b/docs/build-system/machine.md @@ -1,9 +1,43 @@ # 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" @@ -30,14 +64,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 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. @@ -56,6 +95,21 @@ UMOUNT_ON_EXIT="false" # "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++" 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 diff --git a/packages b/packages index a1d678b..2c467d6 160000 --- a/packages +++ b/packages @@ -1 +1 @@ -Subproject commit a1d678b6f049792ef1a586e02260c355aef0ba42 +Subproject commit 2c467d694f748164ce25c344576624c68dca7dd2 diff --git a/sources.txt b/sources.txt index 17312e5..1e2ca66 100644 --- a/sources.txt +++ b/sources.txt @@ -25,13 +25,13 @@ 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 %% 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 @@ -50,17 +50,23 @@ 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://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.tar.gz +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 #> pkgs/dev +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 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 +74,16 @@ 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/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 @@ -89,15 +97,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-11.2.0/gcc-11.2.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 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