Changeset 58

Show
Ignore:
Timestamp:
02/16/2006 09:23:46 PM (2 years ago)
Author:
athomas
Message:
  • Added CPAN support: bpkg cpan://Some::Cool::Module
  • Perl and Python packages automatically have perl- or python prepended to their name if they do not already.
  • You can now specify the package description with --description=foo
  • Attempt to extract Perl module version from Makefile.PL
  • Added a build_post_<builder> phase. This is currently used by the Perl builder to copy the contents of the .packlist into the package root.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bpkg/trunk/bpkg

    r57 r58  
    7070EXPLICIT_PACKAGE=0 
    7171REQUIRED_PROGRAMS='installwatch cpio perl tar bzip2 unzip gzip' 
     72DESCRIPTION="Automatically generated by $SELF" 
    7273MD5SUM='none' 
    7374 
     
    203204} 
    204205 
     206build_pre_python() 
     207{ 
     208        if [ $EXPLICIT_PACKAGE = 0 -] && [[ $PACKAGE != py* ]]; then 
     209                PACKAGE=python-$PACKAGE 
     210        fi 
     211} 
     212 
    205213build_python() 
    206214{ 
    207215        python setup.py build -f 
     216} 
     217 
     218build_pre_perl() 
     219{ 
     220        if [ $EXPLICIT_PACKAGE = 0 ] && [[ $PACKAGE != perl* ]]; then 
     221                PACKAGE=perl-$PACKAGE 
     222        fi 
     223} 
     224 
     225build_post_perl() 
     226{ 
     227        notice "Adding Perl packlist contents to package manifest" 
     228        cat `find "$DESTROOT" -name .packlist` | duplicate_paths "$DESTROOT" 
    208229} 
    209230 
     
    228249packager_slackware() 
    229250{ 
    230         installer 
    231251        cd $DESTROOT 
    232252        local out=$PKGDIR/$PACKAGE-$PACKAGEVER-i386-$PACKAGEREL.tgz 
     
    249269{ 
    250270        pacman -Q "$PACKAGE" > /dev/null 2>&1 && error "package '$PACKAGE' already installed, remove it before packaging" 
     271        if echo "$PACKAGEVER" | grep -q -- -; then 
     272                PACKAGEVER=${PACKAGEVER//-/_} 
     273        fi 
    251274} 
    252275 
    253276packager_arch() 
    254277{ 
    255         installer 
    256278        local configs=`(cd $DESTROOT && find etc -type f) 2> /dev/null` 
    257279        local deps=`(cd $DESTROOT && find . -type f | xargs --no-run-if-empty file | grep 'ELF.*executable' | cut -d: -f1 | xargs --no-run-if-empty ldd 2> /dev/null | awk '{print $3}' | grep ^/ | xargs --no-run-if-empty pacman -Qo 2> /dev/null | awk '{print $5}' | sort | uniq) 2> /dev/null` 
     
    263285        pkgver=$PACKAGEVER 
    264286        pkgrel=$PACKAGEREL 
    265         pkgdesc="Automatically generated by $SELF
     287        pkgdesc="$DESCRIPTION
    266288        url="http://swapoff.org/$SELF" 
    267289        depends=($deps) 
     
    290312packager_gentoo() 
    291313{ 
    292         installer 
    293314        #local deps=`(cd $DESTROOT && find . -type f | xargs --no-run-if-empty file | grep 'ELF.*executable' | cut -d: -f1 | xargs --no-run-if-empty ldd 2> /dev/null | awk '{print $3}' | grep ^/ | xargs --no-run-if-empty pacman -Qo 2> /dev/null | awk '{print $5}' | sort | uniq) 2> /dev/null` 
    294315        ls -d /usr/portage/*/$PACKAGE > /dev/null 2>&1 && error "Package '$PACKAGE' already exists in portage." 
     
    376397quitloop=0 
    377398while [ $quitloop = 0 -a $# != 0 ]; do 
    378         if [[ -f "$1" || "$1" = ftp://* || "$1" = http://* ]]; then 
    379                 AUTOEXTRACT="$1" 
     399        TARGET="$1" 
     400        if [[ "$TARGET" = cpan://* ]]; then 
     401                CPAN_MODULE=`basename "$TARGET"` 
     402                notice "Attempting to download CPAN module $CPAN_MODULE" 
     403                TARGET=`perl -MCPAN -e "get '$CPAN_MODULE'" | grep Checksum | awk '{print $3}'` 
     404                test -f "$TARGET" || error "failed to fetch $CPAN_MODULE from CPAN, try 'perl -MCPAN -e \"get '$CPAN_MODULE'\"" 
     405                PACKAGE=`echo "$CPAN_MODULE" | sed -e 's/:\\+/-/g' | tr A-Z a-z` 
     406                if [[ $PACKAGE != perl-* ]]; then 
     407                        PACKAGE=perl-$PACKAGE 
     408                fi 
     409                PACKAGEVER=`perl -MCPAN -e "print CPAN::Shell->m(\"$CPAN_MODULE\")" | grep CPAN_VERSION | awk '{print $2}'` 
     410                EXPLICIT_PACKAGE=1 
     411        fi 
     412 
     413        if [[ -f "$TARGET" || "$TARGET" = ftp://* || "$TARGET" = http://* ]]; then 
     414                AUTOEXTRACT="$TARGET" 
    380415                if [[ "$AUTOEXTRACT" == *bz2 || "$AUTOEXTRACT" == *tbz ]]; then 
    381416                        FLAGS=j 
     
    424459                fi 
    425460        else 
    426                 case $1 in 
     461                case $TARGET in 
    427462                        --version) 
    428463                                echo $VERSION 
     
    457492    obtained by extracting the package name and version from the package 
    458493    source directory name. 
     494  --description=<description> 
     495    Specify a package description. Default is 'Automatically generated by 
     496    bpkg'. 
    459497  --unique 
    460498    Pass options to autoconf to install into configuration and data directories 
     
    471509    Verify that the source file has the given MD5 checksum. 
    472510 
    473 For further information, including examples, visit http://swapoff.org/bpkg 
     511For further information including examples, visit http://swapoff.org/bpkg 
    474512EOF 
    475513                                exit 0 
    476514                        ;; 
     515                        --description=*) 
     516                                DESCRIPTION=`echo "$TARGET" | cut -d= -f2-` 
     517                        ;; 
    477518                        --install-with=*) 
    478                                 INSTALLER=`echo "$1" | cut -d= -f2-` 
     519                                INSTALLER=`echo "$TARGET" | cut -d= -f2-` 
    479520                        ;; 
    480521                        --build-with=*) 
    481                                 CUSTOMBUILDER=`echo "$1" | cut -d= -f2-` 
     522                                CUSTOMBUILDER=`echo "$TARGET" | cut -d= -f2-` 
    482523                                BUILDER=custom 
    483524                        ;; 
     
    486527                        ;; 
    487528                        --prefix=*) 
    488                                 PREFIX=`echo $1 | cut -d= -f2-` 
     529                                PREFIX=`echo $TARGET | cut -d= -f2-` 
    489530                        ;; 
    490531                        --sysconfdir=*) 
    491                                 SYSCONFDIR=`echo $1 | cut -d= -f2-` 
     532                                SYSCONFDIR=`echo $TARGET | cut -d= -f2-` 
    492533                        ;; 
    493534                        --localstatedir=*) 
    494                                 LOCALSTATEDIR=`echo $1 | cut -d= -f2-` 
     535                                LOCALSTATEDIR=`echo $TARGET | cut -d= -f2-` 
    495536                        ;; 
    496537                        --datadir=*) 
    497                                 DATADIR=`echo $1 | cut -d= -f2-` 
     538                                DATADIR=`echo $TARGET | cut -d= -f2-` 
    498539                        ;; 
    499540                        --unique) 
     
    504545                        ;; 
    505546                        --package=*) 
    506                                 PACKAGE=`echo "$1" | cut -d= -f2- | rev | cut -d- -f2- | rev` 
    507                                 PACKAGEVER=`echo "$1" | cut -d= -f2- | rev | cut -d- -f1 | rev` 
     547                                PACKAGE=`echo "$TARGET" | cut -d= -f2- | rev | cut -d- -f2- | rev` 
     548                                PACKAGEVER=`echo "$TARGET" | cut -d= -f2- | rev | cut -d- -f1 | rev` 
    508549                                EXPLICIT_PACKAGE=1 
    509550                        ;; 
    510551                        --packager=*) 
    511                                 PACKAGER=`echo $1 | cut -d= -f2-` 
     552                                PACKAGER=`echo $TARGET | cut -d= -f2-` 
    512553                        ;; 
    513554                        --md5=*) 
    514                                 MD5SUM=`echo $1 | cut -d= -f2-` 
     555                                MD5SUM=`echo $TARGET | cut -d= -f2-` 
    515556                        ;; 
    516557                        *) 
     
    526567 
    527568if [ $EXPLICIT_PACKAGE = 0 ]; then 
    528         # Always use Python distutils data if available 
     569        # Use Python distutils data if available 
    529570        if [ -r setup.py ]; then 
    530                 PACKAGE=`python setup.py --name | tr A-Z a-z` 
    531                 PACKAGEVER=`python setup.py --version` 
     571                if [[ $PACKAGE != py* ]]; then 
     572                        PACKAGE=`python setup.py --name | tail -1 | tr A-Z a-z` 
     573                fi 
     574                PACKAGEVER=`python setup.py --version | tail -1` 
     575        fi 
     576        # Use MakeMaker data if available 
     577        if [ -r Makefile.PL ]; then 
     578                OLDVER=$PACKAGEVER 
     579                PACKAGEVER=`PERL_MM_USE_DEFAULT=1 perl -e 'do "Makefile.PL"; print $VERSION' | tail -1` 
     580                if [[ $PACKAGEVER != [0-9]*.* ]]; then 
     581                        PACKAGEVER=$OLDVER 
     582                fi 
    532583        fi 
    533584        if [ "_$PACKAGE" = "_$PACKAGEVER" ]; then 
     
    544595        elif [ -x autogen.sh ]; then 
    545596                BUILDER=autogen 
     597        elif [ -r Makefile.PL ]; then 
     598                BUILDER=perl 
    546599        elif [ -r Imakefile ]; then 
    547600                BUILDER=xmkmf 
     
    554607                BUILDER=python 
    555608                INSTALLER='python setup.py install -f' 
    556         elif [ -r Makefile.PL ]; then 
    557                 BUILDER=perl 
    558609        elif [ -r $PACKAGE.pro ]; then 
    559610                BUILDER=qmake 
     
    563614fi 
    564615 
     616declare -F build_pre_$BUILDER > /dev/null && eval build_pre_$BUILDER 
     617 
     618declare -F packager_pre_$PACKAGER > /dev/null && eval packager_pre_$PACKAGER 
     619declare -F packager_$PACKAGER > /dev/null || error "no such function packager_$PACKAGER()" 
     620 
    565621if [ $SKIPBUILD = 0 ]; then 
     622        notice "Running $BUILDER builder" 
    566623        eval build_$BUILDER || error "build failed" 
    567624fi 
    568625 
     626notice "Installing package" 
     627installer 
     628 
     629declare -F build_post_$BUILDER > /dev/null && eval build_post_$BUILDER 
     630 
     631notice "Running $PACKAGER packager" 
    569632eval packager_$PACKAGER 
    570633