Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GPG import issue on post scriptlet #63

Closed
wants to merge 1 commit into from

Conversation

LKHN
Copy link

@LKHN LKHN commented Jan 12, 2022

Unlike EL6 and EL7 in EL8, you need to import the gpg key manually instead of as %post scriptlet
See: https://access.redhat.com/solutions/3720351

These lines was removed:

%post                                                                                                                                                                                     
rpm --import %{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux

It asks for importing the GPG key on the first attempt to install now:

Importing GPG key 0xF14AB620:
 Userid     : "ZFS on Linux <zfs@zfsonlinux.org>"
 Fingerprint: C93A FFFD 9F3F 7B03 C310 CEB6 A9D5 A1C0 F14A B620
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
Is this ok [y/N]: 

I couldn't find repo's of the spec file and uploaded it as the source and binary RPM. Feel free to sign and/or rename them.

Signed-off-by: Elkhan Mammadli elkhan.mammadli@protonmail.com

Unlike EL6 and EL7 in EL8, you need to import the gpg key manually instead of as %post scriptlet

Signed-off-by: Elkhan Mammadli <elkhan.mammadli@protonmail.com>
@tonyhutter
Copy link
Member

I'm unable to reproduce this on Centos 8.5. It prompts me for the key on zfs install:

# sudo dnf install zfs
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                4.8 MB/s |  11 MB     00:02    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                                        569 kB/s | 979 kB     00:01    
Dependencies resolved.
==============================================================================================================================================================================================
 Package                                              Architecture                   Version                                                          Repository                         Size
==============================================================================================================================================================================================
Installing:
 zfs                                                  x86_64                         2.0.7-1.el8                                                      zfs                               625 k
Installing dependencies:
 annobin                                              x86_64                         9.72-1.el8_5.2                                                   appstream                         111 k
 binutils                                             x86_64                         2.30-108.el8_5.1                                                 baseos                            5.8 M
 cpp                                                  x86_64                         8.5.0-4.el8_5                                                    appstream                          10 M
 dkms                                                 noarch                         3.0.3-1.el8                                                      epel                               62 k
 dwz                                                  x86_64                         0.12-10.el8                                                      appstream                         109 k

...

Transaction Summary
==============================================================================================================================================================================================
Install  188 Packages

Total download size: 107 M
Installed size: 289 M
Is this ok [y/N]: y
Downloading Packages:
(1/188): annobin-9.72-1.el8_5.2.x86_64.rpm                                                                                                                    269 kB/s | 111 kB     00:00    
(2/188): dwz-0.12-10.el8.x86_64.rpm                                                                                                                           245 kB/s | 109 kB     00:00    
(3/188): efi-srpm-macros-3-3.el8.noarch.rpm                                                                                                                   225 kB/s |  22 kB     00:00    
(4/188): ghc-srpm-macros-1.4.2-7.el8.noarch.rpm                                                                                                               107 kB/s | 9.3 kB     00:00    
(5/188): go-srpm-macros-2-17.el8.noarch.rpm                                                                                                                   139 kB/s |  13 kB     00:00    

...

(187/188): kernel-devel-4.18.0-348.7.1.el8_5.x86_64.rpm                                                                                                       1.5 MB/s |  20 MB     00:13    
(188/188): zfs-dkms-2.0.7-1.el8.noarch.rpm                                                                                                                    8.4 MB/s |  11 MB     00:01    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         4.0 MB/s | 107 MB     00:27     
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x2F86D6A1:
 Userid     : "Fedora EPEL (8) <epel@fedoraproject.org>"
 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
Is this ok [y/N]: y
Key imported successfully
ZFS on Linux for EL8 - dkms                                                                                                                                   1.6 MB/s | 1.7 kB     00:00    
Importing GPG key 0xF14AB620:
 Userid     : "ZFS on Linux <zfs@zfsonlinux.org>"
 Fingerprint: C93A FFFD 9F3F 7B03 C310 CEB6 A9D5 A1C0 F14A B620
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                      1/1 
  Installing       : perl-Digest-1.17-395.el8.noarch                                                                                                                                    1/188 
  Installing       : perl-Digest-MD5-2.55-396.el8.x86_64                                                                                                                                2/188 
  Installing       : perl-Data-Dumper-2.167-399.el8.x86_64                                                                                                                              3/188 

...

  Installing       : perl-4:5.26.3-420.el8.x86_64                                                                                                                                     186/188 
  Installing       : zfs-dkms-2.0.7-1.el8.noarch                                                                                                                                      187/188 
  Running scriptlet: zfs-dkms-2.0.7-1.el8.noarch                                                                                                                                      187/188 

...

Complete!

@LKHN
Copy link
Author

LKHN commented Feb 21, 2022

I've just run the dnf install https://zfsonlinux.org/epel/zfs-release.el8_5.noarch.rpm command on the generic/centos8 Vagrant box.

Result:

[vagrant@centos85 ~]$ cat /etc/redhat-release 
CentOS Linux release 8.5.2111
[vagrant@centos85 ~]$ sudo dnf install https://zfsonlinux.org/epel/zfs-release.el8_5.noarch.rpm
Last metadata expiration check: 0:10:02 ago on Mon 21 Feb 2022 08:21:15 PM UTC.
zfs-release.el8_5.noarch.rpm                                                                                                                                   22 kB/s | 9.7 kB     00:00    
Dependencies resolved.
==============================================================================================================================================================================================
 Package                                         Architecture                               Version                                    Repository                                        Size
==============================================================================================================================================================================================
Installing:
 zfs-release                                     noarch                                     1-8.5                                      @commandline                                     9.7 k

Transaction Summary
==============================================================================================================================================================================================
Install  1 Package

Total size: 9.7 k
Installed size: 2.9 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                      1/1 
  Installing       : zfs-release-1-8.5.noarch                                                                                                                                             1/1 
  Running scriptlet: zfs-release-1-8.5.noarch                                                                                                                                             1/1 
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
error: /etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux: key 1 import failed.
warning: %post(zfs-release-1-8.5.noarch) scriptlet failed, exit status 1

Error in POSTIN scriptlet in rpm package zfs-release
  Verifying        : zfs-release-1-8.5.noarch                                                                                                                                             1/1 

Installed:
  zfs-release-1-8.5.noarch                                                                                                                                                                    

Complete!

@tmzullinger
Copy link
Contributor

Indeed, the issue is when installing the zfs-release package. That generates the warning when it calls rpm --import in %post which does not work in EL8+ (or Fedora[1]). If it worked, then dnf would not need to prompt to import the key when subsequently running dnf install zfs.

[1] in the fedora zfs-release packages the rpm --import in %post was removed in 2014:

* Tue Dec 23 2014 Brian Behlendorf <behlendorf1@llnl.gov> - 1-4
- Disable 'rpm --import' during %post, the tx lock cannot be acquired.

@behlendorf behlendorf requested a review from tonyhutter June 14, 2022 19:39
@tonyhutter
Copy link
Member

Thanks for this fix. I'm actually working on a "universal" zfs-release RPM, and will roll this in with it. The universal zfs-release RPM will mean you don't have to install a specific Centos 8.4, 8.5, 8.6, etc zfs-release RPM for every minor release.

If it's alright with you, can I close this PR once I've rolled it into the new universal zfs-release RPM?

@tonyhutter
Copy link
Member

The zfs-release.el8_5.noarch.rpm in this PR doesn't have the fix. This worked for me though:

%post
# We don't need to import the key on >= RHEL 8
# https://github.com/zfsonlinux/zfsonlinux.github.com/pull/63
%if 0%{rhel} < 8
rpm --import %{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
%endif

I will incorporate this into my universal zfs-release RPM.

@LKHN
Copy link
Author

LKHN commented Jun 21, 2022

Hey @tonyhutter 👋

I didn't know the RPMs generated by the universal spec file and thought, importing the rpm gpg key manually before the package installation and adding this to the documentation might be a good idea for >= EL8, that's why I only removed the import part in my PR. 🤔

Yes, feel free to close the PR. Thank you!

@tmzullinger
Copy link
Contributor

Hi,

The zfs-release.el8_5.noarch.rpm in this PR doesn't have the fix. This worked for me though:

%post
# We don't need to import the key on >= RHEL 8
# https://github.com/zfsonlinux/zfsonlinux.github.com/pull/63
%if 0%{rhel} < 8
rpm --import %{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
%endif

The %if 0%{rhel} < 8 should probably be adjusted to %if 0%{?rhel} && 0%{?rhel} < 8 to ensure it works properly on Fedora or other systems where the %{rhel} macro might not be set. Or when you say universal, does that still mean a different srpm for each Fedora/RHEL release? (Not that it hurts to make the macro more robust in that case. But if you can be sure that %{rhel} is always set, then it's not as important.)

It might be just as simple to remove it entirely and let the key be imported by yum on those older RHEL systems? That is largely only RHEL 7 at this point (though I know there are folks running RHEL 6 still). AFAIK, yum will prompt on either of them when a key needs to be imported -- but that's from memory and I could always be wrong.

I will incorporate this into my universal zfs-release RPM.

Happy to hear about a universal zfs-release. That sounds much easier for everyone. Thanks!

@tonyhutter
Copy link
Member

tonyhutter commented Jun 21, 2022

The %if 0%{rhel} < 8 should probably be adjusted to %if 0%{?rhel} && 0%{?rhel} < 8 to ensure it works properly on Fedora

There would be separate "universal" RPMs for Centos and Fedora. The reason being that Centos has a [zfs-kmod] section in its /etc/yum.repo.d/zfs.repo file and Fedora does not.

@tmzullinger
Copy link
Contributor

There would be separate "universal" RPMs for Centos and Fedora. The reason being that Centos has a [zfs-kmod] section in its /etc/yum.repo.d/zfs.repo file and Fedora does not.

I was thinking of a shared spec file/srpm. At the risk of getting too far off topic for this PR (apologies), a combined spec file for Fedora and EL could be done something like this (lightly tested): https://gist.github.com/tmzullinger/0bdfb7354ee650dc20e8e1cbf43d9c65.

The version or release field would need to be bumped there, to be newer than the current EL8 packages. If that can help reduce the srpm's you have to manage, please feel free to use any bits of it. :)

@tonyhutter
Copy link
Member

@tmzullinger thank you for the patch! I'll give it a test, and if all goes well we'll use it going forward.

@tonyhutter
Copy link
Member

@tmzullinger unfortunately I don't think it's going to work the way we had hoped. Your changes give us a universal source RPM, which is good, but when you build the actual RPM, it will contain the zfs.repo file for whatever distro you built it on:

$ rpm -qpl SRPMS/zfs-release-2-1.src.rpm
RPM-GPG-KEY-zfsonlinux
zfs-fedora.repo
zfs-release.spec
zfs-rhel.repo

$ rpm -qpl RPMS/noarch/zfs-release-2-1.noarch.rpm
/etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux
/etc/yum.repos.d/zfs.repo

So we'll still need to distribute both a zfs-release-fedora-2-1.noarch.rpm and zfs-release-rhel-2-1.noarch.rpm

@tmzullinger
Copy link
Contributor

Yeah. The binary rpm could choose which repo file to use at install-time, but then we'd have some scripting to parse /etc/os-release or similar. And then the contents of the .repo files aren't tracked by rpm as they normally would be. That seems like more trouble than it's worth. I only aimed for a single srpm which could generate a universal binary rpm for each of the two targets (once it included any changes to the repo files to handle different EL versions).

I'd be happy to take a look at what a universal source and binary rpm might look like, if you think it might be of value. (It could still turn out to be a no, once the rubber hits the road, of course.) If so, perhaps that's best in another issue & pull request?

@tonyhutter
Copy link
Member

If so, perhaps that's best in another issue & pull request?

Yea, we should probably track the "universal" RPM discussion in openzfs/zfs#10328

I'm leaning towards the idea of distributing the "universal" source RPM along with the distro-specific binary RPMs (which support all versions of the distro). That seems to be the easiest and most straightforward solution. Most binary RPMs are distro-specific anyway, so it's not there's an expectation that it should be cross-distro.

tonyhutter added a commit to tonyhutter/zfsonlinux.github.com that referenced this pull request Jun 28, 2022
1. Update the spec files to use $releasever instead of hard
coding the version number (7.9, 8.3, 8.4 ...) in the repo.
This means you can use zfs-release-el-1.rpm for any version
of RHEL/AlmaLinux/Centos, and zfs-release-fedora-1.rpm for
any version of Fedora.
openzfs/zfs#10328

2. Only import our RPM key on CentOS 7:
zfsonlinux#63

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
@tonyhutter
Copy link
Member

So #67 that I just opened includes the GPG fix. Once that gets merged I think we can close this PR.

tonyhutter added a commit to tonyhutter/zfsonlinux.github.com that referenced this pull request Jun 29, 2022
1. Update the spec files to use $releasever instead of hard
coding the version number (7.9, 8.3, 8.4 ...) in the repo.
This means you can use zfs-release-el-1.rpm for any version
of RHEL/AlmaLinux/Centos, and zfs-release-fedora-1.rpm for
any version of Fedora.
openzfs/zfs#10328

2. Only import our RPM key on CentOS 7:
zfsonlinux#63

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
behlendorf pushed a commit that referenced this pull request Jul 5, 2022
1. Update the spec files to use $releasever instead of hard
coding the version number (7.9, 8.3, 8.4 ...) in the repo.
This means you can use zfs-release-el-1.rpm for any version
of RHEL/AlmaLinux/Centos, and zfs-release-fedora-1.rpm for
any version of Fedora.
openzfs/zfs#10328

2. Only import our RPM key on CentOS 7:
#63

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
@tonyhutter
Copy link
Member

I recommend we close this in favor of #67 and openzfs/openzfs-docs#325

@LKHN
Copy link
Author

LKHN commented Jul 6, 2022

I recommend we close this in favor of #67 and openzfs/openzfs-docs#325

Closed.

@tonyhutter Could you publish the spec files? In this way, people can directly contribute to the spec file, and we can see actual and final changes without downloading and inspecting the uploaded source rpm or reading generated patches in the comments in #67.

@LKHN LKHN closed this Jul 6, 2022
tonyhutter added a commit to tonyhutter/zfsonlinux.github.com that referenced this pull request Jul 6, 2022
In the past we've simply checked in the zfs-release RPM files
directly.   It was requested that we start checking in the
spec and repo files too so that you can easily see the diff
when making changes.  This commit checks in all the files
needed to create the RPMs, along with instructions on how
to build them.

Addresses: zfsonlinux#63

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
@tonyhutter
Copy link
Member

@tonyhutter Could you publish the spec files?

No problem: #68

behlendorf pushed a commit that referenced this pull request Jul 8, 2022
In the past we've simply checked in the zfs-release RPM files
directly.   It was requested that we start checking in the
spec and repo files too so that you can easily see the diff
when making changes.  This commit checks in all the files
needed to create the RPMs, along with instructions on how
to build them.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants