Changeset 41

Show
Ignore:
Timestamp:
05/30/05 01:25:58 (4 years ago)
Author:
athomas
Message:
  • Added some pre-checks before compile so you don't have to wait to fix them.
  • Added Gentoo support.
Files:

Legend:

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

    r40 r41  
    4848# XXXXXXXXXXXXXX Not really user-modifiable below here XXXXXXXXXXXXX 
    4949# 
    50 VERSION="0.1
     50VERSION="0.2
    5151PACKAGER=auto 
    5252SELF=`basename $0` 
     
    106106 
    107107warning() { 
    108         print bold brown "warning -- $*" 
     108        print bold brown "warning -- $*" 1>&2 
    109109} 
    110110 
    111111error() { 
    112         print bold red "error -- $*" 
     112        print bold red "error -- $*" 1>&2 
    113113        exit 1 
    114114} 
     
    124124                export INSTALLWATCH_BACKUP_PATH=$SRCDIR/backup-`date +%Y%m%d%H%M%S-backup` 
    125125        fi 
    126         installwatch -o $INSTALLLOG "$@" || exit $? 
     126        installwatch -o $INSTALLLOG "$@" || error "package installation failed" 
    127127        if [ $BACKUP = 1 -a -d $INSTALLWATCH_BACKUP_PATH ]; then 
    128128                notice "Archiving backup to $INSTALLWATCH_BACKUP_PATH.tar.gz" 
     
    166166        notice "detected configuration files: $configs" 
    167167        notice "detected dependencies: $deps" 
    168         cat <<-EOF > $TMPDIR/PKGBUILD 
     168        cd $TMPDIR 
     169        cat <<-EOF > PKGBUILD 
    169170        pkgname=$PACKAGE 
    170171        pkgver=$PACKAGEVER 
     
    181182        } 
    182183        EOF 
    183         cd $TMPDIR 
    184184        makepkg || error "makepkg failed" 
    185185        cp $TMPDIR/*.pkg.tar.gz $PKGDIR 
     
    187187} 
    188188 
     189packager_pre_gentoo() 
     190{ 
     191        eval `grep ^PORTDIR_OVERLAY /etc/make.conf` 
     192        if [ -z "$PORTDIR_OVERLAY" ]; then 
     193                error "You have not configured a portage overlay directory. Refer to http://gentoo-wiki.com/HOWTO_Installing_3rd_Party_Ebuilds for more information." 
     194        fi 
     195} 
     196 
    189197packager_gentoo() 
    190198{ 
    191         error "Gentoo packager not complete" 
     199        installer make install 
     200        #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` 
     201        ls -d /usr/portage/*/$PACKAGE > /dev/null 2>&1 && error "Package '$PACKAGE' already exists in portage." 
     202        eval `grep ^PORTDIR_OVERLAY /etc/make.conf` 
     203        if [ ! -d "$PORTDIR_OVERLAY" ]; then 
     204                notice "Creating portage overlay directory: $PORTDIR_OVERLAY" 
     205        fi 
     206        mkdir -p $PORTDIR_OVERLAY/app-misc/$PACKAGE 
     207        cd $PORTDIR_OVERLAY/app-misc/$PACKAGE 
     208        local ebuild=$PACKAGE-$PACKAGEVER.ebuild 
     209        info "Generating ebuild: $ebuild" 
     210        cat <<-EOF > $ebuild 
     211        inherit eutils flag-o-matic 
     212        DESCRIPTION="$PACKAGE (automatically packaged by $SELF)" 
     213        HOMEPAGE="Unknown, refer to http://swapoff.org/bpkg for information on packager" 
     214        SRC_URI="" 
     215        LICENSE="UNKNOWN" 
     216        SLOT="0" 
     217        DEPENDS="" 
     218        KEYWORDS="alpha amd64 arm hppa ia64 m68k mips ppc ppc64 ppc-macos s390 sh sparc x86 x86-obsd x86-fbsd" 
     219 
     220        src_unpack() { 
     221                : 
     222        } 
     223 
     224        src_compile() { 
     225                : 
     226        } 
     227 
     228        src_install() { 
     229                test -d $DESTROOT || die "You need to install $PACKAGE with $SELF. Can not be emerged." 
     230                cp -a $DESTROOT/* \${D}/ || die "packaging failed" 
     231        } 
     232        EOF 
     233        info "Integrating package into world" 
     234        ebuild $ebuild digest 
     235        emerge $PACKAGE 
    192236} 
    193237 
     
    200244} 
    201245 
    202 packager_auto() 
     246detect_os() 
    203247{ 
    204248        if [ -r /etc/slackware-version ]; then 
    205                 packager_slackware "$@" 
     249                echo slackware 
    206250        elif [ -r /etc/redhat-release ]; then 
    207                 packager_redhat "$@" 
     251                echo redhat 
    208252        elif [ -r /etc/SuSE-release ]; then 
    209                 packager_suse "$@" 
     253                echo suse 
    210254        elif [ -r /etc/arch-release ]; then 
    211                 packager_arch "$@" 
     255                echo arch 
    212256        elif [ -r /etc/gentoo-release ]; then 
    213                 packager_gentoo "$@" 
     257                echo gentoo 
    214258        else 
    215259                error "could not determine packaging system to use" 
     
    263307 
    264308Available <bpkg-options> are: 
     309  --help 
     310    This help. 
    265311  --version 
    266312    Show $SELF version. 
    267313  --skip-configure 
    268     Do not perform the configure phase of bpkg. Useful for already extracted 
     314    Do not perform the configure phase of bpkg. Useful for already configured 
    269315    source. 
    270316  --packager=arch|slackware|rpm|deb|gentoo|redhat|suse|auto 
     
    272318    default. 
    273319  --package=<name>-<version> 
    274     Override package name and version auto-detection. Sometimes necessary if 
    275     the extracted directory name is not useful. 
     320    Override package name and version auto-detection. By default this is 
     321    obtained by extracting the package name and version from the package 
     322    source directory name. 
    276323  --unique 
    277324    Pass options to autoconf to install into configuration and data directories 
     
    320367        shift 
    321368done 
     369 
     370test $PACKAGER = auto && PACKAGER=`detect_os` 
     371 
     372declare -F | grep " packager_pre_$PACKAGER\$" > /dev/null && eval packager_pre_$PACKAGER 
     373declare -F | grep " packager_$PACKAGER\$" > /dev/null || error "no such function packager_$PACKAGER()" 
    322374 
    323375if [ "$PACKAGE" = "$PACKAGEVER" ]; then 
     
    375427make || error "'make failed'" 
    376428 
    377 declare -F | grep " packager_$PACKAGER\$" > /dev/null || error "no such packager $PACKAGER" 
    378  
    379429eval packager_$PACKAGER 
    380430 
  • bpkg/trunk/Makefile

    r40 r41  
    22PREFIX=/usr 
    33INSTALLWATCH=installwatch-0.6.3 
    4 DIST=bpkg Makefile COPYING $(INSTALLWATCH).tgz 
     4DIST=bpkg Makefile README COPYING $(INSTALLWATCH).tgz 
    55 
    66all: $(INSTALLWATCH) 
     
    88 
    99install: $(INSTALLWATCH) 
     10        mkdir -p $(DESTDIR)$(PREFIX)/bin 
     11        mkdir -p $(DESTDIR)$(PREFIX)/lib 
    1012        install -m755 bpkg $(DESTDIR)$(PREFIX)/bin 
    11         $(MAKE) -C $(INSTALLWATCH) PREFIX=$(PREFIX) install 
     13        $(MAKE) -C $(INSTALLWATCH) PREFIX=$(PREFIX) BINDIR=$(DESTDIR)$(PREFIX)/bin LIBDIR=$(DESTDIR)$(PREFIX)/lib install 
    1214        @cat README 
    1315