2008-04-06 03:11:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-11-01 15:33:08 +01:00
|
|
|
m4_include(lib/common.sh)
|
2012-02-09 00:50:15 +01:00
|
|
|
m4_include(lib/valid-tags.sh)
|
2010-02-22 08:13:43 +01:00
|
|
|
|
2012-02-09 00:50:15 +01:00
|
|
|
# parse command line options
|
|
|
|
FORCE=
|
|
|
|
while getopts ':f' flag; do
|
|
|
|
case $flag in
|
|
|
|
f) FORCE=1 ;;
|
|
|
|
:) die "Option requires an argument -- '$OPTARG'" ;;
|
|
|
|
\?) die "Invalid option -- '$OPTARG'" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( OPTIND - 1 ))
|
|
|
|
|
|
|
|
if ! (( $# )); then
|
|
|
|
echo 'Usage: archrelease [-f] <repo>...'
|
2011-11-01 15:33:08 +01:00
|
|
|
exit 1
|
2008-04-06 03:11:32 +02:00
|
|
|
fi
|
|
|
|
|
2012-02-09 00:50:15 +01:00
|
|
|
# validate repo is really repo-arch
|
|
|
|
if [[ -z $FORCE ]]; then
|
|
|
|
for tag in "$@"; do
|
|
|
|
if ! in_array "$tag" "${_tags[@]}"; then
|
|
|
|
die 'archrelease: Invalid tag: "'$tag'" (use -f to force release)'
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2011-07-25 19:52:09 +02:00
|
|
|
|
2011-08-17 03:36:00 +02:00
|
|
|
if [[ ! -f PKGBUILD ]]; then
|
2011-11-01 15:33:08 +01:00
|
|
|
die 'archrelease: PKGBUILD not found'
|
2008-04-22 04:31:51 +02:00
|
|
|
fi
|
|
|
|
|
2011-08-17 03:36:00 +02:00
|
|
|
trunk=${PWD##*/}
|
2010-12-14 15:13:06 +01:00
|
|
|
|
2011-07-25 19:52:09 +02:00
|
|
|
# Normally this should be trunk, but it may be something
|
|
|
|
# such as 'gnome-unstable'
|
2011-08-17 03:36:00 +02:00
|
|
|
IFS='/' read -r -d '' -a parts <<< "$PWD"
|
|
|
|
if [[ "${parts[@]:(-2):1}" == "repos" ]]; then
|
2011-11-01 15:33:08 +01:00
|
|
|
die 'archrelease: Should not be in repos dir (try from trunk/)'
|
2008-04-22 04:31:51 +02:00
|
|
|
fi
|
2011-08-17 03:36:00 +02:00
|
|
|
unset parts
|
2008-04-22 04:31:51 +02:00
|
|
|
|
2011-08-17 03:36:00 +02:00
|
|
|
if [[ $(svn status -q) ]]; then
|
2011-11-01 15:33:08 +01:00
|
|
|
die 'archrelease: You have not committed your changes yet!'
|
2009-10-06 18:20:03 +02:00
|
|
|
fi
|
|
|
|
|
2010-02-12 01:11:59 +01:00
|
|
|
pushd .. >/dev/null
|
2011-08-22 13:59:36 +02:00
|
|
|
IFS=$'\n' read -r -d '' -a known_files < <(svn ls -r HEAD "$trunk")
|
2011-08-19 10:16:48 +02:00
|
|
|
for file in "${known_files[@]}"; do
|
|
|
|
if [[ ${file:(-1)} = '/' ]]; then
|
2011-11-01 15:33:08 +01:00
|
|
|
die "archrelease: subdirectories are not supported in package directories!"
|
2011-08-19 10:16:48 +02:00
|
|
|
fi
|
|
|
|
done
|
2011-08-20 22:18:48 +02:00
|
|
|
|
2012-06-10 11:35:39 +02:00
|
|
|
# gracefully handle files containing an "@" character
|
|
|
|
known_files=("${known_files[@]/%/@}")
|
|
|
|
|
2011-08-20 22:18:48 +02:00
|
|
|
for tag in "$@"; do
|
2011-11-02 01:38:42 +01:00
|
|
|
stat_busy "Copying ${trunk} to ${tag}"
|
2011-08-20 22:18:48 +02:00
|
|
|
|
|
|
|
if [[ -d repos/$tag ]]; then
|
|
|
|
declare -a trash
|
|
|
|
trash=()
|
|
|
|
while read -r file; do
|
|
|
|
trash+=("repos/$tag/$file")
|
|
|
|
done < <(svn ls "repos/$tag")
|
2012-10-13 17:28:52 +02:00
|
|
|
[[ $trash ]] && svn rm -q "${trash[@]/%/@}"
|
2011-08-20 22:18:48 +02:00
|
|
|
else
|
|
|
|
mkdir -p "repos/$tag"
|
|
|
|
svn add --parents -q "repos/$tag"
|
|
|
|
fi
|
|
|
|
|
2011-09-08 23:38:28 +02:00
|
|
|
# copy all files at once from trunk to the subdirectory in repos/
|
|
|
|
svn copy -q -r HEAD ${known_files[@]/#/$trunk/} "repos/$tag/"
|
2011-08-20 22:18:48 +02:00
|
|
|
|
2011-11-01 15:33:08 +01:00
|
|
|
stat_done
|
2011-07-25 19:52:09 +02:00
|
|
|
done
|
2011-08-20 22:18:48 +02:00
|
|
|
|
2011-11-02 01:38:42 +01:00
|
|
|
stat_busy "Releasing package"
|
2011-08-20 22:18:48 +02:00
|
|
|
printf -v tag_list ", %s" "$@"; tag_list="${tag_list#, }"
|
2011-08-22 13:59:36 +02:00
|
|
|
svn commit -q -m "archrelease: copy ${trunk} to $tag_list" || abort
|
2011-11-01 15:33:08 +01:00
|
|
|
stat_done
|
2011-08-20 22:18:48 +02:00
|
|
|
|
|
|
|
popd >/dev/null
|