Newer
Older
# Source makepkg.conf; fail if it is not found
die '/etc/makepkg.conf not found!'
fi
# Source user-specific makepkg.conf overrides
pkgbase=${pkgbase:-$pkgname}
case "$cmd" in
commitpkg)
die 'Usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]'
fi
repo="$1"
shift
;;
*pkg)
repo="${cmd%pkg}"
;;
*)
die 'Usage: commitpkg <reponame> [-f] [-s server] [-l limit] [-a arch] [commit message]'
# find files which should be under source control
needsversioning=()
for s in "${source[@]}"; do
[[ $s != *://* ]] && needsversioning+=("$s")
done
for i in 'changelog' 'install'; do
while read -r file; do
# evaluate any bash variables used
eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
needsversioning+=("$file")
done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
done
# assert that they really are controlled by SVN
if (( ${#needsversioning[*]} )); then
# svn status's output is only two columns when the status is unknown
while read -r status filename; do
[[ $status = '?' ]] && unversioned+=("$filename")
done < <(svn status -v "${needsversioning[@]}")
(( ${#unversioned[*]} )) && die "%s is not under version control" "${unversioned[@]}"
fi
rsyncopts=(-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y)
Pierre Schmitz
committed
archreleaseopts=()
while getopts ':l:a:s:f' flag; do
Pierre Schmitz
committed
f) archreleaseopts+=('-f') ;;
s) server=$OPTARG ;;
l) rsyncopts+=("--bwlimit=$OPTARG") ;;
a) commit_arch=$OPTARG ;;
:) die "Option requires an argument -- '%s'" "$OPTARG" ;;
\?) die "Invalid option -- '%s'" "$OPTARG" ;;
esac
done
shift $(( OPTIND - 1 ))
# check packages have the packager field set
for _arch in ${arch[@]}; do
if [[ -n $commit_arch && ${_arch} != "$commit_arch" ]]; then
continue
fi
for _pkgname in ${pkgname[@]}; do
fullver=$(get_full_version $_pkgname)
if pkgfile=$(find_cached_package "$_pkgname" "$_arch" "$fullver"); then
if grep -q "packager = Unknown Packager" <(bsdtar -xOqf "$pkgfile" .PKGINFO); then
die "PACKAGER was not set when building package"
fi
fi
done
done
msgtemplate="upgpkg: $pkgbase $(get_full_version)"$'\n\n'
svn commit -q -m "${msgtemplate}${1}" || die
stat_done
msgfile="$(mktemp)"
echo "$msgtemplate" > "$msgfile"
$EDITOR "$msgfile"
else
vi "$msgfile"
fi
svn commit -q -F "$msgfile" || die
declare -a commit_arches
declare -a skip_arches
if [[ -n $commit_arch && ${_arch} != "$commit_arch" ]]; then
fullver=$(get_full_version $_pkgname)
if ! pkgfile=$(find_cached_package "$_pkgname" "$fullver" "${_arch}"); then
warning "Skipping $_pkgname-$fullver-$_arch: failed to locate package file"
sigfile="${pkgfile}.sig"
msg "Signing package ${pkgfile}..."
if [[ -n $GPGKEY ]]; then
SIGNWITHKEY="-u ${GPGKEY}"
fi
gpg --detach-sign --use-agent --no-armor ${SIGNWITHKEY} "${pkgfile}" || die
if ! gpg --verify "$sigfile" >/dev/null 2>&1; then
die "Signature %s.sig is incorrect!" "$pkgfile"
for _arch in ${arch[@]}; do
if ! in_array $_arch ${skip_arches[@]}; then
commit_arches+=($_arch)
fi
done
if [[ ${#commit_arches[*]} -gt 0 ]]; then
archrelease "${archreleaseopts[@]}" "${commit_arches[@]/#/$repo-}" || die
fi
if [[ ${#uploads[*]} -gt 0 ]]; then
new_uploads=()
# convert to absolute paths so rsync can work with colons (epoch)
while read -r -d '' upload; do
new_uploads+=("$upload")
done < <(realpath -z "${uploads[@]}")
uploads=("${new_uploads[@]}")
unset new_uploads
msg 'Uploading all package and signature files'
rsync "${rsyncopts[@]}" "${uploads[@]}" "$server:staging/$repo/" || die
if [[ "${arch[*]}" == 'any' ]]; then
if [[ -d ../repos/$repo-i686 && -d ../repos/$repo-x86_64 ]]; then
stat_busy "Removing $repo-i686 and $repo-x86_64"
svn rm -q $repo-i686
svn rm -q $repo-x86_64
svn commit -q -m "Removed $repo-i686 and $repo-x86_64 for $pkgname"
else
pushd ../repos/ >/dev/null
svn commit -q -m "Removed $repo-any for $pkgname"
popd >/dev/null
fi