Lucio Andrés Illanes Albornoz 531158
> N.B. If you're interested in building Midipix using this script, please join
Lucio Andrés Illanes Albornoz 531158
the project's IRC channel #midipix on Libera and ask for the address of the
Lucio Andrés Illanes Albornoz 531158
internal repositories required in order to build Midipix.
Lucio Andrés Illanes Albornoz 531158

ce2a76
> N.B. Due to the present state of the (largely) automated package upstream
ce2a76
updates integration script and, despite frequent contributions, lack of
ce2a76
human resources, it bears mentioning that the 3rd party packages built
ce2a76
and distributed by this script are often not up to date with their resp.
ce2a76
upstream and *may* hence be **insecure**. It is advised that this be taken
ce2a76
into account when deploying and using Midipix distributions.
ce2a76

Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ Table of contents"
Lucio Andrés Illanes Albornoz 531158
# Table of Contents
Lucio Andrés Illanes Albornoz 531158

ce2a76
1. [What is Midipix, and how is it different?](#1-what-is-midipix-and-how-is-it-different)  
Lucio Andrés Illanes Albornoz 531158
2. [Building and deployment](#2-building-and-deployment)  
ce2a76
	2.1. [Building, installing, and using a Midipix distribution](#21-building-installing-and-using-a-midipix-distribution)  
Lucio Andrés Illanes Albornoz 531158
		2.1.1. [Build-time dependencies](#211-build-time-dependencies)  
Lucio Andrés Illanes Albornoz 531158
			2.1.1.1. [Alpine-specific notate bene](#2111-alpine-specific-notate-bene)  
Lucio Andrés Illanes Albornoz 531158
	2.2. [Deployment](#22-deployment)  
Lucio Andrés Illanes Albornoz 531158
	2.3. [System requirements](#23-system-requirements)  
Lucio Andrés Illanes Albornoz 531158
	2.4. [Troubleshooting](#24-troubleshooting)  
4f3e5a
3. [Common concepts and tasks / FAQ](#3-common-concepts-and-tasks-faq)  
Lucio Andrés Illanes Albornoz 531158
	3.1. [Common tasks](#31-common-tasks)  
Lucio Andrés Illanes Albornoz 531158
	3.2. [Adding a package](#32-adding-a-package)  
Lucio Andrés Illanes Albornoz 531158
	3.3. [Addressing build failure](#33-addressing-build-failure)  
Lucio Andrés Illanes Albornoz 531158
	3.4. [Package archive files and Git repositories](#34-package-archive-files-and-git-repositories)  
abd214
	3.5. [Patches and ``vars`` files](#35-patches-and-vars-files)  
76e2d1
4. [Reference](#4-reference)  
Lucio Andrés Illanes Albornoz 531158
	4.1. [Build steps](#41-build-steps)  
Lucio Andrés Illanes Albornoz 531158
	4.2. [Build variables](#42-build-variables)  
76e2d1
	4.3. [File installation DSL](#43-file-installation-dsl)  
76e2d1
	4.4. [Package variables](#44-package-variables)  
76e2d1
		4.4.1. [Package variable types](#441-package-variable-types)  
76e2d1
		4.4.2. [Package variables](#442-package-variables)  
76e2d1
	4.5. [Fault-tolerant & highly optimised 3D laser show-equipped usage screen](#45-fault-tolerant--highly-optimised-3d-laser-show-equipped-usage-screen)  
Lucio Andrés Illanes Albornoz 531158
	4.6. [``pkgtool.sh``](#46-pkgtoolsh)  
e94dc6
	4.7. [Bourne shell coding rules](#47-bourne-shell-coding-rules)  
Lucio Andrés Illanes Albornoz 531158
5. [References](#5-references)  
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: "}}}"
Lucio Andrés Illanes Albornoz 531158

ce2a76
[//]: # "{{{ 1. What is Midipix, and how is it different?"
ce2a76
## 1. What is Midipix, and how is it different?
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
midipix is a development environment that lets you create programs
Lucio Andrés Illanes Albornoz 531158
for Windows using the standard C and POSIX APIs. No compromises made,
Lucio Andrés Illanes Albornoz 531158
no shortcuts taken.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
If you are interested in cross-platform programming that reclaims
Lucio Andrés Illanes Albornoz 531158
the notion of write once, compile everywhere; if you believe that the
Lucio Andrés Illanes Albornoz 531158
'standard' in the C Standard Library should not be a null signifier;
Lucio Andrés Illanes Albornoz 531158
and if you like cooking your code without #ifdef hell and low-level
Lucio Andrés Illanes Albornoz 531158
minutiae, then this page is for you.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
midipix makes cross-platform programming better, simpler and faster,
Lucio Andrés Illanes Albornoz 531158
specifically by bringing a modern, conforming C Runtime Library to the
Lucio Andrés Illanes Albornoz 531158
Windows platform. While the idea itself is not new, the approach taken
Lucio Andrés Illanes Albornoz 531158
in midipix to code portability is radically different from that found
Lucio Andrés Illanes Albornoz 531158
in other projects.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
*(reproduced from [[2](https://midipix.org/#sec-midipix)])*
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: "}}}"
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 2. Building and deployment"
Lucio Andrés Illanes Albornoz 531158
## 2. Building and deployment
Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
ce2a76
[//]: # "{{{ 2.1. Building, installing, and using a Midipix distribution"
ce2a76
### 2.1. Building, installing and using a Midipix distribution
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
A Midipix distribution consists of the following:
7a0b92

Lucio Andrés Illanes Albornoz 531158
* the native Midipix toolchain, consisting of perk, gcc, its dependencies,
Lucio Andrés Illanes Albornoz 531158
  and binutils,
Lucio Andrés Illanes Albornoz 531158
* musl, a lightweight, fast, simple, and free libc[[1](https://www.musl-libc.org/faq.html)] used by Midipix,
Lucio Andrés Illanes Albornoz 531158
* the Midipix runtime components that bridge the gap between the libc and the
Lucio Andrés Illanes Albornoz 531158
  executive subsystems of all Windows NT-derived Windows OS starting with and
Lucio Andrés Illanes Albornoz 531158
  including Windows XP, and
Lucio Andrés Illanes Albornoz 531158
* a steadily increasing number of 3rd party open source packages, as expected in
Lucio Andrés Illanes Albornoz 531158
  any modern POSIX-compliant \*nix environment, including GNU coreutils, shells,
Lucio Andrés Illanes Albornoz 531158
  libraries such as ncurses, libressl, as well as Perl and Python.
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Install the build-time dependencies listed in section [2.1.1](#211-build-time-dependencies),
Lucio Andrés Illanes Albornoz 531158
clone this repository (e.g. ``git clone https://dev.midipix.org/build/midipix_build``)
Lucio Andrés Illanes Albornoz 531158
and run the following command line:
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh -a nt64 -b release -D zipdist -P -v
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
By default, the build will take place within ``${HOME}/midipix/nt64/release``
Lucio Andrés Illanes Albornoz 531158
and package archive files and/or Git repositores will be downloaded into
Lucio Andrés Illanes Albornoz 531158
``${HOME}/midipix/dlcache``. Consult sections [4.2](#42-build-variables) and
76e2d1
[4.4](#44-package-variables) for the list of available build/package variables
Lucio Andrés Illanes Albornoz 531158
and how to override them.  
Lucio Andrés Illanes Albornoz 531158
Parallelisation is enabled by the above command line for both packages that can
Lucio Andrés Illanes Albornoz 531158
be built independently of each other and ``make(1)`` via ``-j``, limited to the
Lucio Andrés Illanes Albornoz 531158
amount of logical processors on the build host divided by two (2).
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 2.1.1. Build-time dependencies"
Lucio Andrés Illanes Albornoz 531158
### 2.1.1. Build-time dependencies
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
* **Alpine Linux**:
328571
  binutils bison bzip2 cmake coreutils curl findutils g++ gawk gcc git grep gzip libc-dev linux-headers lzip m4 make musl-dev net-tools patch perl perl-xml-parser procps sed tar util-linux wget xz zip
f01b1e
* **Arch Linux**:
b9cb10
  binutils bison bzip2 cmake coreutils curl findutils gawk gcc git grep gzip lzip m4 make net-tools patch perl perl-xml-parser procps-ng sed tar util-linux wget xz zip
Lucio Andrés Illanes Albornoz 531158
* **Debian/-derived Linux**:
328571
  binutils bison bzip2 cmake coreutils curl findutils g++ gawk gcc git grep gzip hostname libc6-dev libxml-parser-perl lzip m4 make patch perl procps sed tar util-linux wget xz-utils zip
Lucio Andrés Illanes Albornoz 531158
* **Gentoo Linux**:
328571
  binutils bison bzip2 cmake coreutils curl findutils gawk =gcc-7.5.0-r1 dev-vcs/git grep gzip lzip m4 make patch perl dev-perl/XML-Parser procps sed tar util-linux wget xz-utils zip
Lucio Andrés Illanes Albornoz 531158
* **OpenSUSE Linux**:
328571
  binutils bison bzip2 cmake coreutils curl findutils gawk gcc gcc-c++ git grep gzip hostname linux-glibc-devel lzip m4 make patch perl perl-XML-Parser procps sed tar util-linux wget xz zip
Lucio Andrés Illanes Albornoz 531158
  
ba0fc3
#### The distro matrix:
ba0fc3

f01b1e
|  Alpine Linux:  |    Arch Linux:     |   Debian/-derived Linux:   |    Gentoo Linux:    |  OpenSUSE Linux:  |
f01b1e
| --------------- | ------------------ | -------------------------- | ------------------- | ----------------- |
f01b1e
| binutils        | binutils           | binutils                   | binutils            | binutils          |
f01b1e
| bison           | bison              | bison                      | bison               | bison             |
f01b1e
| bzip2           | bzip2              | bzip2                      | bzip2               | bzip2             |
f01b1e
| cmake           | cmake              | cmake                      | cmake               | cmake             |
f01b1e
| coreutils       | coreutils          | coreutils                  | coreutils           | coreutils         |
f01b1e
| curl            | curl               | curl                       | curl                | curl              |
f01b1e
| findutils       | findutils          | findutils                  | findutils           | findutils         |
f01b1e
| g++             | -                  | g++                        | -                   | gcc-c++           |
f01b1e
| gawk            | gawk               | gawk                       | gawk                | gawk              |
f01b1e
| gcc             | gcc                | gcc                        | =gcc-7.5.0-r1       | gcc               |
f01b1e
| git             | git                | git                        | dev-vcs/git         | git               |
f01b1e
| grep            | grep               | grep                       | grep                | grep              |
f01b1e
| gzip            | gzip               | gzip                       | gzip                | gzip              |
f01b1e
| -               | -                  | hostname                   | -                   | hostname          |
f01b1e
| libc-dev        | -                  | libc6-dev                  | -                   | linux-glibc-devel |
b9cb10
| linux-headers   | -                  | -                          | -                   | -                 |
f01b1e
| lzip            | lzip               | lzip                       | lzip                | lzip              |
f01b1e
| m4              | m4                 | m4                         | m4                  | m4                |
f01b1e
| make            | make               | make                       | make                | make              |
f01b1e
| musl-dev        | -                  | -                          | -                   | -                 |
f01b1e
| net-tools       | net-tools          | -                          | -                   | -                 |
f01b1e
| patch           | patch              | patch                      | patch               | patch             |
f01b1e
| perl            | perl               | perl                       | perl                | perl              |
f01b1e
| perl-xml-parser | perl-xml-parser    | libxml-parser-perl         | dev-perl/XML-Parser | perl-XML-Parser   |
f01b1e
| procps          | procps-ng          | procps                     | procps              | procps            |
f01b1e
| sed             | sed                | sed                        | sed                 | sed               |
f01b1e
| tar             | tar                | tar                        | tar                 | tar               |
f01b1e
| util-linux      | util-linux         | util-linux                 | util-linux          | util-linux        |
f01b1e
| -               | vi                 | -                          | -                   | -                 |
f01b1e
| wget            | wget               | wget                       | wget                | wget              |
f01b1e
| xz              | xz                 | xz-utils                   | xz-utils            | xz                |
f01b1e
| zip             | zip                | zip                        | zip                 | zip               |
ba0fc3

Lucio Andrés Illanes Albornoz 531158
> N.B. Busybox is not supported. Awk implementations other than GNU Awk are not supported.  
Lucio Andrés Illanes Albornoz 531158
  
082c08
> N.B. clang is not supported.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 2.1.1.1. Alpine-specific notate bene"
Lucio Andrés Illanes Albornoz 531158
#### 2.1.1.1. Alpine-specific notate bene
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Some packages (*coreutils*, *grep*, and *tar*, among others) override Alpine's
Lucio Andrés Illanes Albornoz 531158
BusyBox utilities of the same name, as the latter are either non-conformant or
Lucio Andrés Illanes Albornoz 531158
defective.
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 2.2. Deployment"
Lucio Andrés Illanes Albornoz 531158
### 2.2. Deployment
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
On successful completion of the build, a ZIP archive containing the Midipix
Lucio Andrés Illanes Albornoz 531158
distribution will be created inside ``${PREFIX}`` (see section [4.2](#42-build-variables).)
Lucio Andrés Illanes Albornoz 531158
Create a directory on the target machine and extract the contents of the distribution
Lucio Andrés Illanes Albornoz 531158
ZIP archive into it, run ``bash.bat``, and then ``/install.sh`` inside the resulting
Lucio Andrés Illanes Albornoz 531158
self-contained Midipix installation shell window.  
Lucio Andrés Illanes Albornoz 531158
  
abd214
Make sure to consult the notate bene below:  
abd214
  
Lucio Andrés Illanes Albornoz 531158
> N.B. The pathname of the target directory containing ``bash.bat`` and all other
Lucio Andrés Illanes Albornoz 531158
distribution files must not contain whitespaces.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
> N.B. The Midipix installer defaults to ``/dev/fs/c/midipix (C:\midipix)``. If left
Lucio Andrés Illanes Albornoz 531158
unchanged, the distribution ZIP archive must not be extracted into a directory of the
Lucio Andrés Illanes Albornoz 531158
same pathname.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
> N.B. The user installing and using Midipix must have been delegated the ``SeCreateSymbolicLinkPrivilege``
Lucio Andrés Illanes Albornoz 531158
("Create symbolic links") privilege[[3](https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment)] and additionally be a non-administrator account
Lucio Andrés Illanes Albornoz 531158
owing to the UAC-related filtering policy of tokens introduced by Windows Vista[[4](https://docs.microsoft.com/en-us/previous-versions/dotnet/articles/bb530410%28v%3dmsdn%2e10%29)].  
Lucio Andrés Illanes Albornoz 531158
  
abd214
> N.B. On Windows 10 and 11, Windows Defender as well as SmartScreen must be disabled.
abd214
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 2.3. System requirements"
Lucio Andrés Illanes Albornoz 531158
### 2.3. System requirements
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
The following build-time system requirements are assessed on build hosts
Lucio Andrés Illanes Albornoz 531158
equipped with the following hardware at minimum:
e522b8

Lucio Andrés Illanes Albornoz 531158
* Intel(R) Xeon(R) CPU W3520 @ 2.67GHz (8 cores)
Lucio Andrés Illanes Albornoz 531158
* 7200 RPM SATA 3.1 HDD
Lucio Andrés Illanes Albornoz 531158
* 6 GB RAM
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Target architecture | Build kind | Distribution kinds selected | Average build time | Disk space required | Peak RAM usage |
Lucio Andrés Illanes Albornoz 531158
| ------------------- | ---------- | --------------------------- | ------------------ | ------------------- | -------------- |
Lucio Andrés Illanes Albornoz 531158
| nt64                | debug      | (none)                      | 2 hours            | 57.62 GB            | 3.55 GB        |
Lucio Andrés Illanes Albornoz 531158
| nt64                | release    | (none)                      | 1 hours 45 minutes | 36.51 GB            | 3.21 GB        |
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Package archive files and/or Git repositories additionally consume at least
Lucio Andrés Illanes Albornoz 531158
1.82 GB.
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
*(last update: Thu, 05 Mar 2020 09:25:41 +0000)*
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
These are the Midipix distribution disk space system requirements:
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Target architecture | Build kind | Distribution | Installation directory | Archive file |
Lucio Andrés Illanes Albornoz 531158
| ------------------- | ---------- | ------------ | ---------------------- | ------------ |
Lucio Andrés Illanes Albornoz 531158
| nt64                | debug      | 7.3 GB       |  2.3 GB                | 2.1 GB       |
Lucio Andrés Illanes Albornoz 531158
| nt64                | release    | 3.2 GB       |  913 MB                | 830 MB       |
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
The installation directory and archive file may be safely deleted post-installation.
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
*(last update: Thu, 07 Jan 2021 18:20:06 +0000)*
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 2.4. Troubleshooting"
Lucio Andrés Illanes Albornoz 531158
### 2.4. Troubleshooting
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Midipix presently provides, inter alia, strace-like functionality via
Lucio Andrés Illanes Albornoz 531158
ntctty's logging capabilities. This is available both through the regular
Lucio Andrés Illanes Albornoz 531158
``strace(1)`` command as distributed, which however **must** be provided
Lucio Andrés Illanes Albornoz 531158
with an absolute pathname without consideration for ``${PATH}``, as well
Lucio Andrés Illanes Albornoz 531158
as directly via ``ntctty.exe`` for a session by running ``ntctty.exe``
Lucio Andrés Illanes Albornoz 531158
with the ``--log-level 7`` option, e.g.:
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
$ #strace ls -la /        # (incorrect, relative pathname)
Lucio Andrés Illanes Albornoz 531158
$ strace /bin/ls -la /    # (correct, absolute pathname)
Lucio Andrés Illanes Albornoz 531158
$ ntctty.exe --log-level 7 -e /bin/ls -la /
Lucio Andrés Illanes Albornoz 531158
$ ntctty.exe --log-level=7 -e /bin/ls -la /
Lucio Andrés Illanes Albornoz 531158
$ ntctty.exe --log-level 7 -e /bin/sh -c "ls -la /"
Lucio Andrés Illanes Albornoz 531158
$ ntctty.exe --log-level=7 -e /bin/sh -c "ls -la /"
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
By default, ``ntctty.exe`` log files are written into the /var/log/ntctty
Lucio Andrés Illanes Albornoz 531158
directory; this may be adjusted with the ``--log-dir`` and/or
Lucio Andrés Illanes Albornoz 531158
``--log-file`` options. ``strace(1)`` logs to stderr by default.
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 3. Common concepts and tasks"
Lucio Andrés Illanes Albornoz 531158
## 3. Common concepts and tasks
Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 3.1. Common tasks"
Lucio Andrés Illanes Albornoz 531158
### 3.1. Common tasks
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Rebuild set of packages in isolation:
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r mc,zsh
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Restart the ``@install`` (shorthand alias) step, with implicit ``finish``, of the
Lucio Andrés Illanes Albornoz 531158
``mc`` and ``zsh`` packages.
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r mc,zsh:@install
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Rebuild set of packages along w/ their dependencies, if any, as needed, or forcibly,
Lucio Andrés Illanes Albornoz 531158
respectively:
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r \*mc,zsh
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r \*\*mc,zsh
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Forcibly rebuild all reverse dependencies of a set of packages:
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r \*\*\*glib,libflac
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Restart the ``@configure``, ``@build``, and ``@install`` (shorthand alias) steps of the
Lucio Andrés Illanes Albornoz 531158
``coreutils`` package:
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh -r coreutils:@configure,@build,@install
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Rebuild entire build groups including or excluding group dependencies, respectively:
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r ALL native_runtime
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r ALL =native_runtime
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Forcibly (re)download all archive files and/or Git repositories associated with all packages:
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh [ ... ] -r ALL:@fetch
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 3.2. Adding a package"
Lucio Andrés Illanes Albornoz 531158
## 3.2. Adding a package
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Packages are grouped into *build groups* according to sets of common package
Lucio Andrés Illanes Albornoz 531158
variable defaults, such as ``${PKG_CFLAGS_CONFIGURE}, ${PKG_LDFLAGS_CONFIGURE}``
Lucio Andrés Illanes Albornoz 531158
and ``${PKG_CONFIGURE_ARGS}``, and semantic interrelatedness, such as the
Lucio Andrés Illanes Albornoz 531158
``native_runtime`` build group comprising the Midipix runtime components.
Lucio Andrés Illanes Albornoz 531158
Packages may belong to more than one build group such as when subsumed by a shorthand
Lucio Andrés Illanes Albornoz 531158
build group e.g. the ``dev_packages`` build group, as long as the default set of build
Lucio Andrés Illanes Albornoz 531158
groups or as overriden on the command line does not entail group membership conflicts.  
Lucio Andrés Illanes Albornoz 531158
  
78240c
Build groups files beneath ``groups.d/`` named ``[0-9][0-9][0-9].<group name>.group``
Lucio Andrés Illanes Albornoz 531158
contain package variable defaults, the alphabetically sorted list of contained
Lucio Andrés Illanes Albornoz 531158
packages in ``<upper case group name>_PACKAGES``, and their package variables
Lucio Andrés Illanes Albornoz 531158
sorted alphabetically with the exception of ``${PKG_DEPENDS}`` (if present,)
Lucio Andrés Illanes Albornoz 531158
``${PKG_SHA256SUM}``, ``${PKG_URL}``, and ``${PKG_VERSION}``, and/or ``${PKG_URLS_GIT}``,
Lucio Andrés Illanes Albornoz 531158
which are specified in this order.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Pick a build group according to the criteria mentioned, add the package to the
Lucio Andrés Illanes Albornoz 531158
build group's list of contained packages in its corresponding file, and add the
76e2d1
set of package variables required (see above and section [4.4](#44-package-variables).)  
abd214
Consult section [3.5](#35-patches-and-vars-files) if the package to be added
Lucio Andrés Illanes Albornoz 531158
requires patches or additional code amending or replacing package build steps
Lucio Andrés Illanes Albornoz 531158
or the entire package build. Consult section [4.1](#41-build-steps) for a list
Lucio Andrés Illanes Albornoz 531158
of package build steps and how they are overriden.
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 3.3. Addressing build failure"
Lucio Andrés Illanes Albornoz 531158
## 3.3. Addressing build failure
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
During package build, standard error and output are redirected into a log file beneath
Lucio Andrés Illanes Albornoz 531158
``${BUILD_WORKDIR}`` named ``${PKG_NAME}_stderrout.log``, following a package variable
Lucio Andrés Illanes Albornoz c6f88c
dump. If ``-V build`` was specified, package logs will additionally be printed to standard
Lucio Andrés Illanes Albornoz c6f88c
output. If ``-V xtrace`` was specified, ``xtrace`` will be set during package builds for
Lucio Andrés Illanes Albornoz 531158
rudimentary debugging purposes. Additionally, packages using GNU autotools will, if
Lucio Andrés Illanes Albornoz 531158
package configuration failed or appears relevant, log the configuration process in detail
Lucio Andrés Illanes Albornoz 531158
in, most usually, ``${PKG_BUILD_DIR}/config.log``.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 3.4. Package archive files and Git repositories"
Lucio Andrés Illanes Albornoz 531158
### 3.4. Package archive files and Git repositories
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Packages may have either or both of a SHA-256 message digest checked and to be extracted tarball
Lucio Andrés Illanes Albornoz 531158
(set in ``${PKG_URL}``, ``${PKG_FNAME}``, and ``${PKG_SHA256SUM}``) and/or Git repository or set
Lucio Andrés Illanes Albornoz 531158
thereof (set in ``${PKG_URLS_GIT}``.) Complementing these, an implicitly inferred or, in the
Lucio Andrés Illanes Albornoz 531158
presence of both, explicit primary source directory is specified for each package in ``${PKG_SUBDIR}``.
Lucio Andrés Illanes Albornoz 531158
Furthermore, these may be subject to download caching and/or setting up as well as maintaining
Lucio Andrés Illanes Albornoz 531158
mirrors, including automatic cleanup as well as deduplication in both cases.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
A list of pertinent package variables and their formats follows:  
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Name           | Format                                          |
Lucio Andrés Illanes Albornoz 531158
| -------------- | ----------------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| PKG_FNAME      | ``<single file name>``                          |
Lucio Andrés Illanes Albornoz 531158
| PKG_SHA256SUM  | ``<SHA-256 message digest>``                    |
Lucio Andrés Illanes Albornoz 531158
| PKG_SUBDIR     | ``<relative or single directory name>``         |
Lucio Andrés Illanes Albornoz 531158
| PKG_URL        | ``scheme:[//authority]path[?query][#fragment]`` |
Lucio Andrés Illanes Albornoz 531158
| PKG_URLS_GIT   | ``[subdir=]URL[@branch]``                       |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
abd214
[//]: # "{{{ 3.5. Patches and ``vars`` files"
abd214
## 3.5. Patches and ``vars`` files
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Package patches are applied prior and/or subsequent to (GNU autotools or similar) package
Lucio Andrés Illanes Albornoz 531158
configuration during the ``configure_patch_pre`` and/or ``configure_patch`` build steps,
Lucio Andrés Illanes Albornoz 531158
respectively (see section [4.1](#41-build-steps).) Patch files are searched for beneath
Lucio Andrés Illanes Albornoz 531158
``patches/`` with the following globs and in-order:
Lucio Andrés Illanes Albornoz 531158
* ``${PKG_NAME}-${PKG_VERSION}_pre.local.patch``
Lucio Andrés Illanes Albornoz 531158
  or ``${PKG_NAME}_pre.local.patch`` (for packages lacking ``${PKG_VERSION}``)
Lucio Andrés Illanes Albornoz 531158
* ``${PKG_NAME}-${PKG_VERSION}_pre.local@${BUILD_HNAME}.patch``
Lucio Andrés Illanes Albornoz 531158
  or ``${PKG_NAME}_pre.local@${BUILD_HNAME}.patch`` (for packages lacking ``${PKG_VERSION}``)
Lucio Andrés Illanes Albornoz 531158
* ``${PKG_NAME}/*.patch``
Lucio Andrés Illanes Albornoz 531158
* ``${PKG_NAME}-${PKG_VERSION}.local.patch``
Lucio Andrés Illanes Albornoz 531158
  or ``${PKG_NAME}.local.patch`` (for packages lacking ``${PKG_VERSION}``)
Lucio Andrés Illanes Albornoz 531158
* ``${PKG_NAME}-${PKG_VERSION}.local@${BUILD_HNAME}.patch``
Lucio Andrés Illanes Albornoz 531158
  or ``${PKG_NAME}.local@${BUILD_HNAME}.patch`` (for packages lacking ``${PKG_VERSION}``)
Lucio Andrés Illanes Albornoz 531158
* ``${PKG_PATCHES_EXTRA}`` (if set)
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
If the default set of package build steps does not suffice, such as if additional commands
Lucio Andrés Illanes Albornoz 531158
must be executed after package configuration or prior to building, or if an entire or all
Lucio Andrés Illanes Albornoz 531158
build step must be replaced, overrides may be specified in the form of functions in the
786b88
package's ``vars/${PKG_NAME}.vars`` as well as ``vars.<group name>/${PKG_NAME}.vars``
786b88
``vars`` file(s). Consult section [4.1](#41-build-steps) for a list of package build steps
786b88
and how they are overriden.
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158

76e2d1
[//]: # "{{{ 4. Reference"
76e2d1
## 4. Reference
Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 4.1. Build steps"
Lucio Andrés Illanes Albornoz 531158
## 4.1. Build steps
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Package builds are divided up into consecutively executed build steps until
Lucio Andrés Illanes Albornoz 531158
completion or aborted on failure unless relaxed mode is enabled by passing
Lucio Andrés Illanes Albornoz 531158
``-R``.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Each build step corresponds to a function in the corresponding ``subr/pkg_*.subr``
Lucio Andrés Illanes Albornoz 531158
script and may be overriden entirely by a function named ``pkg_<package name>_<build step>()``
Lucio Andrés Illanes Albornoz 531158
or composed in terms of prior and/or subsequent execution by a function named
Lucio Andrés Illanes Albornoz 531158
``pkg_<package name>_<build step>_pre()`` and/or ``pkg_<package name>_<build step>_post()``,
Lucio Andrés Illanes Albornoz 531158
respectively, in the package's ``vars`` file. If a function named ``pkg_<package name>_all()``
Lucio Andrés Illanes Albornoz 531158
exists, it will override all build steps.  
Lucio Andrés Illanes Albornoz 531158
  
76e2d1
Build step functions receive the following arguments in the order specified:
76e2d1
  
76e2d1
| Name          | Description                                              |
76e2d1
| ------------- | -------------------------------------------------------- |
76e2d1
| \_group\_name | Package name                                             |
76e2d1
| \_pkg\_name   | Group name                                               |
76e2d1
| \_restart\_at | Optional list of build steps to restart package build at |
76e2d1
  
Lucio Andrés Illanes Albornoz 531158
Build step status is tracked on a per-package basis by state files beneath
Lucio Andrés Illanes Albornoz 531158
``${BUILD_WORKDIR}`` following the format ``.<package name>.<build step>``;
Lucio Andrés Illanes Albornoz 531158
package build completion corresponds to the pseudo-build step ``finish``.
Lucio Andrés Illanes Albornoz 531158

8e9332
| Name                | Description                                                                                                                                                                                                                                              |
8e9332
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
786b88
| fetch_clean         | Delete and create ``${PKG_SUBDIR}``                                                                                                                                                                                                                      |
8e9332
| fetch_download      | Download package archive & verify w/ SHA-256 message digest and/or clone Git repository/ies                                                                                                                                                              |
8e9332
| fetch_extract       | Extract package archive, if any                                                                                                                                                                                                                          |
786b88
| configure_clean     | Delete and create ``${PKG_BUILD_DIR}``                                                                                                                                                                                                                   |
8e9332
| configure_patch_pre | Apply ``chainport`` patches and/or patches beneath ``patches/`` prior to (GNU autotools or similar) configuration                                                                                                                                        |
8e9332
| configure_autotools | Bootstrap (GNU autools or similar) environment, and install ``config.sub`` and ``config.cache``                                                                                                                                                          |
8e9332
| configure_patch     | Apply patches beneath ``patches/`` and/or set in ``${PKG_PATCHES_EXTRA}`` after (GNU autotools or similar) configuration                                                                                                                                 |
8e9332
| configure           | Perform package (GNU autools or similar or CMake) configuration w/ configuration-time set of environment variables                                                                                                                                       |
786b88
| build_clean         | Clean ``${PKG_BUILD_DIR}`` w/ ``make clean`` invocation                                                                                                                                                                                                  |
8e9332
| build               | Call ``make(1)`` w/ build-time set of make variables                                                                                                                                                                                                     |
786b88
| install_clean       | Delete and create ``${PKG_DESTDIR}``                                                                                                                                                                                                                     |
8e9332
| install_subdirs     | Create default directory hierarchy in ``${PKG_DESTDIR}``, optionally amended w/ ``${PKG_INSTALL_FILES_DESTDIR_EXTRA}``                                                                                                                                   |
8e9332
| install_make        | Call ``make(1)`` w/ ``${PKG_INSTALL_TARGET}`` (defaults to ``install``) and installation-time set of make variables                                                                                                                                      |
8e9332
| install_files       | Install ``${PKG_INSTALL_FILES}`` and/or ``${PKG_INSTALL_FILES_V2}``, fix directory and file mode bits within ``${PKG_DESTDIR}`` and optionally ``${PKG_DESTDIR_HOST}``, ``pkgconf(1)`` package files, and/or stripped binaries within ``${PKG_DESTDIR}`` |
938c5c
|                     | Purge libtool ``.la`` files and install shared objects within ``${PKG_DESTDIR}`` w/ ``perk`` and corresponding symbolic links                                                                                                                            |
8e9332
| install             | Install into ``${PKG_PREFIX}``, and optionally ``${PKG_DESTDIR_HOST}`` into ``${PREFIX}``, under mutex, and add package to ``${PREFIX}/pkglist.${PKG_BUILD_TYPE}`` (unless inhibited)                                                                    |
8e9332
| install_rpm         | Build package RPM w/ auto-generated specifiation file based on ``etc/package.spec`` beneath ``${PREFIX_RPM}``                                                                                                                                            |
8e9332
| clean               | Clean ``${PKG_BUILD_DIR}`` and/or ``${PKG_DESTDIR}`` and/or ``${PKG_DESTDIR_HOST}`` and/or ``${PKG_BASE_DIR}/${PKG_SUBDIR}`` as per ``-C build,dest,src``, resp., if any                                                                                 |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 4.2. Build variables"
Lucio Andrés Illanes Albornoz 531158
## 4.2. Build variables
Lucio Andrés Illanes Albornoz 531158

d79f1f
The following variables are primarily defined in ``env.d/*.env`` and may be
Lucio Andrés Illanes Albornoz 531158
overriden on a per-build basis on the command-line, the environment, and/or
Lucio Andrés Illanes Albornoz 531158
``${HOME}/midipix_build.vars``, ``${HOME}/.midipix_build.vars``, and/or
Lucio Andrés Illanes Albornoz 531158
``../midipix_build.vars``, e.g.:
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
./build.sh -a nt64 -b release -D minipix,zipdist -P -v PREFIX_ROOT="${HOME}/midipix_tmp"
Lucio Andrés Illanes Albornoz 531158
env ARCH=nt64 BUILD_KIND=release PREFIX_ROOT="${HOME}/midipix_tmp" ./build.sh -D minipix,zipdist -P -v
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Variable name    | Default value                        | Description                                                                   |
Lucio Andrés Illanes Albornoz 531158
| ---------------- | ------------------------------------ | ----------------------------------------------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| ARCH             | nt64                                 | Target 32-bit (nt32) or 64-bit (nt64) architecture                            |
Lucio Andrés Illanes Albornoz 531158
| BUILD_DLCACHEDIR | ${PREFIX_ROOT}/dlcache               | Absolute pathname to package downloads cache root directory                   |
Lucio Andrés Illanes Albornoz 531158
| BUILD_HNAME      | $(hostname)                          | Build system hostname                                                         |
Lucio Andrés Illanes Albornoz 531158
| BUILD_KIND       | debug                                | Build w/ debugging (debug) or release compiler flags                          |
Lucio Andrés Illanes Albornoz 531158
| BUILD_WORKDIR    | ${PREFIX}/tmp                        | Absolute pathname to temporary package build root directory                   |
Lucio Andrés Illanes Albornoz 531158
| PREFIX           | ${PREFIX_ROOT}/${ARCH}/${BUILD_KIND} | Absolute pathname to architecture- & build type-specific build root directory |
Lucio Andrés Illanes Albornoz 531158
| PREFIX_CROSS     | ${PREFIX}/${DEFAULT_TARGET}          | Absolute pathname to toolchain root directory                                 |
Lucio Andrés Illanes Albornoz 531158
| PREFIX_MINGW32   | ${PREFIX}/x86_64-w64-mingw32         | Absolute pathname to MinGW toolchain root directory                           |
Lucio Andrés Illanes Albornoz 531158
| PREFIX_MINIPIX   | ${PREFIX}/minipix                    | Absolute pathname to minipix distribution root directory                      |
Lucio Andrés Illanes Albornoz 531158
| PREFIX_NATIVE    | ${PREFIX}/native                     | Absolute pathname to cross-compiled packages root directory                   |
Lucio Andrés Illanes Albornoz 531158
| PREFIX_ROOT      | ${HOME}/midipix                      | Absolute pathname to top-level directory                                      |
Lucio Andrés Illanes Albornoz 531158
| PREFIX_RPM       | ${PREFIX}/rpm                        | Absolute pathname to package RPM archive root directory                       |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
76e2d1
[//]: # "{{{ 4.3. File installation DSL"
76e2d1
## 4.3. File installation DSL
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
File and directory installation, comprising e.g. copying, moving, creating
Lucio Andrés Illanes Albornoz 531158
symbolic links, setting owner and/or permission metadata, are expressed in
Lucio Andrés Illanes Albornoz 531158
a descriptive domain-specific language and integrated with package building
8e9332
via the package variable ``${PKG_INSTALL_FILES_V2}``, applying during
8e9332
``install_files`` after the ``install_make`` build step, and ``${PKG_INSTALL_FILES_DESTDIR}``
8e9332
and ``${PKG_INSTALL_FILES_DESTDIR_EXTRA}`` during ``install_subdirs``. The
8e9332
``${PKG_INSTALL_FILES_V2}`` must adhere to the following syntax specified in EBNF:  
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
(*
Lucio Andrés Illanes Albornoz 531158
SH_GLOB_PATTERN      = any valid portable shell pattern (see sh(1)); superset of PATHNAME
Lucio Andrés Illanes Albornoz 531158
SH_SUBSTRING_PATTERN = any valid portable substring processing shell pattern (see sh(1));
Lucio Andrés Illanes Albornoz 531158
                       superset of PATHNAME
Lucio Andrés Illanes Albornoz 531158
PARAMETER            = any valid portable shell variable name except that [0-9] may occur
Lucio Andrés Illanes Albornoz 531158
                       the beginning
Lucio Andrés Illanes Albornoz 531158
PATHNAME             = any valid filename, directory name, relative or absolute pathname
Lucio Andrés Illanes Albornoz 531158
                       excluding the characters NUL and NL
Lucio Andrés Illanes Albornoz 531158
 *)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
spec                 = { op_flag, } op_unary, "=", op_spec, "\n", { spec } ;
Lucio Andrés Illanes Albornoz 531158
                     | { op_flag, } op_binary, op_spec, "=" op_spec, "\n", { spec } ;
Lucio Andrés Illanes Albornoz 531158
                     | "#" COMMENT ;
Lucio Andrés Illanes Albornoz 531158
op_unary             = "-" | "/" | "t" ;
Lucio Andrés Illanes Albornoz 531158
op_binary            = ":" | "!" | "@" | "+" | "g" | "m" | "o" | "T" ;
Lucio Andrés Illanes Albornoz 531158
op_flag              = "?" ;
Lucio Andrés Illanes Albornoz 531158
op_spec              = pattern_spec | PATHNAME | expr_spec | op_spec ;
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
pattern_spec         = "%<", SH_GLOB_PATTERN, ">" ;
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
expr_spec            = "%[", expr, { sexpr_spec }, "%]" ;
Lucio Andrés Illanes Albornoz 531158
expr                 = [ "@" ], "0" .. "9" | "DNAME" | "FNAME" | "ITEM" | PARAMETER ;
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
sexpr_spec           = sexpr_op_unary, SH_SUBSTRING_PATTERN, { sexpr } ;
Lucio Andrés Illanes Albornoz 531158
sexpr_op_unary       = "##" | "#" | "%%" | "%" ;
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Single ``"="`` characters in ``spec``, the ``"%<"`` and ``"%["`` character
Lucio Andrés Illanes Albornoz 531158
sequences in ``pattern_spec`` and ``expr_spec``, resp., and the ``sexpr_op_unary``
Lucio Andrés Illanes Albornoz 531158
as well as ``sexpr_op_binary`` characters or character sequences may be
Lucio Andrés Illanes Albornoz 531158
escaped with a single backslash (``"\"``.) ``SH_SUBSTRING_PATTERN`` differs
Lucio Andrés Illanes Albornoz 531158
from ``SH_GLOB_PATTERN`` solely in that any of ``sexpr_op_unary`` and
Lucio Andrés Illanes Albornoz 531158
``sexpr_op_binary`` occuring at the beginning of or in the former must
Lucio Andrés Illanes Albornoz 531158
be escaped with a single backslash (``"\"``,) e.g. ``"#\#pattern"`` and
Lucio Andrés Illanes Albornoz 531158
``"%\%pattern"``, etc. and ``"#pat\%ern"`` and ``%patt\#ern", etc., resp.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
Named parameters (``PARAMETER``) are supplied via the ``-p name=value``
Lucio Andrés Illanes Albornoz 531158
argument to ``rtl_install()``, whereas numbered parameters are for
Lucio Andrés Illanes Albornoz 531158
internal usage only; the ``"DNAME"``, ``"FNAME"``, and ``"ITEM"`` parameters
Lucio Andrés Illanes Albornoz 531158
lazily evaluate to the directory name, file (aka base) name, and full
Lucio Andrés Illanes Albornoz 531158
pathname of the current item being processed relative to a specification
Lucio Andrés Illanes Albornoz 531158
with a pattern in it.
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
The following parameters are defined by default during ``install_files``:
7a0b92

Lucio Andrés Illanes Albornoz 531158
| Name           | Value                                  |
Lucio Andrés Illanes Albornoz 531158
| -------------  | -------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| _builddir      | ${PKG_BUILD_DIR}                       |
Lucio Andrés Illanes Albornoz 531158
| _destdir       | ${PKG_BASE_DIR}/${PKG_DESTDIR}         |
Lucio Andrés Illanes Albornoz 531158
| _destdir_host  | ${PKG_BASE_DIR}/${PKG_DESTDIR_HOST}    |
Lucio Andrés Illanes Albornoz 531158
| _files         | ${MIDIPIX_BUILD_PWD}/files/${PKG_NAME} |
Lucio Andrés Illanes Albornoz 531158
| _name          | ${PKG_NAME}                            |
Lucio Andrés Illanes Albornoz 531158
| _prefix        | ${PKG_PREFIX}                          |
Lucio Andrés Illanes Albornoz 531158
| _prefix_host   | ${PREFIX}                              |
Lucio Andrés Illanes Albornoz 531158
| _prefix_native | ${PREFIX_NATIVE}                       |
Lucio Andrés Illanes Albornoz 531158
| _subdir        | ${PKG_BASE_DIR}/${PKG_SUBDIR}          |
Lucio Andrés Illanes Albornoz 531158
| _target        | ${PKG_TARGET}                          |
Lucio Andrés Illanes Albornoz 531158
| _version       | ${PKG_VERSION:-}                       |
Lucio Andrés Illanes Albornoz 531158
| _workdir       | ${BUILD_WORKDIR}                       |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
The following operation flags are defined:
7a0b92

Lucio Andrés Illanes Albornoz 531158
| Flag      | Description              |
Lucio Andrés Illanes Albornoz 531158
| --------- | ------------------------ |
Lucio Andrés Illanes Albornoz 531158
| ``?``     | Continue on soft failure |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
The following operations are defined:
7a0b92

Lucio Andrés Illanes Albornoz 531158
| Operation      | Arity  | Description                                                      |
Lucio Andrés Illanes Albornoz 531158
| -------------- | ------ | ---------------------------------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| ``-``          | Unary  | Remove directories and/or files                                  |
Lucio Andrés Illanes Albornoz 531158
| ``/``          | Unary  | Create directories or trees thereof                              |
Lucio Andrés Illanes Albornoz 531158
| ``t``          | Unary  | touch(1) files and/or directories                                |
Lucio Andrés Illanes Albornoz 95707c
| ``:``          | Binary | Copy directories and/or files                                    |
Lucio Andrés Illanes Albornoz 531158
| ``!``          | Binary | Move/rename directories and/or files                             |
Lucio Andrés Illanes Albornoz 531158
| ``@``          | Binary | Create/update symbolic links                                     |
Lucio Andrés Illanes Albornoz 531158
| ``+``          | Binary | Copy directories and/or files if newer and follow symbolic links |
Lucio Andrés Illanes Albornoz 531158
| ``g``          | Binary | Set group owner of files and/or directories                      |
Lucio Andrés Illanes Albornoz 531158
| ``m``          | Binary | Set mode bits of files and/or directories                        |
Lucio Andrés Illanes Albornoz 531158
| ``o``          | Binary | Set user and/or group owner of files and/or directories          |
Lucio Andrés Illanes Albornoz 531158
| ``T``          | Binary | touch(1) files and/or directories with timestamp                 |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
The following expression modifiers are defined:
7a0b92

Lucio Andrés Illanes Albornoz 531158
| Modifier       | Description                               |
Lucio Andrés Illanes Albornoz 531158
| -------------- | ----------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| ``@``          | Recursively reevaluate after substituting |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
The following subexpression operators are defined:
7a0b92

Lucio Andrés Illanes Albornoz 531158
| Operation      | Arity  | Description                                                      |
Lucio Andrés Illanes Albornoz 531158
| -------------- | ------ | ---------------------------------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| ``##``         | Unary  | Remove largest prefix from left-hand side                        |
Lucio Andrés Illanes Albornoz 531158
| ``#``          | Unary  | Remove prefix from left-hand side                                |
Lucio Andrés Illanes Albornoz 531158
| ``%%``         | Unary  | Remove largest postfix from right-hand side                      |
Lucio Andrés Illanes Albornoz 531158
| ``%``          | Unary  | Remove postfix from right-hand side                              |
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
```shell
Lucio Andrés Illanes Albornoz 531158
#
Lucio Andrés Illanes Albornoz 531158
# Examples:
Lucio Andrés Illanes Albornoz 531158
# 
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
#
Lucio Andrés Illanes Albornoz 531158
# Create directory %[_minipix]/bin and copy all files
Lucio Andrés Illanes Albornoz 531158
# in %[_minipix_dist]/bin/ to %[_minipix]/bin/ with
Lucio Andrés Illanes Albornoz 531158
# identical file names.
Lucio Andrés Illanes Albornoz 531158
/=%[_minipix]/bin
Lucio Andrés Illanes Albornoz 531158
?%[_minipix_dist]/bin/%<*>=%[_minipix]/bin/%[FNAME]
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
#
Lucio Andrés Illanes Albornoz 531158
# Rename all files in share/info/ matching *.info to
Lucio Andrés Illanes Albornoz 531158
# their filenames with the `.info' postfix removed and
Lucio Andrés Illanes Albornoz 531158
# `-2.64.info' appended and all files in share/man/man1/
Lucio Andrés Illanes Albornoz 531158
# matching *.1 with the `.1' postfix removed and -2.64.1
Lucio Andrés Illanes Albornoz 531158
# appended.
Lucio Andrés Illanes Albornoz 531158
!share/info/%<*.info>=share/info/%[FNAME%.info]-2.64.info
Lucio Andrés Illanes Albornoz 531158
!share/man/man1/%<*.1>=share/man/man1/%[FNAME%.1]-2.64.1
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
#
Lucio Andrés Illanes Albornoz 531158
# Create/update symbolic links named include/ffi.h and
Lucio Andrés Illanes Albornoz 531158
# include/ffitarget.h with ../lib/libffi-3.2.1/include/ffi.h
Lucio Andrés Illanes Albornoz 531158
# and ../lib/libffi-3.2.1/include/ffitarget.h as targets, resp.
Lucio Andrés Illanes Albornoz 531158
@../lib/libffi-3.2.1/include/ffi.h=include/ffi.h
Lucio Andrés Illanes Albornoz 531158
@../lib/libffi-3.2.1/include/ffitarget.h=include/ffitarget.h
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
#
Lucio Andrés Illanes Albornoz 531158
# Manual invocation:
8e9332
PKG_INSTALL_FILES_V2="
Lucio Andrés Illanes Albornoz 531158
        [ ... ]
Lucio Andrés Illanes Albornoz 531158
";
Lucio Andrés Illanes Albornoz 531158
rtl_install                                                     \
Lucio Andrés Illanes Albornoz 531158
                -p "_builddir=${PKG_BASE_DIR}/${PKG_BUILD_DIR}" \
Lucio Andrés Illanes Albornoz 531158
                -p "_minipix=${PREFIX_MINIPIX##*/}"             \
Lucio Andrés Illanes Albornoz 531158
                -p "_minipix_dist=${PREFIX}/minipix_dist"       \
Lucio Andrés Illanes Albornoz 531158
                -p "_native=${PREFIX_NATIVE##*/}"               \
Lucio Andrés Illanes Albornoz 531158
                -p "_subdir=${PKG_BASE_DIR}/${PKG_SUBDIR}"      \
Lucio Andrés Illanes Albornoz 531158
                -p "_target=${PKG_TARGET}"                      \
Lucio Andrés Illanes Albornoz 531158
                -n -- "${PREFIX}"                               \
8e9332
                "${PKG_INSTALL_FILES_V2}"; then
Lucio Andrés Illanes Albornoz 531158
        return 1;
Lucio Andrés Illanes Albornoz 531158
fi;
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
#
Lucio Andrés Illanes Albornoz 531158
# Usage screen:
Lucio Andrés Illanes Albornoz 531158
usage: rtl_install [-i] [-I ifs] [-n] [-p name=val] [-v] prefix spec_list
Lucio Andrés Illanes Albornoz 531158
       -i...........: continue on soft errors
Lucio Andrés Illanes Albornoz 531158
       -I ifs.......: process spec_list with ifs instead of NL
Lucio Andrés Illanes Albornoz 531158
       -n...........: perform dry run
Lucio Andrés Illanes Albornoz 531158
       -p name=val..: set named parameter
Lucio Andrés Illanes Albornoz 531158
       -v...........: increase verbosity
Lucio Andrés Illanes Albornoz 531158
       prefix.......: pathname prefix
Lucio Andrés Illanes Albornoz 531158
       spec_list....: ifs-separated list of specs
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
76e2d1
[//]: # "{{{ 4.4. Package variables"
76e2d1
### 4.4. Package variables
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
The following variables are package-specific and receive their value from either
d79f1f
top-level defaults defined in ``env.d/*.env``, build group-specific defaults from the
Lucio Andrés Illanes Albornoz 531158
build group the package pertains to and defined in its corresponding file beneath
78240c
``groups.d/``, or package-specific overrides defined either in the latter and/or in its
Lucio Andrés Illanes Albornoz 531158
corresponding file beneath ``vars/``, with one of the following prefixes:
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Variable name prefix					|
Lucio Andrés Illanes Albornoz 531158
| ----------------------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| DEFAULT						|
Lucio Andrés Illanes Albornoz 531158
| DEFAULT_``${BUILD_TYPE}``				|
Lucio Andrés Illanes Albornoz 531158
| DEFAULT_``${GROUP_NAME}``				|
Lucio Andrés Illanes Albornoz 531158
| ``${GROUP_NAME}``					|
Lucio Andrés Illanes Albornoz 531158
| [PKG_``${RELATED_PACKAGE(S)}``]			|
Lucio Andrés Illanes Albornoz 531158
| [PKG_``${RELATED_PACKAGE(S)}``_``${BUILD_KIND}``]	|
Lucio Andrés Illanes Albornoz 531158
| PKG_``${NAME}``					|
Lucio Andrés Illanes Albornoz 531158
| PKG_``${NAME}``_``${BUILD_KIND}``			|
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
Additionally, overrides may be specified on a per-build basis on the command-
Lucio Andrés Illanes Albornoz 531158
line, with each variable prefixed w/ ``PKG_``, e.g.:
Lucio Andrés Illanes Albornoz 531158
``./build.sh [ ... ] PKG_ZSH_CC="/usr/bin/clang"``.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
The minimum set of package variables that must be provided is ``SHA256SUM, URL,
Lucio Andrés Illanes Albornoz 531158
VERSION`` and/or ``URLS_GIT``, respectively.
Lucio Andrés Illanes Albornoz 531158

76e2d1
[//]: # "{{{ 4.4.1 Package variable types"
76e2d1
## 4.4.1 Package variable types
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Type definition               | Description                                                                                                                                  |
Lucio Andrés Illanes Albornoz 531158
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
Lucio Andrés Illanes Albornoz 531158
| DirName(Abs)			| Absolute pathname to directory                                                                                                               |
Lucio Andrés Illanes Albornoz 531158
| DirName(Rel)			| Relative pathname to director                                                                                                                |
Lucio Andrés Illanes Albornoz 531158
| DirName(Unit)			| Single non-{absolute,relative} directory nam                                                                                                 |
Lucio Andrés Illanes Albornoz 531158
| DirName			| Absolute or relative pathname to director                                                                                                    |
Lucio Andrés Illanes Albornoz 531158
| CmdName			| Absolute or relative pathname to comman                                                                                                      |
Lucio Andrés Illanes Albornoz 531158
| FileName(Abs)			| Absolute pathname to file                                                                                                                    |
Lucio Andrés Illanes Albornoz 531158
| FileName(Rel)			| Relative pathname to file                                                                                                                    |
Lucio Andrés Illanes Albornoz 531158
| FileName(Unit)		| Single non-{absolute,relative} file name                                                                                                     |
Lucio Andrés Illanes Albornoz 531158
| FileName			| Absolute or relative pathname to file                                                                                                        |
Lucio Andrés Illanes Albornoz 531158
| Flag(<type>,<default>)	| Boolean flag of type <type>, e.g. Flag(Boolean) (``true``, ``false``,) Flag(UInt) (0, 1,) Flag(ExitStatus) (>=1, 0) with default or ``auto`` |
Lucio Andrés Illanes Albornoz 531158
| FlagLine			| String of {SP,VT}-separated flags, arguments, options, etc. pp. to a command                                                                 |
ebe6d8
| List(<sep>[,<sep\|type>..])	| \<sep\>-separated list, optionally recursively and/or sub-typing, e.g.: ``List(:,=,String)`` and ``"name=value:name2=value"``                |
Lucio Andrés Illanes Albornoz 531158
| PkgName			| Single name of package                                                                                                                       |
e9fa07
| PkgRelation			| Single, possibly parametrised, package-package relation; see section [3.5](#35-package-package-and-packagegroup-group-relationships)         |
Lucio Andrés Illanes Albornoz 531158
| PkgVersion			| Single version of package                                                                                                                    |
Lucio Andrés Illanes Albornoz 531158
| Set(<type>)			| Set of alternatives of <type>, e.g. one of ``cross``, ``host``, ``native``                                                                   |
Lucio Andrés Illanes Albornoz 531158
| String			| Semantically generic string                                                                                                                  |
Lucio Andrés Illanes Albornoz 531158
| URL				| URL in standard format; see section [3.4](#34-package-archive-files-and-git-repositories)                                                    |
Lucio Andrés Illanes Albornoz 531158
| URL(Git)			| Git URL in the format ``[subdir=]URL[@branch]``; see section [3.4](#34-package-archive-files-and-git-repositories)                           |
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
76e2d1
[//]: # "{{{ 4.4.2 Package variables"
76e2d1
## 4.4.2 Package variables
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
| Package variable name        | Type             | Description                                                                                                                                |
Lucio Andrés Illanes Albornoz 531158
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
Lucio Andrés Illanes Albornoz 531158
| AR                           | CmdName          | Toolchain library archive editor ``ar(1)``                                                                                                 |
01b005
| AUTOCONF_CONFIG_GUESS        | String           | Either of ``copy`` (copy ``config.guess`` from ``etc/config.guess``) or ``keep``; defaults to ``copy``                                     |
Lucio Andrés Illanes Albornoz 531158
| BASE_DIR                     | DirName(Abs)     | Package build root directory beneath ``${BUILD_WORKDIR}``                                                                                  |
Lucio Andrés Illanes Albornoz 531158
| BUILD_DIR                    | DirName(Unit)    | Package build directory beneath ``${PKG_BASE_DIR}``                                                                                        |
Lucio Andrés Illanes Albornoz 531158
| BUILD_STAGES_DISABLE         | List( )          | Build stages to disable during package build                                                                                               |
Lucio Andrés Illanes Albornoz 531158
| BUILD_TYPE                   | Set(String)      | ``cross``: Cross-compiled toolchain, ``host``: host, ``native``: cross-compiled package                                                    |
Lucio Andrés Illanes Albornoz 531158
| CC                           | FileName         | Toolchain C compiler ``cc(1)``                                                                                                             |
b70ff5
| CCLD                         | FileName         | Toolchain C compiler-qua-linker ``cc(1)``                                                                                                  |
Lucio Andrés Illanes Albornoz 4d6e26
| CFLAGS_BUILD_EXTRA           | FlagLine         | Additional C compiler flags during package ``make(1)`` build                                                                               |
Lucio Andrés Illanes Albornoz 531158
| CFLAGS_BUILD                 | FlagLine         | C compiler flags during package ``make(1)``  build                                                                                         |
Lucio Andrés Illanes Albornoz 531158
| CFLAGS_CONFIGURE_EXTRA       | FlagLine         | Additional C compiler flags during package (GNU autotools in implementation and/or interface) configuration                                |
Lucio Andrés Illanes Albornoz 531158
| CFLAGS_CONFIGURE             | FlagLine         | C compiler flags during package (GNU autotools in implementation and/or interface) configuration                                           |
Lucio Andrés Illanes Albornoz 531158
| CMAKE_ARGS_EXTRA             | FlagLine         | Additional arguments to ``cmake(1)``                                                                                                       |
Lucio Andrés Illanes Albornoz 531158
| CMAKE_ARGS                   | FlagLine         | Arguments to ``cmake(1)``                                                                                                                  |
Lucio Andrés Illanes Albornoz 531158
| CMAKE                        | CmdName          | ``cmake(1)`` executable                                                                                                                    |
Lucio Andrés Illanes Albornoz 531158
| CMAKE_LISTFILE               | FileName         | ``cmake(1)`` listfile                                                                                                                      |
Lucio Andrés Illanes Albornoz 531158
| CONFIG_CACHE_EXTRA           | List(\n)         | Additional GNU autotools configuration cache variables                                                                                     |
Lucio Andrés Illanes Albornoz 531158
| CONFIG_CACHE                 | List(\n)         | GNU autotools configuration cache variables                                                                                                |
Lucio Andrés Illanes Albornoz 531158
| CONFIG_CACHE_LOCAL           | List(\n)         | Additional GNU autotools configuration cache variables                                                                                     |
Lucio Andrés Illanes Albornoz 531158
| CONFIGURE_ARGS               | FlagLine         | Arguments to package (GNU autotools in implementation and/or interface) configuration script                                               |
1cbe20
| CONFIGURE_ARGS_EXTRA         | FlagLine         | Additional arguments to package (GNU autotools in implementation and/or interface) configuration script                                    |
1cbe20
| CONFIGURE_ARGS_LIST          | List(:)          | Arguments to package (GNU autotools in implementation and/or interface) configuration script                                               |
1cbe20
| CONFIGURE_ARGS_EXTRA_LIST    | List(:)          | Additional arguments to package (GNU autotools in implementation and/or interface) configuration script                                    |
Lucio Andrés Illanes Albornoz 531158
| CONFIGURE                    | CmdName          | Package's (GNU autotools in implementation and/or interface) configuration script                                                          |
Lucio Andrés Illanes Albornoz 531158
| CONFIGURE_TYPE               | String           | Either of ``autotools`` (GNU autotools or similar) or ``sofort`` or ``cmake`` (CMake)                                                      |
368822
| CPPFLAGS_CONFIGURE_EXTRA     | FlagLine         | Additional C preprocessor flags during package (GNU autotools in implementation and/or interface) configuration                            |
Lucio Andrés Illanes Albornoz 531158
| CXX                          | CmdName          | Toolchain C++ compiler ``c++(1)``                                                                                                          |
Lucio Andrés Illanes Albornoz 531158
| CXXFLAGS_CONFIGURE_EXTRA     | FlagLine         | Additional C++ compiler flags during package (GNU autotools in implementation and/or interface) configuration                              |
Lucio Andrés Illanes Albornoz 531158
| CXXFLAGS_CONFIGURE           | FlagLine         | C++ compiler flags during package (GNU autotools in implementation and/or interface) configuration                                         |
Lucio Andrés Illanes Albornoz 531158
| DEPENDS                      | List( )          | Mandatory package-package dependencies                                                                                                     |
Lucio Andrés Illanes Albornoz 531158
| DESTDIR                      | DirName(Unit)    | Package installation destination directory beneath ``${PKG_BASE_DIR}``                                                                     |
Lucio Andrés Illanes Albornoz 531158
| DESTDIR_HOST                 | DirName(Unit)    | Optional host package installation destination directory beneath ``${PKG_BASE_DIR}``                                                       |
Lucio Andrés Illanes Albornoz 531158
| DISABLED                     | Flag(UInt,0)     | Disable package                                                                                                                            |
Lucio Andrés Illanes Albornoz 531158
| ENV_VARS_EXTRA               | List(:,=)        | Name-value pairs of environment variables to set during package build                                                                      |
Lucio Andrés Illanes Albornoz 531158
| FNAME                        | FileName(Unit)   | Filename of package archive file                                                                                                           |
Lucio Andrés Illanes Albornoz 531158
| FORCE_AUTORECONF             | Flag(UInt,0)     | Forcibly run ``autoreconf -fiv`` prior to package (GNU autotools in implementation and/or interface) configuration                         |
Lucio Andrés Illanes Albornoz 531158
| GITROOT                      | URL              | midipix packages Git URL prefix                                                                                                            |
Lucio Andrés Illanes Albornoz 531158
| INHERIT_FROM                 | String           | Inherit variables from named package                                                                                                       |
Lucio Andrés Illanes Albornoz 531158
| INSTALL_FILES_DESTDIR_EXTRA  | List( )          | Additional files to initialise the package installation destination directory beneath ``${PKG_BASE_DIR}`` with                             |
Lucio Andrés Illanes Albornoz 531158
| INSTALL_FILES_DESTDIR        | List( )          | Files to initialise the package installation destination directory beneath ``${PKG_BASE_DIR}`` with                                        |
Lucio Andrés Illanes Albornoz 531158
| INSTALL_FILES                | List( )          | Files to manually install into the package installation destination directory beneath ``${PKG_BASE_DIR}``                                  |
8e9332
| INSTALL_FILES_V2             | List( )          | Files to manually install into the package installation destination directory beneath ``${PKG_BASE_DIR}``                                  |
Lucio Andrés Illanes Albornoz 531158
| INSTALL_TARGET_EXTRA         | String           | Additional name of package build ``make(1)`` installation target                                                                           |
Lucio Andrés Illanes Albornoz 531158
| INSTALL_TARGET               | String           | Name of package build ``make(1)`` installation target                                                                                      |
Lucio Andrés Illanes Albornoz 531158
| IN_TREE                      | Flag(UInt,auto)  | Build package in-tree within ``${PKG_SUBDIR}``                                                                                             |
Lucio Andrés Illanes Albornoz 531158
| LDFLAGS_BUILD_EXTRA          | FlagLine         | Additional linker flags during package ``make(1)``  build                                                                                  |
Lucio Andrés Illanes Albornoz 531158
| LDFLAGS_CONFIGURE_EXTRA      | FlagLine         | Additional linker flags during package (GNU autotools in implementation and/or interface) configuration                                    |
Lucio Andrés Illanes Albornoz 531158
| LDFLAGS_CONFIGURE            | FlagLine         | Linker flags during package (GNU autotools in implementation and/or interface) configuration                                               |
Lucio Andrés Illanes Albornoz 531158
| LIBTOOL                      | CmdName          | ``libtool(1)`` implementation (defaults to ``slibtool``)                                                                                   |
Lucio Andrés Illanes Albornoz 531158
| MAKE                         | CmdLine          | Command line of ``make(1)``                                                                                                                |
481fa2
| MAKEFLAGS_BUILD              | FlagLine         | ``make(1)`` flags during package ``make(1)``  build; subject to field splitting w/ ``:``                                                   |
1cbe20
| MAKEFLAGS_BUILD_EXTRA        | FlagLine         | Additional ``make(1)`` flags during package ``make(1)``  build; subject to field splitting w/ ``:``                                        |
1cbe20
| MAKEFLAGS_BUILD_LIST         | List(:)          | ``make(1)`` flags during package ``make(1)``  build; subject to field splitting w/ ``:``                                                   |
1cbe20
| MAKEFLAGS_BUILD_EXTRA_LIST   | List(:)          | Additional ``make(1)`` flags during package ``make(1)``  build; subject to field splitting w/ ``:``                                        |
481fa2
| MAKEFLAGS_INSTALL            | FlagLine         | ``make(1)`` flags during package ``make(1)``  installation; subject to field splitting w/ ``:``                                            |
1cbe20
| MAKEFLAGS_INSTALL_EXTRA      | FlagLine         | ``make(1)`` flags during package ``make(1)``  installation; subject to field splitting w/ ``:``                                            |
1cbe20
| MAKEFLAGS_INSTALL_LIST       | List(:)          | ``make(1)`` flags during package ``make(1)``  installation; subject to field splitting w/ ``:``                                            |
1cbe20
| MAKEFLAGS_INSTALL_EXTRA_LIST | List(:)          | ``make(1)`` flags during package ``make(1)``  installation; subject to field splitting w/ ``:``                                            |
b70ff5
| MAKEFLAGS_LOADAVG            | FlagLine         | ``make(1)`` load average limit (e.g. -l load) flag                                                                                         |
b70ff5
| MAKEFLAGS_PARALLELISE        | FlagLine         | ``make(1)`` parallelisation (e.g. -j jobs) flag                                                                                            |
Lucio Andrés Illanes Albornoz 531158
| MAKEFLAGS_VERBOSITY          | String           | Variable-value pair to pass to ``make(1)`` in order to force echo-back of command lines prior to execution                                 |
Lucio Andrés Illanes Albornoz 531158
| MAKE_INSTALL_VNAME           | String           | Variable name of ``make(1)`` installation destination directory variable during package ``make(1)``  installation                          |
Lucio Andrés Illanes Albornoz 531158
| MAKE_SUBDIRS                 | List( )          | ``make(1)`` subdirectories to exclusively build                                                                                            |
Lucio Andrés Illanes Albornoz 531158
| MIRRORS_GIT                  | List( )          | Package Git repository mirror base URLs to attempt cloning from; cf. ``pkgtool.sh -m <dname>``                                             |
Lucio Andrés Illanes Albornoz 531158
| MIRRORS                      | List( )          | Package archive mirror base URLs to attempt downloading from; cf. ``pkgtool.sh -m <dname>``                                                |
Lucio Andrés Illanes Albornoz 531158
| NO_CLEAN_BASE_DIR            | Flag(UInt,0)     | Inhibit cleaning of package build root directory beneath ``${BUILD_WORKDIR}``                                                              |
Lucio Andrés Illanes Albornoz 531158
| NO_CLEAN                     | Flag(UInt,0)     | Inhibit cleaning of package build directory beneath ``${PKG_BASE_DIR}`` pre-finish                                                         |
Lucio Andrés Illanes Albornoz 531158
| NO_LOG_VARS                  | Flag(UInt,0)     | Inhibit logging of build & package variables pre-package build                                                                             |
Lucio Andrés Illanes Albornoz 531158
| PATCHES_EXTRA                | List( )          | Additional patches to apply                                                                                                                |
Lucio Andrés Illanes Albornoz 531158
| PKG_CONFIG                   | CmdName          | ``pkg-config(1)`` implementation                                                                                                           |
Lucio Andrés Illanes Albornoz 531158
| PKG_CONFIG_LIBDIR            | DirName          | ``pkg-config(1)`` search directory                                                                                                         |
Lucio Andrés Illanes Albornoz 531158
| PKGLIST_DISABLE              | Flag(UInt,0)     | Inhibit inclusion into ``${PREFIX}/pkglist.${PKG_BUILD_TYPE}``                                                                             |
Lucio Andrés Illanes Albornoz 531158
| PREFIX                       | DirName(Abs)     | Top-level installation directory and package search path                                                                                   |
Lucio Andrés Illanes Albornoz 531158
| PYTHON                       | CmdName          | Python >=3.x interpreter                                                                                                                   |
Lucio Andrés Illanes Albornoz 531158
| RANLIB                       | CmdName          | Toolchain library archive index generator ``ranlib(1)``                                                                                    |
Lucio Andrés Illanes Albornoz 531158
| RELATES                      | Set(PkgRelation) | Package-package relationships                                                                                                              |
Lucio Andrés Illanes Albornoz 531158
| RPM_DISABLE                  | Flag(UInt,0)     | Inhibit creation of RPM archive                                                                                                            |
Lucio Andrés Illanes Albornoz 531158
| SHA256SUM                    | String           | SHA-256 message digest of package archive                                                                                                  |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_CC             | FileName         | ``sofort`` variable during ``native`` build: Toolchain C compiler ``cc(1)``                                                                |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_CFLAGS_EXTRA   | FlagLine         | ``sofort`` variable during ``native`` build: Additional C compiler flags during package (GNU autotools or similar) configuration           |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_CFLAGS         | FlagLine         | ``sofort`` variable during ``native`` build: C compiler flags during package (GNU autotools or similar) configuration                      |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_CXXFLAGS_EXTRA | FlagLine         | ``sofort`` variable during ``native`` build: Additional list of C++ compiler flags during package (GNU autotools or similar) configuration |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_CXXFLAGS       | FlagLine         | ``sofort`` variable during ``native`` build: List of C++ compiler flags during package (GNU autotools or similar) configuration            |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_CXX            | FlagLine         | ``sofort`` variable during ``native`` build: Command- or pathname of toolchain C++ compiler ``c++(1)``                                     |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_LDFLAGS_EXTRA  | FlagLine         | ``sofort`` variable during ``native`` build: Additional linker flags during package (GNU autotools or similar) configuration               |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_LDFLAGS        | FlagLine         | ``sofort`` variable during ``native`` build: Linker flags during package (GNU autotools or similar) configuration                          |
Lucio Andrés Illanes Albornoz 531158
| SOFORT_NATIVE_LD             | FileName         | ``sofort`` variable during ``native`` build: Command- or pathname of toolchain C compiler ``cc(1)``                                        |
Lucio Andrés Illanes Albornoz 531158
| SUBDIR                       | DirName(Rel)     | Extracted archive or git-{clone,pull}(1)'d directory                                                                                       |
Lucio Andrés Illanes Albornoz 531158
| TARGET                       | String           | Dash-separated {build,host,target} triplet                                                                                                 |
Lucio Andrés Illanes Albornoz 531158
| URL                          | List( ,URL)      | URL to package archives w/ optional alternatives; see section [3.4](#34-package-archive-files-and-git-repositories)                        |
Lucio Andrés Illanes Albornoz 531158
| URLS_GIT                     | List( ,URL(Git)) | Package Git URL(s) (format: ``[subdir=]URL[@branch]``, see section [3.4](#34-package-archive-files-and-git-repositories))                  |
Lucio Andrés Illanes Albornoz 531158
| VARS_FILE                    | FileName         | Optional package variables file (defaults to ``vars/${PKG_NAME}.vars``)                                                                    |
Lucio Andrés Illanes Albornoz 531158
| VERSION                      | PkgVersion       | Package version                                                                                                                            |
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
76e2d1
[//]: # "{{{ 4.5. Fault-tolerant & highly optimised 3D laser show-equipped usage screen"
76e2d1
## 4.5. Fault-tolerant & highly optimised 3D laser show-equipped usage screen
76e2d1

76e2d1
```
76e2d1
usage: ./build.sh [-a nt32|nt64]  [-b debug|release]    [-C dir[,..]]  [-D kind[,..]]
76e2d1
                  [-F ipv4|ipv6|offline]    [-h|--help] [-p jobs|-P]    [-r ALL|LAST]
76e2d1
                  [-r [*[*[*]]]name[,..][:ALL|LAST|[^|<|<=|>|>=]step,..]]        [-R]
3a7f9a
                  [-v] [-V [+]tag|pat[,..]]
76e2d1

ff8dc6
                  [--as-needed] [--debug-minipix]  [--reset-state] [--roar]
3a7f9a
                  [--theme theme] [[=]<group>|<variable name>=<variable override>[ ..]]
76e2d1

76e2d1
        -a nt32|nt64        Selects 32-bit or 64-bit architecture; defaults to nt64.
76e2d1
        -b debug|release    Selects debug or release build kind; defaults to debug.
76e2d1
        -C dir[,..]         Clean build directory (build,) ${PREFIX} before processing build
76e2d1
                            scripts (prefix,) source directory (src,) and/or destination
76e2d1
                            directory (dest) after successful package builds.
76e2d1
        -D kind[,..]        Produce minimal midipix distribution directory (minipix,) RPM
76e2d1
                            binary packages (rpm,) and/or deployable distribution ZIP
76e2d1
                            archive (zipdist.) zipdist implies minipix.
76e2d1
        -F ipv4|ipv6|offline
76e2d1
                            Force IPv4 (ipv4) or IPv6 (ipv6) when downloading package
76e2d1
                            archives and/or Git repositories or don't download either at all
76e2d1
                            (offline.)
76e2d1
        -h|--help           Show short/full help screen, respectively.
76e2d1
        -p jobs|-P          Enables parallelisation at group-level, whenever applicable.
76e2d1
                            The maximum count of jobs defaults to the number of logical
76e2d1
                            processors on the host system divided by two (2.)
76e2d1

76e2d1
                            If -R is not specified and at least one (1) package fails to
76e2d1
                            build, all remaining package builds will be forcibly aborted.
76e2d1

76e2d1
        -r ALL|LAST         Restart all packages or the last failed package and resume
76e2d1
                            build, resp.
76e2d1
        -r [*[*[*]]]name[,..][:ALL|LAST|[^|<|<=|>|>=]step,..]
76e2d1
                            Restart the specified comma-separated package(s) w/ inhibition
76e2d1
                            of package build step state resetting completely (`ALL',) starting
76e2d1
                            at the resp. last successfully executed build steps (`LAST',) or the
76e2d1
                            specified comma-separated list of build steps, optionally subject
76e2d1
                            concerning package name(s) and/or build step(s) to the below modifiers:
76e2d1

76e2d1
                            Prepend name w/ `*' to automatically include dependencies, `**'
76e2d1
                            to forcibly rebuild all dependencies, and `***' to forcibly
76e2d1
                            rebuild all packages that depend on the specified package(s).
76e2d1

76e2d1
                            Prepend step w/ `^' to filter build steps with, `<' or `<='
76e2d1
                            to constrain build steps to below or below or equal with, resp.,
76e2d1
                            `>' or `>=' to constrain build steps to above or above or equal
76e2d1
                            with, resp.
76e2d1

76e2d1
                            Currently defined build steps are:
76e2d1
                            fetch_clean, fetch_download, fetch_extract, configure_clean,
76e2d1
                            configure_patch_pre, configure_autotools, configure_patch,
76e2d1
                            configure, build_clean, build, install_clean, install_subdirs,
938c5c
                            install_make, install_files, install, install_rpm, and clean.
76e2d1

76e2d1
                            Additionally, the following virtual steps are provided:
76e2d1
                            @fetch, @configure, @build, @install, @clean, and finish.
76e2d1

76e2d1
        -R                  Ignore build failures, skip printing package logs, and continue
76e2d1
                            building (relaxed mode.)
76e2d1

76e2d1
        -v                  Increase logging verbosity.
76e2d1
        -V [+]tag|pat[,..]  Enable logging for messages with tag or pattern matching tags of:
76e2d1
                            + (prefix)..: initialise tags with normal verbosity (implies normal) (see etc/build.theme,)
76e2d1
                            all.........: log everything (see etc/build.theme,)
76e2d1
                            clear|none..: log nothing,
76e2d1
                            normal......: log at normal verbosity (see etc/build.theme,)
76e2d1
                            verbose.....: log at increased verbosity (implies normal) (see etc/build.theme) (-v,)
76e2d1

76e2d1
                            build.......: log package build logs,
76e2d1
                            fileops.....: log RTL file operations,
76e2d1
                            install.....: log RTL installation DSL operations,
76e2d1
                            zipdist.....: log deployable distribution ZIP archive operations,
76e2d1
                            xtrace......: set xtrace during package builds,
76e2d1

76e2d1
                            fatal.......: fatal, unrecoverable errors,
76e2d1
                            info........: informational messages,
76e2d1
                            verbose.....: verbose informational messages,
76e2d1
                            warning.....: warning messages possibly relating to imminent fatal, unrecoverable errors,
76e2d1

76e2d1
                            build_*.....: general build messages (viz.: begin, finish, finish_time, vars,)
76e2d1
                            group_*.....: build group messages (viz.: begin, finish,)
76e2d1
                            pkg_*.......: package build messages (viz.: begin, finish, msg, skip, step, strip.)
76e2d1

76e2d1
        --as-needed         Don't build unless the midipix_build repository has received
76e2d1
                            new commits.
76e2d1
        --debug-minipix     Don't strip(1) minipix binaries to facilitate debugging minipix.
76e2d1
        --reset-state       Reset package build step state on exit.
6a7974
        --theme theme       Set theme.
76e2d1

76e2d1
        <group>[ ..]        One of: dev_packages, dist, host_deps, host_deps_rpm,
76e2d1
                            host_toolchain, host_tools, minipix, native_packages,
76e2d1
                            native_runtime, native_toolchain, native_tools.
76e2d1

76e2d1
                            Prepend w/ `=' to inhibit group-group dependency expansion.
76e2d1

76e2d1
        <variable name>=<variable override>[ ..]
76e2d1
                            Override build or package variable.
76e2d1
```
76e2d1
  
76e2d1
[Back to top](#table-of-contents)
76e2d1

76e2d1
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 4.6. ``pkgtool.sh``"
Lucio Andrés Illanes Albornoz 531158
## 4.6. ``pkgtool.sh``
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
```
16c4a3
usage: ./pkgtool.sh [-a nt32|nt64] [-b debug|release] [-e|-f|-i|-m <dname> -M <dname>|-p|-r|-R|-t]
3a7f9a
                    [--theme theme] [-v]
a790c7
                    [<variable name>=<variable override>[ ..]] name[,name..]
Lucio Andrés Illanes Albornoz 531158

9d89ab
        -a nt32|nt64      Selects 32-bit or 64-bit architecture; defaults to nt64.
9d89ab
        -b debug|release  Selects debug or release build kind; defaults to debug.
b570fd
        -e                Edit package group file of single named package with ${EDITOR}.
16c4a3
        -f                List files installed by single package.
a790c7
        -i                List package variables and dependencies of named package(s).
9d89ab
        -m <dname>        Setup package archives mirror in <dname> and/or
9d89ab
        -M <dname>        Setup Git repositories mirror in <dname>
9d89ab
                          Specify "" or '' as <dname> to default to the defaults in
9d89ab
                          ${HOME}/pkgtool.vars, if present.
9d89ab
        -p <log_fname>    Profile last build.
9d89ab
        -r                List reverse dependencies of single named package.
9d89ab
        -R                List recursive reverse dependencies of single named package.
9d89ab
        -t                Produce tarball of package build root directory and build log
9d89ab
                          file for the purpose of distribution given build failure.
9d89ab
        -v                Increase verbosity.
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
        <variable name>=<variable override>[ ..]
9d89ab
                          Override build or package variable.
Lucio Andrés Illanes Albornoz 531158
```
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
> N.B. When using ``pkgtool.sh`` on a build w/ build variables (see section [4.2](#42-build-variables))
Lucio Andrés Illanes Albornoz 531158
overriden on the command line or via the environment, ensure that they are included in the
afd086
``pkgtool.sh`` command line, preceding the package name, or exported, respectively.  
afd086
  
afd086
> N.B. ``pkgtool.sh`` will source the ``${HOME}/pkgtool.vars`` file, if present, on startup where the
afd086
following option arguments may be set: ``-a nt32|nt64`` by setting ``ARCH=...``, ``-b debug|release``
afd086
by setting ``BUILD_KIND=...``, ``-m <dname>`` by setting ``ARG_MIRROR_DNAME=...``, and ``-M <dname>``
afd086
by setting ``ARG_MIRROR_DNAME_GIT=...``.  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
e94dc6
[//]: # "{{{ 4.7. Bourne shell coding rules"
e94dc6
## 4.7. Bourne shell coding rules
e94dc6

bfd925
If no rationale is specified for any specific point, the rationale is avoidance of undefined behaviour
bfd925
and/or implicit behaviour contingent on often subtle special cases, both of which are prone to cause
bfd925
hard to debug or even diagnose bugs.
bfd925

bfd925
### Shell options
bfd925

bfd925
1)  The `noglob` option is set at all times *except* for when globbing is required, e.g.:
bfd925
    `set +o noglob; files=*; set -o noglob`
bfd925
2)  The `nounset` option is set at all times; if a parameter is to be expanded that may be
bfd925
    unset, use the `${parameter:-word}` expansion format.
bfd925
3)  The `errexit` option is unset at all times *except* for top-level subshell code that does
bfd925
    *not* engage in conditional evaluation, e.g. `([...] set -o errexit; [...]) &` due to its
bfd925
    implicit unsetting when a/any function is subject to conditional evaluation, e.g.: `[...]
bfd925
    set -o errexit; [...] if some_function; then [ ... ] fi`
bfd925

bfd925
### Quoting and brace-enclosing
bfd925

bfd925
4)  Quoting with single quotes or double quotes is mandatory at all times *except* for when field 
bfd925
    splitting subsequent to parameter expansion, etc. is required, e.g.: `params="a b c";
bfd925
    param="single parameter"; fn ${params} "${param}"`
bfd925
5)  Enclosing parameter names in braces is mandatory at all times, e.g.: `${parameter_name123}`
bfd925

bfd925
### Checking parameter status
bfd925

bfd925
6)  Checking for whether a parameter is set/non-empty or unset/empty is expressed with the following
bfd925
    the idiom: `[ "${parameter:+1}" = 1 ]` and `[ "${parameter:+1}" != 1 ]` 
bfd925
  
bfd925
    This is necessary to avoid the potentially costly expansion of a parameter's value when only its
bfd925
    status of being set/non-empty or unset/empty is of concern, particularly when this is done repeatedly.
bfd925

bfd925
### Functions
bfd925

bfd925
7)  Functions must explicitly return either `0` or `1` at all times *except* for when specific
bfd925
    return exit statuses are specified according to the function's interface contract.
bfd925
8)  Function names must have namespace prefixes followed by a `p` in the topmost namespace prefix
bfd925
    field in private functions, e.g.: `rtlp_log_do_something() { [...] }`
bfd925
9)  The non-POSIX but extremely widely available `local` command must be used at at all times
bfd925
    in functions on all function-local variables.  
bfd925
  
bfd925
    This is necessary in order to avoid polluting the (global) parameter namespace.
bfd925
10) Function-local variables must be lower case and prefixed with a `_`, a prefix comprised of the
bfd925
    initial letters of each word in the function's name plus, in private functions, the `p` topmost
bfd925
    namespace prefix field postfix, and a `_`, where words are separated by `_` characters, e.g.:
bfd925
    `rtlp_log_do_something() { local _rplds_parameter=""; [...] }` and `ex_something() {
bfd925
    local _es_parameter=""; [ ...] }` 
bfd925
  
bfd925
    This is necessary in order to prevent implicit conflicts between two or more functions that share
bfd925
    a call path and would otherwise use the same variables names, such as `function1() { local
bfd925
    list="${1}"; function2 "${list}"; }; function2() { local list="${2}"; }`, particularly when those
bfd925
    functions acess and/or mutate each other's variables. Additionally, local variables are thus marked
bfd925
    with a `_` prefix and by being lower case.
bfd925

bfd925
### `eval` rules
bfd925

bfd925
11) The following special characters must be escaped with a backslash at all times in `eval`
bfd925
    expressions: `<newline>`, `"`, `'`, `[`, `\`, `]`, `<backtick>`, `$`
bfd925
12) If parameter expansion is to be evaluated with respect to a parameter reference, the following idiom
bfd925
    must be used at all times: `eval [...]\${${rparameter[...]}}`
bfd925
13) If quoting with single quotes or double quotes is required - see 4) - or brace-enclosing - see 5) -
bfd925
    and with respect to 11), viz. the single quotes or double quotes have been escaped with a backslash,
bfd925
    something must be evaluated as a single field, then that field must be doubly quoted with single or
bfd925
    double quotes, where the second set of quotes must not be escaped with a backslash, e.g.: `
bfd925
    rparameter=parameter; eval ${rparameter}="\"a b c\""`. 
bfd925
    This is very rarely required.
bfd925

bfd925
### Passing arguments
bfd925

bfd925
14) The `fork/exec/write`-`read` pattern where a parameter is set to the result of a command
bfd925
    substitution expression which is executed in a subshell process, e.g.: `parameter="$(function)"`
bfd925
    is prohibited at all times *except* when an actual external command is invoked, e.g. `sort(1)`
bfd925
    or `sed(1)`.  
bfd925
  
bfd925
    This is necessary due to the very significant cost of the mentioned pattern, particularly concerning
bfd925
    primitive e.g. list or string processing functions with high contention.
bfd925
15) If a function is to return, produce, evaluate to, etc. an arbitrary value apart from the exit status,
bfd925
    it shall do so by receiving references to the target variables in the callers' scope from the caller
bfd925
    prefixed with a single `$` character, e.g. `function \$parameter` and `function() {
bfd925
    local _fn_rparameter="${1#\$}"; [..]; }` which are then set with `eval` expressions: `
bfd925
    function() { local _fn_rparameter="${1#\$}"; [...]; eval ${_fn_rparameter}=\'a b c\'; };` Refer to
bfd925
    11)-13) for the rules concerning `eval`.  
bfd925

bfd925
    This is necessary due to 14) as well as the absence of any other calling convention other than using
bfd925
    implicit global variables, e.g.: `function1() { VARIABLE=; function2; }; function2() { VARIABLE=1;
bfd925
    }`
e94dc6
  
e94dc6
[Back to top](#table-of-contents)
e94dc6

e94dc6
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "{{{ 5. References"
Lucio Andrés Illanes Albornoz 531158
## 5. References
Lucio Andrés Illanes Albornoz 531158

bfd925
* ``Sun, 25 Apr 2016 09:04:08 +0000 [1]``musl FAQ  
bfd925
* ``Wed, 04 Mar 2020 13:36:19 +0000 [2]``midipix - what is midipix, and how is it different?  
bfd925
* ``Wed, 29 Apr 2020 23:33:34 +0100 [3]``User Rights Assignment (Windows 10) - Windows security | Microsoft Docs  
bfd925
* ``Wed, 29 Apr 2020 23:33:50 +0100 [4]``Windows Vista Application Development Requirements for User Account Control Compatibility | Microsoft Docs  
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[Back to top](#table-of-contents)
Lucio Andrés Illanes Albornoz 531158

Lucio Andrés Illanes Albornoz 531158
[//]: # "}}}"
Lucio Andrés Illanes Albornoz 531158
  
Lucio Andrés Illanes Albornoz 531158
[modeline]: # ( vim: set ff=dos tw=0: )