-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsign-rpm-repos
executable file
·117 lines (103 loc) · 4.05 KB
/
sign-rpm-repos
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Usage: sign-rpm-repos rpm-directory area version repo
usage() {
echo "Usage: $(basename $0) input area version repo"
echo
echo input example: /nobackup/tim/externals/9.1
echo area examples: public private security test
echo version examples: 8.8.2, 8.9.1
echo repo examples: snapshot, daily, alpha, rc, beta, update, release
}
confirm=1
if [ $# -ge 1 -a "$1" = "-y" ]; then
confirm=0
shift
fi
if [ $# -ne 4 ]; then
usage
exit 1
fi
input=$1
area=$2
version=$3
repo=$4
if [ ! -d $1 ]; then
echo ERROR: no directory: $1
usage
exit 1
fi
echo "Input: ${input} Area: ${area}, Version: ${version}, Repo: ${repo}"
if [ $confirm -eq 1 ]; then
read -p "Continue? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
else
echo
fi
. $(dirname $0)/common.sh
sign_rpm_repo() {
platform_name=$1
platform=$2
arch=$3
mkdir -p ${repository}/${repo_version}/${platform}/${arch}/${repo}
mkdir -p ${repository}/${repo_version}/${platform}/${arch}/${repo}/SRPMS
mkdir -p ${repository}/${repo_version}/${platform}/${arch}/${repo}/debug
echo ======= ${repo_version}/${platform}/${arch}/${repo}/SRPMS =======
createrepo --update \
${repository}/${repo_version}/${platform}/${arch}/${repo}/SRPMS
gpg --detach-sign -u 0x$key --digest-algo=sha256 --yes --armor \
${repository}/${repo_version}/${platform}/${arch}/${repo}/SRPMS/repodata/repomd.xml
echo ======= ${repo_version}/${platform}/${arch}/${repo}/debug =======
createrepo --update \
${repository}/${repo_version}/${platform}/${arch}/${repo}/debug
gpg --detach-sign -u 0x$key --digest-algo=sha256 --yes --armor \
${repository}/${repo_version}/${platform}/${arch}/${repo}/debug/repodata/repomd.xml
echo ======= ${repo_version}/${platform}/${arch}/${repo} =======
createrepo --excludes='debug/*' --excludes='SRPMS/*' --update \
${repository}/${repo_version}/${platform}/${arch}/${repo}
gpg --detach-sign -u 0x$key --digest-algo=sha256 --yes --armor \
${repository}/${repo_version}/${platform}/${arch}/${repo}/repodata/repomd.xml
}
echo ======= Updating ${repository} =======
pushd ${input}
for dir in *; do
if [ $dir = 'aarch64_AlmaLinux8' ]; then
sign_rpm_repo "aarch64_AlmaLinux8" "el8" "aarch64"
elif [ $dir = 'ppc64le_AlmaLinux8' ]; then
sign_rpm_repo "ppc64le_AlmaLinux8" "el8" "ppc64le"
elif [ $dir = 'x86_64_AlmaLinux8' ]; then
sign_rpm_repo "x86_64_AlmaLinux8" "el8" "x86_64"
elif [ $dir = 'aarch64_AlmaLinux9' ]; then
sign_rpm_repo "aarch64_AlmaLinux9" "el9" "aarch64"
elif [ $dir = 'x86_64_AlmaLinux9' ]; then
sign_rpm_repo "x86_64_AlmaLinux9" "el9" "x86_64"
elif [ $dir = 'aarch64_AlmaLinux10' ]; then
sign_rpm_repo "aarch64_AlmaLinux10" "el10" "aarch64"
elif [ $dir = 'x86_64_AlmaLinux10' ]; then
sign_rpm_repo "x86_64_AlmaLinux10" "el10" "x86_64"
elif [ $dir = 'x86_64_AmazonLinux2' ]; then
sign_rpm_repo "x86_64_AmazonLinux2" "amzn2" "x86_64"
elif [ $dir = 'x86_64_AmazonLinux2023' ]; then
sign_rpm_repo "x86_64_AmazonLinux2023" "amzn2023" "x86_64"
elif [ $dir = 'x86_64_CentOS7' ]; then
sign_rpm_repo "x86_64_CentOS7" "el7" "x86_64"
elif [ $dir = 'x86_64_CentOS8' ]; then
sign_rpm_repo "x86_64_CentOS8" "el8" "x86_64"
elif [ $dir = 'x86_64_Fedora38' ]; then
sign_rpm_repo "x86_64_Fedora38" "fc38" "x86_64"
elif [ $dir = 'x86_64_Fedora39' ]; then
sign_rpm_repo "x86_64_Fedora39" "fc39" "x86_64"
elif [ $dir = 'x86_64_Fedora40' ]; then
sign_rpm_repo "x86_64_Fedora40" "fc40" "x86_64"
elif [ $dir = 'x86_64_Fedora41' ]; then
sign_rpm_repo "x86_64_Fedora41" "fc41" "x86_64"
elif [ $dir = 'x86_64_Rocky8' ]; then
sign_rpm_repo "x86_64_Rocky8" "el8" "x86_64"
elif [ $dir = 'x86_64_openSUSE15' ]; then
sign_rpm_repo "x86_64_openSUSE15" "leap15" "x86_64"
fi
done
popd