morpheus

suckless linux distro
git clone git://git.2f30.org/morpheus
Log | Files | Refs | Submodules | README | LICENSE

commit 777862ca7f3ce909c7bd5deb2c3d25aba220282e
parent 5080bfd8b56a49e059cd8b31eddf7f75c7f2c97e
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  6 Jul 2014 23:06:22 +0000

misc: add install-slackware

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
Amisc/install-slackware | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+), 0 deletions(-)

diff --git a/misc/install-slackware b/misc/install-slackware @@ -0,0 +1,91 @@ +#!/bin/sh + +set -e + +mirror="http://mirror.nl.leaseweb.net/slackware/" +release="slackware64-current" +url="$mirror/$release/slackware64" +filelist="$url/FILE_LIST" +pkgtools="pkgtools-14.1-noarch-2.tgz" +pkgtoolsurl="$url/a/$pkgtools" +installdir="/ns/slackware-current" +tmpdir="/tmp/slackware" +pkgdir="/tmp/slackware/pkgs" + +# a template file is just a plain-text file with a package per line. +templateurl="http://git.2f30.org/templates/plain/minimal-server.template" +templatefile="$tmpdir/template" + +tar113="$tmpdir/tar-1.13" +tar113url="http://www.codemadness.nl/downloads/morpheus/slackware/tar-1.13" +tar113checksum="9f011c843944e03dc56f30f513344ac7f73621da762520370ab4150e26475b1f1f2daec15076fa3e096e78432b51fbc55cda1db66ff7e329b0c6f55d61028d6d tar-1.13" + +mkdir -p "$tmpdir" +cd "$tmpdir" + +# get precompiled tar-1.13 required by installpkg (static x86_64 musl binary). +if ! test -f "$tar113"; then + wget "${tar113url}" -O "$tar113" + printf '%s' "$tar113checksum" | sha512sum -c - +fi + +# make sure this tar version is in $PATH and prefered. +export PATH="${tmpdir}:$PATH" +chmod "755" "$tar113" +ln -sf "$tar113" "tar" + +# get template of packages to install. +if ! test -f "$templatefile"; then + wget "$templateurl" -O "$templatefile" +fi + +# get pkgtools. +installpkg="$tmpdir/sbin/installpkg" +if ! test -f "$pkgtools"; then + wget "${pkgtoolsurl}" -O "$tmpdir/$pkgtools" +fi +if ! test -f "$installpkg"; then + tar -xzf "$tmpdir/$pkgtools" +fi + +# get packages. +mkdir -p "$pkgdir" +cd "$pkgdir" +wget "$filelist" -q -O - | grep -E -o '[^ ]*$' | grep -E '\.(txz|tgz|txt|asc)$' | while read -r line; do + pset=$(dirname "$line" | sed 's@[^a-z]*@@g') + pfilename=$(basename "$line") + # strip version part of name for matching (this should be fine in most cases). + pname=$(printf '%s' "${pfilename}" | sed -E 's@^([^-]*-?[a-z]*?)-.+@\1@g') + pattern="^${pname}\$" + + if grep -qE "$pattern" "$templatefile"; then + mkdir -p "$pset" + if ! test -f "$pset/$pfilename"; then + wget "$url/$line" -O "$pset/$pfilename" + fi + fi +done + +# install packages. +mkdir -p "$installdir" +#cd "$pkgdir" +cat "$templatefile" | while read -r line; do + f=$(find "." -name "$line-*.t?z" | sed 1q) + "$installpkg" --terse --root "$installdir" "$f" +done + +# fix symlink references for libs. +cd "$installdir/lib64" +for i in *; do + if realpath "$i" | grep -qE '\.incoming$'; then + r=$(basename "$(realpath "$i" | sed -E 's@\.incoming$@@')") + if test -L "$i"; then + ln -sf "$r" "$i" + fi + fi +done + +# copy /etc/resolv.conf +mkdir -p "${installdir}/etc" +cp /etc/resolv.conf "${installdir}/etc/resolv.conf" +chmod 644 "${installdir}/etc/resolv.conf"