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

feat(rpm): support %config(missingok) #854

Merged
merged 2 commits into from
Sep 23, 2024
Merged

feat(rpm): support %config(missingok) #854

merged 2 commits into from
Sep 23, 2024

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Sep 5, 2024

closes #853

@caarlos0 caarlos0 added the enhancement New feature or request label Sep 5, 2024
@caarlos0 caarlos0 self-assigned this Sep 5, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 5, 2024
Copy link

cloudflare-workers-and-pages bot commented Sep 5, 2024

Deploying nfpm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4e1d1d0
Status:⚡️  Build in progress...

View logs

Copy link
Contributor

@robsliwi robsliwi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow dnf running on AlmaLinux 8.10 is still complaining with a warning, though.
fav32.png is a config|missingok and grafana_icon.svg is a config|noreplace in a little Toy example:

Running transaction
  Preparing        :                                                                                                    1/1
  Erasing          : grafana-re-configuration-0.0.1-1.x86_64                                                            1/1
warning: file /tmp/grafana_icon.svg: remove failed: No such file or directory
warning: file /tmp/fav32.png: remove failed: No such file or directory
                                                                                                                            
  Verifying        : grafana-re-configuration-0.0.1-1.x86_64                                                            1/1
                                                                                                                            
Removed:
  grafana-re-configuration-0.0.1-1.x86_64

I will try to reproduce the toy example with a classic specfile and see if dnf complains with the warning here, too. But what for sure is possible with the specfile is to combine missingok and noreplace in a %config(missingok,noreplace) directive.

Was pleasantly surprised that direnv was asking me to allow the Nix devShell after checking out the repo 👍

files/files.go Outdated Show resolved Hide resolved
@robsliwi
Copy link
Contributor

robsliwi commented Sep 6, 2024

Small follow-up:

I will try to reproduce the toy example with a classic specfile and see if dnf complains with the warning here, too.

I did with the following spec file:

[root@d3d1a05f3904 ~]# cat hello.spec
Name:       hello-world
Version:    1
Release:    1
Summary:    Lets see if we can make it missingok
License:    FIXME
                                                                                                        
%description
This is my first RPM package, which does nothing.
                                                                                                        
%build
cat > config.conf <<EOF
# some config
EOF
                                                                                                        
%install
mkdir -p %{buildroot}/tmp/
install -m 755 config.conf %{buildroot}/tmp/config.conf
                                                                                                        
%files
%config(missingok) /tmp/config.conf
                                                                                                        
%changelog
# let's skip this for now

And the removal of the build RPM with a missing/moved /tmp/config.conf:

[root@d3d1a05f3904 ~]# mv /tmp/config.conf /tmp/config.conf.moved
mv: overwrite '/tmp/config.conf.moved'? y
[root@d3d1a05f3904 ~]# dnf remove hello-world
Dependencies resolved.
========================================================================================================
 Package                    Architecture          Version            Repository                    Size
========================================================================================================
Removing:
 hello-world                x86_64                1-1                @@commandline                 14
                                                                                                        
Transaction Summary
========================================================================================================
Remove  1 Package
                                                                                                        
Freed space: 14
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                1/1
  Erasing          : hello-world-1-1.x86_64                                                         1/1
  Verifying        : hello-world-1-1.x86_64                                                         1/1
                                                                                                        
Removed:
  hello-world-1-1.x86_64
                                                                                                        
Complete!

No warnings here. Is there some place where I could have a peak at the generated spec file before "building" the RPM in the source code?

@caarlos0
Copy link
Member Author

caarlos0 commented Sep 6, 2024

we don't create a spec file, that's why you don't need to have rpm installed to use this.

that said, I double checked https://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/pkgformat.html#AEN27560 and google/rpmpack (which we use) and everything seems correct...

maybe its a bug on rpmpack? not sure yet

Copy link
Contributor

@robsliwi robsliwi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just went through the examples and verified the file flags and those were set correctly.

rpm -qp --qf '[%{FILENAMES} %{FILEFLAGS:fflags}\n]' example-0.0.1-1.x86_64.rpm
/tmp/fav32.png cm
/tmp/grafana_icon.svg cn

And dnf is happy with all missing files with the newly introduced cn file flag 📦 🎉

Thanks a lot for the blazing fast implementation!

The duplicated line is fine?

files/files.go Outdated Show resolved Hide resolved
@caarlos0 caarlos0 merged commit fa30aa2 into main Sep 23, 2024
42 of 46 checks passed
@caarlos0 caarlos0 deleted the missingok branch September 23, 2024 12:07
@github-actions github-actions bot added this to the 2.38.0 milestone Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to specify %config(missingok)
2 participants