install-slackware (3042B)
1 #!/bin/sh 2 3 set -e 4 5 mirror="http://mirror.nl.leaseweb.net/slackware/" 6 release="slackware64-current" # "slackware-current", "slackware64-current" 7 url="$mirror/$release/slackware64" # "slackware", "slackware64" 8 filelist="$url/FILE_LIST" 9 pkgtools="pkgtools-14.1-noarch-2.tgz" 10 pkgtoolsurl="$url/a/$pkgtools" 11 root="/ns/$release" 12 test x"$1" != x"" && root="$1" 13 tmpdir="/tmp/slackware/$release" 14 pkgdir="$tmpdir/pkgs" 15 16 # a template file is just a plain-text file with a package per line. 17 templateurl="http://git.2f30.org/templates/plain/minimal-server.template" 18 templatefile="$tmpdir/template" 19 20 tar113="$tmpdir/tar-1.13" 21 tar113url="http://www.codemadness.nl/downloads/morpheus/slackware/tar-1.13.gz" 22 tar113checksum="b121b4d03e5ac37fa601f3edf44a80ad1782316442a69372ec1ab33871369780150dffe2d9c67459cbe90ea3ee33a1ea566e57a7b5d63cab08655e2b5220858a tar-1.13" 23 24 mkdir -p "$tmpdir" 25 cd "$tmpdir" 26 27 # get precompiled tar-1.13 required by installpkg (static i486 glibc binary). 28 # NOTE: if you want to build tar-1.13 yourself, the source is available at: 29 # http://mirror.nl.leaseweb.net/slackware/slackware-current/source/a/tar/tar-1.13.tar.gz 30 # build instructions: 31 # ./configure --disable-nls; make CC="gcc -static"; strip src/tar; <copy src/tar>. 32 if ! test -f "$tar113"; then 33 wget "${tar113url}" -O - | gunzip -c - > "${tar113}" 34 printf '%s' "$tar113checksum" | sha512sum -c - 35 fi 36 37 # make sure this tar version is in $PATH and preferred. 38 export PATH="${tmpdir}:$PATH" 39 chmod "755" "$tar113" 40 ln -sf "$tar113" "tar" 41 42 # get template of packages to install. 43 if ! test -f "$templatefile"; then 44 wget "$templateurl" -O "$templatefile" 45 fi 46 47 # get pkgtools. 48 installpkg="$tmpdir/sbin/installpkg" 49 if ! test -f "$pkgtools"; then 50 wget "${pkgtoolsurl}" -O "$tmpdir/$pkgtools" 51 fi 52 if ! test -f "$installpkg"; then 53 tar -xzf "$tmpdir/$pkgtools" 54 fi 55 56 # get packages. 57 mkdir -p "$pkgdir" 58 cd "$pkgdir" 59 wget "$filelist" -q -O - | grep -E -o '[^ ]*$' | grep -E '\.(txz|tgz|txt|asc)$' | while read -r line; do 60 pset=$(dirname "$line" | sed 's@[^a-z]*@@g') 61 pfilename=$(basename "$line") 62 # strip version part of name for matching (this should be fine in most cases). 63 pname=$(printf '%s' "${pfilename}" | sed -E 's@^([^-]*-?[a-z]*?)-.+@\1@g') 64 pattern="^${pname}\$" 65 66 if grep -qE "$pattern" "$templatefile"; then 67 mkdir -p "$pset" 68 if ! test -f "$pset/$pfilename"; then 69 wget "$url/$line" -O "$pset/$pfilename" 70 fi 71 fi 72 done 73 74 # install package sets in order. 75 mkdir -p "$root" 76 cd "$pkgdir" 77 for pset in *; do 78 find "$pset" -name "*.t?z" | while read -r f; do 79 "$installpkg" --terse --root "$root" "$f" 80 done 81 done 82 83 # fix symlink references for libs. 84 libdir="$root/lib64" 85 if ! test -d "$libdir"; then 86 libdir="$root/lib" 87 fi 88 cd "$libdir" 89 for i in *; do 90 if readlink "$i" | grep -qE '\.incoming$'; then 91 r=$(basename "$(readlink "$i" | sed -E 's@\.incoming$@@')") 92 if test -L "$i"; then 93 ln -sf "$r" "$i" 94 fi 95 fi 96 done 97 98 # copy /etc/resolv.conf 99 mkdir -p "${root}/etc" 100 cp /etc/resolv.conf "${root}/etc/resolv.conf" 101 chmod 644 "${root}/etc/resolv.conf"