文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>SlackBuild

SlackBuild

时间:2010-04-03  来源:digwtx


#!/bin/sh

print() {
        echo -e "\e[32m $1\e[0m"
}

ARCH=${ARCH:-i686}
BUILD=${BUILD:-1}
PKGTYPE=${PKGTYPE:-txz}

if [ "$ARCH" = "i486" ]; then
        SLKCFLAGS="-O2 -march=i486 -mtune=i686 -pipe"
        LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
        SLKCFLAGS="-O2 -march=i686 -pipe"
        LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
        SLKCFLAGS="-O2 -fPIC"
        LIBDIRSUFFIX="64"
fi

PACKAGE=`basename "$1" | sed -e 's/\(\.tar.*\|\.t[gblx]z.*\|\.zip\|\.egg\)$//' | rev | cut -d- -f2- | rev `
VERSION=`basename "$1" | sed -e 's/\(\.tar.*\|\.t[gblx]z.*\|\.zip\|\.egg\)$//' | rev | cut -d- -f1 | rev `

CWD=$(pwd)
TMP=${TMP:-/tmp/}
PKG=$TMP/package-$PACKAGE
OUTPUT=${OUTPUT:-/tmp}

prepare() {
        print "$PACKAGE $VERSION prepare..."
        set -e
        rm -rf $PKG
        mkdir -p $TMP $PKG $OUTPUT
        cd $TMP
        rm -rf $PACKAGE-$VERSION/
        [ -r `dirname $1`/`basename $1` ] && tar xf `dirname $1`/`basename $1`
        [ -r $CWD/`basename $1` ] && tar xf $CWD/`basename $1`
        [ -r $CWD/`dirname $1`/`basename $1` ] && tar xf $CWD/`dirname $1`/`basename $1`
        cd ./$PACKAGE-$VERSION/

        find . -perm 666 -exec chmod 644 {} \;
        find . -perm 664 -exec chmod 644 {} \;
        find . -perm 600 -exec chmod 644 {} \;
        find . -perm 444 -exec chmod 644 {} \;
        find . -perm 400 -exec chmod 644 {} \;
        find . -perm 440 -exec chmod 644 {} \;
        find . -perm 777 -exec chmod 755 {} \;
        find . -perm 775 -exec chmod 755 {} \;
        find . -perm 511 -exec chmod 755 {} \;
        find . -perm 711 -exec chmod 755 {} \;
        find . -perm 555 -exec chmod 755 {} \;
        chown -R root:root .
}

configure() {
        autoconf() {
                CFLAGS="$SLKCFLAGS" \
                CXXFLAGS="$SLKCFLAGS" \
                ./configure \
                        --prefix=/usr \
                        --libdir=/usr/lib${LIBDIRSUFFIX} \
                        --sysconfdir=/etc \
                        --mandir=/usr/man \
            --infodir=/usr/info
        }
        print "$PACKAGE $VERSION configure..."
        cd $TMP/$PACKAGE-$VERSION/
        if [ -x ./configure ]; then
                print "autoconf..."
                autoconf
        elif [ -x ./autogen.sh ]; then
                print "autogen..."
                ./autogen.sh
                if test ! -r Makefile; then
                        print "./autogen.sh did not run configure, running it now"
                        autoconf
                fi
        else
                echo "Can't not configure the package $PACKAGE!"
        fi
}

build() {
        print "$PACKAGE $VERSION building..."
        cd $TMP/$PACKAGE-$VERSION/
        make || exit 1
        make install DESTDIR=$PKG
}

makepkg() {
    #Strip
    find $PKG | xargs file | grep -e "executable" -e "shared object" \
     | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

    # Compress and link manpages, if any:
    if [ -d $PKG/usr/man ]; then
        ( cd $PKG/usr/man
         find . -type f -exec gzip -9 {} \;
         for i in $(find . -type l) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
        )
    fi
    
    #Compress info pages
    if [ -d $PKG/usr/info ]; then
        rm -f $PKG/usr/info/dir
        gzip -9 $PKG/usr/info/*
    fi

    #Build the Slackware Package
        print "$PACKAGE $VERSION makepkg..."
        cd $PKG
        /sbin/makepkg -l y -c n $OUTPUT/$PACKAGE-$VERSION-$ARCH-$BUILD.$PKGTYPE
        print "Cleaning the temp files..."
        rm -rf $TMP/$PACKAGE-$VERSION/
        rm -rf $PKG
}

######################################

prepare $1 && configure && build && makepkg


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载