-
Notifications
You must be signed in to change notification settings - Fork 1
/
update-repo.sh
executable file
·95 lines (81 loc) · 3.11 KB
/
update-repo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash -xe
#
# Copyright 2022 Andrew Meredith <[email protected]>
# Copyright 2022 Cudo Ventures - All rights reserved.
#
# 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 2 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 is intended for use with a CI/CD package.
# It is designed to be called by the job once the packages
# have been uploaded to the repo server.
#
# It is placed in the target directory of the "end of job upload" and
# executed by changing to that directory and calling ./update-repo.sh
#
# It assumes the current directory is the base of the repository as
# referenced in the respository client configuration (eg cudos.repo)
#
# It assumes that the rpm packages have been uploaded to the
# usual RPM and SRPM locations and updates the repo index in the current
# directory.
#
# It assumes that the debian packages were uploaded to a subdirectory
# called debian, distributes them into the appropriate subdirectories
# and runs the relevant indexers
#
# It can be used to maintain separate repositories on the same server using
# different usernames eg user "testnet" for the "cudos-testnet" repository.
# Different credentials and access right can then be used to separate the
# repositories in security terms. The different "repo users" can have full
# control over their "repo tag" on the web service but limited access to
# the rest of the server.
export PWTMP=$1
export RPMLISTFILE=$2
export DEBLISTFILE=$3
#
# RPMS
#
# Sign the rpm files
if [[ -f $PWTMP ]]
then
echo -ne "\n== Sign the new packages == \n\n"
# Set the gpg parameters needed
cat << EOF > ~/.gnupg/gpg.conf
status-fd 1
batch
pinentry-mode loopback
passphrase-file ${PWTMP}
EOF
# Sign the new packages as listed in the file named in ARG2
rpmsign --delsign `cat ${RPMLISTFILE}`
rpmsign --addsign `cat ${RPMLISTFILE}`
fi
# Replace the "cudos-release" rpm link
RLSFILE="$( find RPMS -name "cudos-release*rpm" | sort | tail -1 )"
rm -f cudos-release.rpm
ln -s "$RLSFILE" cudos-release.rpm
# Update the rpm repo files
/usr/bin/createrepo --update --verbose --deltas . || true
#
# DEBS
#
# lay out the debian files
cd debian
mkdir -p ./dists/stable/main/binary-amd64
mkdir -p ./dists/stable/main/binary-arm64
mkdir -p ./dists/stable/main/binary-i386
mv -v *.deb ./dists/stable/main/binary-amd64 || true
# Run the package scanner
dpkg-scanpackages -m dists/stable/main/binary-amd64 > dists/stable/main/binary-amd64/Packages
dpkg-scanpackages -m dists/stable/main/binary-arm64 > dists/stable/main/binary-arm64/Packages
dpkg-scanpackages -m dists/stable/main/binary-i386 > dists/stable/main/binary-i386/Packages