All pastes #1046584 Raw Edit

newpkg 1.0

public c v1 · immutable
#1046584 ·published 2008-06-13 00:18 UTC
rendered paste body
#!/bin/bash# vim: set ts=8 fdm=marker :BASEDIR="${HOME}/builds"PROTODIR='/usr/share/pacman'#### Lines below this point should not need to be edited.##MYVERSION=1.0DOCOPYINSTALL=0 # Copy the .install fileDOCOPYRC=0 # Copy the prototype rc.d scriptDOFORCE=0 # Overwrite existing filesPROTO_PKGBUILD="${PROTODIR}/PKGBUILD.proto"PROTO_INSTALL="${PROTODIR}/proto.install"PROTO_RC="${PROTODIR}/rc-script.proto"# {{{ usage()function usage {        cat << _USAGE$(basename $0) version $MYVERSION -- A script to speed up creating new PKGBUILDsUsage: $(basename $0) [options] PKGNAMEOptions:        -h --help           - Print this usage        -f --force          - Overwrite existing files in the target dir        -i --proto-install  - Copy the prototype .install file        --rc                - Copy the protype for an rc.d script        --cvs               - Copy the prototype for a cvs PKGBUILD        --darcs             - Copy the prototype for a darcs PKGBUILD        --git               - Copy the prototype for a git PKGBUILD        --svn               - Copy the prototype for a svn PKGBUILD_USAGE        exit 0}# }}}# {{{  die() warn() quit() msg()function die {        warn "${1:-Unknown error}"        quit ${2:-1}}function warn {        if [ -n "$1" ]; then                echo "$1" 1>&2        fi}function quit {        exit ${1:-0}}function msg {        echo "$1"}# }}}if [ -z "$1" ]; then        usagefiwhile [ "$#" -ne 0 ]; do        case $1 in                -h|--help)                         usage                        ;;                -i|--proto-install)                             DOCOPYINSTALL=1                        ;;                -f|--force)                        DOFORCE=1                        ;;                --cvs)                        PROTO_PKGBUILD='PKGBUILD-cvs.proto'                        ;;                --darcs)                        PROTO_PKGBUILD='PKGBUILD-darcs.proto'                        ;;                --git)                        PROTO_PKGBUILD='PKGBUILD-git.proto'                        ;;                --svn)                        PROTO_PKGBUILD='PKGBUILD-svn.proto'                        ;;                --rc)                        DOCOPYRC=1                        ;;                *)                              pkgname=$(echo $1 | sed 's/ //g') # Remove spaces from the name                        ;;        esac        shiftdonepkgdir="${BASEDIR}/${pkgname}"if [ -d "$pkgdir" ]; then        if [ "$DOFORCE" -eq 1 ]; then                warn "$pkgname already exists in $BASEDIR -- continuing anyway!"        else                die "$pkgname already exists in $BASEDIR -- aborting"        fielse        mkdir -p "$pkgdir"        msg "Creating package dir for $pkgname"ficd "$pkgdir"if [ -r "$PROTO_PKGBUILD" ]; then        msg "Copying prototype PKGBUILD"        cp "$PROTO_PKGBUILD" ./PKGBUILD        sed -i "s#^pkgname=.*#pkgname=$pkgname#" PKGBUILDelse        warn "Could not find prototype PKGBUILD"fiif [ "$DOCOPYINSTALL" -eq 1 ]; then        if [ -r "$PROTO_INSTALL" ]; then                 msg "Copying prototype .install file"                cp "$PROTO_INSTALL" "./${pkgname}.install"                sed -i "s#^install=.*#install='${pkgname}.install'#" PKGBUILD        else                warn "Could not find prototype .install"        fifiif [ "$DOCOPYRC" -eq 1 ]; then        if [ -r "$PROTO_RC" ]; then                 msg "Copying prototype r#!/bin/bash# vim: set ts=8 fdm=marker :BASEDIR="${HOME}/builds"PROTODIR='/usr/share/pacman'#### Lines below this point should not need to be edited.##MYVERSION=1.0DOCOPYINSTALL=0 # Copy the .install fileDOCOPYRC=0 # Copy the prototype rc.d scriptDOFORCE=0 # Overwrite existing filesPROTO_PKGBUILD="${PROTODIR}/PKGBUILD.proto"PROTO_INSTALL="${PROTODIR}/proto.install"PROTO_RC="${PROTODIR}/rc-script.proto"# {{{ usage()function usage {        cat << _USAGE$(basename $0) version $MYVERSION -- A script to speed up creating new PKGBUILDsUsage: $(basename $0) [options] PKGNAMEOptions:        -h --help           - Print this usage        -f --force          - Overwrite existing files in the target dir        -i --proto-install  - Copy the prototype .install file        --rc                - Copy the protype for an rc.d script        --cvs               - Copy the prototype for a cvs PKGBUILD        --darcs             - Copy the prototype for a darcs PKGBUILD        --git               - Copy the prototype for a git PKGBUILD        --svn               - Copy the prototype for a svn PKGBUILD_USAGE        exit 0}# }}}# {{{  die() warn() quit() msg()function die {        warn "${1:-Unknown error}"        quit ${2:-1}}function warn {        if [ -n "$1" ]; then                echo "$1" 1>&2        fi}function quit {        exit ${1:-0}}function msg {        echo "$1"}# }}}if [ -z "$1" ]; then        usagefiwhile [ "$#" -ne 0 ]; do        case $1 in                -h|--help)                         usage                        ;;                -i|--proto-install)                             DOCOPYINSTALL=1                        ;;                -f|--force)                        DOFORCE=1                        ;;                --cvs)                        PROTO_PKGBUILD='PKGBUILD-cvs.proto'                        ;;                --darcs)                        PROTO_PKGBUILD='PKGBUILD-darcs.proto'                        ;;                --git)                        PROTO_PKGBUILD='PKGBUILD-git.proto'                        ;;                --svn)                        PROTO_PKGBUILD='PKGBUILD-svn.proto'                        ;;                --rc)                        DOCOPYRC=1                        ;;                *)                              pkgname=$(echo $1 | sed 's/ //g') # Remove spaces from the name                        ;;        esac        shiftdonepkgdir="${BASEDIR}/${pkgname}"if [ -d "$pkgdir" ]; then        if [ "$DOFORCE" -eq 1 ]; then                warn "$pkgname already exists in $BASEDIR -- continuing anyway!"        else                die "$pkgname already exists in $BASEDIR -- aborting"        fielse        mkdir -p "$pkgdir"        msg "Creating package dir for $pkgname"ficd "$pkgdir"if [ -r "$PROTO_PKGBUILD" ]; then        msg "Copying prototype PKGBUILD"        cp "$PROTO_PKGBUILD" ./PKGBUILD        sed -i "s#^pkgname=.*#pkgname=$pkgname#" PKGBUILDelse        warn "Could not find prototype PKGBUILD"fiif [ "$DOCOPYINSTALL" -eq 1 ]; then        if [ -r "$PROTO_INSTALL" ]; then                 msg "Copying prototype .install file"                cp "$PROTO_INSTALL" "./${pkgname}.install"                sed -i "s#^install=.*#install='${pkgname}.install'#" PKGBUILD        else                warn "Could not find prototype .install"        fifiif [ "$DOCOPYRC" -eq 1 ]; then        if [ -r "$PROTO_RC" ]; then                 msg "Copying prototype rc.d script"                cp "$PROTO_RC" "./${pkgname}"                sed -i "s#^source=(\(.*\))#source=(\1 $pkgname)#" PKGBUILD        else                warn "Could not find prototype rc.d script"        fifimsg "All done! New package prepared in $pkgdir"quit 0c.d script"                cp "$PROTO_RC" "./${pkgname}"                sed -i "s#^source=(\(.*\))#source=(\1 $pkgname)#" PKGBUILD        else                warn "Could not find prototype rc.d script"        fifimsg "All done! New package prepared in $pkgdir"quit 0