Shellfunctions making the usage of chroots easier
Atsutane, 28.12.2009 - 15:16
As ArchLinux user one has to build his packages in chroots in order to make sure, that everything is fine with them and the package will build on other people's machines. ArchLinux provides several scripts which makes this easier with the devtools package. How they are used is described in the DeveloperWiki. So as you can see this is really simple but if you have a real build machine and want to build your packages with different chroots it helps a lot to have a function in your shell configuration, note that I use a x86_64 system, so the last two functions need small modifications to run on an i686 installation.
alias mktesting="mkchr testing64 && mkchr testing32"
alias mkstable="mkchr stable64 && mkchr stable32"
# Update the given chroot/all
function upchr() {
if [ $1 = "all" ]; then
print 'e[1;32mUpdating the e[1;31mstable32e[1;32m chroot.e[0m'
sudo mkarchroot -u /var/chroots/stable32/root/
print 'e[1;32mUpdating the e[1;31mtesting32e[1;32m chroot.e[0m'
sudo mkarchroot -u /var/chroots/testing32/root/
print 'e[1;32mUpdating the e[1;31mstable64e[1;32m chroot.e[0m'
sudo mkarchroot -u /var/chroots/stable64/root/
print 'e[1;32mUpdating the e[1;31mtesting64e[1;32m chroot.e[0m'
sudo mkarchroot -u /var/chroots/testing64/root/
elif [ ! $1 = "" ]; then
print 'e[1;32mUpdating the e[1;31m'$1'e[1;32m chroot.e[0m'
sudo mkarchroot -u /var/chroots/$1/root/
fi
}
# Build the package with the given chroot
function mkchr() {
if [ ! $1 = "" ]; then
print 'e[1;32mBuilding package using the e[1;31m'$1'e[1;32m chroot.e[0m'
sudo makechrootpkg -c -r /var/chroots/$1/
fi
}
# Create a set of stable chroots for both architectures
function create_stable_chroots () {
sudo mkdir -p $1/stable64 $1/stable32
# 64 Bit Chroot
sudo mkarchroot $1/stable64/root base base-devel sudo
sudo $EDITOR $1/stable64/root/etc/pacman.d/mirrorlist
# 32 Bit Chroot
sudo sed -e 's/x86_64/i686/g' $1/stable64/root/etc/pacman.d/mirrorlist > /tmp/mirrorlist
sed -e 's@/etc/pacman.d/mirrorlist@/tmp/mirrorlist@g' $1/stable64/root/etc/pacman.conf > /tmp/pacman.conf
sudo mkarchroot $1/stable32/root base base-devel sudo
echo "Created stable32 and stable64 under ."
}
# Create a set of testing chroots for both architectures
function create_testing_chroots () {
sudo mkdir -p $1/testing64 $1/testing32
# 64 Bit Chroot
sudo mkarchroot $1/testing64/root base base-devel sudo
sudo $EDITOR $1/testing64/root/etc/pacman.conf
sudo $EDITOR $1/testing64/root/etc/pacman.d/mirrorlist
# 32 Bit Chroot
sudo sed -e 's/x86_64/i686/g' $1/testing64/root/etc/pacman.d/mirrorlist > /tmp/mirrorlist
sed -e 's@/etc/pacman.d/mirrorlist@/tmp/mirrorlist@g' $1/testing64/root/etc/pacman.conf > /tmp/pacman.conf
sudo mkarchroot $1/testing32/root base base-devel sudo
sudo $EDITOR $1/testing32/root/etc/pacman.conf
sudo $EDITOR $1/testing32/root/etc/pacman.d/mirrorlist
echo "Created testing32 and testing64 under ."
}
If your shell is not bash compatible, the functions may need small modifications.


Kommentare:
mirabilos - 25.03.2010 - 22:48
sudoedit kennst Du? (Das ruft den Editor als nicht-root auf,
aber die Datei wird als root gelesen und geschrieben, geht
via Temporaries und ist bei sudo von Haus aus mit dabei.)
Hinterlasse selbst einen Kommentar: