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 relocatable packages #691

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nfpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ type RPM struct {
Compression string `yaml:"compression,omitempty" json:"compression,omitempty" jsonschema:"title=compression algorithm to be used,enum=gzip,enum=lzma,enum=xz,default=gzip:-1"`
Signature RPMSignature `yaml:"signature,omitempty" json:"signature,omitempty" jsonschema:"title=rpm signature"`
Packager string `yaml:"packager,omitempty" json:"packager,omitempty" jsonschema:"title=organization that actually packaged the software"`
Prefixes []string `yaml:"prefixes,omitempty" json:"prefixes,omitempty" jsonschema:"title=Prefixes for relocatable packages"`
}

// RPMScripts represents scripts only available on RPM packages.
Expand Down
1 change: 1 addition & 0 deletions rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func buildRPMMeta(info *nfpm.Info) (*rpmpack.RPMMetaData, error) {
URL: info.Homepage,
Vendor: info.Vendor,
Packager: defaultTo(info.RPM.Packager, info.Maintainer),
Prefixes: info.RPM.Prefixes,
Group: info.RPM.Group,
Provides: provides,
Recommends: recommends,
Expand Down
1 change: 1 addition & 0 deletions rpm/rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func exampleInfo() *nfpm.Info {
PostRemove: "../testdata/scripts/postremove.sh",
},
RPM: nfpm.RPM{
Prefixes: []string{"/opt"},
Scripts: nfpm.RPMScripts{
PreTrans: "../testdata/scripts/pretrans.sh",
PostTrans: "../testdata/scripts/posttrans.sh",
Expand Down
83 changes: 42 additions & 41 deletions testdata/acceptance/core.complex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,71 @@ platform: "linux"
version: "v1.2.3-beta"
maintainer: "Foo Bar"
depends:
- bash
- bash
provides:
- fake
- fake
recommends:
- fish
- fish
replaces:
- foo
- foo
suggests:
- zsh
- zsh
description: |
Foo bar
Multiple lines
vendor: "foobar"
homepage: "https://foobar.org"
license: "MIT"
contents:
- src: ./testdata/fake
dst: /usr/bin/fake
- src: ./testdata/acceptance/folder/*
dst: /usr/share/whatever/folder
- src: ./testdata/whatever.conf
dst: /etc/foo/whatever.conf
type: config
- src: ./testdata/something
dst: /etc/something
- dst: /usr/foo/bar/something
type: dir
- dst: /var/log/whatever
type: dir
- dst: /usr/share/foo
type: dir
- src: ./testdata/fake
dst: /usr/bin/fake
- src: ./testdata/acceptance/folder/*
dst: /usr/share/whatever/folder
- src: ./testdata/whatever.conf
dst: /etc/foo/whatever.conf
type: config
- src: ./testdata/something
dst: /etc/something
- dst: /usr/foo/bar/something
type: dir
- dst: /var/log/whatever
type: dir
- dst: /usr/share/foo
type: dir

# Packager specifics:
# Packager specifics:

- packager: deb
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755
- packager: deb
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755

- packager: rpm
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755
- packager: rpm
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755

- packager: apk
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755
- packager: apk
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755

- packager: archlinux
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755
- packager: archlinux
src: ./testdata/fake
dst: /usr/bin/fake2
file_info:
mode: 04755

scripts:
preinstall: ./testdata/acceptance/scripts/preinstall.sh
postinstall: ./testdata/acceptance/scripts/postinstall.sh
preremove: ./testdata/acceptance/scripts/preremove.sh
postremove: ./testdata/acceptance/scripts/postremove.sh
rpm:
prefixes: ["/usr/bin"]
scripts:
pretrans: ./testdata/acceptance/scripts/pretrans.sh
posttrans: ./testdata/acceptance/scripts/posttrans.sh
Expand Down
11 changes: 6 additions & 5 deletions testdata/acceptance/rpm.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ RUN test -f /usr/share/whatever/folder2/file2


# ---- complex test ----
FROM min AS complex
FROM test_base AS complex
RUN rpm --prefix=/opt -ivh /tmp/foo.rpm
RUN test "$(rpm -qp --recommends /tmp/foo.rpm)" = "fish"
RUN test "$(rpm -qp --suggests /tmp/foo.rpm)" = "zsh"
RUN test "$(rpm -qp --requires /tmp/foo.rpm)" = "bash"
RUN test -e /usr/bin/fake
RUN test -e /opt/fake
RUN test -f /etc/foo/whatever.conf
RUN test -d /usr/share/whatever/folder
RUN test -f /usr/share/whatever/folder/file1
Expand All @@ -55,7 +56,7 @@ RUN test -f /etc/something/a
RUN test -f /etc/something/b
RUN test -d /etc/something/c
RUN test -f /etc/something/c/d
RUN test $(stat -c %a /usr/bin/fake2) -eq 4755
RUN test $(stat -c %a /opt/fake2) -eq 4755
RUN test -f /tmp/preinstall-proof
RUN test -f /tmp/postinstall-proof
RUN test -f /tmp/pretrans-proof
Expand All @@ -65,8 +66,8 @@ RUN test ! -f /tmp/postremove-proof
RUN echo wat >> /etc/foo/whatever.conf
RUN rpm -e foo
RUN test -f /etc/foo/whatever.conf.rpmsave
RUN test ! -f /usr/bin/fake
RUN test ! -f /usr/bin/fake2
RUN test ! -f /opt/fake
RUN test ! -f /opt/fake2
RUN test -f /tmp/preremove-proof
RUN test -f /tmp/postremove-proof
RUN test ! -d /var/log/whatever
Expand Down
4 changes: 4 additions & 0 deletions www/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ rpm:
# Compression algorithm (gzip (default), zstd, lzma or xz).
compression: zstd

# Prefixes for relocatable packages.
prefixes:
- /usr/bin

# The package is signed if a key_file is set
signature:
# PGP secret key (can also be ASCII-armored), the passphrase is taken
Expand Down
Loading