Giter VIP home page Giter VIP logo

static-unix-userland's Introduction

Static UNIX Userland

This repository contains a build system and patches to statically compile and customize applications the maintainer likes to use on UNIX-like systems. The Makefile is licensed under the 2-clause BSD license, and the patches are licensed under each project's respective license. The following programs are currently supported:

Dependency Graph

findutils

sed

tree

          ,-> coreutils
(GMP) ---|
  |       `-> (MPFR) -----------,+-> GAWK
   `-------->------------------/ ^
                                 |
                                 ,
             ,-> (libreadline) -+--> Bash
(ncurses) --|
             `-> Less, tmux, Vim
                        ^
                        |
                        ,
(libevent) ------------'

Build System

The build system has been tested on the following platforms and make(1) implementations though it most certainly works on others:

  • Debian Linux 9
    • GNU Make
    • NetBSD Make
  • OpenBSD 6.1
    • GNU Make
    • OpenBSD Make (NetBSD derivative forked c. 1995)
  • FreeBSD 11
    • GNU Make
    • NetBSD Make
  • macOS 10.12 (Sierra)
    • GNU Make

On Linux, musl libc is used instead of GNU libc (glibc) because many of glibc's functions support Name Service Switch making it impossible to achieve full static linking without making changes to the code that depends on those functions or by hybrid linking against both musl libc and glibc. Although this repository's build system supports GNU and BSD Make, GNU Make must be installed to compile musl.

On macOS, everything is compiled using using dynamic linking because building statically linked binaries is not well supported on the platform.

Make Targets

This repository includes a configuration script that will generate a Makfile targetting a specific platform. A typical build consists of ./configure && make.

  • all: Build every binary, then execute the "sanity" target. Intermediate build failures are temporarily ignored and reported later. This is the default target.
  • sanity: Perform basic sanity checks to verify that compiled binaries can be executed.
  • deps: Attempt to automatically install build dependencies. This target should typically be run as root, e.g. sudo make deps or doas make deps.
  • install: Install any applications that have been compiled and fail if there is nothing to install. The variable "BIN" must be set to a folder where the binaries, "vimruntime" and "awklib" folders should be installed, e.g. make install BIN=$HOME/bin. Program manuals can optionally be installed by setting the "MAN" variable to destination folder that would typically be added to man(1)'s search path, e.g. make install BIN=$HOME/bin MAN=$HOME/.local/share/man. Note that "MAN" must always accompany "BIN" because a manual is only installed when its associated tool is. Assume that anything with the same name as one of the installed files will be overwritten.
  • what: Display a list of binaries that can be compiled and their status. A "+" indicates that a binary has been compiled, and a "~" indicates that the source code has been downloaded and unpacked.
  • dist: Create a distributable archive named "dist.tar.xz" that includes all compiled programs, documentation and a Makefile for quick installation. The variables "DIST_BIN" and "DIST_MAN" control the default values of "BIN" and "MAN" used by the distributable's Makefile. The default value of "DIST_BIN" is "~/.local/bin", and the default value of "DIST_MAN" is "~/.local/share/man".
  • clean: Iterate over source code and build folders in this directory and, if a folder is a Git repository, restore it to a pristine state while other folders are deleted in their entirety. To clean a specific project's folder, use clean-$PROJECT_NAME e.g. "clean-bash," "clean-less," etc.
  • pristine: Like clean but deletes everything except musl.

Patches

In the descriptions below, "EXEDIR" is the parent directory of "/proc/self/exe" resolved to its real path using readlink(2). The value of the environment variable "_", which some shells set to the path of an executable being launched, is used as a fallback when "/proc/self/exe" cannot be read.

  • GNU Awk
    • The default value for "AWKPATH" and "AWKLIBPATH" is ".:$EXEDIR/awklib".
    • The handling of implementation compatibility options has been changed. Most notably, the "--lint" option no longer warns about non-POSIX features and GNU extensions unless POSIX or traditional mode has been explicitly enabled, and some non-standard features that were accepted when using one of those modes will now produce fatal errors. No changes to code only affecting "--lint-old" were made.
    • These lint warnings have been modified:
      • Disabled: "assignment used in conditional context"
      • Disabled: "regular expression on right of assignment"
      • Refined: "substr: start index … is past end of string" will only be displayed if the third argument is set or if the start index is more than character beyond the end of a string.
      • Disabled: "substr: length 0 is not >= 1"
      • Disabled: "subscript of array … is null string"
  • Vim
    • When $VIMRUNTIME is unset, it will default to "$EXEDIR/vimruntime".
    • If the tmux source code is available, a syntax file will be generated and added added to Vim's runtime folder as part of the installation process.
    • When closing Vim with ":x" after opening multiple files but only editing some of them, E173 is no longer raised, and Vim will quit immediately.
  • GNU Core Utilities
    • When using ls(1) to list the contents of a directory, "-A" is implicit for every directory except $HOME.
    • If the current user's information cannot be queried from the password database, the environment variables "LOGNAME" and "USER" act as fallbacks for pwent->pw_name.
  • Bash
    • When running commands interactively, the terminal attributes are modified so the suspend character is interpreted as literal sequence at the prompt but produces a SIGTSTP signal during command execution.
    • If a user's information cannot be queried from the password database, Bash will use the environment variables "LOGNAME", "HOME" and "SHELL" if they are set.
    • The prompt will always be displayed on a clean line even if the output of the last program did not end with a newline.
  • Grep
    • If standard input is a terminal, running grep(1) without any files specified as command line arguments implies "-r". A notice is written to standard error, and the search is delayed if standard output is also a terminal so the user has time to abort the search before the screen is pollutted with potentially unwanted information.
  • Less
    • Unpatched, hitting Ctrl+C when less than one screen of text has been shown effectively results in "--quit-if-one-screen" being ignored. To resolve this, Less has been modified to to act as though "--quit-on-intr" ("-K") is set when less than one screen of text has been shown, "--no-init" ("-X") and "--quit-if-one-screen" ("-F") are set.
  • tmux
    • When "mode-keys" is set to "vi" and there is an active search query in copy-mode, the search query is preserved when using movement commands.
  • musl
    • The wcwidth(3) function has been reimplemented with utf8proc. The replacement code can also be compiled as a shared library that can be used with "LD_PRELOAD" so other, dynamically linked applications "agree" on the width of characters.

Repository Layout

Applications

Each application's source code is downloaded and extracted into folder named in the form $PROGRAM_NAME-$VERSION or, when the application is compiled directly from its source repository, $PROGRAM_NAME-src. This folder is referred to as $PROGRAM_FOLDER below.

Patches

Official, upstream patches for a given application will be stored in a folder named $PROGRAM_FOLDER-patches. Other customizations are stored in "patches/" with names like $PROGRAM_FOLDER-$DESCRIPTION. Patches intended to be applied against revision-controlled source trees may have a revision indicator after $PROGRAM_FOLDER.

PGP / GPG Keys

Public keys used by GPG for cryptographic signature verification are stored in "public-keys/". The GPG home directory used to store the keys in their imported form is "gnupghome/" which will be created by the Makefile.

Below is a list of the keys and where they were obtained. Each entry will typically have two sub-items: the first is the indirect location of a key (i.e. a page hosting a link to the key), and the second is the direct URL or other means of actually fetching the key. The idea is that it will make finding replacement keys easier if they are moved.

static-unix-userland's People

Contributors

ericpruitt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.