mid-kid
6 years ago
8 changed files with 215 additions and 3 deletions
@ -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 . |
@ -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 <slackware> <chroot>" 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. |
Loading…
Reference in new issue