#!/bin/sh set -e # DISCLAIMER # Don't ever think of installing every single package generated with this script. # While it *should* not cause any problems, doing so is simply overkill, untested, and not recommended in the least. if [ "$#" -lt 2 ]; then echo "Usage: $0 [whitelist]" 1>&2 exit 1 fi scriptdir="$(realpath "$(dirname "$0")")" slackware="$1" slackware64="$2" whitelist="$3" find "$slackware" -type f -name "*.t?z" -printf '%P\n' | sort | while read -r pkg; do # See /sbin/installpkg pkgbase="$(echo "$pkg" | sed -e 's?.*/??;s/\.t[bglx]z$//')" pkgext="$(echo "$pkg" | sed -e 's?.*/??;s/.*\.\(t[bglx]z\)$/\1/')" pkgname="$(echo "$pkgbase" | sed -e 's?-[^-]*-[^-]*-[^-]*$??')" pkgver="$(echo "$pkgbase" | sed -e 's?.*-\([^-]*\)-[^-]*-[^-]*$?\1?')" pkgarch="$(echo "$pkgbase" | sed -e 's?.*-[^-]*-\([^-]*\)-[^-]*$?\1?')" if [ "$whitelist" ]; then if ! grep -v '^#' "$whitelist" | fgrep -xq "$pkgname"; then continue fi fi case "$pkgarch" in i?86) pkgarch=x86_64 ;; # Architecture-independent stuff noarch|fw) continue ;; # Only kernel-headers uses x86 as pkgarch. That doesn't need conversion. x86) continue ;; *) echo "WARNING: Package '$pkg' has an unsupported architecture: '$pkgarch'" exit ;; esac if [ ! -f "$slackware64/$(dirname "$pkg")/$pkgname-$pkgver-$pkgarch-"*".$pkgext" ]; then echo "WARNING: Package '$pkg' doesn't exist in slackware64, or there were multiple with different build versions." continue fi rpkg="$(realpath "$slackware/$pkg")" rpkg64="$(realpath "$slackware64/$(dirname "$pkg")/$pkgname-$pkgver-$pkgarch-"*".$pkgext")" mkdir -p "$(dirname "$pkg")" ( cd "$(dirname "$pkg")" "$scriptdir/convert32pkg.sh" "$rpkg" "$rpkg64" ) done