Add signing to Akraino deploy templates
[ci-management.git] / jjb / shell / ta-rpm-deploy.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 echo "---> ta-rpm-deploy.sh"
13
14 # Ensure we fail the job if any steps fail.
15 set -eu -o pipefail
16
17 set -x  # Trace commands for this script to make debugging easier.
18
19 set +f  # Ensure filename expansion (globbing) is enabled
20
21 NEXUS_REPO=rpm.snapshots
22 release_path=TA/release-1
23
24 repo_dir="$WORKSPACE/work/nexus/$NEXUS_REPO"
25 arch_dir="$repo_dir/$release_path/rpms/$(uname -m)"
26 sources_dir="$repo_dir/$release_path/rpms/Sources"
27 nexus_repo_url="$RPM_REPO_URL/repository/$NEXUS_REPO"
28 results_dir="$WORKSPACE/work/results"
29 repo_name=`echo $WORKSPACE | awk -F '/' '{print $4}' | cut -d '-' -f2- | sed 's|\(.*\)-.*|\1|'`
30
31 #Creating dirs to move duplicate RPMs/SRPMs to avoid re-upload and copy the changed RPMs/SRPMs
32 rm -rf "$results_dir/repo/duplicates" "$results_dir/src_repo/duplicates"
33 mkdir "$results_dir/repo/duplicates"
34 mkdir "$results_dir/src_repo/duplicates"
35 mkdir -p "$arch_dir"
36 mkdir -p "$sources_dir"
37
38 #List all RPMs available in Nexus, move the duplicates and copy the changed ones
39 for artifact in \
40   `ls $results_dir/repo/*.rpm`
41     do
42         if curl -L --head --fail $nexus_repo_url/$release_path/rpms/$(uname -m)/$(basename $artifact)
43         then
44             echo "RPM - $(basename $artifact) already available in Nexus"
45             mv $results_dir/repo/$(basename $artifact) $results_dir/repo/duplicates/
46         else
47             echo "RPM - $(basename $artifact) is not available in Nexus. Will be uploaded"
48             cp $results_dir/repo/$(basename $artifact) $arch_dir
49         fi
50     done
51
52 #List all Source RPMs available in Nexus, move the duplicates and copy the changed ones
53 for artifact in \
54   `ls $results_dir/src_repo/*.rpm`
55     do
56         if curl -L --head --fail $nexus_repo_url/$release_path/rpms/Sources/$(basename $artifact)
57         then
58             echo "Source RPM - $(basename $artifact) already available in Nexus"
59             mv $results_dir/src_repo/$(basename $artifact) $results_dir/src_repo/duplicates/
60         else
61             echo "Source RPM - $(basename $artifact) is not available in Nexus. Will be uploaded"
62             cp $results_dir/src_repo/$(basename $artifact) $sources_dir
63         fi
64     done
65
66 echo "-----> Sign all artifacts"
67 lftools sign sigul "$repo_dir"
68
69 echo "-----> Upload RPMs to Nexus"
70 lftools deploy nexus "$nexus_repo_url" "$repo_dir"
71
72 set +x  # Disable trace since we no longer need it.
73 echo "RPMs location: <a href=\"$nexus_repo_url\">$nexus_repo_url</a>"