#!/bin/sh # # convert # # Convert to architecture set -e # Commandline checks if ! [ $# -eq 2 ]; then echo "Wrong number of arguments:" echo "Usage convert " exit 1 fi export ARCH="$1" DEB="$2" case "$ARCH" in amd64|ia64) ;; *) echo "Wrong architecture '$ARCH'. Expecting amd64 or ia64." exit 1;; esac if ! [ -e "$DEB" ]; then echo "$0: '$DEB': No such file or directory." exit 1 fi RENAME="/usr/share/ia32-libs-tools/rename" # Mangle dependecies for field $1 mangle_dep() { grep-dctrl "" -s"$1" -n DEBIAN/control | tr "," "\n" \ | while read LINE; do echo "$LINE" | tr "|" "\n" \ | while read PKG2 VER2; do echo " $("$RENAME" "$PKG2") $VER2 " done | tr '\n' '|' | sed 's/ / /g' | sed 's/ |$/,/' done | tr '\n' ',' | sed 's/ \(.*\),/\1\n/' } # Check for Debian or Ubuntu if [ "$(lsb_release -s -i)" = "Debian" ]; then ROOT=emul/ia32-linux/ ROOTL=emul_ia32-linux_ SUFFIX= SUFFIXL= else ROOT=./ ROOTL= SUFFIX=32 SUFFIXL=32 fi # Convert package ################## PKG="$(echo "$DEB" | cut -d_ -f1)" PKG32="$("$RENAME" "$PKG")" # Unpack old apckage rm -rf "debian/$PKG32" mkdir -p "debian/$PKG32" dpkg -x "$DEB" "debian/$PKG32" dpkg -e "$DEB" "debian/$PKG32/DEBIAN" cd "debian/$PKG32" VER="$(grep-dctrl "" -n -s Version DEBIAN/control)" if [ -L "usr/share/doc/$PKG" ]; then # Change link name and target PKG2="$(readlink "usr/share/doc/$PKG")" rm "usr/share/doc/$PKG" NEWPKG2="$("$RENAME" "$PKG2")" ln -s "$NEWPKG2" "usr/share/doc/$PKG32" mkdir -p "usr/share/doc/$NEWPKG2" ( export EDITOR="/bin/true"; \ export DEBEMAIL="nobody@noreply.org"; \ export DEBFULLNAME="ia32-libs-tools"; \ dch --preserve --create --changelog "t" --package "$PKG32" --newversion "0.0" --distribution "unstable" "Automatic conversion from i386 by ia32-libs-tools (@VERSION@)") grep -v "Initial release" < t > "usr/share/doc/$NEWPKG2/changelog.ia32-libs-tools" rm t else # Unpack changelog and add entry if [ -e "usr/share/doc/$PKG/changelog.Debian.gz" ]; then gunzip "usr/share/doc/$PKG/changelog.Debian.gz" CHANGELOG="usr/share/doc/$PKG/changelog.Debian" else if [ -e "usr/share/doc/$PKG/changelog.Debian" ]; then CHANGELOG="usr/share/doc/$PKG/changelog.Debian" else CHANGELOG="usr/share/doc/$PKG/changelog" if [ -e "usr/share/doc/$PKG/changelog.gz" ]; then gunzip "usr/share/doc/$PKG/changelog.gz" fi fi fi ( export DEBFULLNAME="Debian ia32-libs Team" export DEBEMAIL="pkg-ia32-libs-maintainers@lists.alioth.debian.org" dch --preserve --multimaint --mainttrailer --append --changelog "$CHANGELOG" "Automatic conversion from i386 by ia32-libs-tools (@VERSION@)" ) # Move doc dir mv "usr/share/doc/$PKG" "usr/share/doc/$PKG32" fi # Rename package and source and change architecture sed -i "s/Package: $PKG/Package: $PKG32/" DEBIAN/control sed -i "s/Source: /Source: ia32-/" DEBIAN/control sed -i "s/Architecture: .*$/Architecture: $ARCH/" DEBIAN/control # Fix dependencies for FIELD in Depends Pre-Depends Conflicts Suggests Recommends Replaces Provides; do sed -i -e "s/^$FIELD: .*$/$FIELD: `mangle_dep $FIELD`/" DEBIAN/control done # Add depend on 64bit package with exact version to keep both packages in sync if [ "$PKG" = "libc6" ] && [ "$ARCH" = "ia64" ]; then DEPPKG="libc6.1" else DEPPKG="$PKG" fi if grep -q "^Depends:" DEBIAN/control; then sed -i "s/Depends: /Depends: $DEPPKG (= $VER), /" DEBIAN/control else echo "Depends: $DEPPKG (= $VER)" >>DEBIAN/control fi # Replace older ia32-libs if grep -q "^Replaces:" DEBIAN/control; then sed -i "s/Replaces: /Replaces: ia32-libs (<= 2.3), /" DEBIAN/control else echo "Replaces: ia32-libs (<= 2.3)" >>DEBIAN/control fi # Move libraries if [ -d lib ]; then mkdir -p "$ROOT" mv lib "${ROOT}lib${SUFFIX}" fi if [ -d usr/lib ]; then mkdir -p "${ROOT}usr" mv usr/lib "${ROOT}usr/lib${SUFFIX}" fi # Rename lintian overrides if [ -e "usr/share/lintian/overrides/$PKG" ]; then mv "usr/share/lintian/overrides/$PKG" "usr/share/lintian/overrides/$PKG32" fi # Fix shlibs file if [ -r DEBIAN/shlibs ]; then while read LIB VER DEP; do # No udebs for converted packages if [ "$LIB" = "udeb:" ]; then continue; fi echo "$DEP" | tr "|" "\n" \ | while read PKG2 VER2; do echo " $("$RENAME" "$PKG2") $VER2 " done | tr '\n' '|' | sed "s/\(.*\) |$/$LIB $VER\1\n/" done < DEBIAN/shlibs > t mv t DEBIAN/shlibs fi # Check for hook if [ -x "../$PKG.hook" ]; then "../$PKG.hook" fi # Sanity check if [ -e etc ]; then echo "Warning: conffiles might conflict" fi if [ -e bin ]; then echo "Warning: package contains binaries in bin" fi if [ -e sbin ]; then echo "Warning: package contains binaries in sbin" fi if [ -e usr/bin ]; then echo "Warning: package contains binaries in usr/bin" fi if [ -e usr/sbin ]; then echo "Warning: package contains binaries in usr/sbin" fi if [ -e usr/share/man ]; then echo "Warning: manpages might conflict" fi