Skip to content

Commit 1c234d6

Browse files
authored
[main] Adding Mariner's GPG keys to RPM's database in the worker chroot. (#2640)
* Update 'tdnf' to import Mariner GPG keys. * Removing '--assumeyes'.
1 parent b6b8a2e commit 1c234d6

File tree

8 files changed

+45
-31
lines changed

8 files changed

+45
-31
lines changed

SPECS/tdnf/tdnf.spec

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: dnf/yum equivalent using C libs
22
Name: tdnf
33
Version: 3.2.2
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: LGPLv2.1 AND GPLv2
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -37,6 +37,7 @@ Requires: curl
3737
Requires: libmetalink
3838
Requires: libsolv
3939
Requires: openssl-libs
40+
Requires: rpm
4041
Requires: rpm-libs
4142
Requires: tdnf-cli-libs = %{version}-%{release}
4243
Obsoletes: yum
@@ -133,6 +134,12 @@ find %{buildroot} -name '*.pyc' -delete
133134

134135
%ldconfig_scriptlets
135136

137+
%triggerin -n %{name} -- mariner-repos-shared
138+
for gpg_key in $(rpm -q -l mariner-repos-shared | grep "rpm-gpg")
139+
do
140+
rpm --import "$gpg_key"
141+
done
142+
136143
%files
137144
%license COPYING
138145
%defattr(-,root,root,0755)
@@ -178,6 +185,9 @@ find %{buildroot} -name '*.pyc' -delete
178185
%{_bindir}/tdnf-automatic
179186

180187
%changelog
188+
* Thu Mar 31 2022 Pawel Winogrodzki <[email protected]> - 3.2.2-2
189+
- Installing Mariner GPG keys when present/installed.
190+
181191
* Wed Jan 12 2022 Mateusz Malisz <[email protected]> - 3.2.2-1
182192
- Update to 3.2.2 version
183193
- Remove upstreamed patches

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ krb5-1.19.2-1.cm2.aarch64.rpm
193193
curl-7.82.0-1.cm2.aarch64.rpm
194194
curl-devel-7.82.0-1.cm2.aarch64.rpm
195195
curl-libs-7.82.0-1.cm2.aarch64.rpm
196-
tdnf-3.2.2-1.cm2.aarch64.rpm
197-
tdnf-cli-libs-3.2.2-1.cm2.aarch64.rpm
198-
tdnf-devel-3.2.2-1.cm2.aarch64.rpm
199-
tdnf-plugin-repogpgcheck-3.2.2-1.cm2.aarch64.rpm
196+
tdnf-3.2.2-2.cm2.aarch64.rpm
197+
tdnf-cli-libs-3.2.2-2.cm2.aarch64.rpm
198+
tdnf-devel-3.2.2-2.cm2.aarch64.rpm
199+
tdnf-plugin-repogpgcheck-3.2.2-2.cm2.aarch64.rpm
200200
createrepo_c-0.17.5-1.cm2.aarch64.rpm
201201
libxml2-2.9.13-1.cm2.aarch64.rpm
202202
libxml2-devel-2.9.13-1.cm2.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ krb5-1.19.2-1.cm2.x86_64.rpm
193193
curl-7.82.0-1.cm2.x86_64.rpm
194194
curl-devel-7.82.0-1.cm2.x86_64.rpm
195195
curl-libs-7.82.0-1.cm2.x86_64.rpm
196-
tdnf-3.2.2-1.cm2.x86_64.rpm
197-
tdnf-cli-libs-3.2.2-1.cm2.x86_64.rpm
198-
tdnf-devel-3.2.2-1.cm2.x86_64.rpm
199-
tdnf-plugin-repogpgcheck-3.2.2-1.cm2.x86_64.rpm
196+
tdnf-3.2.2-2.cm2.x86_64.rpm
197+
tdnf-cli-libs-3.2.2-2.cm2.x86_64.rpm
198+
tdnf-devel-3.2.2-2.cm2.x86_64.rpm
199+
tdnf-plugin-repogpgcheck-3.2.2-2.cm2.x86_64.rpm
200200
createrepo_c-0.17.5-1.cm2.x86_64.rpm
201201
libxml2-2.9.13-1.cm2.x86_64.rpm
202202
libxml2-devel-2.9.13-1.cm2.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,13 @@ systemd-bootstrap-devel-250.3-2.cm2.aarch64.rpm
542542
systemd-bootstrap-rpm-macros-250.3-2.cm2.noarch.rpm
543543
tar-1.34-1.cm2.aarch64.rpm
544544
tar-debuginfo-1.34-1.cm2.aarch64.rpm
545-
tdnf-3.2.2-1.cm2.aarch64.rpm
546-
tdnf-autoupdate-3.2.2-1.cm2.aarch64.rpm
547-
tdnf-cli-libs-3.2.2-1.cm2.aarch64.rpm
548-
tdnf-debuginfo-3.2.2-1.cm2.aarch64.rpm
549-
tdnf-devel-3.2.2-1.cm2.aarch64.rpm
550-
tdnf-plugin-repogpgcheck-3.2.2-1.cm2.aarch64.rpm
551-
tdnf-python-3.2.2-1.cm2.aarch64.rpm
545+
tdnf-3.2.2-2.cm2.aarch64.rpm
546+
tdnf-autoupdate-3.2.2-2.cm2.aarch64.rpm
547+
tdnf-cli-libs-3.2.2-2.cm2.aarch64.rpm
548+
tdnf-debuginfo-3.2.2-2.cm2.aarch64.rpm
549+
tdnf-devel-3.2.2-2.cm2.aarch64.rpm
550+
tdnf-plugin-repogpgcheck-3.2.2-2.cm2.aarch64.rpm
551+
tdnf-python-3.2.2-2.cm2.aarch64.rpm
552552
texinfo-6.8-1.cm2.aarch64.rpm
553553
texinfo-debuginfo-6.8-1.cm2.aarch64.rpm
554554
unzip-6.0-19.cm2.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,13 @@ systemd-bootstrap-devel-250.3-2.cm2.x86_64.rpm
542542
systemd-bootstrap-rpm-macros-250.3-2.cm2.noarch.rpm
543543
tar-1.34-1.cm2.x86_64.rpm
544544
tar-debuginfo-1.34-1.cm2.x86_64.rpm
545-
tdnf-3.2.2-1.cm2.x86_64.rpm
546-
tdnf-autoupdate-3.2.2-1.cm2.x86_64.rpm
547-
tdnf-cli-libs-3.2.2-1.cm2.x86_64.rpm
548-
tdnf-debuginfo-3.2.2-1.cm2.x86_64.rpm
549-
tdnf-devel-3.2.2-1.cm2.x86_64.rpm
550-
tdnf-plugin-repogpgcheck-3.2.2-1.cm2.x86_64.rpm
551-
tdnf-python-3.2.2-1.cm2.x86_64.rpm
545+
tdnf-3.2.2-2.cm2.x86_64.rpm
546+
tdnf-autoupdate-3.2.2-2.cm2.x86_64.rpm
547+
tdnf-cli-libs-3.2.2-2.cm2.x86_64.rpm
548+
tdnf-debuginfo-3.2.2-2.cm2.x86_64.rpm
549+
tdnf-devel-3.2.2-2.cm2.x86_64.rpm
550+
tdnf-plugin-repogpgcheck-3.2.2-2.cm2.x86_64.rpm
551+
tdnf-python-3.2.2-2.cm2.x86_64.rpm
552552
texinfo-6.8-1.cm2.x86_64.rpm
553553
texinfo-debuginfo-6.8-1.cm2.x86_64.rpm
554554
unzip-6.0-19.cm2.x86_64.rpm

toolkit/tools/imagegen/installutils/installutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ func initializeTdnfConfiguration(installRoot string) (err error) {
580580

581581
logger.Log.Debugf("Downloading '%s' package to a clean RPM root under '%s'.", releasePackage, installRoot)
582582

583-
err = shell.ExecuteLive(squashErrors, "tdnf", "download", "--assumeyes", "--alldeps", "--destdir", installRoot, releasePackage)
583+
err = shell.ExecuteLive(squashErrors, "tdnf", "download", "--alldeps", "--destdir", installRoot, releasePackage)
584584
if err != nil {
585585
logger.Log.Errorf("Failed to prepare the RPM database on downloading the 'mariner-release' package: %v", err)
586586
return

toolkit/tools/internal/packagerepo/repocloner/rpmrepocloner/rpmrepocloner.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ func (r *RpmRepoCloner) Clone(cloneDeps bool, packagesToClone ...*pkgjson.Packag
269269

270270
logger.Log.Debugf("Cloning: %s", pkgName)
271271
args := []string{
272-
"--assumeyes",
273272
"--destdir",
274273
chrootDownloadDir,
275274
pkgName,
@@ -302,7 +301,6 @@ func (r *RpmRepoCloner) WhatProvides(pkgVer *pkgjson.PackageVer) (packageNames [
302301
baseArgs := []string{
303302
"provides",
304303
provideQuery,
305-
"--assumeyes",
306304
fmt.Sprintf("--disablerepo=%s", allRepoIDs),
307305
}
308306

@@ -425,7 +423,6 @@ func (r *RpmRepoCloner) ClonedRepoContents() (repoContents *repocloner.RepoConte
425423
tdnfArgs := []string{
426424
"list",
427425
"ALL",
428-
"--assumeyes",
429426
fmt.Sprintf("--disablerepo=%s", allRepoIDs),
430427
fmt.Sprintf("--enablerepo=%s", checkedRepoID),
431428
}

toolkit/tools/pkggen/worker/create_worker_chroot.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ chroot_log="$log_path"/$chroot_name.log
2222
install_one_toolchain_rpm () {
2323
error_msg_tail="Inspect $chroot_log for more info. Did you hydrate the toolchain?"
2424

25-
echo "Adding RPM to worker chroot: $1." | tee -a "$chroot_log"
25+
echo "Adding RPM to worker chroot: $1." | tee -a "$chroot_log"
2626

2727
full_rpm_path=$(find "$rpm_path" -name "$1" -type f 2>>"$chroot_log")
2828
if [ ! $? -eq 0 ] || [ -z "$full_rpm_path" ]
@@ -55,7 +55,7 @@ while read -r package || [ -n "$package" ]; do
5555
done < "$packages"
5656

5757
TEMP_DB_PATH=/temp_db
58-
echo "Setting up a clean RPM database before the Berkeley DB -> SQLite conversion under '$TEMP_DB_PATH'." | tee -a "$chroot_log"
58+
echo "Setting up a clean RPM database before the Berkeley DB -> SQLite conversion under '$TEMP_DB_PATH'." | tee -a "$chroot_log"
5959
chroot "$chroot_builder_folder" mkdir -p "$TEMP_DB_PATH"
6060
chroot "$chroot_builder_folder" rpm --initdb --dbpath="$TEMP_DB_PATH"
6161

@@ -64,16 +64,23 @@ while read -r package || [ -n "$package" ]; do
6464
full_rpm_path=$(find "$rpm_path" -name "$package" -type f 2>>"$chroot_log")
6565
cp $full_rpm_path $chroot_builder_folder/$package
6666

67-
echo "Adding RPM DB entry to worker chroot: $package." | tee -a "$chroot_log"
67+
echo "Adding RPM DB entry to worker chroot: $package." | tee -a "$chroot_log"
6868

6969
chroot "$chroot_builder_folder" rpm -i -v --nodeps --noorder --force --dbpath="$TEMP_DB_PATH" --justdb "$package" &>> "$chroot_log"
7070
chroot "$chroot_builder_folder" rm $package
7171
done < "$packages"
7272

73-
echo "Overwriting old RPM database with the results of the conversion." | tee -a "$chroot_log"
73+
echo "Overwriting old RPM database with the results of the conversion." | tee -a "$chroot_log"
7474
chroot "$chroot_builder_folder" rm -rf /var/lib/rpm
7575
chroot "$chroot_builder_folder" mv "$TEMP_DB_PATH" /var/lib/rpm
7676

77+
echo "Importing CBL-Mariner GPG keys." | tee -a "$chroot_log"
78+
for gpg_key in $(chroot "$chroot_builder_folder" rpm -q -l mariner-repos-shared | grep "rpm-gpg")
79+
do
80+
echo "Importing GPG key: $gpg_key" | tee -a "$chroot_log"
81+
chroot "$chroot_builder_folder" rpm --import "$gpg_key"
82+
done
83+
7784
HOME=$ORIGINAL_HOME
7885

7986
# In case of Docker based build do not add the below folders into chroot tarball

0 commit comments

Comments
 (0)