Skip to content
Snippets Groups Projects

Draft: Switch release scripts to python-gitlab

Open Walter Lozano requested to merge wip/wlozano/python-gitlab-release into main
1 file
+ 46
49
Compare changes
  • Side-by-side
  • Inline
@@ -89,89 +89,86 @@ function tally_rev ()
local pkg=$1
local git_branch=$2
local comp=$3
local rel=$4
base_rev=`get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$rel"`
branch_rev=`get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$rel-$git_branch"`
base_rev=`get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$RELEASE"`
branch_rev=`get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$RELEASE-$git_branch"`
if [ "$base_rev" = "null" ] || [ "$branch_rev" = "null" ]
then
echo "Revision cannot be null. Possibly '$OSNAME/$rel => $base_rev' OR '$OSNAME/$rel-$git_branch => $branch_rev' is non-existent"
echo "Revision cannot be null. Possibly '$OSNAME/$RELEASE => $base_rev' OR '$OSNAME/$RELEASE-$git_branch => $branch_rev' is non-existent"
return 1
else
echo "Package $pkg $rel is $base_rev and $rel-$git_branch is $branch_rev"
echo "Package $pkg $RELEASE is $base_rev and $RELEASE-$git_branch is $branch_rev"
test "$base_rev" = "$branch_rev"
fi
}
function clean_obs ()
{
local release=$1
local branch=$2
local comp=$3
local pkg=$4
local branch=$1
local comp=$2
local pkg=$3
echo "Deleting package $OSNAME:$release:$branch:$comp/$pkg"
echo "Deleting package $OSNAME:$RELEASE:$branch:$comp/$pkg"
# Delete the respective package form the updates/security repo too
echo "Deleting package $pkg from repository $OSNAME:$release:$branch:$comp"
$OSC rdelete "$OSNAME:$release:$branch:$comp/$pkg" -m "Delete package $pkg from repo $OSNAME:$release:$branch:$comp/$pkg"
echo "Deleting package $pkg from repository $OSNAME:$RELEASE:$branch:$comp"
$OSC rdelete "$OSNAME:$RELEASE:$branch:$comp/$pkg" -m "Delete package $pkg from repo $OSNAME:$RELEASE:$branch:$comp/$pkg"
}
function clean_reprepro ()
{
local release=$1
local branch=$2
local comp=$3
local pkg=$4
local branch=$1
local comp=$2
local pkg=$3
# Also delete it from the reprepro db
echo "Deleting package $pkg from reprepro database"
echo "sudo -u obsrun reprepro --gnupghome /srv/obs/gnupg/ -Vb /srv/obs/repos/shared/$OSNAME/public/$OSNAME removesrc $release-$branch $pkg" || echo "ERROR: Failed to remove the $release-$branch/$pkg sources from reprepro" >&2
echo "sudo -u obsrun reprepro --gnupghome /srv/obs/gnupg/ -Vb /srv/obs/repos/shared/$OSNAME/public/$OSNAME removesrc $RELEASE-$branch $pkg" || echo "ERROR: Failed to remove the $RELEASE-$branch/$pkg sources from reprepro" >&2
echo
}
function fold_and_clean ()
{
local release=$1
local branch=$2
local comp=$3
local pkg=$4
local branch=$1
local comp=$2
local pkg=$3
if tally_rev $pkg $branch $comp $release
if tally_rev $pkg $branch $comp
then
echo
echo "Package $pkg is in sync in branches: $release and $release-$branch"
echo "Package $pkg is in sync in branches: $RELEASE and $RELEASE-$branch"
if [ $CLEAN_GITLAB -eq 1 ]
then
echo "Deleting branch $release-$branch"
echo "Deleting branch $RELEASE-$branch"
DELETE=0
$RUN $PYTHON_GITLAB project-branch delete --project-id "pkg/$pkg" --name "$OSNAME/$release-$branch" && DELETE=1
$RUN $PYTHON_GITLAB project-branch delete --project-id "pkg/$pkg" --name "$OSNAME/$RELEASE-$branch" && DELETE=1
# Delete the respective package form the updates/security repo too
if [ $CLEAN_OBS -eq 1 ] && [ $DELETE -eq 1 ]; then
clean_obs $release $branch $comp $pkg || return 1
clean_obs $branch $comp $pkg || return 1
fi
if [ $CLEAN_REPREPRO -eq 1 ] && [ $DELETE -eq 1 ]; then
clean_reprepro $release $branch $comp $pkg || return 1
clean_reprepro $branch $comp $pkg || return 1
fi
fi
echo
echo CLEAN $pkg >> $release-$branch-$comp.log
echo CLEAN $pkg >> $RELEASE-$branch-$comp.log
else
echo
echo "Checking if branch $OSNAME/$release-$branch exists on server"
branch_rev=$(get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$release-$branch")
echo "Checking if branch $OSNAME/$RELEASE-$branch exists on server"
branch_rev=$(get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$RELEASE-$branch")
if [ -z "$branch_rev" ] || [ "$branch_rev" = "null" ]
then
echo "Branch $OSNAME/$release-$branch non-existent for package $pkg on remote git repository. Skipping."
echo "Branch $OSNAME/$RELEASE-$branch non-existent for package $pkg on remote git repository. Skipping."
echo
echo SKIP $pkg >> $release-$branch-$comp.log
echo SKIP $pkg >> $RELEASE-$branch-$comp.log
return 0
fi
echo "Checking if $release is available"
base_rev=$(get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$release")
echo "Checking if $RELEASE is available"
base_rev=$(get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$RELEASE")
other_branch=
if [ "$branch" = "security" ]
@@ -182,24 +179,24 @@ function fold_and_clean ()
other_branch=security
fi
echo "Checking if branch $OSNAME/$release-$other_branch exists on server"
branch_rev=$(get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$release-$other_branch")
echo "Checking if branch $OSNAME/$RELEASE-$other_branch exists on server"
branch_rev=$(get_repo_branch_short_id "pkg/$pkg" "$OSNAME/$RELEASE-$other_branch")
if [ -z "$base_rev" ] || [ "$base_rev" = null ]
then
echo "Branch $release is not available, this seems to be a new package"
echo "Package $pkg is NOT IN SYNC in branches: $release does not exist"
echo "Branch $RELEASE is not available, this seems to be a new package"
echo "Package $pkg is NOT IN SYNC in branches: $RELEASE does not exist"
elif [ -n "$branch_rev" ] && [ "$branch_rev" != "null" ]
then
echo "Branch $OSNAME/$release-$other_branch which might have already been merged"
echo "Package $pkg is NOT IN SYNC in branches: $release and $release-$branch, but $release-$other_branch present"
echo "Branch $OSNAME/$RELEASE-$other_branch which might have already been merged"
echo "Package $pkg is NOT IN SYNC in branches: $RELEASE and $RELEASE-$branch, but $RELEASE-$other_branch present"
else
echo "Package $pkg is NOT IN SYNC in branches: $release and $release-$branch"
echo "Package $pkg is NOT IN SYNC in branches: $RELEASE and $RELEASE-$branch"
fi
echo "Merging branch $release-$branch into $release"
echo "Merging branch $RELEASE-$branch into $RELEASE"
if [ $DRY_RUN -ne 1 ]
then
mr_url=$(create_merge_request "pkg/$pkg" "$OSNAME/$release-$branch" "$OSNAME/$release")
mr_url=$(create_merge_request "pkg/$pkg" "$OSNAME/$RELEASE-$branch" "$OSNAME/$RELEASE")
mr_id=$(echo $mr_url | grep -o '[^/]*$')
echo $mr_url
echo "MR ID is: $mr_id"
@@ -216,14 +213,14 @@ function fold_and_clean ()
merge_merge_request "pkg/$pkg" $mr_id ||
(sleep 3; merge_merge_request "pkg/$pkg" $mr_id)
echo
echo MERGE $pkg $mr_url >> $release-$branch-$comp.log
echo MERGE $pkg $mr_url >> $RELEASE-$branch-$comp.log
else
echo "Invalid MR ID $mr_id for URL $mr_url for project pkg/$pkg"
return 1
fi
else
create_merge_request "pkg/$pkg" "$OSNAME/$release-$branch" "$OSNAME/$release"
echo NEEDS-MERGE $pkg $release-$branch into $release >> $release-$branch-$comp.log
create_merge_request "pkg/$pkg" "$OSNAME/$RELEASE-$branch" "$OSNAME/$RELEASE"
echo NEEDS-MERGE $pkg $RELEASE-$branch into $RELEASE >> $RELEASE-$branch-$comp.log
fi
echo
fi
@@ -342,15 +339,15 @@ do
then
if [ $CLEAN_OBS -eq 1 ]
then
clean_obs $RELEASE $branch $comp $pkg
clean_obs $branch $comp $pkg
fi
if [ $CLEAN_REPREPRO -eq 1 ]
then
clean_reprepro $RELEASE $branch $comp $pkg
clean_reprepro $branch $comp $pkg
fi
elif [ $FOLD -eq 1 ]
then
if ! fold_and_clean $RELEASE $branch $comp $pkg
if ! fold_and_clean $branch $comp $pkg
then
echo ERROR $pkg >> $RELEASE-$branch-$comp.log
fi
Loading