debian_builds
debian_builds copied to clipboard
crossgrade builds..
https://wiki.debian.org/CrossGrading
minorly borked from manally trying how the arm64 kernel much more useful .. /mnt/gentoo (aarch64) via hdd for builds
point being is crossgrade , drop arm7hf >>>> pure arm64 release at fin on your build root. to 32bit and or arm64 as a choice
# scary script to crossgrade your debian machine between arches.
# usage crossgrade <final-architecture>
set -e
if [ -z "$1" ]; then
echo "Usage: crossgrade <architecture> (debian architecture to convert to)"
exit 1
fi
#validate arch
if ! TO=$(dpkg-architecture -qDEB_HOST_ARCH -a$1); then
echo "$1 is not a recognised architecture name"
exit 1
fi
FROM=$(dpkg --print-architecture)
echo "Crossgrading from $FROM to $TO"
#check for a compatible kernel
# should check $FROM and $TO harder
# allow for switching kernel over too to minimal one if requested?
case $TO in
amd64)
TO_KERN=amd64
;;
i386)
TO_KERN=amd64
;;
armhf)
TO_KERN=armhf
;;
armel)
TO_KERN=armhf
;;
arm64)
TO_KERN=arm64
;;
mips)
TO_KERN=mips64le
;;
mipsel)
TO_KERN=mips64le
;;
mips64le)
TO_KERN=mips64le
;;
ppc)
TO_KERN=ppc64el
;;
powerpc)
TO_KERN=ppc64el
;;
ppc64el)
TO_KERN=ppc64el
esac
dpkg --add-architecture $TO
# check that dpkg --print-foreign-architectures is $TO
apt update
apt upgrade
# Install a kernel capable to run the new architecture with the old
# architecture in userspace
KERNEL=$(uname -m)
echo "Current kernel arch is $KERNEL"
if [ "$KERNEL" != "$TO_KERN" ]; then
if apt install linux-image-$TO:$TO; then
echo "There should be a reboot here"
exit 1
#reboot
else
echo "kernel updating to linux-image-$TO:$TO failed"
fi
fi
echo Crossgrading dpkg and apt
apt clean
apt --download-only install dpkg:$TO apt:$TO tar:$TO
#check ever package to be installed is available in same version for amd64 if installed (multiarch sync is needed)
#for pkg in /var/cache/apt/archives/*_$TO.deb
#do
# file=$(basename $pkg)
# pkgname= ${file%%_.*}
# version= ${file##*._}
# if dpkg -l $($pkgname)
#done
#in practice this needs to run twice (do it more? is there a better way?)
if ! dpkg --install /var/cache/apt/archives/*_$TO.deb; then
dpkg --install /var/cache/apt/archives/*_$TO.deb
fi
test $(dpkg --print-architecture) = $TO
test $(dpkg --print-foreign-architectures | grep $FROM) = $FROM
echo "Yay! dpkg and apt crossgrade completed successfully"
echo "Updating core packages"
apt upgrade
apt full-upgrade
echo "Removing obsolete packages"
apt install aptitude:$TO
aptitude purge '?obsolete'
echo "Mass reinstalling $TO packages -- double check installed packages match warned-about packages"
apt install $(dpkg -l | grep '^.i.*:'"$FROM" | grep ":$FROM" | sed -e "s/:$FROM/:$TO/" | awk '{print $2}')
echo "Removing redundant libraries"
apt purge $(dpkg -l | grep '^.i.*:'"$FROM" | awk '{print $2}')
echo "Removing $FROM"
dpkg --remove-architecture "$FROM"
apt update