diff options
author | Slack Coder <slackcoder@server.ky> | 2018-10-20 07:47:57 +0200 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2018-10-20 07:47:57 +0200 |
commit | 4aff578ab86483ebf57f19a10b70c4eeb34af88e (patch) | |
tree | eb84d012c2afdec065923fd5fb9d0490fc2e46c4 /cmd | |
download | muslack64-current-4aff578ab86483ebf57f19a10b70c4eeb34af88e.tar.xz |
initial commit
Diffstat (limited to 'cmd')
-rwxr-xr-x | cmd/build-all.sh | 63 | ||||
-rwxr-xr-x | cmd/build-env.sh | 36 | ||||
-rwxr-xr-x | cmd/init-env.sh | 67 | ||||
-rwxr-xr-x | cmd/pkg-set.sh | 14 | ||||
-rwxr-xr-x | cmd/sync-files.sh | 58 |
5 files changed, 238 insertions, 0 deletions
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 - |