[pacman-dev] [PATCH v3 4/4] Moved makepkg download functions into libmakepkg

Ashley Whetter ashley at awhetter.co.uk
Sun Sep 22 06:25:32 EDT 2013


Signed-off-by: Ashley Whetter <ashley at awhetter.co.uk>
---
 scripts/.gitignore                    |   7 +
 scripts/Makefile.am                   |  23 ++-
 scripts/libmakepkg/source.sh.in       |  71 +++++++++
 scripts/libmakepkg/source/bzr.sh.in   |  77 ++++++++++
 scripts/libmakepkg/source/file.sh.in  |  89 ++++++++++++
 scripts/libmakepkg/source/git.sh.in   |  65 +++++++++
 scripts/libmakepkg/source/hg.sh.in    |  59 ++++++++
 scripts/libmakepkg/source/local.sh.in |  44 ++++++
 scripts/libmakepkg/source/svn.sh.in   |  67 +++++++++
 scripts/makepkg.sh.in                 | 261 ----------------------------------
 10 files changed, 501 insertions(+), 262 deletions(-)
 create mode 100644 scripts/libmakepkg/source.sh.in
 create mode 100644 scripts/libmakepkg/source/bzr.sh.in
 create mode 100644 scripts/libmakepkg/source/file.sh.in
 create mode 100644 scripts/libmakepkg/source/git.sh.in
 create mode 100644 scripts/libmakepkg/source/hg.sh.in
 create mode 100644 scripts/libmakepkg/source/local.sh.in
 create mode 100644 scripts/libmakepkg/source/svn.sh.in

diff --git a/scripts/.gitignore b/scripts/.gitignore
index 6f2e84d..c129207 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -9,6 +9,13 @@ repo-add
 repo-elephant
 repo-remove
 
+libmakepkg/source.sh
+libmakepkg/source/bzr.sh
+libmakepkg/source/file.sh
+libmakepkg/source/git.sh
+libmakepkg/source/hg.sh
+libmakepkg/source/local.sh
+libmakepkg/source/svn.sh
 libmakepkg/util.sh
 libmakepkg/util/url.sh
 libmakepkg/util/util.sh
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 4c52bd4..994a168 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -41,6 +41,13 @@ LIBMAKEPKG = \
 	util/message.sh
 
 LIBMAKEPKG_INC = \
+	source.sh \
+	source/bzr.sh \
+	source/file.sh \
+	source/git.sh \
+	source/hg.sh \
+	source/local.sh \
+	source/svn.sh \
 	util.sh \
 	util/url.sh \
 	util/util.sh
@@ -99,6 +106,13 @@ $(addprefix libmakepkg/,$(LIBMAKEPKG_INC)): Makefile
 	@$(BASH_SHELL) -O extglob -n $@
 
 libmakepkg: \
+	$(srcdir)/libmakepkg/source.sh \
+	$(srcdir)/libmakepkg/source/bzr.sh \
+	$(srcdir)/libmakepkg/source/file.sh \
+	$(srcdir)/libmakepkg/source/git.sh \
+	$(srcdir)/libmakepkg/source/hg.sh \
+	$(srcdir)/libmakepkg/source/local.sh \
+	$(srcdir)/libmakepkg/source/svn.sh \
 	$(srcdir)/libmakepkg/util.sh \
 	$(srcdir)/libmakepkg/util/message.sh \
 	$(srcdir)/libmakepkg/util/url.sh \
@@ -153,6 +167,13 @@ makepkg-wrapper: \
 	$(srcdir)/makepkg-wrapper.sh.in \
 	$(srcdir)/makepkg.sh.in \
 	$(srcdir)/library/parseopts.sh \
+	$(srcdir)/libmakepkg/source.sh \
+	$(srcdir)/libmakepkg/source/bzr.sh \
+	$(srcdir)/libmakepkg/source/file.sh \
+	$(srcdir)/libmakepkg/source/git.sh \
+	$(srcdir)/libmakepkg/source/hg.sh \
+	$(srcdir)/libmakepkg/source/local.sh \
+	$(srcdir)/libmakepkg/source/svn.sh \
 	$(srcdir)/libmakepkg/util.sh \
 	$(srcdir)/libmakepkg/util/message.sh \
 	$(srcdir)/libmakepkg/util/url.sh \
@@ -173,7 +194,7 @@ install-data-hook:
 	cd $(DESTDIR)$(bindir) && \
 		$(RM) makepkg makepkg-wrapper
 	$(INSTALL) .lib/makepkg $(DESTDIR)$(bindir)/makepkg
-	$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/util
+	$(AM_V_at)$(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/{source,util}
 	for lib in $(LIBMAKEPKG); do \
 		$(INSTALL) libmakepkg/$$lib $(DESTDIR)$(libmakepkgdir)/$$lib; \
 	done
diff --git a/scripts/libmakepkg/source.sh.in b/scripts/libmakepkg/source.sh.in
new file mode 100644
index 0000000..3e69aa4
--- /dev/null
+++ b/scripts/libmakepkg/source.sh.in
@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+#   download.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_SH" ] && return
+LIBMAKEPKG_SOURCE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+for lib in "$LIBRARY/source/"*.sh; do
+	source "$lib"
+done
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+
+download_sources() {
+	msg "$(gettext "Retrieving sources...")"
+
+	local GET_VCS=1
+	if [[ $1 == "fast" ]]; then
+		GET_VCS=0
+	fi
+
+	local netfile
+	for netfile in "${source[@]}"; do
+		pushd "$SRCDEST" &>/dev/null
+
+		local proto=$(get_protocol "$netfile")
+		case "$proto" in
+			local)
+				download_local "$netfile"
+				;;
+			bzr*)
+				(( GET_VCS )) && download_bzr "$netfile"
+				;;
+			git*)
+				(( GET_VCS )) && download_git "$netfile"
+				;;
+			hg*)
+				(( GET_VCS )) && download_hg "$netfile"
+				;;
+			svn*)
+				(( GET_VCS )) && download_svn "$netfile"
+				;;
+			*)
+				download_file "$netfile"
+				;;
+		esac
+
+		popd &>/dev/null
+	done
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/libmakepkg/source/bzr.sh.in b/scripts/libmakepkg/source/bzr.sh.in
new file mode 100644
index 0000000..85e6436
--- /dev/null
+++ b/scripts/libmakepkg/source/bzr.sh.in
@@ -0,0 +1,77 @@
+#!/bin/bash
+#
+#   bzr.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_BZR_SH" ] && return
+LIBMAKEPKG_SOURCE_BZR_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+source "$LIBRARY/util/util.sh"
+
+download_bzr() {
+	local netfile=$1
+
+	local url=$(get_url "$netfile")
+	url=${url##*bzr+}
+	url=${url%%#*}
+
+	local repo=$(get_filename "$netfile")
+	local displaylocation="$url"
+
+	local dir=$(get_filepath "$netfile")
+	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
+
+	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
+		msg2 "$(gettext "Branching %s ...")" "${displaylocation}"
+		if ! bzr branch "$url" "$dir" --no-tree --use-existing-dir; then
+			error "$(gettext "Failure while branching %s")" "${displaylocation}"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
+	elif (( ! HOLDVER )); then
+		# Make sure we are fetching the right repo
+		local distant_url="$(bzr info $url 2> /dev/null | sed -n '/branch root/{s/  branch root: //p;q;}')"
+		local local_url="$(bzr config parent_location -d $dir)"
+		if [[ -n $distant_url ]]; then
+			if [[ $distant_url != "$local_url" ]]; then
+				error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
+				plain "$(gettext "Aborting...")"
+				exit 1
+			fi
+		else
+			if [[ $url != "$local_url" ]] ; then
+				error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
+				error "$(gettext "The local URL is %s")" "$local_url"
+				plain "$(gettext "Aborting...")"
+				exit 1
+			fi
+		fi
+		msg2 "$(gettext "Pulling %s ...")" "${displaylocation}"
+		cd_safe "$dir"
+		if ! bzr pull "$url" --overwrite; then
+			# only warn on failure to allow offline builds
+			warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
+		fi
+	fi
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/libmakepkg/source/file.sh.in b/scripts/libmakepkg/source/file.sh.in
new file mode 100644
index 0000000..14a122e
--- /dev/null
+++ b/scripts/libmakepkg/source/file.sh.in
@@ -0,0 +1,89 @@
+#!/bin/bash
+#
+#   file.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_FILE_SH" ] && return
+LIBMAKEPKG_SOURCE_FILE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+
+download_file() {
+	local netfile=$1
+
+	local filepath=$(get_filepath "$netfile")
+	if [[ -n "$filepath" ]]; then
+		msg2 "$(gettext "Found %s")" "${filepath##*/}"
+		rm -f "$srcdir/${filepath##*/}"
+		ln -s "$filepath" "$srcdir/"
+		return
+	fi
+
+	local proto=$(get_protocol "$netfile")
+
+	# find the client we should use for this URL
+	local dlcmd
+	dlcmd=$(get_downloadclient "$proto") || exit $?
+
+	local filename=$(get_filename "$netfile")
+	local url=$(get_url "$netfile")
+
+	if [[ $proto = "scp" ]]; then
+		# scp downloads should not pass the protocol in the url
+		url="${url##*://}"
+	fi
+
+	msg2 "$(gettext "Downloading %s...")" "$filename"
+
+	# temporary download file, default to last component of the URL
+	local dlfile="${url##*/}"
+
+	# replace %o by the temporary dlfile if it exists
+	if [[ $dlcmd = *%o* ]]; then
+		dlcmd=${dlcmd//\%o/\"$filename.part\"}
+		dlfile="$filename.part"
+	fi
+	# add the URL, either in place of %u or at the end
+	if [[ $dlcmd = *%u* ]]; then
+		dlcmd=${dlcmd//\%u/\"$url\"}
+	else
+		dlcmd="$dlcmd \"$url\""
+	fi
+
+	local ret=0
+	eval "$dlcmd >&2 || ret=\$?"
+	if (( ret )); then
+		[[ ! -s $dlfile ]] && rm -f -- "$dlfile"
+		error "$(gettext "Failure while downloading %s")" "$filename"
+		plain "$(gettext "Aborting...")"
+		exit 1
+	fi
+
+	# rename the temporary download file to the final destination
+	if [[ $dlfile != "$filename" ]]; then
+		mv -f "$SRCDEST/$dlfile" "$SRCDEST/$filename"
+	fi
+
+	rm -f "$srcdir/$filename"
+	ln -s "$SRCDEST/$filename" "$srcdir/"
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/libmakepkg/source/git.sh.in b/scripts/libmakepkg/source/git.sh.in
new file mode 100644
index 0000000..ab7fdce
--- /dev/null
+++ b/scripts/libmakepkg/source/git.sh.in
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+#   git.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_GIT_SH" ] && return
+LIBMAKEPKG_SOURCE_GIT_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+source "$LIBRARY/util/util.sh"
+
+download_git() {
+	local netfile=$1
+
+	local dir=$(get_filepath "$netfile")
+	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
+
+	local repo=$(get_filename "$netfile")
+
+	local url=$(get_url "$netfile")
+	url=${url##*git+}
+	url=${url%%#*}
+
+	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
+		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
+		if ! git clone --mirror "$url" "$dir"; then
+			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
+	elif (( ! HOLDVER )); then
+		cd_safe "$dir"
+		# Make sure we are fetching the right repo
+		if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
+			error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
+		msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
+		if ! git fetch --all -p; then
+			# only warn on failure to allow offline builds
+			warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
+		fi
+	fi
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/libmakepkg/source/hg.sh.in b/scripts/libmakepkg/source/hg.sh.in
new file mode 100644
index 0000000..e3cd115
--- /dev/null
+++ b/scripts/libmakepkg/source/hg.sh.in
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+#   hg.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_HG_SH" ] && return
+LIBMAKEPKG_SOURCE_HG_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+source "$LIBRARY/util/util.sh"
+
+download_hg() {
+	local netfile=$1
+
+	local dir=$(get_filepath "$netfile")
+	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
+
+	local repo=$(get_filename "$netfile")
+
+	local url=$(get_url "$netfile")
+	url=${url##*hg+}
+	url=${url%%#*}
+
+	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
+		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
+		if ! hg clone -U "$url" "$dir"; then
+			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
+	elif (( ! HOLDVER )); then
+		msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg"
+		cd_safe "$dir"
+		if ! hg pull; then
+			# only warn on failure to allow offline builds
+			warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
+		fi
+	fi
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/libmakepkg/source/local.sh.in b/scripts/libmakepkg/source/local.sh.in
new file mode 100644
index 0000000..d51317b
--- /dev/null
+++ b/scripts/libmakepkg/source/local.sh.in
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+#   local.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_LOCAL_SH" ] && return
+LIBMAKEPKG_SOURCE_LOCAL_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+
+download_local() {
+	local netfile=$1
+	local filepath=$(get_filepath "$netfile")
+
+	if [[ -n "$filepath" ]]; then
+		msg2 "$(gettext "Found %s")" "${filepath##*/}"
+		rm -f "$srcdir/${filepath##*/}"
+		ln -s "$filepath" "$srcdir/"
+	else
+		local filename=$(get_filename "$netfile")
+		error "$(gettext "%s was not found in the build directory and is not a URL.")" "$filename"
+		exit 1 # $E_MISSING_FILE
+	fi
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/libmakepkg/source/svn.sh.in b/scripts/libmakepkg/source/svn.sh.in
new file mode 100644
index 0000000..5b7b557
--- /dev/null
+++ b/scripts/libmakepkg/source/svn.sh.in
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+#   svn.sh
+#
+#   Copyright (c) 2006-2013 Pacman Development Team <pacman-dev at archlinux.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+[ -n "$LIBMAKEPKG_SOURCE_SVN_SH" ] && return
+LIBMAKEPKG_SOURCE_SVN_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/url.sh"
+source "$LIBRARY/util/util.sh"
+
+download_svn() {
+	local netfile=$1
+
+	local fragment=${netfile#*#}
+	if [[ $fragment = "$netfile" ]]; then
+		unset fragment
+	fi
+
+	local dir=$(get_filepath "$netfile")
+	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
+
+	local repo=$(get_filename "$netfile")
+
+	local url=$(get_url "$netfile")
+	if [[ $url != svn+ssh* ]]; then
+		url=${url##*svn+}
+	fi
+	url=${url%%#*}
+
+	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
+		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn"
+		mkdir -p "$dir/.makepkg"
+		if ! svn checkout --config-dir "$dir/.makepkg" "$url" "$dir"; then
+			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn"
+			plain "$(gettext "Aborting...")"
+			exit 1
+		fi
+	elif (( ! HOLDVER )); then
+		msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn"
+		cd_safe "$dir"
+		if ! svn update; then
+			# only warn on failure to allow offline builds
+			warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
+		fi
+	fi
+}
+
+# vim: set ts=2 sw=2 noet:
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index d1dd964..42d45af 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -177,81 +177,6 @@ enter_fakeroot() {
 	fakeroot -- $0 -F "${ARGLIST[@]}" || exit $?
 }
 
-download_local() {
-	local netfile=$1
-	local filepath=$(get_filepath "$netfile")
-
-	if [[ -n "$filepath" ]]; then
-		msg2 "$(gettext "Found %s")" "${filepath##*/}"
-		rm -f "$srcdir/${filepath##*/}"
-		ln -s "$filepath" "$srcdir/"
-	else
-		local filename=$(get_filename "$netfile")
-		error "$(gettext "%s was not found in the build directory and is not a URL.")" "$filename"
-		exit 1 # $E_MISSING_FILE
-	fi
-}
-
-download_file() {
-	local netfile=$1
-
-	local filepath=$(get_filepath "$netfile")
-	if [[ -n "$filepath" ]]; then
-		msg2 "$(gettext "Found %s")" "${filepath##*/}"
-		rm -f "$srcdir/${filepath##*/}"
-		ln -s "$filepath" "$srcdir/"
-		return
-	fi
-
-	local proto=$(get_protocol "$netfile")
-
-	# find the client we should use for this URL
-	local dlcmd
-	dlcmd=$(get_downloadclient "$proto") || exit $?
-
-	local filename=$(get_filename "$netfile")
-	local url=$(get_url "$netfile")
-
-	if [[ $proto = "scp" ]]; then
-		# scp downloads should not pass the protocol in the url
-		url="${url##*://}"
-	fi
-
-	msg2 "$(gettext "Downloading %s...")" "$filename"
-
-	# temporary download file, default to last component of the URL
-	local dlfile="${url##*/}"
-
-	# replace %o by the temporary dlfile if it exists
-	if [[ $dlcmd = *%o* ]]; then
-		dlcmd=${dlcmd//\%o/\"$filename.part\"}
-		dlfile="$filename.part"
-	fi
-	# add the URL, either in place of %u or at the end
-	if [[ $dlcmd = *%u* ]]; then
-		dlcmd=${dlcmd//\%u/\"$url\"}
-	else
-		dlcmd="$dlcmd \"$url\""
-	fi
-
-	local ret=0
-	eval "$dlcmd >&2 || ret=\$?"
-	if (( ret )); then
-		[[ ! -s $dlfile ]] && rm -f -- "$dlfile"
-		error "$(gettext "Failure while downloading %s")" "$filename"
-		plain "$(gettext "Aborting...")"
-		exit 1
-	fi
-
-	# rename the temporary download file to the final destination
-	if [[ $dlfile != "$filename" ]]; then
-		mv -f "$SRCDEST/$dlfile" "$SRCDEST/$filename"
-	fi
-
-	rm -f "$srcdir/$filename"
-	ln -s "$SRCDEST/$filename" "$srcdir/"
-}
-
 extract_file() {
 	local file=$1
 	# do not rely on extension for file type
@@ -305,53 +230,6 @@ extract_file() {
 	fi
 }
 
-download_bzr() {
-	local netfile=$1
-
-	local url=$(get_url "$netfile")
-	url=${url##*bzr+}
-	url=${url%%#*}
-
-	local repo=$(get_filename "$netfile")
-	local displaylocation="$url"
-
-	local dir=$(get_filepath "$netfile")
-	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
-
-	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
-		msg2 "$(gettext "Branching %s ...")" "${displaylocation}"
-		if ! bzr branch "$url" "$dir" --no-tree --use-existing-dir; then
-			error "$(gettext "Failure while branching %s")" "${displaylocation}"
-			plain "$(gettext "Aborting...")"
-			exit 1
-		fi
-	elif (( ! HOLDVER )); then
-		# Make sure we are fetching the right repo
-		local distant_url="$(bzr info $url 2> /dev/null | sed -n '/branch root/{s/  branch root: //p;q;}')"
-		local local_url="$(bzr config parent_location -d $dir)"
-		if [[ -n $distant_url ]]; then
-			if [[ $distant_url != "$local_url" ]]; then
-				error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
-				plain "$(gettext "Aborting...")"
-				exit 1
-			fi
-		else
-			if [[ $url != "$local_url" ]] ; then
-				error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
-				error "$(gettext "The local URL is %s")" "$local_url"
-				plain "$(gettext "Aborting...")"
-				exit 1
-			fi
-		fi
-		msg2 "$(gettext "Pulling %s ...")" "${displaylocation}"
-		cd_safe "$dir"
-		if ! bzr pull "$url" --overwrite; then
-			# only warn on failure to allow offline builds
-			warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
-		fi
-	fi
-}
-
 extract_bzr() {
 	local netfile=$1
 
@@ -391,41 +269,6 @@ extract_bzr() {
 	popd &>/dev/null
 }
 
-download_git() {
-	local netfile=$1
-
-	local dir=$(get_filepath "$netfile")
-	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
-
-	local repo=$(get_filename "$netfile")
-
-	local url=$(get_url "$netfile")
-	url=${url##*git+}
-	url=${url%%#*}
-
-	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
-		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
-		if ! git clone --mirror "$url" "$dir"; then
-			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
-			plain "$(gettext "Aborting...")"
-			exit 1
-		fi
-	elif (( ! HOLDVER )); then
-		cd_safe "$dir"
-		# Make sure we are fetching the right repo
-		if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
-			error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
-			plain "$(gettext "Aborting...")"
-			exit 1
-		fi
-		msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
-		if ! git fetch --all -p; then
-			# only warn on failure to allow offline builds
-			warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
-		fi
-	fi
-}
-
 extract_git() {
 	local netfile=$1
 
@@ -480,35 +323,6 @@ extract_git() {
 	popd &>/dev/null
 }
 
-download_hg() {
-	local netfile=$1
-
-	local dir=$(get_filepath "$netfile")
-	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
-
-	local repo=$(get_filename "$netfile")
-
-	local url=$(get_url "$netfile")
-	url=${url##*hg+}
-	url=${url%%#*}
-
-	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
-		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
-		if ! hg clone -U "$url" "$dir"; then
-			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
-			plain "$(gettext "Aborting...")"
-			exit 1
-		fi
-	elif (( ! HOLDVER )); then
-		msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg"
-		cd_safe "$dir"
-		if ! hg pull; then
-			# only warn on failure to allow offline builds
-			warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
-		fi
-	fi
-}
-
 extract_hg() {
 	local netfile=$1
 
@@ -549,43 +363,6 @@ extract_hg() {
 	popd &>/dev/null
 }
 
-download_svn() {
-	local netfile=$1
-
-	local fragment=${netfile#*#}
-	if [[ $fragment = "$netfile" ]]; then
-		unset fragment
-	fi
-
-	local dir=$(get_filepath "$netfile")
-	[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
-
-	local repo=$(get_filename "$netfile")
-
-	local url=$(get_url "$netfile")
-	if [[ $url != svn+ssh* ]]; then
-		url=${url##*svn+}
-	fi
-	url=${url%%#*}
-
-	if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
-		msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn"
-		mkdir -p "$dir/.makepkg"
-		if ! svn checkout --config-dir "$dir/.makepkg" "$url" "$dir"; then
-			error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn"
-			plain "$(gettext "Aborting...")"
-			exit 1
-		fi
-	elif (( ! HOLDVER )); then
-		msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn"
-		cd_safe "$dir"
-		if ! svn update; then
-			# only warn on failure to allow offline builds
-			warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
-		fi
-	fi
-}
-
 extract_svn() {
 	local netfile=$1
 
@@ -630,44 +407,6 @@ extract_svn() {
 	popd &>/dev/null
 }
 
-download_sources() {
-	msg "$(gettext "Retrieving sources...")"
-
-	local GET_VCS=1
-	if [[ $1 == "fast" ]]; then
-		GET_VCS=0
-	fi
-
-	local netfile
-	for netfile in "${source[@]}"; do
-		pushd "$SRCDEST" &>/dev/null
-
-		local proto=$(get_protocol "$netfile")
-		case "$proto" in
-			local)
-				download_local "$netfile"
-				;;
-			bzr*)
-				(( GET_VCS )) && download_bzr "$netfile"
-				;;
-			git*)
-				(( GET_VCS )) && download_git "$netfile"
-				;;
-			hg*)
-				(( GET_VCS )) && download_hg "$netfile"
-				;;
-			svn*)
-				(( GET_VCS )) && download_svn "$netfile"
-				;;
-			*)
-				download_file "$netfile"
-				;;
-		esac
-
-		popd &>/dev/null
-	done
-}
-
 # Automatically update pkgver variable if a pkgver() function is provided
 # Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver
 update_pkgver() {
-- 
1.8.4



More information about the pacman-dev mailing list