Browse Source

Added massconver32.sh

master
mid-kid 8 years ago
parent
commit
111edeeebb
  1. 52
      convert32pkg.sh
  2. 49
      massconvert32.sh

52
convert32pkg.sh

@ -21,8 +21,16 @@ pkgver="$(echo "$pkgbase" | sed -e 's?.*-\([^-]*\)-[^-]*-[^-]*$?\1?')"
pkgarch="$(echo "$pkgbase" | sed -e 's?.*-[^-]*-\([^-]*\)-[^-]*$?\1?')" pkgarch="$(echo "$pkgbase" | sed -e 's?.*-[^-]*-\([^-]*\)-[^-]*$?\1?')"
pkgbuild="$(echo "$pkgbase" | sed -e 's?.*-[^-]*-[^-]*-\([^-]*\)$?\1?')" pkgbuild="$(echo "$pkgbase" | sed -e 's?.*-[^-]*-[^-]*-\([^-]*\)$?\1?')"
pkginfo="$pkginfodir/$pkgname-$pkgver-x86_64-$pkgbuild" case "$pkgarch" in
pkgscript="$pkgscriptdir/$pkgname-$pkgver-x86_64-$pkgbuild" i?86) pkgarch=x86_64 ;;
*)
echo "Unknown package architecture '$pkgarch'. Can't proceed." 1>&2
exit 1
;;
esac
pkginfo="$pkginfodir/$pkgname-$pkgver-$pkgarch-$pkgbuild"
pkgscript="$pkgscriptdir/$pkgname-$pkgver-$pkgarch-$pkgbuild"
case "$pkgext" in case "$pkgext" in
tgz) tool=gzip ;; tgz) tool=gzip ;;
@ -37,14 +45,16 @@ trap "rm -rf '$temp'" EXIT
cd "$temp" cd "$temp"
explodepkg "$pkg32" explodepkg "$pkg32"
# Remove all files present in the x86_64 package # Remove all files present in the 64bit package
if [ "$pkg64" ]; then if [ "$pkg64" ]; then
echo
echo "Removing files:"
$tool -cd "$pkg64" | tar-1.13 t | grep -v "^install/" | while read -r file; do $tool -cd "$pkg64" | tar-1.13 t | grep -v "^install/" | while read -r file; do
rm -vf "./$file" 2> /dev/null || true rm -vf "./$file" 2> /dev/null || true
done done
else else
if [ ! -f "$pkginfo" ]; then if [ ! -f "$pkginfo" ]; then
echo "Package '$pkgname-$pkgver-x86_64-$pkgbuild' is not installed. Can't proceed." 1>&2 echo "Package '$pkgname-$pkgver-$pkgarch-$pkgbuild' is not installed. Can't proceed." 1>&2
exit 1 exit 1
fi fi
@ -54,24 +64,29 @@ else
else else
TRIGGER="FILE LIST:" TRIGGER="FILE LIST:"
fi fi
echo
echo "Removing files:"
sed -n "/$TRIGGER/,/^$/p" "$pkginfo" | fgrep -v "FILE LIST:" | grep -v "^install/" | while read -r file; do sed -n "/$TRIGGER/,/^$/p" "$pkginfo" | fgrep -v "FILE LIST:" | grep -v "^install/" | while read -r file; do
rm -vf "./$file" 2> /dev/null || true rm -vf "./$file" 2> /dev/null || true
done done
fi fi
# Clean empty directories # Clean empty directories
find . -mindepth 1 -type d -empty -delete echo
echo "Empty directories:"
find . -mindepth 1 -type d -empty -print -delete
# Remove all symlinks present in the x86_64 package # Remove all symlinks present in the 64bit package
if [ -f install/doinst.sh ]; then if [ -f install/doinst.sh ]; then
if [ "$pkg64" ]; then if [ "$pkg64" ]; then
if ! $tool -cd "$pkg64" | tar-1.13 xO install/doinst.sh > install/doinst.64; then if ! $tool -cd "$pkg64" | tar-1.13 xO install/doinst.sh > install/doinst.64; then
echo "Failed to extract install/doinst.sh from '$pkg64'. Aborting." 1>&2 echo "Failed to extract install/doinst.sh from '$pkg64'. Can't proceed." 1>&2
exit 1 exit 1
fi fi
else else
if [ ! -f "$pkgscript" ]; then if [ ! -f "$pkgscript" ]; then
echo "Package '$pkgname-$pkgver-x86_64-$pkgbuild' is installed but has no installation script. Can't proceed." 1>&2 echo "Package '$pkgname-$pkgver-$pkgarch-$pkgbuild' is installed but has no installation script. Can't proceed." 1>&2
exit 1 exit 1
fi fi
cp "$pkgscript" install/doinst.64 cp "$pkgscript" install/doinst.64
@ -80,10 +95,25 @@ if [ -f install/doinst.sh ]; then
# Extract all lines treating with symlinks. See /sbin/removepkg # Extract all lines treating with symlinks. See /sbin/removepkg
sed -n -e 's,^[ ]*( [ ]*cd[ ]* .* [ ]*; [ ]*\(rm\|ln\) [ ]*-\(rf\|sf\)[ ]* .* [ ]*)[ ]*$,&,p' -e 's,^[ ]*config .*[ ]*,&,p' install/doinst.64 > install/doinst sed -n -e 's,^[ ]*( [ ]*cd[ ]* .* [ ]*; [ ]*\(rm\|ln\) [ ]*-\(rf\|sf\)[ ]* .* [ ]*)[ ]*$,&,p' -e 's,^[ ]*config .*[ ]*,&,p' install/doinst.64 > install/doinst
# Remove all symlinks present in the x86_64 package echo
fgrep -vxf install/doinst install/doinst.sh > install/doinst.sh.new echo "Removed lines in doinst.sh:"
fgrep -xf install/doinst install/doinst.sh || true
# Remove all symlinks present in the 64bit package
fgrep -vxf install/doinst install/doinst.sh > install/doinst.sh.new || true
mv install/doinst.sh.new install/doinst.sh mv install/doinst.sh.new install/doinst.sh
rm -f install/doinst install/doinst.64 rm -f install/doinst install/doinst.64
fi fi
makepkg -l y -c n "$OLDPWD/convert32-$pkgname-$pkgver-x86_64-$pkgbuild.$pkgext" # Rename package in slack-desc
if [ -f install/slack-desc ]; then
sed -i -e '/^\$\|#\| *|/!s/^[^:]*:/convert32-&/' install/slack-desc
fi
if ! find . | grep -v '^.$\|^./install' > /dev/null; then
echo
echo "Package is empty. Not running makepkg." 1>&2
exit 0
fi
makepkg -l n -c n "$OLDPWD/convert32-$pkgname-$pkgver-$pkgarch-$pkgbuild.$pkgext"

49
massconvert32.sh

@ -0,0 +1,49 @@
#!/bin/sh -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, and not recommended in the least.
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <slackware> <slackware64>" 1>&2
exit 1
fi
scriptdir="$(realpath "$(dirname "$0")")"
slackware="$1"
slackware64="$2"
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?')"
pkgbuild="$(echo "$pkgbase" | sed -e 's?.*-[^-]*-[^-]*-\([^-]*\)$?\1?')"
case "$pkgarch" in
i?86) pkgarch=x86_64 ;;
*) continue ;;
esac
pkg64="$(dirname "$pkg")/$pkgname-$pkgver-$pkgarch-$pkgbuild.$pkgext"
if [ ! -f "$slackware64/$pkg64" ]; then
continue
fi
rpkg="$(realpath "$slackware/$pkg")"
rpkg64="$(realpath "$slackware64/$pkg64")"
mkdir -p "$(dirname "$pkg")"
( cd "$(dirname "$pkg")"
"$scriptdir/convert32pkg.sh" "$rpkg" "$rpkg64"
)
done
# if [ ! "$(tar tf "convert32-$pkgname-$pkgver-$pkgarch-$pkgbuild.$pkgext" | grep -v '^./\|^install/')" ]; then
# rm -f "convert32-$pkgname-$pkgver-$pkgarch-$pkgbuild.$pkgext"
# fi
Loading…
Cancel
Save