Atsutanes kleiner Blog
  • home
  • about me
  • downloads
  • unterseiten
  • feed
  • suche

Tags

archlinux blog empfehlung english event frei hinweis howto netzkultur opensource politik projekte psp rl server software systeme unterhaltung vl

Blogroll

  • af-music
  • AVGP
  • ax86
  • BadBoy_
  • botnetz.com
  • Chaosblog
  • darkerradio
  • Ein Mädchen erobert Linux Mint
  • F.A.L.K.
  • Hanshiro
  • holycrap
  • js Blog
  • Kabarakh
  • Keepaway
  • last.fm
  • latino_heat
  • NoName e.V.
  • Planet Archlinux
  • Planet NoName e.V.
  • Planet Pytal
  • Pytalhost-Suche
  • RadioRock
  • somesay
  • Timothy
  • wemaflo
  • wonder's corner
  • XTaran

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 mkarchchroot $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 mkarchchroot $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 mkarchchroot $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 mkarchchroot $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.

Tags: archlinux english

Trackback: http://atsutane.freethoughts.de/128/shellfunctions-making-the-usage-of-chroots-easier/trackback  :: 0 Kommentare

Kommentare:

keine Kommentare vorhanden

Hinterlasse selbst einen Kommentar:

Was ist die Lösung von sechs minus eins?

Mit * markierte Felder müssen angegeben werden

devbird v0.4.2 :: Design: AkB :: Impressum :: Login