You are not logged in.

#1 2009-05-03 09:36:13

xaff
Member
Registered: 2009-02-26
Posts: 64

Script to rebuild all installed packages from ABS

I realize pacbuilder is for that, but it doesn't seem to work properly for me. Skipping a lot of packages etc.

Anyway, I've made this very simple script to just rebuild every installed package from core/extra/community. Sorry for the localized echo output, but I think it's all very simple and straightforward to understand.

Edit:
I've improved it a bit, now it should work flawlessly and remember what stuff it has to finish no matter when you ^C out of it. Also it installs all compiled packages, if you want to avoid that, remove -i switch from makepkg.

#!/bin/sh

# user configuration
absdir="/home/mateusz/abs/autobuild"
pkgdir="/home/mateusz/abs/packages"
pkgfile="/home/mateusz/abs/autobuild.list"
# end of user configuration

topabs="/var/abs"

if [ ! -d $absdir ]; then
        mkdir -pv $absdir
fi

if [ ! -d $pkgdir ]; then
        mkdir -pv $pkgdir
fi

echo "(autobuild) Uaktualnianie bazy abs..."
sudo abs

if [ ! -f $pkgfile ]; then
        echo "(autobuild) Tworzę listę pakietów do zbudowania..."
        pacman -Qq > $pkgfile
else
        echo "(autobuild) Znaleziono poprzedni build."
        echo "(autobuild) Jeżeli nie chcesz go wykorzystać, skasuj $pkgfile"
fi

for pkgname in $(cat $pkgfile); do
        echo "(autobuild) Szukanie pakietu $pkgname..."
        find $topabs -type d -name "$pkgname" -exec cp -R {} $absdir \; 2> /dev/null
        if [ -d "$absdir/$pkgname" ]; then
                echo "(autobuild) Budowanie pakietu $pkgname..."
                cd "$absdir/$pkgname"
                makepkg -csir --noconfirm > /dev/null
                if [ $? -eq 0 ]; then
                        echo "(autobuild) Pakiet zbudowany."
                        cat $pkgfile | grep -vx $pkgname > "$pkgfile.tmp"
                        mv $pkgfile.tmp $pkgfile
                else
                        echo "(autobuild) Błąd budowania pakietu!"
                fi
        else
                echo "(autobuild) Pakiet nieodnaleziony!"
                cat $pkgfile | grep -vx $pkgname > "$pkgfile.tmp"
                mv $pkgfile.tmp $pkgfile
        fi
done

echo "(autobuild) Linkowanie pakietów do $pkgdir..."
find $absdir -name "*`uname -m`.pkg.tar.gz" -exec ln -v {} $pkgdir \; >/dev/null

echo "(autobuild) Zakończono."
exit 0

Last edited by xaff (2009-05-03 13:47:17)

Offline

#2 2009-05-17 13:41:59

smartboyathome
Member
From: $HOME
Registered: 2007-12-23
Posts: 334
Website

Re: Script to rebuild all installed packages from ABS

Here is the script translated into English (with a bit of help from Google Translate, as well as grammar cleanup).

#!/bin/sh

# user configuration
absdir="/home/aabbott/abs/autobuild"
pkgdir="/home/aabbott/abs/packages"
pkgfile="/home/aabbott/abs/autobuild.list"
# end of user configuration

topabs="/var/abs"

if [ ! -d $absdir ]; then
        mkdir -pv $absdir
fi

if [ ! -d $pkgdir ]; then
        mkdir -pv $pkgdir
fi

echo "(autobuild) Updating the ABS database..."
sudo abs

if [ ! -f $pkgfile ]; then
        echo "(autobuild) Creating a list of packages to build..."
        pacman -Qq > $pkgfile
else
        echo "(autobuild) Found a previous build."
        echo "(autobuild) If you don't want to use this build, delete ${pkgfile}."
fi

for pkgname in $(cat $pkgfile); do
        echo "(autobuild) Searching for $pkgname..."
        find $topabs -type d -name "$pkgname" -exec cp -R {} $absdir \; 2> /dev/null
        if [ -d "$absdir/$pkgname" ]; then
                echo "(autobuild) Building $pkgname..."
                cd "$absdir/$pkgname"
                makepkg -csir --noconfirm > /dev/null
                if [ $? -eq 0 ]; then
                        echo "(autobuild) $pkgname built."
                        cat $pkgfile | grep -vx $pkgname > "$pkgfile.tmp"
                        mv $pkgfile.tmp $pkgfile
                else
                        echo "(autobuild) There was an error when building ${pkgname}!"
                fi
        else
                echo "(autobuild) $pkgname not found!"
                cat $pkgfile | grep -vx $pkgname > "$pkgfile.tmp"
                mv $pkgfile.tmp $pkgfile
        fi
done

echo "(autobuild) Linking to $pkgdir..."
find $absdir -name "*`uname -m`.pkg.tar.gz" -exec ln -v {} $pkgdir \; >/dev/null

echo "(autobuild) Finished."
exit 0

Offline

#3 2009-05-21 21:41:21

lamegaptop
Member
From: Orlando
Registered: 2009-05-10
Posts: 33

Re: Script to rebuild all installed packages from ABS

This worked fine for me on a fresh 64 bit install with gnome DE. After changing the 3 directories in front to suit my needs and setting up sudo for no password on pacman I kicked the script off and let her run overnight. In the morning all went well and  I can feel the difference that a custom compiled install can make. Smooth and snappy.

Thanks for this handy tool. Now to figure out an effortless way to keep this box updated with ABS......


Don't break the silence unless you can improve upon it.

Offline

#4 2009-05-24 12:20:44

Mikko777
Member
From: Suomi, Finland
Registered: 2006-10-30
Posts: 837

Re: Script to rebuild all installed packages from ABS

Nice script, works well smile

What I did is I ran this script once to recompile all packages.

And now I use yaourt -Sybu --devel --aur --noconfirm to install new packages.

No need for pacbuilder smile

and ofc cflags:

CFLAGS="-march=x86-64 -mtune=native -Os -msse3 -floop-interchange -floop-strip-mine -floop-block -pipe"

and makes more difference on "crappy" server:

CFLAGS="-march=native -Os -floop-interchange -floop-strip-mine -floop-block -pipe"

Offline

Board footer

Powered by FluxBB