4 3

[alpine-devel] [PATCH] Added python as a new template

Fabian Affolter
Details
Message ID
<1309217777-23476-1-git-send-email-fabian@affolter-engineering.ch>
Sender timestamp
1309217777
DKIM signature
missing
Download raw message
Patch: +74 -32
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 <natanael.copa@gmail.com>
 #
 # 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
---
Kiyoshi Aman
Details
Message ID
<BANLkTikHV1UEiqaPML0qTysSOVaQ-g1KRQ@mail.gmail.com>
In-Reply-To
<20110628092134.34ac48d3@ncopa-desktop.nor.wtbts.net> (view parent)
Sender timestamp
1309263581
DKIM signature
missing
Download raw message
Hi folks,

I think at this point we should probably be writing utilities outside
of newapkbuild (a la apkbuild-cpan), at least for those libraries &
applications which can be obtained from CPAN-like code stores. I think
this is particularly needful because newapkbuild is getting a bit on
the hefty side, and in any event, apkbuild-cpan can also be used
separately for added functionality.

--Kiyoshi Aman


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Jeff Bilyk
Details
Message ID
<364A904A-BA3E-4DD9-98B3-7BF52AC58175@gmail.com>
In-Reply-To
<BANLkTikHV1UEiqaPML0qTysSOVaQ-g1KRQ@mail.gmail.com> (view parent)
Sender timestamp
1309266407
DKIM signature
missing
Download raw message
On Jun 28, 2011, at 8:19 AM, Kiyoshi Aman <aphrael@alpinelinux.org> wrote:

> Hi folks,
> 
> I think at this point we should probably be writing utilities outside
> of newapkbuild (a la apkbuild-cpan), at least for those libraries &
> applications which can be obtained from CPAN-like code stores. I think
> this is particularly needful because newapkbuild is getting a bit on
> the hefty side, and in any event, apkbuild-cpan can also be used
> separately for added functionality.
> 
> --Kiyoshi Aman

What about keeping apkbuild-cpan separate for when you want more advanced functionality but having an option to call it from within newapkbuild for basic usage like bumping versions and similar tasks?

Jeff
> 
> 
> ---
> Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
> Help:         alpine-devel+help@lists.alpinelinux.org
> ---
> 


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa
Details
Message ID
<20110628092134.34ac48d3@ncopa-desktop.nor.wtbts.net>
In-Reply-To
<1309217777-23476-1-git-send-email-fabian@affolter-engineering.ch> (view parent)
Sender timestamp
1309245694
DKIM signature
missing
Download raw message
On Mon, 27 Jun 2011 23:36:17 +0000
Fabian Affolter <fabian@affolter-engineering.ch> wrote:

> 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.

Thanks!

I changed the -q to -y for now. I wonder if we should use -t <type>
instead: newapkbuild -t python ...

I also renamed config_* to build_* since this functions now also
includes the 'make' command if needed.

And i added a build_make() and package_make() in case there is only a
single Makefile.

While there I also moved the init.d script stuff since all kinds of
build types could have an init.d script, not only autotools.

Please test!

Thanks!
-nc


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa
Details
Message ID
<20110628165718.501b5496@ncopa-desktop.nor.wtbts.net>
In-Reply-To
<364A904A-BA3E-4DD9-98B3-7BF52AC58175@gmail.com> (view parent)
Sender timestamp
1309273038
DKIM signature
missing
Download raw message
On Tue, 28 Jun 2011 09:06:47 -0400
Jeff Bilyk <jbilyk@gmail.com> wrote:

> 
> On Jun 28, 2011, at 8:19 AM, Kiyoshi Aman <aphrael@alpinelinux.org>
> wrote:
> 
> > Hi folks,
> > 
> > I think at this point we should probably be writing utilities
> > outside of newapkbuild (a la apkbuild-cpan), at least for those
> > libraries & applications which can be obtained from CPAN-like code
> > stores. I think this is particularly needful because newapkbuild is
> > getting a bit on the hefty side, and in any event, apkbuild-cpan
> > can also be used separately for added functionality.
> > 
> > --Kiyoshi Aman
> 
> What about keeping apkbuild-cpan separate for when you want more
> advanced functionality but having an option to call it from within
> newapkbuild for basic usage like bumping versions and similar tasks?

We could also have newapkbuild call apkbuild-cpan. apkbuild-cpan has
some extra stuff that helps keeping the apkbuild updated.

but for now, apkbuild-cpan works only with stuff that are in cpan.
newapkbuild can handle perl things that are not in cpan.


-nc


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---