Subscribe to the RSS Feed

 

FreeBSD binary package repository howto

For a long time we have been trying to come up with a way to have a binary package repository which is based on heterogeneous package sources. (pkg_add/ports)
After playing with “portupgrade” and “make package” which often failed due to various reasons, it became obvious this method wont be beneficial in long-term.
This howto explains how to create the exact package replica of a jail full of installed packages.



PACKAGEDIR=/packages
mkdir -p $PACKAGEDIR/All
PACKAGELIST=`find /var/db/pkg -type d | awk -F/ {‘print $NF’} | tail -n +2`
for i in $PACKAGELIST; do cd $PACKAGEDIR/All if [ ! -r $i.tbz ]; then echo “Packaging $i” pkg_create -b $i else echo “Packaging $i skipped” fi
done

for i in $PACKAGELIST; do cd $PACKAGEDIR/All ORIGIN=`grep “@comment ORIGIN” /var/db/pkg/$i/+CONTENTS | awk -F: {‘print $2’}` ORIGIN_CAT=`echo $ORIGIN | awk -F/ {‘print $1’}` ORIGIN_PORTNAME=`echo $ORIGIN | awk -F/ {‘print $2’}`

echo “Linking $ORIGIN_CAT/$ORIGIN_PORTNAME” [ -f $PACKAGEDIR/$ORIGIN_CAT/$i.tbz ] && rm $PACKAGEDIR/$ORIGIN_CAT/$i.tbz [ -f $PACKAGEDIR/Latest/$ORIGIN_PORTNAME.tbz ] && rm $PACKAGEDIR/Latest/$ORIGIN_PORTNAME.tbz FINDNAME=`echo $i | sed ‘s/\(.\)\-./\1/’` OLD_TARGETS=`ls 1 | grep -e “$FINDNAME[-]*\.tbz” | grep -v $i` [ ! -d $PACKAGEDIR/$ORIGIN_CAT ] && mkdir -p $PACKAGEDIR/$ORIGIN_CAT [ ! -d $PACKAGEDIR/Latest ] && mkdir -p $PACKAGEDIR/Latest for x in $OLD_TARGETS; do TEMP_ORIGIN_NAME=`tar -xjOf $x “+CONTENTS” | grep “@comment ORIGIN” | awk -F: {‘print $2’} | awk -F/ {‘print $2’}` if [ $ORIGIN_PORTNAME == $TEMP_ORIGIN_NAME ]; then echo “Deleting unneeded target: $x” [ -r $PACKAGEDIR/$ORIGIN_CAT/$x ] && rm $PACKAGEDIR/$ORIGIN_CAT/$x; [ -r $PACKAGEDIR/All/$x ] && rm $PACKAGEDIR/All/$x; fi done cd $PACKAGEDIR/$ORIGIN_CAT && ln -s ../All/$i.tbz $i.tbz cd $PACKAGEDIR/Latest && ln -s ../All/$i.tbz $ORIGIN_PORTNAME.tbz done


Download

Explanation:
The first loop backs up all the installed packages on the system to $PACKAGEDIR/All. Then by going through the packages again the script recreates the symlinks used in FreeBSD packaging. It also checks for package files with different versions (but same origin) and deletes those which are not installed.
Example #1:
A common roll-back scenario

mysql-server-5.1.43.tbz [installed]
mysql-server-5.1.45.tbz
To be deleted: mysql-server-5.1.45.tbz

Example #2:
Packages with different versions that can co-exist on the same system

ruby-1.8.7.248,1 [installed]
ruby-1.9.1.376_1,1 [installed]
To be deleted: none

The script checks for package origins and by determining that lang/ruby18 is different from lang/ruby19 both packages remain untouched and included to the repository.

Known bugs: Does not check for deleted packages. It’s better to recreate the whole repository after a big portupgrade anyway.

Posted 2010/03/23 23:10 by jos


Comments

  1. Jan 31, 07:51 PM

    ldvpskw Says:

    dslDow <a href=“http://zanthlayiyai.com/”>zanthlayiyai</a>, [url=http://dgwcbchvxnqo.com/]dgwcbchvxnqo[/url], [link=http://vvwzoglsadke.com/]vvwzoglsadke[/link], http://qcqonrwoskjx.com/

  2. Feb 7, 12:11 PM

    adrian ilarion ciobanu Says:

    “cleanup test operator fix”: http://slwdc.shrd.net/f/bsdbased_com_pkg_repo_fix_cleanup_test_operator.diff

    this textile thing doesn’t seem to do what it says :)

  3. Feb 16, 12:26 PM

    ozblwhlbre Says:

    x847Kt <a href=“http://lheiasisrqei.com/”>lheiasisrqei</a>, [url=http://uaxvnmftehwu.com/]uaxvnmftehwu[/url], [link=http://hbfqwjsrtoem.com/]hbfqwjsrtoem[/link], http://guetehizhtbj.com/

  4. May 11, 03:57 AM

    cheap Montblanc pens Says:

    This article is very good, very appealing. Affects every reader chord, hoping to share with you the exchange. Thank articles.

  5. May 11, 04:29 AM

    Day Date II swiss watches Says:

    This article is very good, very appealing. Affects every reader chord, hoping to share with you the exchange. Thank articles.

  6. May 17, 05:10 AM

    knockoff Fendi watches Says:

    This article is good, very good, let I learned a lot from ~ you don’t miss, hurry to join!

  7. May 19, 03:48 AM

    Hublot wristwatch replicas Says:

    Articles are moving every reader with heart, and full of appeal. Let us have to admire, thank your article!

  8. Mar 10, 08:41 AM

    crystal case for iphone 4 Says:

    You really surpassed visitors’ expected results. Thanks for rendering such informative, safe, educational and in addition fun tips on your topic to Julie.

  9. Oct 11, 10:55 AM

    time for a smile Says:

    Wow, awesome blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site
    is wonderful, as well as the content!

Leave a Comment

Add your comment. Preview then Submit.


Hidden


Textile Help