[pacman-dev] [PATCH] makepkg: add --allsource option

Dan McGee dan at archlinux.org
Sat May 31 13:07:45 EDT 2008


This supplements the --source option and does nearly the same thing, except
downloaded source files are included in the archive as well.

This is mainly an RFC patch and interested parties are encouraged to
comment. I was also planning on making a patch for adding the package/
prefix to the archived files, but apparently no archive program makes this
easy to do with is just plain stupid. If someone knows how without creating
a temporary dir and moving files there, let me know.

Signed-off-by: Dan McGee <dan at archlinux.org>
---
 scripts/makepkg.sh.in |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 27da281..2c479fd 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -856,6 +856,15 @@ create_package() {
 
 create_srcpackage() {
 	cd "$startdir"
+	if [ "$SOURCEONLY" = "2" ]; then
+		# get back to our src directory so we can begin with sources
+		mkdir -p "$srcdir"
+		cd "$srcdir"
+		download_sources
+		# we can only check checksums if we have all files
+		check_checksums
+		cd "$startdir"
+	fi
 	msg "$(gettext "Creating source package...")"
 	local comp_files="$BUILDSCRIPT"
 	msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
@@ -874,11 +883,15 @@ create_srcpackage() {
 		comp_files="$comp_files ChangeLog"
 	fi
 
-	local i
-	for i in ${source[@]}; do
-		if [ -f $i ]; then
-			msg2 "$(gettext "Adding %s...")" "$i"
-			comp_files="$comp_files $i"
+	local netfile
+	for netfile in ${source[@]}; do
+		local file=$(strip_url "$netfile")
+		if [ -f $netfile ]; then
+			msg2 "$(gettext "Adding %s...")" "$netfile"
+			comp_files="$comp_files $netfile"
+		elif [ "$SOURCEONLY" = "2" -a -f "$srcdir/$file" ]; then
+			msg2 "$(gettext "Adding %s...")" "$file"
+			comp_files="$comp_files -C $srcdir $file"
 		fi
 	done
 
@@ -1061,8 +1074,10 @@ SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
 
 # Parse Command Line Options.
 OPT_SHORT="AbcCdefFghiLmop:rRsSV"
-OPT_LONG="ignorearch,asroot,builddeps,clean,cleancache,nodeps,noextract,force,forcever:,geninteg,help,holdver"
-OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source,syncdeps,usesudo,version"
+OPT_LONG="allsource,asroot,ignorearch,builddeps,clean,cleancache,nodeps"
+OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver"
+OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source"
+OPT_LONG="$OPT_LONG,syncdeps,usesudo,version"
 # Pacman Options
 OPT_LONG="$OPT_LONG,noconfirm,noprogressbar"
 OPT_TEMP="$(getopt -o "$OPT_SHORT" -l "$OPT_LONG" -n "$(basename "$0")" -- "$@" || echo 'GETOPT GO BANG!')"
@@ -1080,6 +1095,7 @@ while true; do
 		--noprogressbar)  PACMAN_OPTS="$PACMAN_OPTS --noprogressbar" ;;
 
 		# Makepkg Options
+		--allsource)      SOURCEONLY=2 ;;
 		--asroot)         ASROOT=1 ;;
 		-A|--ignorearch)  IGNOREARCH=1 ;;
 		-c|--clean)       CLEANUP=1 ;;
@@ -1316,7 +1332,7 @@ if [ $EUID -eq 0 ]; then
 fi
 
 # if we are creating a source-only package, go no further
-if [ "$SOURCEONLY" = "1" ]; then
+if [ "$SOURCEONLY" != "0" ]; then
 	if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" \
 	     -a "$FORCE" = "0" ]; then
 		error "$(gettext "A package has already been built. (use -f to overwrite)")"
-- 
1.5.5.3





More information about the pacman-dev mailing list