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 APT_REPO_BASE_DIR="/var/lib/freight"
12 RPM_REPO_BASE_DIR="/var/www/rpm.arvados.org"
14 ### MAIN ####################################################################
17 echo " $0 --distros <distroA,distroB,...,distroN> --packages <packageA,packageB,...,packageN>"
18 echo " (both parameters are mandatory)"
24 while [ ${#} -gt 0 ]; do
26 --packages) packages="$2"; shift 2 ;;
27 --distros) distros="$2"; shift 2 ;;
28 *) echo "$0: Unrecognized option: $1" >&2; exit 1;
32 # Make sure the variables are set or provide an example of how to use them
33 if [ -z "${packages}" ]; then
34 echo "You must provide a comma-separated list of packages to publish, ie."
35 echo "* Debian: --packages=arvados-ws_0.1.20170906144951.22418ed6e-1_amd64.deb,keep-exercise_*,*170906144951*"
36 echo "* Centos: --packages=arvados-ws_0.1.20170906144951.22418ed6e-1.x86_64.rpm,keep-exercise_0.1.20170906144951.22418ed6e-1.x86_64.rpm,crunch-dispatch-local_0.1.20170906144951.22418ed6e-1.x86_64.rpm"
39 if [ -z "${distros}" ]; then
40 echo "You must provide a space-separated list of LSB distribution codenames to which you want to publish to, ie."
41 echo "* Debian: --distros=jessie,xenial,stretch,etc."
42 echo "* Centos: --distros=centos7,etc."
46 DIST_LIST=$(echo ${distros} | sed s/,/' '/g |tr '[:upper:]' '[:lower:]')
47 PACKAGES=$(echo ${packages} | sed s/,/' '/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 ${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 cd ${APT_REPO_BASE_DIR}
77 mkdir -p ${APT_REPO_BASE_DIR}/apt/${DISTNAME}
78 echo "Copying packages ..."
79 for P in ${PACKAGES}; do
80 cp ${APT_REPO_BASE_DIR}/apt/${DISTNAME}-testing/${P} ${APT_REPO_BASE_DIR}/apt/${DISTNAME}/
82 FAILED_PACKAGES="${FAILED_PACKAGES} ${P}"
84 TMP=`ls -C1 ${APT_REPO_BASE_DIR}/apt/${DISTNAME}-testing/${P}`
85 ADDED+=( "${TMP[@]}" )
88 for P in "${ADDED[@]}"; do
89 freight add apt/${DISTNAME}/$(basename ${P}) apt/${DISTNAME}
91 echo "Recreating repo apt/${DISTNAME} ..."
92 freight cache apt/${DISTNAME}
96 if [ "${FAILED_PACKAGES}" != "" ]; then
97 echo "PACKAGES THAT FAILED TO PUBLISH"
98 echo "${FAILED_PACKAGES}"
100 echo "All packages published correctly"