From 6c75c97058748096bd6ae7a1be1b80cdc7d62833 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Fri, 10 Aug 2018 16:24:42 +0200 Subject: [PATCH] Re-organize --- .../convert32-supported | 0 convert32pkg.sh => 14.2/convert32pkg.sh | 0 kernel.SlackBuild => 14.2/kernel.SlackBuild | 0 14.2/makechroot-minimal.sh | 151 ++++++++++++++++++ 14.2/makechroot.sh | 63 ++++++++ massconvert32.sh => 14.2/massconvert32.sh | 0 update-repo.sh => 14.2/update-repo.sh | 2 - readme.txt | 2 +- 8 files changed, 215 insertions(+), 3 deletions(-) rename convert32-supported => 14.2/convert32-supported (100%) rename convert32pkg.sh => 14.2/convert32pkg.sh (100%) rename kernel.SlackBuild => 14.2/kernel.SlackBuild (100%) create mode 100755 14.2/makechroot-minimal.sh create mode 100755 14.2/makechroot.sh rename massconvert32.sh => 14.2/massconvert32.sh (100%) rename update-repo.sh => 14.2/update-repo.sh (99%) diff --git a/convert32-supported b/14.2/convert32-supported similarity index 100% rename from convert32-supported rename to 14.2/convert32-supported diff --git a/convert32pkg.sh b/14.2/convert32pkg.sh similarity index 100% rename from convert32pkg.sh rename to 14.2/convert32pkg.sh diff --git a/kernel.SlackBuild b/14.2/kernel.SlackBuild similarity index 100% rename from kernel.SlackBuild rename to 14.2/kernel.SlackBuild diff --git a/14.2/makechroot-minimal.sh b/14.2/makechroot-minimal.sh new file mode 100755 index 0000000..a77b781 --- /dev/null +++ b/14.2/makechroot-minimal.sh @@ -0,0 +1,151 @@ +#!/bin/sh +set -eu + +if [ "$(id -u)" != 0 ]; then + echo "This script needs root permissions!" 1>&2 + exit 1 +fi + +if [ "$#" -lt 2 ]; then + echo "Usage: $0 [-a arch] [-v version] [-m mirror] [-b localmirror]" 1>&2 + exit 1 +fi + + +version='14.2' +arch="$(uname -m)" +mirror='https://mirrors.slackware.com/slackware' +base='' + +# Minimal amount of packages required to run installpkg, removepkg and upgradepkg +# bzip2 and gzip are optional, but required to support .tgz and .tbz packages +# All of these exist in the 'a' package set +packages_pkgtools=' +aaa_base +aaa_elflibs +bash +bzip2 +coreutils +etc +findutils +glibc-solibs +grep +gzip +pkgtools +sed +tar +util-linux +xz +' + +# Minimal amount of packages required to run slackpkg without the dialog interface +# gnupg is optional, but required to verify the GPG signatures of packages +# ca-certificates, openssl, bin and perl are optional, but required for HTTPS support +# These exist over the 'a', 'ap' and 'n' package sets +# perl exists in the 'd' package set +# openssl and ca-certificates need to be installed last (after perl and bin, at least) for the doinst.sh to run correctly +packages_slackpkg=' +bin +diffutils +gawk +gnupg +openssl-solibs +perl +slackpkg +wget +which + +openssl +ca-certificates +' + +# Parse arguments +while getopts "v:a:m:b:" opt; do + case "$opt" in + v) version="$OPTARG" ;; + a) arch="$OPTARG" ;; + m) mirror="$OPTARG" ;; + b) base="$(realpath "$OPTARG")" # Path to local mirror, to get the files from. + esac +done + +# Build final variables +case "$arch" in + x86_64) + pkgmain='slackware64' + ;; + + *) + pkgmain='slackware' + ;; +esac +release="$pkgmain-$version" +initrd='isolinux/initrd.img' +checksums='CHECKSUMS.md5' + +# Create working directory +temp="$(mktemp -d -t "$(basename "$0")".XXXXXX)" +trap "rm -rf '$temp'" EXIT +destdir="$PWD" +cd "$temp" + +# Function to download (or copy) a file +get() { + if [ "$base" ]; then + cp "$base/$1" "$2" + else + wget "$mirror/$release/$1" -O "$2" + fi +} + +# Function to verify files based on the checksums file +check() { + printf '%s' "$(tail +13 CHECKSUMS.md5 | grep "^[0-9a-f]* ./$1$" | cut -d ' ' -f 1) $2" | md5sum -c --quiet - +} + +# Get the full path to a package +package() { + tail +13 CHECKSUMS.md5 | grep "^[0-9a-f]* ./$pkgmain/[^/]*/$1-[^-]*-[^-]*-[^-]*\.t.z$" | cut -d ' ' -f 3- | cut -c 3- +} + +# Download checksums +get "$checksums" CHECKSUMS.md5 + +# Download installer initrd.img +get "$initrd" initrd.img +check "$initrd" initrd.img + +# Unpack and prepare the installer +zcat initrd.img | cpio -id +rm -rf initrd.img mnt pkg +mkdir -p mnt/pkg pkg + +# Download packages +for pkg in $packages_pkgtools; do + path="$(package "$pkg")" + name="$(basename "$path")" + + get "$path" "pkg/$name" + check "$path" "pkg/$name" + echo "$name" >> pkg/_ +done +for pkg in $packages_slackpkg; do + path="$(package "$pkg")" + name="$(basename "$path")" + + get "$path" "mnt/pkg/$name" + check "$path" "mnt/pkg/$name" + echo "$name" >> mnt/pkg/_ +done + +# Bootstrap pkgtools and it's dependencies +env -i chroot . sh -l -c 'while read pkg; do /usr/lib/setup/installpkg --root /mnt --terse "/pkg/$pkg"; done < /pkg/_' + +# Install slackpkg and it's dependencies +env -i chroot mnt sh -l -c 'while read pkg; do /sbin/installpkg --terse "/pkg/$pkg"; done < /pkg/_' + +# Configuration +printf '%s\n' "$mirror/$release/" >> mnt/etc/slackpkg/mirrors + +# Compress the package +tar cvJf "$destdir/$release.tar.xz" --sort=name --exclude=./pkg -C mnt . diff --git a/14.2/makechroot.sh b/14.2/makechroot.sh new file mode 100755 index 0000000..10eee18 --- /dev/null +++ b/14.2/makechroot.sh @@ -0,0 +1,63 @@ +#!/bin/sh -e +set -e + +if [ "$(id -u)" != 0 ]; then + echo "This script needs root permissions!" 1>&2 + exit 1 +fi + +if [ "$#" -lt 2 ]; then + echo "Usage: $0 " 1>&2 + exit 1 +fi + +slackware="$(realpath "$1")" +chroot="$(realpath "$2")" + +temp="$(mktemp -d -t makechroot.XXXXXX)" + +# Make sure we clean up properly before exitting +cleanup() { + mountpoint -q "$temp/mnt" && umount "$temp/mnt" + mountpoint -q "$temp/dvd" && umount "$temp/dvd" + rm -rf "$temp" +} +trap 'cleanup' EXIT + +# Extract the initrd +cd "$temp" +gzip -cd "$slackware/isolinux/initrd.img" | cpio -id + +# Mount the dvd +mkdir dvd +mount --bind "$slackware" dvd + +# Mount the destination +mkdir -p "$chroot" +mount --bind "$chroot" mnt + +# Install the packages +env -i chroot . sh -l -c ' +/usr/lib/setup/installpkg --root /mnt --terse /dvd/slackware*/*/*.t?z + +cd /mnt +for script in \ + 04.mkfontdir \ + 05.fontconfig \ + 07.update-desktop-database \ + 07.update-mime-database \ + 08.gtk-update-icon-cache \ + 11.cacerts \ + cups-genppdupdate +do + var/log/setup/setup.$script +done +chroot . /usr/bin/update-gtk-immodules > /dev/null 2>&1 +chroot . /usr/bin/update-gdk-pixbuf-loaders > /dev/null 2>&1 +chroot . /usr/bin/update-pango-querymodules > /dev/null 2>&1 +chroot . /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas > /dev/null 2>&1 +' +# We only run a few setup scripts that do not require user interaction, and deal with updating caches and such, which is not done (properly) by the doinst.sh scripts. +# To get a full list, run: bzcat MANIFEST.bz2 | awk '{print $6}' | grep '^var/log/setup/setup\.' | sort +# Besides the setup scripts, we also need to run some programs which are usually ran from /etc/rc.d/rc.M, but not from the setup scripts. +# This is tailored to Slackware 14.2. I'm unsure whether it'll work properly on any other version. diff --git a/massconvert32.sh b/14.2/massconvert32.sh similarity index 100% rename from massconvert32.sh rename to 14.2/massconvert32.sh diff --git a/update-repo.sh b/14.2/update-repo.sh similarity index 99% rename from update-repo.sh rename to 14.2/update-repo.sh index 2d5d394..9cfa3d5 100755 --- a/update-repo.sh +++ b/14.2/update-repo.sh @@ -49,8 +49,6 @@ find . -regex '.*\.t[bglx]z$' | while read -r package; do pkgsum="$cachedir/$pkgdir/$pkgbase.checksum" - skip=false - if [ -f "$pkgtxt" -a \ -f "$pkgmeta" -a \ -f "$pkgmanifest" -a \ diff --git a/readme.txt b/readme.txt index 6122f61..fdfc10a 100644 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ This repo contains all my slackware modifications of the base install. Additional packages are contained in RocketLinux and built in a non-standard manner. -This branch contains a few scripts I use to manage things. +This branch contains a few scripts I use, related to slackware. - kernel.SlackBuild is capable of building a near-identical slackware kernel - convert32pkg.sh converts a 32bit package to be installable on 64bit (by