From 06fd4a903b11d06c66c51207883b0b8f1d4f2fb7 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sun, 26 Sep 2021 10:48:02 -0400 Subject: Add muslbuild, a small set of shell scripts to statically build a few things against musl libc --- bin/Makefile | 2 +- bin/vol | 29 ++++++++++++++++++++++------- bin/volCtl | 24 ------------------------ build/musl | 53 ----------------------------------------------------- build/polybar | 12 ------------ muslbuild/all | 11 +++++++++++ muslbuild/jq | 36 ++++++++++++++++++++++++++++++++++++ muslbuild/libevent | 33 +++++++++++++++++++++++++++++++++ muslbuild/musl | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ muslbuild/ncurses | 47 +++++++++++++++++++++++++++++++++++++++++++++++ muslbuild/oksh | 33 +++++++++++++++++++++++++++++++++ muslbuild/tmux | 36 ++++++++++++++++++++++++++++++++++++ muslbuild/upx | 26 ++++++++++++++++++++++++++ readme.md | 8 ++++---- 14 files changed, 302 insertions(+), 101 deletions(-) delete mode 100644 bin/volCtl delete mode 100755 build/musl delete mode 100755 build/polybar create mode 100755 muslbuild/all create mode 100755 muslbuild/jq create mode 100755 muslbuild/libevent create mode 100755 muslbuild/musl create mode 100755 muslbuild/ncurses create mode 100755 muslbuild/oksh create mode 100755 muslbuild/tmux create mode 100755 muslbuild/upx diff --git a/bin/Makefile b/bin/Makefile index 0189db6..ea174e3 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -14,5 +14,5 @@ install: install night $(HOME)/bin/ install wallpaper $(HOME)/bin/ install status-bar $(HOME)/bin/ - install volCtl $(HOME)/bin/ + install vol $(HOME)/bin/ diff --git a/bin/vol b/bin/vol index 2ddc2d4..1071d8c 100755 --- a/bin/vol +++ b/bin/vol @@ -1,9 +1,24 @@ #!/bin/sh -sink=1 -step=5 -# Default down -mode=- -case $1 in - up) mode=+ +sinkName=$(pacmd info | grep 'Default sink' | awk '{print $4}') +sinkNumber=$(pacmd info | grep "sink:.*$sinkName" | awk '{print $2}') + +getVolume() { + volumeInput=$(pactl list sinks) + currentVolume=$(echo "${volumeInput#*Sink #$sinkNumber}" | grep -E 'V.*-left' | grep -oE '[0-9]+%' | tail -n 1) + notify-send "Volume: $currentVolume" +} + +case "$1" in + up) pactl set-sink-volume @DEFAULT_SINK@ +5%; getVolume;; + down) pactl set-sink-volume @DEFAULT_SINK@ -5%; getVolume;; + mute) muted=$(pactl list sinks | grep 'Mute: yes') + if [ -z "$muted" ]; then + pactl set-sink-mute @DEFAULT_SINK@ 1 + notify-send Volume: Muted + else + pactl set-sink-mute @DEFAULT_SINK@ 0 + getVolume + fi;; + *) echo error;; esac -pactl set-sink-volume "$sink" "$mode${step}%" + diff --git a/bin/volCtl b/bin/volCtl deleted file mode 100644 index 1071d8c..0000000 --- a/bin/volCtl +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -sinkName=$(pacmd info | grep 'Default sink' | awk '{print $4}') -sinkNumber=$(pacmd info | grep "sink:.*$sinkName" | awk '{print $2}') - -getVolume() { - volumeInput=$(pactl list sinks) - currentVolume=$(echo "${volumeInput#*Sink #$sinkNumber}" | grep -E 'V.*-left' | grep -oE '[0-9]+%' | tail -n 1) - notify-send "Volume: $currentVolume" -} - -case "$1" in - up) pactl set-sink-volume @DEFAULT_SINK@ +5%; getVolume;; - down) pactl set-sink-volume @DEFAULT_SINK@ -5%; getVolume;; - mute) muted=$(pactl list sinks | grep 'Mute: yes') - if [ -z "$muted" ]; then - pactl set-sink-mute @DEFAULT_SINK@ 1 - notify-send Volume: Muted - else - pactl set-sink-mute @DEFAULT_SINK@ 0 - getVolume - fi;; - *) echo error;; -esac - diff --git a/build/musl b/build/musl deleted file mode 100755 index 13487e5..0000000 --- a/build/musl +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -set -e -set -x -relver="1.2.2" -build_dir="/v/pub/musl" - -PREFIX="$HOME/musl" - -if ! [ -d "$build_dir" ] ; then - mkdir -p "$build_dir" -fi -cd "$build_dir" - -sigLoc="https://musl.libc.org/releases/musl-${relver}.tar.gz.asc" -sigFn="musl-${relver}.tar.gz.asc" -arLoc="https://musl.libc.org/releases/musl-${relver}.tar.gz" -arFn="musl-${relver}.tar.gz" - -curl https://musl.libc.org/musl.pub | gpg --import - -if ! [ -e "$arFn" ] ; then - curl -o "$arFn" "$arLoc" -fi - -if ! [ -e "$sigFn" ] ; then - curl -o "$sigFn" "$sigLoc" -fi - -_out="$(mktemp)"; -gpg --fingerprint --verify "$sigFn" >"$_out" 2>&1 -ret=$? - -if [ $ret -ne 0 ] ; then - cat "$_out" - rm "$_out" - echo "Bad signature" -fi - -if ! grep -q '^Primary key fingerprint: 8364 8929 0BB6 B70F 99FF DA05 56BC DB59 3020 450F' \ - < "$_out" ; then - cat "$_out" - rm "$_out" - echo "Bad signature" - exit 1 -fi -rm "$_out" || printf "" - -tar xzvf "$arFn" -cd "musl-${relver}" -./configure --prefix="$PREFIX" --bindir="$HOME/bin" --disable-shared \ - --enable-static -make -make install -j$(nproc) diff --git a/build/polybar b/build/polybar deleted file mode 100755 index 45120e0..0000000 --- a/build/polybar +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -e - -# Based off of -# https://github.com/polybar/polybar/wiki/Compiling - -git clean -fdx . -mkdir build -cd build -cmake .. -make -j$(nproc) -sudo make install diff --git a/muslbuild/all b/muslbuild/all new file mode 100755 index 0000000..fdcf41d --- /dev/null +++ b/muslbuild/all @@ -0,0 +1,11 @@ +#!/bin/sh +set -e +pkgs="musl +oksh +ncurses +libevent +tmux +upx" +for pkg in $pkgs ; do + ./$pkg +done diff --git a/muslbuild/jq b/muslbuild/jq new file mode 100755 index 0000000..b3873a2 --- /dev/null +++ b/muslbuild/jq @@ -0,0 +1,36 @@ +#!/bin/sh +set -e +set -x +relver="1.6" +build_dir="/v/muslbuild/jq" + +export CC="musl-gcc" +PREFIX="$HOME/musl" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +arLoc="https://github.com/stedolan/jq/releases/download/jq-%s/jq-%s.tar.gz" +arLoc="$(printf "$arLoc\n" "$relver" "$relver")" +arFn="jq-${relver}.tar.gz" + +checksum=5de8c8e29aaa3fb9cc6b47bb27299f271354ebb72514e3accadc7d38b5bbaa72 + +if ! [ -e "$arFn" ] ; then + curl -L -o "$arFn" "$arLoc" +fi + +echo "${checksum} $arFn" | sha256sum -c + +tar xzvf "$arFn" +cd "jq-${relver}" +./configure --prefix="$PREFIX" --bindir="$HOME/bin" --host=x86_64 \ + --build=x86_64-pc-linux-gnu \ + --enable-all-static --enable-static=yes --enable-shared=no --disable-docs \ + --with-oniguruma=builtin \ + --disable-maintainer-mode +make +make install -j$(nproc) + diff --git a/muslbuild/libevent b/muslbuild/libevent new file mode 100755 index 0000000..ccd24ec --- /dev/null +++ b/muslbuild/libevent @@ -0,0 +1,33 @@ +#!/bin/sh +set -e +set -x +relver="2.1.12" +build_dir="/v/muslbuild/libevent" + +export CC="musl-gcc" +PREFIX="$HOME/musl" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +arLoc="https://github.com/libevent/libevent/releases/download/release-%s-stable/libevent-%s-stable.tar.gz" +arLoc="$(printf "$arLoc\n" "$relver" "$relver")" +arFn="libevent-${relver}-stable.tar.gz" + +checksum=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb + +if ! [ -e "$arFn" ] ; then + curl -L -o "$arFn" "$arLoc" +fi + +echo "${checksum} libevent-${relver}-stable.tar.gz" | sha256sum -c + +tar xzvf "$arFn" +cd "libevent-${relver}-stable" +./configure --prefix="$PREFIX" --host=x86_64 \ + --disable-doxygen-doc --enable-static=yes --enable-shared=no \ + --disable-openssl +make +make install -j1 diff --git a/muslbuild/musl b/muslbuild/musl new file mode 100755 index 0000000..13487e5 --- /dev/null +++ b/muslbuild/musl @@ -0,0 +1,53 @@ +#!/bin/sh +set -e +set -x +relver="1.2.2" +build_dir="/v/pub/musl" + +PREFIX="$HOME/musl" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +sigLoc="https://musl.libc.org/releases/musl-${relver}.tar.gz.asc" +sigFn="musl-${relver}.tar.gz.asc" +arLoc="https://musl.libc.org/releases/musl-${relver}.tar.gz" +arFn="musl-${relver}.tar.gz" + +curl https://musl.libc.org/musl.pub | gpg --import + +if ! [ -e "$arFn" ] ; then + curl -o "$arFn" "$arLoc" +fi + +if ! [ -e "$sigFn" ] ; then + curl -o "$sigFn" "$sigLoc" +fi + +_out="$(mktemp)"; +gpg --fingerprint --verify "$sigFn" >"$_out" 2>&1 +ret=$? + +if [ $ret -ne 0 ] ; then + cat "$_out" + rm "$_out" + echo "Bad signature" +fi + +if ! grep -q '^Primary key fingerprint: 8364 8929 0BB6 B70F 99FF DA05 56BC DB59 3020 450F' \ + < "$_out" ; then + cat "$_out" + rm "$_out" + echo "Bad signature" + exit 1 +fi +rm "$_out" || printf "" + +tar xzvf "$arFn" +cd "musl-${relver}" +./configure --prefix="$PREFIX" --bindir="$HOME/bin" --disable-shared \ + --enable-static +make +make install -j$(nproc) diff --git a/muslbuild/ncurses b/muslbuild/ncurses new file mode 100755 index 0000000..a9419d8 --- /dev/null +++ b/muslbuild/ncurses @@ -0,0 +1,47 @@ +#!/bin/sh +set -e +set -x +relver="6.2-20210911" +build_dir="/v/muslbuild/ncurses" + +PREFIX="$HOME/musl" +export CC="musl-gcc -static" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +# arLoc="https://invisible-mirror.net/archives/ncurses/ncurses-%s.tar.gz" +# arLoc="https://invisible-mirror.net/archives/ncurses/ncurses-%s.tar.gz" +arLoc="https://invisible-mirror.net/archives/ncurses/current/ncurses-%s.tgz" +arLoc="$(printf "$arLoc\n" "$relver")" +arFn="ncurses-${relver}.tar.gz" + +checksum=13f221dda7a5839fe7ccee827c93fafb420c943d0f7e7de4d60299046b965867f5afba54c84c1dce2d8b58ff7a5a112bea87c89eca103a14c0fea2ccdf430eaf + +if ! [ -e "$arFn" ] ; then + # we're verifying the checksum anyway, it's freaking out the full + # chain not being there + curl -k -L -o "$arFn" "$arLoc" +fi + +echo "${checksum} $arFn" | sha512sum -c + +tar xzvf "$arFn" +cd "ncurses-${relver}" +./configure --prefix="$PREFIX" --bindir="$HOME/bin" \ + --enable-static \ + --includedir="$PREFIX/include" \ + --without-ada \ + --without-tests \ + --disable-termcap \ + --with-termlib \ + --disable-rpath-hack \ + --without-cxx-binding \ + --enable-pc-files \ + --disable-shared \ + --without-pkg-config +make clean +make -j$(nproc) +make install -j$(nproc) diff --git a/muslbuild/oksh b/muslbuild/oksh new file mode 100755 index 0000000..23213cf --- /dev/null +++ b/muslbuild/oksh @@ -0,0 +1,33 @@ +#!/bin/sh +set -e +set -x +relver="6.9" +build_dir="/v/muslbuild/oksh" + +export CC="musl-gcc -static" +PREFIX="$HOME/musl" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +arLoc="https://github.com/ibara/oksh/releases/download/oksh-%s/oksh-%s.tar.gz" +arLoc="$(printf "$arLoc\n" "$relver" "$relver")" +arFn="oksh-${relver}.tar.gz" + +checksum=c08d97b2ac9ee5d88e9e508d27c75502b2d06c20d4c5ab87b496cb3b9951bd35 + +if ! [ -e "$arFn" ] ; then + curl -L -o "$arFn" "$arLoc" +fi + +echo "${checksum} $arFn" | sha256sum -c + +tar xzvf "$arFn" +cd "oksh-${relver}" +./configure --prefix="$PREFIX" --bindir="$HOME/bin" --enable-ksh \ + --enable-static +make +make install -j$(nproc) + diff --git a/muslbuild/tmux b/muslbuild/tmux new file mode 100755 index 0000000..f160062 --- /dev/null +++ b/muslbuild/tmux @@ -0,0 +1,36 @@ +#!/bin/sh +set -e +set -x +relver="3.2a" +build_dir="/v/muslbuild/tmux" + +PREFIX="$HOME/musl" +export CC="musl-gcc -static -I. -I$PREFIX/include/ncursesw -DHAVE_FORKPTY=1 -DHAVE_FDFORKPTY=1" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +arLoc="https://github.com/tmux/tmux/releases/download/%s/tmux-%s.tar.gz" +arLoc="$(printf "$arLoc\n" "$relver" "$relver")" +arFn="tmux-${relver}.tar.gz" + +checksum=551553a4f82beaa8dadc9256800bcc284d7c000081e47aa6ecbb6ff36eacd05f + +if ! [ -e "$arFn" ] ; then + curl -L -o "$arFn" "$arLoc" +fi + +echo "${checksum} $arFn" | sha256sum -c + +tar xzvf "$arFn" +cd "tmux-${relver}" +./configure --prefix="$PREFIX" --bindir="$HOME/bin" \ + --enable-static \ + --host=x86_64-alpine-linux-musl \ + --build=x86_64-alpine-linux-musl +make clean +make -j$(nproc) +make install -j$(nproc) + diff --git a/muslbuild/upx b/muslbuild/upx new file mode 100755 index 0000000..6c4e98b --- /dev/null +++ b/muslbuild/upx @@ -0,0 +1,26 @@ +#!/bin/sh +set -e +set -x +relver="3.96" +build_dir="/v/muslbuild/jq" + +if ! [ -d "$build_dir" ] ; then + mkdir -p "$build_dir" +fi +cd "$build_dir" + +arLoc="https://github.com/upx/upx/releases/download/v%s/upx-%s-amd64_linux.tar.xz" +arLoc="$(printf "$arLoc\n" "$relver" "$relver")" +arFn="upx-${relver}-amd64_linux.tar.xz" + +checksum=ac75f5172c1c530d1b5ce7215ca9e94586c07b675a26af3b97f8421b8b8d413d + +if ! [ -e "$arFn" ] ; then + curl -L -o "$arFn" "$arLoc" +fi + +echo "${checksum} $arFn" | sha256sum -c + +tar xJvf "$arFn" +cd "upx-${relver}-amd64_linux" +cp upx "$HOME/bin/upx" diff --git a/readme.md b/readme.md index 9456fba..d3d29bc 100644 --- a/readme.md +++ b/readme.md @@ -29,9 +29,9 @@ etc ) ## Shell Configuration -`mkshrc`, generated using `build.sh` inside of the `shell/` directory. +`kshrc`, generated using `build.sh` inside of the `shell/` directory. -Specifically targets mksh which has been my default shell for quite a long time +Specifically targets ksh which has been my default shell for quite a long time now. Though I do test it against `bash` and `ash` as well. Some useful features are: @@ -43,7 +43,7 @@ Some useful features are: * Aliases for `apt`, `yum`, `pacman`, etc to use `sudo` by default. * Utilize `doas` as `sudo` if installed, for instance on OpenBSD. * Utils - * `set_go` can be called in `~/.mkshrc.local` or similar to add the + * `set_go` can be called in `~/.kshrc.local` or similar to add the `GOROOT` and `GOPATH` `bin`'s to your `PATH`. [Example and code.](https://git.riedstra.dev/mitch/dotfiles/tree/shell/utils#n1) * Aggressively set the editor based off of a list in order of ascending preference. ( `set_editor` ) @@ -73,7 +73,7 @@ Some useful features are: * `updatevimrc` Installs [my full vim configuration](https://git.riedstra.dev/mitch/vim-cfg/about) * `updatevimrc_basic` Installs the `.vimrc` file which is a basic but useful vim configuration. * `updatetmuxconf` Pulls in the tmux configuration from this repository. - * `updateshell` Pulls the latest version of `mkshrc` from this repository. + * `updateshell` Pulls the latest version of `kshrc` from this repository. * `pullkeys_github ` Creates the `~/.ssh/authorized_keys` file with the SSH keys for a given github username * Conf

All of the pieces above don't actually do anything automatically, they just -- cgit v1.2.3