makepkg: Separate vcs download and extract
Previously makepkg would clone vcs sources in the download function, regardless of the noextract settings. Now the download_* functions only download or update the vcs sources, and the new extract_* functions just create working copies using the specified protocols. The extract_sources function will call the needed extract function for the protocol specified. The tarball extraction has also been moved into its own extract_file function to keep things consistent. Signed-off-by: William Giokas <1007380@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
06d761a020
commit
fcdaa46b65
1 changed files with 131 additions and 68 deletions
|
@ -379,6 +379,59 @@ download_file() {
|
||||||
ln -s "$SRCDEST/$filename" "$srcdir/"
|
ln -s "$SRCDEST/$filename" "$srcdir/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extract_file() {
|
||||||
|
local file=$1
|
||||||
|
# fix flyspray #6246
|
||||||
|
local file_type=$(file -bizL "$file")
|
||||||
|
local ext=${file##*.}
|
||||||
|
local cmd=''
|
||||||
|
case "$file_type" in
|
||||||
|
*application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
|
||||||
|
cmd="bsdtar" ;;
|
||||||
|
*application/x-gzip*)
|
||||||
|
case "$ext" in
|
||||||
|
gz|z|Z) cmd="gzip" ;;
|
||||||
|
*) continue;;
|
||||||
|
esac ;;
|
||||||
|
*application/x-bzip*)
|
||||||
|
case "$ext" in
|
||||||
|
bz2|bz) cmd="bzip2" ;;
|
||||||
|
*) continue;;
|
||||||
|
esac ;;
|
||||||
|
*application/x-xz*)
|
||||||
|
case "$ext" in
|
||||||
|
xz) cmd="xz" ;;
|
||||||
|
*) continue;;
|
||||||
|
esac ;;
|
||||||
|
*)
|
||||||
|
# See if bsdtar can recognize the file
|
||||||
|
if bsdtar -tf "$file" -q '*' &>/dev/null; then
|
||||||
|
cmd="bsdtar"
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local ret=0
|
||||||
|
msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
|
||||||
|
if [[ $cmd = "bsdtar" ]]; then
|
||||||
|
$cmd -xf "$file" || ret=$?
|
||||||
|
else
|
||||||
|
rm -f -- "${file%.*}"
|
||||||
|
$cmd -dcf "$file" > "${file%.*}" || ret=$?
|
||||||
|
fi
|
||||||
|
if (( ret )); then
|
||||||
|
error "$(gettext "Failed to extract %s")" "$file"
|
||||||
|
plain "$(gettext "Aborting...")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( EUID == 0 )); then
|
||||||
|
# change perms of all source files to root user & root group
|
||||||
|
chown -R 0:0 "$srcdir"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
download_bzr() {
|
download_bzr() {
|
||||||
local netfile=$1
|
local netfile=$1
|
||||||
|
|
||||||
|
@ -386,11 +439,6 @@ download_bzr() {
|
||||||
url=${url##*bzr+}
|
url=${url##*bzr+}
|
||||||
url=${url%%#*}
|
url=${url%%#*}
|
||||||
|
|
||||||
local fragment=${netfile#*#}
|
|
||||||
if [[ $fragment = "$netfile" ]]; then
|
|
||||||
unset fragment
|
|
||||||
fi
|
|
||||||
|
|
||||||
local displaylocation="$url"
|
local displaylocation="$url"
|
||||||
local revision=('-r-1')
|
local revision=('-r-1')
|
||||||
|
|
||||||
|
@ -431,6 +479,18 @@ download_bzr() {
|
||||||
warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
|
warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_bzr() {
|
||||||
|
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")"
|
||||||
|
|
||||||
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${dir}" "bzr"
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${dir}" "bzr"
|
||||||
pushd "$srcdir" &>/dev/null
|
pushd "$srcdir" &>/dev/null
|
||||||
|
@ -448,11 +508,6 @@ download_bzr() {
|
||||||
download_git() {
|
download_git() {
|
||||||
local netfile=$1
|
local netfile=$1
|
||||||
|
|
||||||
local fragment=${netfile#*#}
|
|
||||||
if [[ $fragment = "$netfile" ]]; then
|
|
||||||
unset fragment
|
|
||||||
fi
|
|
||||||
|
|
||||||
local dir=$(get_filepath "$netfile")
|
local dir=$(get_filepath "$netfile")
|
||||||
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
||||||
|
|
||||||
|
@ -485,6 +540,22 @@ download_git() {
|
||||||
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_git() {
|
||||||
|
local netfile=$1
|
||||||
|
|
||||||
|
local fragment=${netfile#*#}
|
||||||
|
if [[ $fragment = "$netfile" ]]; then
|
||||||
|
unset fragment
|
||||||
|
fi
|
||||||
|
|
||||||
|
local repo=${netfile##*/}
|
||||||
|
repo=${repo%%#*}
|
||||||
|
repo=${repo%%.git*}
|
||||||
|
|
||||||
|
local dir=$(get_filepath "$netfile")
|
||||||
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
||||||
|
|
||||||
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
|
||||||
pushd "$srcdir" &>/dev/null
|
pushd "$srcdir" &>/dev/null
|
||||||
|
@ -528,11 +599,6 @@ download_git() {
|
||||||
download_hg() {
|
download_hg() {
|
||||||
local netfile=$1
|
local netfile=$1
|
||||||
|
|
||||||
local fragment=${netfile#*#}
|
|
||||||
if [[ $fragment = "$netfile" ]]; then
|
|
||||||
unset fragment
|
|
||||||
fi
|
|
||||||
|
|
||||||
local dir=$(get_filepath "$netfile")
|
local dir=$(get_filepath "$netfile")
|
||||||
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
[[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
|
||||||
|
|
||||||
|
@ -558,6 +624,21 @@ download_hg() {
|
||||||
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_hg() {
|
||||||
|
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=${netfile##*/}
|
||||||
|
repo=${repo%%#*}
|
||||||
|
|
||||||
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
|
||||||
pushd "$srcdir" &>/dev/null
|
pushd "$srcdir" &>/dev/null
|
||||||
|
@ -620,6 +701,21 @@ download_svn() {
|
||||||
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
|
warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_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=${netfile##*/}
|
||||||
|
repo=${repo%%#*}
|
||||||
|
|
||||||
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
|
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
|
||||||
pushd "$srcdir" &>/dev/null
|
pushd "$srcdir" &>/dev/null
|
||||||
|
@ -682,12 +778,6 @@ download_sources() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( PKGVERFUNC && GET_VCS )); then
|
|
||||||
update_pkgver
|
|
||||||
check_pkgver || exit 1
|
|
||||||
check_build_status
|
|
||||||
fi
|
|
||||||
|
|
||||||
popd &>/dev/null
|
popd &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1232,57 +1322,30 @@ extract_sources() {
|
||||||
# these are marked explicitly to NOT be extracted
|
# these are marked explicitly to NOT be extracted
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
local proto=$(get_protocol "$netfile")
|
||||||
|
case "$proto" in
|
||||||
# fix flyspray #6246
|
bzr*)
|
||||||
local file_type=$(file -bizL "$file")
|
extract_bzr "$netfile"
|
||||||
local ext=${file##*.}
|
;;
|
||||||
local cmd=''
|
git*)
|
||||||
case "$file_type" in
|
extract_git "$netfile"
|
||||||
*application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
|
;;
|
||||||
cmd="bsdtar" ;;
|
hg*)
|
||||||
*application/x-gzip*)
|
extract_hg "$netfile"
|
||||||
case "$ext" in
|
;;
|
||||||
gz|z|Z) cmd="gzip" ;;
|
svn*)
|
||||||
*) continue;;
|
extract_svn "$netfile"
|
||||||
esac ;;
|
;;
|
||||||
*application/x-bzip*)
|
|
||||||
case "$ext" in
|
|
||||||
bz2|bz) cmd="bzip2" ;;
|
|
||||||
*) continue;;
|
|
||||||
esac ;;
|
|
||||||
*application/x-xz*)
|
|
||||||
case "$ext" in
|
|
||||||
xz) cmd="xz" ;;
|
|
||||||
*) continue;;
|
|
||||||
esac ;;
|
|
||||||
*)
|
*)
|
||||||
# See if bsdtar can recognize the file
|
extract_file "$file"
|
||||||
if bsdtar -tf "$file" -q '*' &>/dev/null; then
|
;;
|
||||||
cmd="bsdtar"
|
|
||||||
else
|
|
||||||
continue
|
|
||||||
fi ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local ret=0
|
|
||||||
msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
|
|
||||||
if [[ $cmd = "bsdtar" ]]; then
|
|
||||||
$cmd -xf "$file" || ret=$?
|
|
||||||
else
|
|
||||||
rm -f -- "${file%.*}"
|
|
||||||
$cmd -dcf "$file" > "${file%.*}" || ret=$?
|
|
||||||
fi
|
|
||||||
if (( ret )); then
|
|
||||||
error "$(gettext "Failed to extract %s")" "$file"
|
|
||||||
plain "$(gettext "Aborting...")"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( EUID == 0 )); then
|
if (( PKGVERFUNC )); then
|
||||||
# change perms of all source files to root user & root group
|
update_pkgver
|
||||||
chown -R 0:0 "$srcdir"
|
check_pkgver || exit 1
|
||||||
|
check_build_status
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue