Changeset 48

Show
Ignore:
Timestamp:
07/19/05 04:46:11 (3 years ago)
Author:
athomas
Message:
  • Now handles zip files
  • Fixed issue with Python packages
Files:

Legend:

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

    r46 r48  
    3636SKIPCONFIGURE=0 
    3737# Program used to download source 
    38 DOWNLOADER='wget -nv -c' 
     38DOWNLOADER='wget -c' 
    3939# Attempt to automatically download and extract source files given on the 
    4040# command line? 
     
    4545IGNOREPATHS="/tmp /dev /root /usr/src" 
    4646 
     47# Load system config 
     48test -r /etc/bpkg.conf && . /etc/bpkg.conf 
     49 
    4750# 
    4851# XXXXXXXXXXXXXX Not really user-modifiable below here XXXXXXXXXXXXX 
    4952# 
    50 VERSION="0.2
     53VERSION="0.3
    5154PACKAGER=auto 
    5255SELF=`basename $0` 
     
    6164TMPFILES="$TMPDIR $DESTROOT $INSTALLLOG" 
    6265MAKEINSTALL='make install' 
     66EXPLICIT_PACKAGE=0 
     67REQUIRED_PROGRAMS='installwatch cpio perl tar bzip2 gzip' 
    6368 
    6469colour() 
     
    112117} 
    113118 
     119# duplicate_paths <destination> 
     120#  Duplicate permissions for a list of files read from stdin and place them 
     121#  at <destination>. 
     122duplicate_paths() { 
     123        while read file; do 
     124                echo "$file" | perl -ne 'print "/\n"; $out = ""; chomp($_); for $v (split("/", $_)) { next if not $v; print "$out/$v\n"; $out = "$out/$v"; }' 
     125        done | sort | uniq | cpio -pdm "$1" > /dev/null 
     126} 
     127 
    114128# usage: installer 
    115129installer() 
    116130{ 
    117131        umask 022 
    118         which installwatch > /dev/null 2>&1 || error "installwatch is required by $SELF" 
    119132        unset INSTALLWATCH_BACKUP_PATH 
    120133        if [ $BACKUP = 1 ]; then 
     
    132145        cat $INSTALLLOG | awk '{print $3 "\n" $4}' | egrep -v "^(${IGNOREPATHS// /|}|$SRCDIR)" | sort | uniq | while read FILE; do 
    133146                if [ -e "$FILE" -a ! -d "$FILE" ]; then 
    134                         mkdir -p "$DESTROOT/`dirname $FILE`" 
    135                         cp -a "$FILE" "$DESTROOT/`dirname $FILE`" 
    136                 fi 
    137         done 
     147                        echo "$FILE" 
     148                fi 
     149        done | duplicate_paths "$DESTROOT" 
    138150        test `find $DESTROOT -type f | wc -l` = 0 && error "No files installed. This could mean the source is already installed." 
    139151} 
     
    267279} 
    268280 
     281# Look for programs we require 
     282for x in $REQUIRED_PROGRAMS; do 
     283        which $x > /dev/null 2>&1 || error "required program '$x' not found" 
     284done 
     285 
    269286# Make sure some default directories exist 
    270287mkdir -p "$TMPDIR" 
     
    278295quitloop=0 
    279296while [ $quitloop = 0 -a $# != 0 ]; do 
     297#       if [[ "$1" = cpan://* ]]; then 
     298#               CPAN="${1#cpan://}" 
     299#               PACKAGE=perl-`echo ${CPAN/::/-} | tr A-Z a-z` 
     300#               notice "Pre-installing Perl module before packaging" 
     301#               perl -MCPAN -e "install '$CPAN'" || error "CPAN install failed" 
     302#               PACKAGEVER=`perl -MExtUtils::Installed -e "print ExtUtils::Installed->new()->version('$CPAN')" 2> /dev/null` 
     303#               CPANTMP="/tmp/$SELF.$PACKAGE.$$.cpan" 
     304#               TMPFILES="$TMPFILES $CPANTMP" 
     305#               mkdir -p $CPANTMP 
     306#               cd "$CPANTMP" 
     307#               SRCDIR=$PWD 
     308#               test -z "$PACKAGEVER" && error "could not determine version of Perl module $CPAN" 
     309#               perl -MExtUtils::Installed -e "print join(\"\n\", ExtUtils::Installed->new()->files('$CPAN')) . \"\n\"" | duplicate_paths "$CPANTMP" || error "failed to extract PERL module content list" 
     310#               cat <<EOF > Makefile 
     311#all: 
     312# 
     313#install: 
     314#       find ./ | cpio -pdm / 
     315#       rm -f /Makefile 
     316#EOF 
     317#               notice "packaging perl module $CPAN as $PACKAGE-$PACKAGEVER" 
    280318        if [[ -f "$1" || "$1" = ftp://* || "$1" = http://* ]]; then 
    281319                AUTOEXTRACT="$1" 
     
    286324                elif [[ "$AUTOEXTRACT" == *Z ]]; then 
    287325                        FLAGS=z 
     326                elif [[ "$AUTOEXTRACT" == *zip ]]; then 
     327                        FLAGS=zip 
    288328                else 
    289329                        error "unknown archive format for '$AUTOEXTRACT'" 
     
    296336                fi 
    297337                notice "uncompressing package '$AUTOEXTRACT'" 
    298                 tar xf$FLAGS "$AUTOEXTRACT" || error "failed to auto-extract '$AUTOEXTRACT'" 
    299                 BUILDDIR=`tar tf$FLAGS "$AUTOEXTRACT" | cut -d/ -f1 | head -1` 
     338                if [ $FLAGS = zip ]; then 
     339                        unzip "$AUTOEXTRACT" || error "failed to auto-extract '$AUTOEXTRACT'" 
     340                        BUILDDIR=`unzip -lqq | awk '{print $NF}' | cut -d/ -f1 | head -1` 
     341                else 
     342                        tar xf$FLAGS "$AUTOEXTRACT" || error "failed to auto-extract '$AUTOEXTRACT'" 
     343                        BUILDDIR=`tar tf$FLAGS "$AUTOEXTRACT" | cut -d/ -f1 | head -1` 
     344                fi 
    300345                notice "package uncompressed, moving into build directory '$BUILDDIR'" 
    301346                cd "$BUILDDIR" 
    302347                SRCDIR=$PWD 
    303                 PACKAGE=`basename "$PWD" | rev | cut -d- -f2- | rev | tr A-Z a-z` 
    304                 PACKAGEVER=`basename "$PWD" | rev | cut -d- -f1 | rev | tr A-Z a-z` 
     348                if [ $EXPLICIT_PACKAGE = 0 ]; then 
     349                        PACKAGE=`basename "$PWD" | rev | cut -d- -f2- | rev | tr A-Z a-z` 
     350                        PACKAGEVER=`basename "$PWD" | rev | cut -d- -f1 | rev | tr A-Z a-z` 
     351                        if [ "_$PACKAGE" = "_$PACKAGEVER" ]; then 
     352                                notice "Using source tarball for package name and version" 
     353                                PACKAGE=`basename "$AUTOEXTRACT" | sed -e 's/\(\.tar.*\|\.t[gb]z.*\)$//' | rev | cut -d- -f2- | rev | tr A-Z a-z` 
     354                                PACKAGEVER=`basename "$AUTOEXTRACT" | sed -e 's/\(\.tar.*\|\.t[gb]z.*\)$//' | rev | cut -d- -f1 | rev | tr A-Z a-z` 
     355                        fi 
     356                fi 
    305357        else 
    306358                case $1 in 
     
    379431                                PACKAGE=`echo "$1" | cut -d= -f2- | rev | cut -d- -f2- | rev` 
    380432                                PACKAGEVER=`echo "$1" | cut -d= -f2- | rev | cut -d- -f1 | rev` 
     433                                EXPLICIT_PACKAGE=1 
    381434                        ;; 
    382435                        --packager=*) 
     
    432485                notice "generating stub Makefile for python" 
    433486                cat <<EOF > Makefile 
    434 DESTDIR=/ 
    435  
    436487build: 
    437488        python setup.py build 
    438489 
    439490install: 
    440         python setup.py install -f --root=\$(DESTDIR) 
     491        python setup.py install -f 
    441492EOF 
    442493        elif [ -r Makefile.PL ]; then 
  • bpkg/trunk/Makefile

    r47 r48  
    2323install-raw: all $(OS)-install 
    2424        mkdir -p $(DESTDIR)$(PREFIX)/bin 
    25         mkdir -p $(DESTDIR)$(PREFIX)/lib 
    2625        install -m755 bpkg $(DESTDIR)$(PREFIX)/bin 
    2726        @cat README