2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # This script publishes packages from our testing repo to the prod repo (#11572 and #11878)
7 # Parameters (both are mandatory):
8 # --packages list of packages, comma separated, to move from dev_repo_dir to prod_repo_dir
9 # --distros list of distros, comma separated, to which to publish packages
11 RPM_REPO_BASE_DIR="/var/www/rpm.arvados.org"
13 ### MAIN ####################################################################
16 echo " $0 --distros <distroA,distroB,...,distroN> --packages <packageA,packageB,...,packageN>"
17 echo " (both parameters are mandatory)"
23 while [ ${#} -gt 0 ]; do
25 --packages) packages="$2"; shift 2 ;;
26 --distros) distros="$2"; shift 2 ;;
27 *) echo "$0: Unrecognized option: $1" >&2; exit 1;
31 # Make sure the variables are set or provide an example of how to use them
32 if [ -z "${packages}" ]; then
33 echo "You must provide a comma-separated list of packages to publish, ie."
34 echo "* Debian: --packages=arvados-ws:0.1.20170906144951.22418ed6e-1,keep-exercise:1.2.3-1"
35 echo "* Centos: --packages=arvados-ws:0.1.20170906144951.22418ed6e-1,keep-exercise:1.2.3-1"
38 if [ -z "${distros}" ]; then
39 echo "You must provide a space-separated list of LSB distribution codenames to which you want to publish to, ie."
40 echo "* Debian: --distros=jessie,xenial,stretch,etc."
41 echo "* Centos: --distros=centos7,etc."
45 DIST_LIST=$(echo ${distros} | sed s/,/' '/g |tr '[:upper:]' '[:lower:]')
46 CENTOS_PACKAGES=$(echo ${packages} | sed 's/\([a-z-]*\):[[:blank:]]*\([0-9.-]*\)/\1*\2*/g; s/,/ /g;')
47 DEBIAN_PACKAGES=$(echo ${packages} | sed 's/\([a-z-]*\):[[:blank:]]*\([0-9.-]*\)/\1 (= \2)/g;')
49 if ( echo ${DIST_LIST} |grep -q centos ); then
50 for DISTNAME in ${DIST_LIST}; do
53 DIST_DIR_TEST='7/testing/x86_64'
54 DIST_DIR_PROD='7/os/x86_64'
57 echo "Only centos7 is accepted right now"
61 cd ${RPM_REPO_BASE_DIR}
62 mkdir -p ${RPM_REPO_BASE_DIR}/CentOS/${DIST_DIR_PROD}
63 echo "Copying packages ..."
64 for P in ${CENTOS_PACKAGES}; do
65 cp ${RPM_REPO_BASE_DIR}/CentOS/${DIST_DIR_TEST}/${P} ${RPM_REPO_BASE_DIR}/CentOS/${DIST_DIR_PROD}/
67 FAILED_PACKAGES="${FAILED_PACKAGES} ${P}"
70 echo "Recreating repo CentOS/${DIST_DIR_PROD} ..."
71 createrepo ${RPM_REPO_BASE_DIR}/CentOS/${DIST_DIR_PROD}
74 for DISTNAME in ${DIST_LIST}; do
76 echo "Copying packages ..."
79 for P in ${DEBIAN_PACKAGES}; do
80 aptly repo search ${DISTNAME}-testing "${P}"
82 echo "ERROR: unable to find a match for '${P}' in ${DISTNAME}-testing"
83 FAILED_PACKAGES="${FAILED_PACKAGES} ${DISTNAME}-testing:${P}"
85 aptly repo copy ${DISTNAME}-testing ${DISTNAME} "${P}"
87 echo "ERROR: unable to copy '${P}' from ${DISTNAME}-testing to ${DISTNAME}"
88 FAILED_PACKAGES="${FAILED_PACKAGES} ${DISTNAME}-testing:${P}"
93 echo "Publishing ${DISTNAME} repository..."
94 aptly publish update ${DISTNAME} filesystem:${DISTNAME}:
98 if [ "${FAILED_PACKAGES}" != "" ]; then
99 echo "PACKAGES THAT FAILED TO PUBLISH"
100 echo "${FAILED_PACKAGES}"
103 echo "All packages published correctly"