Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvy Foster <escondida@iff.ink>2020-11-25 22:38:24 -0600
committerAllan McRae <allan@archlinux.org>2020-11-26 21:58:40 +1000
commit08f4ae709ca00ec9b4c56d92d3cdd7de4e6effc2 (patch)
tree9e923698858a61e97fa31cafbf92d1f066dbebd3
parent73e0d7dedc197f71c4fd6b7c18d2b2f2d63bf013 (diff)
Add fossil scm support to makepkg
Signed-off-by: Ivy Foster <escondida@iff.ink> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--doc/PKGBUILD.5.asciidoc3
-rw-r--r--etc/makepkg.conf.in1
-rw-r--r--scripts/libmakepkg/executable/vcs.sh.in2
-rw-r--r--scripts/libmakepkg/source/fossil.sh.in126
-rw-r--r--scripts/libmakepkg/source/meson.build1
-rw-r--r--scripts/libmakepkg/util/source.sh.in5
6 files changed, 136 insertions, 2 deletions
diff --git a/doc/PKGBUILD.5.asciidoc b/doc/PKGBUILD.5.asciidoc
index 2e2108a0..1db0b6c4 100644
--- a/doc/PKGBUILD.5.asciidoc
+++ b/doc/PKGBUILD.5.asciidoc
@@ -499,6 +499,9 @@ The source URL is divided into four components:
*bzr*;;
revision (see `'bzr help revisionspec'` for details)
+ *fossil*;;
+ branch, commit, tag
+
*git*;;
branch, commit, tag
diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index e9582646..b13b1d5d 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -24,6 +24,7 @@ DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
#-- The package required by makepkg to download VCS sources
# Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
+ 'fossil::fossil'
'git::git'
'hg::mercurial'
'svn::subversion')
diff --git a/scripts/libmakepkg/executable/vcs.sh.in b/scripts/libmakepkg/executable/vcs.sh.in
index 436b82db..756eeb81 100644
--- a/scripts/libmakepkg/executable/vcs.sh.in
+++ b/scripts/libmakepkg/executable/vcs.sh.in
@@ -77,7 +77,7 @@ executable_vcs() {
local proto=$(get_protocol "$netfile")
case $proto in
- bzr*|git*|hg*|svn*)
+ bzr*|fossil*|git*|hg*|svn*)
if ! type -p ${proto%%+*} > /dev/null; then
local client
client=$(get_vcsclient "$proto") || exit $?
diff --git a/scripts/libmakepkg/source/fossil.sh.in b/scripts/libmakepkg/source/fossil.sh.in
new file mode 100644
index 00000000..91cb114b
--- /dev/null
+++ b/scripts/libmakepkg/source/fossil.sh.in
@@ -0,0 +1,126 @@
+#!/bin/bash
+#
+# fossil.sh - function for handling the download and extraction of Fossil sources
+#
+# Copyright (c) 2020 Pacman Development Team <pacman-dev@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_FOSSIL_SH" ]] && return
+LIBMAKEPKG_SOURCE_FOSSIL_SH=1
+
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/pkgbuild.sh"
+
+download_fossil() {
+ # abort early if parent says not to fetch
+ if declare -p get_vcs > /dev/null 2>&1; then
+ (( get_vcs )) || return
+ fi
+
+ local netfile=$1
+
+ local db=$(get_filepath "$netfile")
+ [[ -z "$db" ]] && db="$SRCDEST/$(get_filename "$netfile")"
+
+ local repo=$db
+
+ local url=$(get_url "$netfile")
+ url=${url#fossil+}
+ url=${url%%#*}
+ url=${url%%\?*}
+
+ if [[ ! -f "$db" ]]; then
+ msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "fossil"
+ if ! fossil clone "$url" "$db"; then
+ error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "fossil"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ fi
+ elif (( ! HOLDVER )); then
+ # Make sure we are fetching the right repo
+ if ! [[ $(fossil remote -R "$db") = "$url" ]]; then
+ error "$(gettext "%s is not a clone of %s")" "$db" "$url"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ fi
+ msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "fossil"
+ if ! fossil pull -R "$db"; then
+ # only warn on failure to allow offline builds
+ warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "fossil"
+ fi
+ fi
+}
+
+extract_fossil() {
+ local netfile=$1 tagname
+
+ local fragment=$(get_uri_fragment "$netfile")
+ local repo=$(get_filename "$netfile")
+
+ local db=$(get_filepath "$netfile")
+ [[ -z "$db" ]] && db="$SRCDEST/$(get_filename "$netfile")"
+ local dir=${db%%.fossil}
+ dir=${dir##*/}
+
+ msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "fossil"
+ pushd "$srcdir" &>/dev/null
+
+ if [[ -d "$dir" ]]; then
+ if [[ -f "$dir/.fslckout" ]]; then
+ cd_safe "$dir"
+ if ! [[ $(fossil info | awk '/^repository/ {print $2}') = "$db" ]]; then
+ error "$(gettext "%s is not a checkout of %s repo %s")" "${srcdir}/${dir}" "fossil" "${repo}"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ fi
+ cd_safe "$srcdir"
+ else
+ error "$(gettext "%s is not a checkout of %s repo %s")" "${srcdir}/${dir}" "fossil" "${repo}"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ fi
+ elif ! fossil open "$db" --workdir "$dir" >/dev/null; then
+ error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "fossil"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ fi
+
+ cd_safe "${dir##*/}"
+
+ ref=tip
+ if [[ -n $fragment ]]; then
+ case ${fragment%%=*} in
+ branch|commit|tag)
+ ref=${fragment##*=}
+ ;;
+ *)
+ error "$(gettext "Unrecognized reference: %s")" "${fragment}"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ esac
+ fi
+
+ if ! fossil update "$ref" >/dev/null; then
+ error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "fossil"
+ plainerr "$(gettext "Aborting...")"
+ exit 1
+ fi
+
+ popd &>/dev/null
+}
diff --git a/scripts/libmakepkg/source/meson.build b/scripts/libmakepkg/source/meson.build
index 59326133..41b18c37 100644
--- a/scripts/libmakepkg/source/meson.build
+++ b/scripts/libmakepkg/source/meson.build
@@ -3,6 +3,7 @@ libmakepkg_module = 'source'
sources = [
'bzr.sh.in',
'file.sh.in',
+ 'fossil.sh.in',
'git.sh.in',
'hg.sh.in',
'local.sh.in',
diff --git a/scripts/libmakepkg/util/source.sh.in b/scripts/libmakepkg/util/source.sh.in
index be7c15c2..029bf8ed 100644
--- a/scripts/libmakepkg/util/source.sh.in
+++ b/scripts/libmakepkg/util/source.sh.in
@@ -65,7 +65,7 @@ get_filename() {
local proto=$(get_protocol "$netfile")
case $proto in
- bzr|git|hg|svn)
+ bzr|fossil|git|hg|svn)
filename=${netfile%%#*}
filename=${filename%%\?*}
filename=${filename%/}
@@ -73,6 +73,9 @@ get_filename() {
if [[ $proto = bzr ]]; then
filename=${filename#*lp:}
fi
+ if [[ $proto = fossil ]]; then
+ filename=$filename.fossil
+ fi
if [[ $proto = git ]]; then
filename=${filename%%.git*}
fi