From 4aff578ab86483ebf57f19a10b70c4eeb34af88e Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Sat, 20 Oct 2018 07:47:57 +0200 Subject: initial commit --- README.md | 51 ++++++++++++++++++++++++++++++++++++++++++ cmd/build-all.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ cmd/build-env.sh | 36 ++++++++++++++++++++++++++++++ cmd/init-env.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmd/pkg-set.sh | 14 ++++++++++++ cmd/sync-files.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 289 insertions(+) create mode 100644 README.md create mode 100755 cmd/build-all.sh create mode 100755 cmd/build-env.sh create mode 100755 cmd/init-env.sh create mode 100755 cmd/pkg-set.sh create mode 100755 cmd/sync-files.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..5ad1324 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +MuSlack +======= + +MuSlack is an unoffical attempt at porting some +[Slackware](https://www.slackware.com) current packages to statically built +[musl](https://www.musl-libc.org) based ones. + +Auditing Changes +---------------- + +An easy way to audit the build scripts is to compare them to Slackware's +official one. To do this, copy the '.git' folder from this project into the +root of Slackware-current and run 'git diff'. + +Requirements +------------ + + - [bubblewrap](https://slackbuilds.org/repository/14.2/system/bubblewrap/) + - [musl libc](https://slackbuilds.org/repository/14.2/system/musl/) + - Slackware OS + +Building these Packages +----------------------- + +To build the packages in this project, a locally installed MuSlack system is +used under /opt/muslack. + + export PATH=/bin:/sbin:$PATH:$(realpath ./cmd) + sudo mkdir /opt/muslack + sudo chown $USER /opt/muslack + + # Pull supporting package contents from Slackware + sync-files.sh + + # Create _very_ minimal base system + init-env.sh + + # Enter build environment + build-env.sh + + # install kernel headers + ( + cd /tmp + wget ftp://ftp.slackware.com/pub/slackware/slackware64-current/slackware64/d/kernel-headers-4.4.14-x86-1.txz + wget ftp://ftp.slackware.com/pub/slackware/slackware64-current/slackware64/d/kernel-headers-4.4.14-x86-1.txz.asc + gpg2 --verify-files *.asc + installpkg kernel-headers*.txz + ) + + # Try building + installing everything + build-all.sh diff --git a/cmd/build-all.sh b/cmd/build-all.sh new file mode 100755 index 0000000..b626592 --- /dev/null +++ b/cmd/build-all.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +CMD_DIR="$(realpath $(dirname $0))" +PATH=$PATH:$CMD_DIR +PROJ_DIR="$(realpath $CMD_DIR/..)" + +while : +do + >"$TMP/before.txt" find "${PROJ_DIR}" -name '*.txz' + mkdir -p "${PROJ_DIR}/patches/packages/" + for pkg in $PROJ_DIR/patches/source/*; do + ( + cd "$pkg" + + export OUTPUT="${PROJ_DIR}/patches/packages/" + PKG_NAME=$(basename $(realpath .)) + + built=$(find "$OUTPUT" -name "$PKG_NAME-*.txz") + if [ -n "$built" ]; then + continue + fi + + sh *.SlackBuild + built="$(find "$TMP" -name "*.txz")" + if [ -z "$built" ]; then + continue + fi + mkdir -p "${OUTPUT}" + upgradepkg --install-new "$TMP"/*.txz + mv "$TMP"/*.txz "${OUTPUT}" + ) + done + + for pkg in $PROJ_DIR/source/**/*; do + ( + cd "$pkg" + + export OUTPUT="${PROJ_DIR}/slackware/$(pkg-set.sh)" + PKG_NAME=$(basename $(realpath .)) + + built=$(find "$OUTPUT" -name "$PKG_NAME-*.txz") + if [ -n "$built" ]; then + continue + fi + + sh *.SlackBuild + built="$(find "$TMP" -name "*.txz")" + if [ -z "$built" ]; then + continue + fi + mkdir -p "${OUTPUT}" + upgradepkg --install-new "$TMP"/*.txz + mv "$TMP"/*.txz "${OUTPUT}" + ) + done + >"$TMP/after.txt" find "${PROJ_DIR}" -name '*.txz' + + NEW_PACKAGES="$(diff $TMP/before.txt $TMP/after.txt | grep "^>" | sed "s#^> ##")" + if [ ! $NEW_PACKAGES ]; then + break + fi +done + diff --git a/cmd/build-env.sh b/cmd/build-env.sh new file mode 100755 index 0000000..fb003e2 --- /dev/null +++ b/cmd/build-env.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +CMD_DIR="$(realpath $(dirname $0))" +PROJ_DIR="$(realpath $CMD_DIR/..)" + +export CC="${CC:=musl-gcc --static}" +export ROOT="${ROOT:=/opt/muslack64-14.2}" +export TMP="${TMP:=/tmp/muslack}" +export USE_STATIC="${USE_STATIC:=true}" +export PKGTYPE="txz" + +export PS1="[muslack-dev] $PS1" + +TARGET="bash" +if [ $# -gt 0 ]; then + TARGET=$@ +fi + +if [ ! -d "$ROOT" ]; then + >&2 echo "This script expects $ROOT to exist. Maybe you should create it?" + exit 1 +fi + +bwrap \ + --unshare-all \ + --uid 0 \ + --gid 0 \ + --ro-bind / / \ + --bind /tmp /tmp \ + --bind "$PROJ_DIR" "$PROJ_DIR" \ + --ro-bind "$ROOT/usr/include" /usr/include/musl \ + --ro-bind "$ROOT/usr/lib64" /usr/lib64/musl \ + --bind "$ROOT" "$ROOT" \ + --dev-bind /dev /dev \ + $TARGET + diff --git a/cmd/init-env.sh b/cmd/init-env.sh new file mode 100755 index 0000000..3a5bef4 --- /dev/null +++ b/cmd/init-env.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -e + +CMD_DIR="$(realpath $(dirname $0))" +PROJ_DIR="$(realpath $CMD_DIR/..)" + +export ROOT="${ROOT:=/opt/muslack64-14.2}" +export TMP="${TMP:=/tmp}" + +if [ ! -d "$ROOT" ]; then + >&2 echo "This script expects $ROOT to exist. Maybe you should create it?" + exit 1 +fi + +(cd "$PROJ_DIR/source/a/aaa_base" + sh *.SlackBuild + ) +bwrap \ + --unshare-all \ + --uid 0 \ + --gid 0 \ + --ro-bind / / \ + --bind /tmp /tmp \ + --bind "$ROOT" "$ROOT" \ + --dev-bind /dev /dev \ +installpkg "$TMP/aaa_base-*.txz" + +(cd "$PROJ_DIR/source/l/musl" + bwrap \ + --unshare-all \ + --uid 0 \ + --gid 0 \ + --ro-bind / / \ + --bind /tmp /tmp \ + --dev-bind /dev /dev \ + sh *.SlackBuild + ) +bwrap \ + --unshare-all \ + --uid 0 \ + --gid 0 \ + --ro-bind / / \ + --bind /tmp /tmp \ + --bind "$ROOT" "$ROOT" \ + --dev-bind /dev /dev \ + installpkg "$TMP/musl-*.t*z" + +(cd "$PROJ_DIR/source/a/etc" + bwrap \ + --unshare-all \ + --uid 0 \ + --gid 0 \ + --ro-bind / / \ + --bind /tmp /tmp \ + --dev-bind /dev /dev \ + sh *.SlackBuild + ) +bwrap \ + --unshare-all \ + --uid 0 \ + --gid 0 \ + --ro-bind / / \ + --bind /tmp /tmp \ + --bind "$ROOT" "$ROOT" \ + --dev-bind /dev /dev \ + installpkg "$TMP/etc-*.t*z" + diff --git a/cmd/pkg-set.sh b/cmd/pkg-set.sh new file mode 100755 index 0000000..058a7b7 --- /dev/null +++ b/cmd/pkg-set.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +TARGET="$(pwd)" +if [ $# -eq 1 ]; then + TARGET=$1 +fi + +# check file path +PKG_SET=$(pwd | \ + awk -F '/source/' '{print $2}' | \ + awk -F '/' '{print $1}' +) + +echo "$PKG_SET" diff --git a/cmd/sync-files.sh b/cmd/sync-files.sh new file mode 100755 index 0000000..54b1e97 --- /dev/null +++ b/cmd/sync-files.sh @@ -0,0 +1,58 @@ +#!/bin/sh +set -e + +CMD_DIR="$(realpath $(dirname $0))" +PROJ_DIR="$(realpath $CMD_DIR/..)" + +MIRROR="${MIRROR:=ftp://ftp.slackware.com/pub/slackware/slackware64-14.2}" + +echo "Fetching CHECKSUMS.md5" +wget --continue "$MIRROR/CHECKSUMS.md5" +wget --continue "$MIRROR/CHECKSUMS.md5.asc" + +# verify +gpg2 --verify-files CHECKSUMS.md5.asc + +echo "fetching packages" +for pkg in source/*/*; do + echo "$pkg" + grep $pkg CHECKSUMS.md5 | \ + grep -v SlackBuild | \ + tr -s " " | \ + cut -f2 -d " " | \ + while read -r line; + do + mkdir -p $(echo "$line" | rev | cut -d'/' -f2- | rev) + echo "url: $MIRROR/$line" + sleep 1 + wget -c -O "$line" "$MIRROR/$line" + done +done + +for pkg in patches/source/*; do + echo "$pkg" + grep $pkg CHECKSUMS.md5 | \ + grep -v SlackBuild | \ + tr -s " " | \ + cut -f2 -d " " | \ + while read -r line; + do + mkdir -p $(echo "$line" | rev | cut -d'/' -f2- | rev) + echo "url: $MIRROR/$line" + sleep 1 + wget -c -O "$line" "$MIRROR/$line" + done +done + +for pkg in $(find . -name '*.info' | xargs -n1 dirname); do + ( + echo "$pkg" + cd "$pkg" + source ./*.info + wget -c "$DOWNLOAD" + ) +done + +echo "verify checksums..." +tail +13 CHECKSUMS.md5 | grep -v SlackBuild | md5sum --check --ignore-missing --quiet - +tail +13 CHECKSUMS_MUSLACK.md5 | md5sum --check --ignore-missing --quiet - -- cgit v1.2.3