+++ /dev/null
-#!/bin/bash
-echo "---> jjb/ci-management/packagecloud-repo-cleanup.sh"
-
-set -euxo pipefail
-
-# Number of packages to keep.
-N_PACKAGES=5
-
-PACKAGECLOUD_REPO_DEB="https://packagecloud.io/install/repositories/fdio/${STREAM}/script.deb.sh"
-
-FACTER_OS=$(/usr/bin/facter operatingsystem)
-PACKAGE_LIST=""
-VERSION_REGEX="[0-9]+.[0-9]+[-_][0-9]+[-_]release(-1)?|[0-9]+.[0-9]+[-_][0-9]+~g[[:graph:]]+"
-
-declare -A FUNCTIONS
-
-echo_err () {
- >&2 echo ${@}
- exit 1
-}
-
-contains() {
- [[ ${1} =~ (^|[[:space:]])${2}($|[[:space:]]) ]] && return 1 || return 0
-}
-
-check_version_whitelist() {
- if [[ ${1} =~ ([0-9]+).([0-9]+)[-_]([0-9]+).+ ]]; then
- MAJOR=${BASH_REMATCH[1]}
- MINOR=${BASH_REMATCH[2]}
- REVISION=${BASH_REMATCH[3]}
- VER="${MAJOR}.${MINOR}-${REVISION}"
-
- if contains "${VERSION_WHITELIST}" ${VER}; then
- return 1;
- fi
- fi
-
- return 0
-}
-
-# Params
-# $1: Package list
-build_package_blacklist_ubuntu () {
- PACKAGE_LIST=${@}
- OUTPUT_LIST=""
- ARCH=$(dpkg --print-architecture)
-
- for package in ${PACKAGE_LIST}; do
- OUTPUT=$(apt-cache policy ${package} 2> /dev/null)
-
- if [[ ${?} -ne 0 || -z "${OUTPUT}" ]]; then
- continue
- fi
-
- # N_PACKAGES + 2 is justified by the fact thathe output of apt-cache policy is in the form:
- # apt-cache policy libhicn
- # libhicn:
- # Installed: (none)
- # Candidate: 20.05-11-release
- # Version table:
- # 20.05-11-release 500
- #
- # The first version candidate is printed twice.
- # So we need to exclude the "Candidate: 20.05-11-release" (+1).
- # Also `tail -n +M` starts to print from the Mth line, being 1 the first line.
- # So to exclude the Mth line an additional +1 is needed.
- VERSIONS="$(echo ${OUTPUT} | grep -E -o ${VERSION_REGEX} | tail -n +$((N_PACKAGES + 2)))"
-
- for version in ${VERSIONS}; do
- if ! check_version_whitelist ${version}; then
- OUTPUT_LIST+="${package}_${version}_${ARCH}.deb "
- fi
- done
- done
-
- echo ${OUTPUT_LIST}
-}
-
-promote_attic_repo_ubuntu () {
- FACTER_LSBNAME=$(/usr/bin/facter lsbdistcodename)
-
- for package in ${@}; do
- echo package_cloud promote ${PCIO_CO}/${STREAM}/ubuntu/${FACTER_LSBNAME}/main/ \
- ${package} ${PCIO_CO}/attic/ubuntu/${FACTER_LSBNAME}/main/
- package_cloud promote ${PCIO_CO}/${STREAM}/ubuntu/${FACTER_LSBNAME}/main/ \
- ${package} ${PCIO_CO}/attic/ubuntu/${FACTER_LSBNAME}/main/
- done
-}
-
-promote_to_attic_repo () {
- ${FUNCTIONS["promote_attic_repo"]} ${@}
-}
-
-setup_fdio_repo () {
- case "${FACTER_OS}" in
- Ubuntu)
- curl -s ${PACKAGECLOUD_REPO_DEB} | sudo bash
- FUNCTIONS["package_blacklist"]="build_package_blacklist_ubuntu"
- FUNCTIONS["promote_attic_repo"]="promote_attic_repo_ubuntu"
- PACKAGE_LIST="${PACKAGE_LIST_COMMON} ${PACKAGE_LIST_UBUNTU}"
- ;;
- *)
- echo_err "Distribution ${FACTER_OS} is not supported."
- ;;
- esac
-}
-
-# Params
-# $1: Package list
-build_package_blacklist () {
- ${FUNCTIONS["package_blacklist"]} ${@}
-}
-
-setup_fdio_repo
-PACKAGES_TO_PROMOTE=$(build_package_blacklist ${PACKAGE_LIST})
-promote_to_attic_repo ${PACKAGES_TO_PROMOTE}
+++ /dev/null
-- project:
- name: packagecloud-repo-cleanup-x86_64
- jobs:
- - 'packagecloud-repo-cleanup-release-{os}-{executor-arch}'
- project: 'ci-management'
- os:
- - ubuntu2004
-
- executor-arch: "x86_64"
-
-- project:
- name: packagecloud-repo-cleanup-aarch64
- jobs:
- - 'packagecloud-repo-cleanup-release-{os}-{executor-arch}'
- project: 'ci-management'
- os:
- - ubuntu2004
-
- executor-arch: "aarch64"
-
-- project:
- name: packagecloud-view
- views:
- - project-view
- project-name: packagecloud
-
-- job-template:
- name: 'packagecloud-repo-cleanup-release-{os}-{executor-arch}'
-
- project-type: freestyle
- node: 'builder-{os}-prod-{executor-arch}'
- concurrent: true
-
- properties:
- - lf-infra-properties:
- build-days-to-keep: "{build-days-to-keep}"
-
- parameters:
- - project-parameter:
- project: '{project}'
- - gerrit-parameter:
- branch: '{branch}'
- - os-parameter:
- os: '{os}'
- - stream-parameter:
- stream: 'release'
-
- wrappers:
- - fdio-infra-wrappers:
- build-timeout: 120
-
- triggers:
- - gerrit:
- server-name: 'Primary'
- trigger-on:
- - comment-added-contains-event:
- comment-contains-value: 'release-cleanup'
- projects:
- - project-compare-type: 'ANT'
- project-pattern: '{project}'
- branches:
- - branch-compare-type: 'ANT'
- branch-pattern: '**/{branch}'
-
- builders:
- - config-file-provider:
- files:
- - file-id: '.packagecloud'
- target: '/root/.packagecloud'
- - config-file-provider:
- files:
- - file-id: 'packagecloud_api'
- target: '/root/packagecloud_api'
- - shell:
- !include-raw-escape:
- - ../scripts/setup_executor_env.sh
- - shell:
- !include-raw-escape:
- - package-list.sh
- - packagecloud-repo-cleanup.sh
-
- publishers:
- - fdio-infra-publish