60 lines
1.7 KiB
Bash
Executable File
60 lines
1.7 KiB
Bash
Executable File
#! /usr/bin/bash
|
|
set -x
|
|
|
|
UPSTREAM_BRANCH=rawhide
|
|
TARGET_BRANCH=main
|
|
|
|
help() {
|
|
echo -e "$0 [[-u <upstream>][-t <target>]] <target_dir>|[-h]\n" \
|
|
"Convert package from ingress directory to sha256 git in\n"\
|
|
"directory <target_dir> and reformat it for SUSE.\n" \
|
|
"The ingress can either be a single package directory or\n" \
|
|
"a top level directory containing the file 'packagelist.\n" \
|
|
"\t-u <upstream>: upstream branch. Default:\n" \
|
|
"\t-t <target>: target branch. Default: \n" \
|
|
"\t-h: help"
|
|
}
|
|
|
|
update_one_package() {
|
|
local script_dir=$1
|
|
local target_dir=$2
|
|
[ -n "$target_dir" ] || target_dir=../../ROCm
|
|
local dir=$(pwd)
|
|
package_name=$(basename $dir)
|
|
[ -e ${package_name}.spec ] || { echo "No package directory?"; exit 1; }
|
|
$script_dir/git_to_256 push $target_dir/$package_name origin/$UPSTREAM_BRANCH || exit 1
|
|
cd $target_dir/$package_name
|
|
## Cave: force push?
|
|
#git push origin refs/remotes/upstream/rawhide:refs/remotes/upstream/rawhide
|
|
$script_dir/susefy-package.sh -r upstream/$UPSTREAM_BRANCH -t $TARGET_BRANCH
|
|
$no_push || git push origin $TARGET_BRANCH
|
|
}
|
|
|
|
no_push=false
|
|
|
|
while [ -n "$1" ]; do
|
|
case $1 in
|
|
-u) shift; UPSTREAM=$i; shift ;;
|
|
-t) shift; TARGET=$i; shift ;;
|
|
-n) shift; no_push=true ;;
|
|
-h) help; exit 0 ;;
|
|
-*) echo "unknown option $1" &>2; exit 1 ;;
|
|
*) target_dir=$1; shift ;;
|
|
esac
|
|
done
|
|
|
|
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
if [ -e ./packagelist ]; then
|
|
dir=$(pwd)
|
|
for i in $(cat ./packagelist); do
|
|
cd $dir/$i
|
|
update_one_package $script_dir $target_dir
|
|
done
|
|
elif [ -d .git -a *.spec != \*.spec ]; then
|
|
update_one_package $script_dir $target_dir
|
|
else
|
|
echo "No package file nor spec or no git directory?" >&2
|
|
exit 1
|
|
fi
|
|
|