X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from tux29.hoststar.ch (tux29.hoststar.ch [85.10.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 3A21A13137BC for ; Mon, 27 Jun 2011 23:36:30 +0000 (UTC) Received: from localhost.localdomain (77-56-73-198.dclient.hispeed.ch [77.56.73.198]) (authenticated bits=0) by tux29.hoststar.ch (8.13.8/8.12.11) with ESMTP id p5RNaWHH027272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 28 Jun 2011 01:36:34 +0200 From: Fabian Affolter To: alpine-devel@lists.alpinelinux.org Cc: Fabian Affolter Subject: [alpine-devel] [PATCH] Added python as a new template Date: Mon, 27 Jun 2011 23:36:17 +0000 Message-Id: <1309217777-23476-1-git-send-email-fabian@affolter-engineering.ch> X-Mailer: git-send-email 1.7.4.5 X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: With -q ('-q' for the moment, please change that) a template APKBUILD file for a python module is created. 'depends' and 'makedepends' are filled with standard values. --- newapkbuild.in | 106 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 74 insertions(+), 32 deletions(-) diff --git a/newapkbuild.in b/newapkbuild.in index c4f5aa9..110b47d 100755 --- a/newapkbuild.in +++ b/newapkbuild.in @@ -1,6 +1,6 @@ #!/bin/sh - -# script to generate a new APKBUILD +# +# Script to generate a new APKBUILD # Copyright (c) 2009 Natanael Copa # # Distributed under GPL-2 @@ -14,7 +14,7 @@ datadir=@datadir@ prog=${0##*/} -# source $PACKAGER +# Source $PACKAGER for i in $sysconfdir/abuild.conf $HOME/.abuild/abuild.conf; do if [ -f "$i" ]; then . $i @@ -32,6 +32,7 @@ is_url() { return 1 } +# Build sections config_autotools() { cat >>APKBUILD<<__EOF__ ./configure --prefix=/usr \\ @@ -40,22 +41,54 @@ config_autotools() { --infodir=/usr/share/info \\ --localstatedir=/var \\ || return 1 + make || return 1 __EOF__ } config_perl() { cat >>APKBUILD<<__EOF__ PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1 + make || return 1 +__EOF__ +} + +config_python() { + cat >>APKBUILD<<__EOF__ + python setup.py build || return 1 __EOF__ } -cleanup_perl() { +# Package sections +package_autotools() { + cat >>APKBUILD<<__EOF__ + make DESTDIR="\$pkgdir" install || return 1 + rm -f "\$pkgdir"/usr/lib/*.la +__EOF__ + if [ -n "$cpinitd" ]; then + cat >>APKBUILD<<__EOF__ + + install -m755 -D "\$srcdir"/\$pkgname.initd \\ + "\$pkgdir"/etc/init.d/\$pkgname || return 1 + install -m644 -D "\$srcdir"/\$pkgname.confd \\ + "\$pkgdir"/etc/conf.d/\$pkgname || return 1 +__EOF__ + fi +} + +package_perl() { cat >>APKBUILD<<__EOF__ + make DESTDIR="\$pkgdir" install || return 1 find "\$pkgdir" \\( -name perllocal.pod -o -name .packlist \\) -delete __EOF__ } -# create new aport from templates +package_python() { + cat >>APKBUILD<<__EOF__ + python setup.py install --prefix=/usr --root="\$pkgdir" || return 1 +__EOF__ +} + +# Create new aport from templates newaport() { local newname="${1##*/}" local pn=${newname%-[0-9]*} @@ -78,12 +111,22 @@ newaport() { source="http://downloads.sourceforge.net/$pn/$pn-$pv.tar.gz" fi - # replace pkgver in $source + if [ -z "$depends" ] &&[ "$buildtype" == "python" ]; then + depends="python" + fi + + if [ -z "$makedepends" ] &&[ "$buildtype" == "python" ]; then + makedepends="python-dev" + else + makedepends="\$depends_dev" + fi + + # Replace pkgver in $source if [ -n "$source" ]; then source=$(echo "$source" | sed "s/$pv/\$pkgver/g") fi - # copy init.d scripts if requested + # Copy init.d scripts if requested if [ -n "$cpinitd" ]; then cp "$datadir"/sample.initd $pn.initd cp "$datadir"/sample.confd $pn.confd @@ -96,7 +139,7 @@ newaport() { " fi - # generate header with standard variables + # Generate header with standard variables cat >APKBUILD<<__EOF__ # Contributor:${PACKAGER:+" "}${PACKAGER} # Maintainer:${MAINTAINER:+" "}${MAINTAINER} @@ -107,9 +150,9 @@ pkgdesc="$pkgdesc" url="$url" arch="all" license="$license" -depends= -depends_dev= -makedepends="\$depends_dev" +depends="$depends" +depends_dev="" +makedepends="$makedepends" install="$install" subpackages="\$pkgname-dev \$pkgname-doc" source="$source" @@ -117,7 +160,7 @@ source="$source" __EOF__ abuild -f fetch unpack - # figure out the _builddir + # Figure out the _builddir for i in src/*; do if [ -d "$i" ]; then sdir=$i @@ -127,7 +170,7 @@ __EOF__ done echo "_builddir=$_builddir" >> APKBUILD - # check if its autotools + # Check if its autotools if [ -z "$buildtype" ]; then if [ -x "$sdir"/configure ]; then buildtype="autotools" @@ -139,11 +182,13 @@ __EOF__ buildtype="cmake" elif [ -r "$sdir"/Makefile ]; then buildtype="make" + elif [ -r "$sdir"/setup.py ]; then + buildtype="python" fi fi - # create the prepare() template + # Create the prepare() template cat >>APKBUILD<<__EOF__ prepare() { local i @@ -157,7 +202,7 @@ prepare() { __EOF__ - # create build() + # Create build() function cat >>APKBUILD<<__EOF__ build() { cd "\$_builddir" @@ -168,33 +213,28 @@ __EOF__ config_autotools;; perl) config_perl;; + python) + config_python;; esac cat >>APKBUILD<<__EOF__ - make || return 1 } __EOF__ - # create package() function + # Create package() function cat >>APKBUILD<<__EOF__ package() { cd "\$_builddir" - make DESTDIR="\$pkgdir" install || return 1 - rm -f "\$pkgdir"/usr/lib/*.la __EOF__ - if [ -n "$cpinitd" ]; then - cat >>APKBUILD<<__EOF__ - - install -m755 -D "\$srcdir"/\$pkgname.initd \\ - "\$pkgdir"/etc/init.d/\$pkgname || return 1 - install -m644 -D "\$srcdir"/\$pkgname.confd \\ - "\$pkgdir"/etc/conf.d/\$pkgname || return 1 -__EOF__ - fi case "$buildtype" in - perl) cleanup_perl;; + autotools) + package_autotools;; + perl) + package_perl;; + python) + package_python;; esac cat >>APKBUILD<<__EOF__ @@ -208,19 +248,20 @@ usage() { echo "usage: $prog [-cfh] [-d DESC] [-l LICENSE] [-u URL] PKGNAME[-PKGVER]" echo "Options:" echo " -a Create autotools (use ./configure ...)" - echo " -c Copy a sample init.d, conf.d and install script to new directory" + echo " -c Copy a sample init.d, conf.d, and install script to new directory" echo " -d Set package description (pkgdesc) to DESC" echo " -f Force even if directory already exist" echo " -h Show this help" echo " -l Set package license to LICENSE" echo " -p Create perl package (Assume Makefile.PL is there)" + echo " -q Create python package (Assume setup.py is there)" echo " -u Set package URL" - echo " -s Use sourceforge source url" + echo " -s Use sourceforge source URL" echo "" exit 0 } -while getopts "acd:fhl:pu:s" opt; do +while getopts "acd:fhl:pqu:s" opt; do case $opt in 'a') buildtype="autotools";; 'c') cpinitd=1;; @@ -229,6 +270,7 @@ while getopts "acd:fhl:pu:s" opt; do 'h') usage;; 'l') license="$OPTARG";; 'p') buildtype="perl";; + 'q') buildtype="python";; 'u') url="$OPTARG";; 's') sourceforge=1;; esac -- 1.7.4.5 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---