automate/utils/delete-deb-to-gitea.sh

50 lines
1.4 KiB
Bash

#!/usr/bin/env bash
USERNAME="cyteen"
PASSWORD="mlpfinsonik"
DISTRIBUTION="ceres"
COMPONENT="main"
ARCH=$(dpkg --print-architecture)
# Function to delete a package
delete_package() {
local PACKAGE_NAME=$1
local PACKAGE_VERSION=$2
local ARCHITECTURE=${3}
# Construct the GITEA URL for deletion
GITEA_DELETE_URL="https://git2.ring-zero.co.uk/api/packages/${USERNAME}/debian/pool/${DISTRIBUTION}/${COMPONENT}/${PACKAGE_NAME}/${PACKAGE_VERSION}/${ARCHITECTURE}"
# Perform the DELETE request
curl --user ${USERNAME}:${PASSWORD} -X DELETE ${GITEA_DELETE_URL}
echo "Deleted ${PACKAGE_NAME}-${PACKAGE_VERSION}-${ARCHITECTURE} from the repository."
}
# local ARCHITECTURE="${DEB_FILE%.*}" # Assuming DEB_FILE is defined and contains the package name and version
# Check if both package name and version were provided as arguments
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: $0 <package_name> <version> <arch>"
exit 1
fi
PACKAGE="$1"
VERSION="$2"
ARCH="$3"
echo "PACKAGE: ${PACKAGE}"
echo "VERSION: ${VERSION}"
echo "ARCH: ${ARCH}"
echo ${GITEA_URL}
# Use the constructed URL in the curl command to delete the specified package version
curl --user ${USERNAME}:${PASSWORD} \
-X DELETE \
-H 'accept: application/json' \
"${GITEA_URL}"
# Show available packages
curl -s --url https://cyteen:mlpfinsonik@git2.ring-zero.co.uk/api/v1/packages/cyteen/ | jq '.[] | select(.type == "debian") | {type, name, version, html_url, created_at}'