[pacman-dev] [PATCHv2] makepkg: Add special case with -e and -o together

William Giokas 1007380 at gmail.com
Fri Feb 22 10:54:57 EST 2013


Passing -e and -o (noextract and nobuild, respectively) should cause
makepkg to not extract and not build. This means that it should still
download sources and verify them.

Signed-off-by: William Giokas <1007380 at gmail.com>
---
 doc/makepkg.8.txt     |   7 +-
 scripts/makepkg.sh.in | 177 +++++++++++++++++++++++++++-----------------------
 2 files changed, 100 insertions(+), 84 deletions(-)

diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt
index 498c79b..341d96e 100644
--- a/doc/makepkg.8.txt
+++ b/doc/makepkg.8.txt
@@ -63,7 +63,9 @@ Options
 	use whatever source already exists in the $srcdir/ directory. This is
 	handy if you want to go into $srcdir/ and manually patch or tweak code,
 	then make a package out of the result. Keep in mind that creating a
-	patch may be a better solution to allow others to use your PKGBUILD.
+	patch may be a better solution to allow others to use your PKGBUILD. If
+	used with '\--nobuild', 'makepkg' will only download the sources, it will
+	not extract them into $srcdir/.
 
 *-f, \--force*::
 	makepkg will not build a package if a built package already exists in
@@ -112,7 +114,8 @@ Options
 *-o, \--nobuild*::
 	Download and extract files, run the prepare() function, but do not build
 	them. Useful with the '\--noextract' option if you wish to tweak the files
-	in $srcdir/ before building.
+	in $srcdir/ before building. When passed to 'makepkg' with '\--noextract',
+	the sources will be downloaded and checked, but not extracted.
 
 *-p* <buildscript>::
 	Read the package script `buildscript` instead of the `PKGBUILD` default;
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index bd29d73..cfe1e0c 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -432,17 +432,19 @@ download_bzr() {
 		fi
 	fi
 
-	msg2 "$(gettext "Creating working copy of %s %s repo...")" "${dir}" "bzr"
-	pushd "$srcdir" &>/dev/null
-	rm -rf "${dir##*/}"
+	if (( ! NOEXTRACT )); then
+		msg2 "$(gettext "Creating working copy of %s %s repo...")" "${dir}" "bzr"
+		pushd "$srcdir" &>/dev/null
+		rm -rf "${dir##*/}"
 
-	if ! bzr checkout "$dir" --lightweight; then
-		error "$(gettext "Failure while creating working copy of %s %s repo")" "${dir}" "bzr"
-		plain "$(gettext "Aborting...")"
-		exit 1
-	fi
+		if ! bzr checkout "$dir" --lightweight; then
+			error "$(gettext "Failure while creating working copy of %s %s repo")" "${dir}" "bzr"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
 
-	popd &>/dev/null
+		popd &>/dev/null
+	fi
 }
 
 download_git() {
@@ -486,43 +488,45 @@ download_git() {
 		fi
 	fi
 
-	msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
-	pushd "$srcdir" &>/dev/null
-	rm -rf "${dir##*/}"
+	if (( ! NOEXTRACT )); then
+		msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
+		pushd "$srcdir" &>/dev/null
+		rm -rf "${dir##*/}"
 
-	if ! git clone "$dir"; then
-		error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
-		plain "$(gettext "Aborting...")"
-		exit 1
-	fi
+		if ! git clone "$dir"; then
+			error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
 
-	cd_safe "${dir##*/}"
+		cd_safe "${dir##*/}"
 
-	local ref
-	if [[ -n $fragment ]]; then
-		case ${fragment%%=*} in
-			commit|tag)
-				ref=${fragment##*=}
-				;;
-			branch)
-				ref=origin/${fragment##*=}
-				;;
-			*)
-				error "$(gettext "Unrecognized reference: %s")" "${fragment}"
+		local ref
+		if [[ -n $fragment ]]; then
+			case ${fragment%%=*} in
+				commit|tag)
+					ref=${fragment##*=}
+					;;
+				branch)
+					ref=origin/${fragment##*=}
+					;;
+				*)
+					error "$(gettext "Unrecognized reference: %s")" "${fragment}"
+					plain "$(gettext "Aborting...")"
+					exit 1
+			esac
+		fi
+
+		if [[ -n $ref ]]; then
+			if ! git checkout -b makepkg $ref; then
+				error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
 				plain "$(gettext "Aborting...")"
 				exit 1
-		esac
-	fi
-
-	if [[ -n $ref ]]; then
-		if ! git checkout -b makepkg $ref; then
-			error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
-			plain "$(gettext "Aborting...")"
-			exit 1
+			fi
 		fi
-	fi
 
-	popd &>/dev/null
+		popd &>/dev/null
+	fi
 }
 
 download_hg() {
@@ -559,30 +563,32 @@ download_hg() {
 		fi
 	fi
 
-	msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
-	pushd "$srcdir" &>/dev/null
-	rm -rf "${dir##*/}"
+	if (( ! NOEXTRACT )); then
+		msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
+		pushd "$srcdir" &>/dev/null
+		rm -rf "${dir##*/}"
 
-	local ref
-	if [[ -n $fragment ]]; then
-		case ${fragment%%=*} in
-			branch|revision|tag)
-				ref=('-u' "${fragment##*=}")
-				;;
-			*)
-				error "$(gettext "Unrecognized reference: %s")" "${fragment}"
-				plain "$(gettext "Aborting...")"
-				exit 1
-		esac
-	fi
+		local ref
+		if [[ -n $fragment ]]; then
+			case ${fragment%%=*} in
+				branch|revision|tag)
+					ref=('-u' "${fragment##*=}")
+					;;
+				*)
+					error "$(gettext "Unrecognized reference: %s")" "${fragment}"
+					plain "$(gettext "Aborting...")"
+					exit 1
+			esac
+		fi
 
-	if ! hg clone "${ref[@]}" "$dir" "${dir##*/}"; then
-		error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
-		plain "$(gettext "Aborting...")"
-		exit 1
-	fi
+		if ! hg clone "${ref[@]}" "$dir" "${dir##*/}"; then
+			error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
 
-	popd &>/dev/null
+		popd &>/dev/null
+	fi
 }
 
 download_svn() {
@@ -621,29 +627,31 @@ download_svn() {
 		fi
 	fi
 
-	msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
-	pushd "$srcdir" &>/dev/null
-	rm -rf "${dir##*/}"
+	if (( ! NOEXTRACT )); then
+		msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
+		pushd "$srcdir" &>/dev/null
+		rm -rf "${dir##*/}"
 
-	local ref
-	if [[ -n $fragment ]]; then
-		case ${fragment%%=*} in
-			revision)
-				ref=('-r' "${fragment##*=}")
-				;;
-			*)
-				error "$(gettext "Unrecognized reference: %s")" "${fragment}"
-				plain "$(gettext "Aborting...")"
-				exit 1
-		esac
-	fi
+		local ref
+		if [[ -n $fragment ]]; then
+			case ${fragment%%=*} in
+				revision)
+					ref=('-r' "${fragment##*=}")
+					;;
+				*)
+					error "$(gettext "Unrecognized reference: %s")" "${fragment}"
+					plain "$(gettext "Aborting...")"
+					exit 1
+			esac
+		fi
 
-	if ! svn export ${ref[@]} "$dir"; then
-		error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn"
-		plain "$(gettext "Aborting...")"
-	fi
+		if ! svn export ${ref[@]} "$dir"; then
+			error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn"
+			plain "$(gettext "Aborting...")"
+		fi
 
-	popd &>/dev/null
+		popd &>/dev/null
+	fi
 }
 
 download_sources() {
@@ -682,7 +690,7 @@ download_sources() {
 		esac
 	done
 
-	if (( PKGVERFUNC && GET_VCS )); then
+	if (( PKGVERFUNC && GET_VCS && ! NOEXTRACT )); then
 		update_pkgver
 		check_pkgver || exit 1
 		check_build_status
@@ -2885,7 +2893,7 @@ mkdir -p "$srcdir"
 chmod a-s "$srcdir"
 cd_safe "$srcdir"
 
-if (( NOEXTRACT )); then
+if (( NOEXTRACT && ! NOBUILD )); then
 	warning "$(gettext "Using existing %s tree")" "src/"
 elif (( REPKG )); then
 	if (( ! PKGFUNC && ! SPLITPKG )) \
@@ -2894,6 +2902,11 @@ elif (( REPKG )); then
 		plain "$(gettext "Aborting...")"
 		exit 1
 	fi
+elif (( NOEXTRACT && NOBUILD )); then
+	download_sources
+	check_source_integrity
+	msg "$(gettext "Sources have been downloaded.")"
+	exit 0 #E_OK
 else
 	download_sources
 	check_source_integrity
-- 
1.8.2.rc0.22.gb3600c3



More information about the pacman-dev mailing list