From 256b4e89b035c6ec7b87286541f78f6eaf861db2 Mon Sep 17 00:00:00 2001 From: aviau <alexandre@alexandreviau.net> Date: Tue, 26 Jul 2016 15:14:42 -0400 Subject: [PATCH] Create deploy-packages script This new scripts creates a local repository and deploys it with rsync. It will be used by Jenkins to deploy packages to dl.ring.cx. Change-Id: Ib1d9526e88fa15b053ae234f05839e86a3ce263a Tuleap: #872 --- .gitignore | 1 + scripts/deploy-packages.sh | 109 +++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100755 scripts/deploy-packages.sh diff --git a/.gitignore b/.gitignore index 98a017e5..077261c6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ docs/build packages ring_*.tar.gz Makefile.packaging.distro_targets +repositories diff --git a/scripts/deploy-packages.sh b/scripts/deploy-packages.sh new file mode 100755 index 00000000..e708c405 --- /dev/null +++ b/scripts/deploy-packages.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# +# Copyright (C) 2016 Savoir-faire Linux Inc. +# +# Author: Alexandre Viau <alexandre.viau@savoirfairelinux.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# +# This script sings and deploys pacakges from packages/distro. +# It should be ran from the project root directory. +# + +# Exit immediately if a command exits with a non-zero status +set -e + +for i in "$@" +do +case $i in + --distribution=*) + DISTRIBUTION="${i#*=}" + shift + ;; + --keyid=*) + KEYID="${i#*=}" + shift + ;; + --remote-location=*) + REMOTE_LOCATION="${i#*=}" + shift + ;; + *) + echo "Unrecognized option ${i}" + exit 1 + ;; +esac +done + +################################################## +## Create local repository for the given distro ## +################################################## +echo "#########################" +echo "## Creating repository ##" +echo "#########################" + +DISTRIBUTION_FOLDER=$(realpath repositories)/${DISTRIBUTION} +rm -rf ${DISTRIBUTION_FOLDER} +mkdir -p ${DISTRIBUTION_FOLDER}/conf + +# Distributions file +cat << EOF > ${DISTRIBUTION_FOLDER}/conf/distributions +Origin: ring +Label: Ring ${DISTRIBUTION} Repository +Codename: ring +Architectures: i386 amd64 +Components: main +Description: This repository contains Ring ${DISTRIBUTION} packages +SignWith: ${KEYID} +EOF + +# Options file +cat << EOF > ${DISTRIBUTION_FOLDER}/conf/options +basedir ${DISTRIBUTION_FOLDER} +EOF + +#################################### +## Add packages to the repository ## +#################################### + +# Sign the debs +echo "##################" +echo "## signing debs ##" +echo "##################" + +for package in packages/${DISTRIBUTION}*/*.deb; do + dpkg-sig -k ${KEYID} --sign builder ${package} +done + +# Include the debs +echo "####################" +echo "## including debs ##" +echo "####################" +for package in packages/${DISTRIBUTION}*/*.deb; do + reprepro --verbose --basedir ${DISTRIBUTION_FOLDER} includedeb ring ${package} +done + +# Rebuild the index +reprepro --verbose --basedir ${DISTRIBUTION_FOLDER} export ring + +# Deploy the repository +echo "##########################" +echo "## deploying repository ##" +echo "##########################" +rsync --archive --recursive --verbose --delete ${DISTRIBUTION_FOLDER} ${REMOTE_LOCATION} + +# Remove the local copy of the repository +rm -rf repositories -- GitLab