github.com/goreleaser/nfpm/v2@v2.44.0/testdata/acceptance/rpm.dockerfile (about)

     1  FROM fedora AS test_base
     2  ARG package
     3  RUN echo "${package}"
     4  COPY ${package} /tmp/foo.rpm
     5  
     6  
     7  # ---- minimal test ----
     8  FROM test_base AS min
     9  RUN rpm -ivh /tmp/foo.rpm
    10  
    11  
    12  # ---- symlink test ----
    13  FROM min AS symlink
    14  RUN ls -l /path/to/symlink | grep "/path/to/symlink -> /etc/foo/whatever.conf"
    15  
    16  
    17  # ---- simple test ----
    18  FROM min AS simple
    19  RUN test -e /usr/bin/fake
    20  RUN test -f /etc/foo/whatever.conf
    21  RUN echo wat >> /etc/foo/whatever.conf
    22  RUN rpm -e foo
    23  RUN test -f /etc/foo/whatever.conf.rpmsave
    24  RUN test ! -f /usr/bin/fake
    25  
    26  
    27  # ---- no-glob test ----
    28  FROM min AS no-glob
    29  RUN test -d /usr/share/whatever/
    30  RUN test -f /usr/share/whatever/file1
    31  RUN test -f /usr/share/whatever/file2
    32  RUN test -d /usr/share/whatever/folder2
    33  RUN test -f /usr/share/whatever/folder2/file1
    34  RUN test -f /usr/share/whatever/folder2/file2
    35  
    36  
    37  # ---- complex test ----
    38  FROM test_base AS complex
    39  RUN rpm --prefix=/opt -ivh /tmp/foo.rpm
    40  RUN test "$(rpm -qp --recommends /tmp/foo.rpm)" = "fish"
    41  RUN test "$(rpm -qp --suggests /tmp/foo.rpm)" = "zsh"
    42  RUN test "$(rpm -qp --requires /tmp/foo.rpm)" = "bash"
    43  RUN test -e /opt/fake
    44  RUN test -f /etc/foo/whatever.conf
    45  RUN test -d /usr/share/whatever/folder
    46  RUN test -f /usr/share/whatever/folder/file1
    47  RUN test -f /usr/share/whatever/folder/file2
    48  RUN test -d /usr/share/whatever/folder/folder2
    49  RUN test -f /usr/share/whatever/folder/folder2/file1
    50  RUN test -f /usr/share/whatever/folder/folder2/file2
    51  RUN test -d /var/log/whatever
    52  RUN test -d /usr/share/foo
    53  RUN test -d /usr/foo/bar/something
    54  RUN test -d /etc/something
    55  RUN test -f /etc/something/a
    56  RUN test -f /etc/something/b
    57  RUN test -d /etc/something/c
    58  RUN test -f /etc/something/c/d
    59  RUN test $(stat -c %a /opt/fake2) -eq 4755
    60  RUN test -f /tmp/preinstall-proof
    61  RUN test -f /tmp/postinstall-proof
    62  RUN test -f /tmp/pretrans-proof
    63  RUN test -f /tmp/posttrans-proof
    64  RUN test ! -f /tmp/preremove-proof
    65  RUN test ! -f /tmp/postremove-proof
    66  RUN echo wat >> /etc/foo/whatever.conf
    67  RUN rpm -e foo
    68  RUN test -f /etc/foo/whatever.conf.rpmsave
    69  RUN test ! -f /opt/fake
    70  RUN test ! -f /opt/fake2
    71  RUN test -f /tmp/preremove-proof
    72  RUN test -f /tmp/postremove-proof
    73  RUN test ! -d /var/log/whatever
    74  RUN test ! -d /usr/share/foo
    75  RUN test ! -d /usr/foo/bar/something
    76  
    77  
    78  # ---- signed test ----
    79  FROM test_base AS signed
    80  COPY keys/pubkey.asc /tmp/pubkey.asc
    81  RUN rpm --import /tmp/pubkey.asc
    82  RUN rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n'
    83  RUN rpm -K /tmp/foo.rpm
    84  RUN rpm -K /tmp/foo.rpm | grep -E "(?:pgp|digests signatures) OK"
    85  RUN rpm -vK /tmp/foo.rpm
    86  RUN rpm -vK /tmp/foo.rpm | grep "RSA/SHA256 Signature, key ID 15bd80b3: OK"
    87  
    88  # Test with a repo
    89  RUN yum install -y createrepo yum-utils
    90  RUN rm -rf /etc/yum.repos.d/*.repo
    91  COPY keys/test.rpm.repo /etc/yum.repos.d/test.rpm.repo
    92  RUN createrepo /tmp
    93  RUN yum install -y foo
    94  
    95  
    96  # ---- overrides test ----
    97  FROM min AS overrides
    98  RUN test -e /usr/bin/fake
    99  RUN test -f /etc/foo/whatever.conf
   100  RUN test -d /usr/share/whatever/folder
   101  RUN test -f /usr/share/whatever/folder/file1
   102  RUN test -f /usr/share/whatever/folder/file2
   103  RUN test -d /usr/share/whatever/folder/folder2
   104  RUN test -f /usr/share/whatever/folder/folder2/file1
   105  RUN test -f /usr/share/whatever/folder/folder2/file2
   106  RUN test -f /tmp/preinstall-proof
   107  RUN test ! -f /tmp/postinstall-proof
   108  RUN test ! -f /tmp/preremove-proof
   109  RUN test ! -f /tmp/postremove-proof
   110  RUN echo wat >> /etc/foo/whatever.conf
   111  RUN rpm -e foo
   112  RUN test -f /etc/foo/whatever.conf.rpmsave
   113  RUN test ! -f /usr/bin/fake
   114  RUN test ! -f /tmp/preremove-proof
   115  RUN test -f /tmp/postremove-proof
   116  
   117  
   118  # ---- meta test ----
   119  FROM test_base AS meta
   120  RUN dnf install -y /tmp/foo.rpm
   121  RUN command -v zsh
   122  
   123  
   124  # ---- env-var-version test ----
   125  FROM min AS env-var-version
   126  ENV EXPECTVER="Version : 1.0.0~0.1.b1+git.abcdefgh" \
   127  	EXPECTREL="Release : 1"
   128  RUN rpm -qpi /tmp/foo.rpm | sed -e 's/ \+/ /g' | grep "Version" > found.ver
   129  RUN rpm -qpi /tmp/foo.rpm | sed -e 's/ \+/ /g' | grep "Release" > found.rel
   130  RUN export FOUND_VER="$(cat found.ver)" && \
   131  	echo "Expected: ${EXPECTVER}' :: Found: '${FOUND_VER}'" && \
   132  	test "${FOUND_VER}" = "${EXPECTVER}"
   133  RUN export FOUND_REL="$(cat found.rel)" && \
   134  	echo "Expected: '${EXPECTREL}' :: Found: '${FOUND_REL}'" && \
   135  	test "${FOUND_REL}" = "${EXPECTREL}"
   136  
   137  
   138  # ---- changelog test ----
   139  FROM min AS withchangelog
   140  RUN rpm -qp /tmp/foo.rpm --changelog | grep "Carlos A Becker <pkg@carlosbecker.com>"
   141  RUN rpm -qp /tmp/foo.rpm --changelog | grep -E "^- note 1$"
   142  RUN rpm -qp /tmp/foo.rpm --changelog | grep -E "^- note 2$"
   143  RUN rpm -qp /tmp/foo.rpm --changelog | grep -E "^- note 3$"
   144  RUN rpm -q foo --changelog | grep "Carlos A Becker <pkg@carlosbecker.com>"
   145  RUN rpm -q foo --changelog | grep -E "^- note 1$"
   146  RUN rpm -q foo --changelog | grep -E "^- note 2$"
   147  RUN rpm -q foo --changelog | grep -E "^- note 3$"
   148  
   149  
   150  # ---- compression test ----
   151  FROM min AS compression
   152  ARG compression
   153  RUN test "${compression}" = "$(rpm -qp --qf '%{PAYLOADCOMPRESSOR}' /tmp/foo.rpm)"
   154  RUN test -e /usr/bin/fake
   155  RUN test -f /etc/foo/whatever.conf
   156  RUN echo wat >> /etc/foo/whatever.conf
   157  RUN rpm -e foo
   158  RUN test -f /etc/foo/whatever.conf.rpmsave
   159  RUN test ! -f /usr/bin/fake
   160  
   161  # ---- upgrade test ----
   162  FROM test_base AS upgrade
   163  ARG oldpackage
   164  RUN echo "${oldpackage}"
   165  COPY ${oldpackage} /tmp/old_foo.rpm
   166  RUN rpm -ivh /tmp/old_foo.rpm
   167  
   168  RUN test -f /tmp/preinstall-proof
   169  RUN cat /tmp/preinstall-proof | grep "Install"
   170  
   171  RUN test -f /tmp/postinstall-proof
   172  RUN cat /tmp/postinstall-proof | grep "Install"
   173  
   174  RUN echo modified > /etc/regular.conf
   175  RUN echo modified > /etc/noreplace.conf
   176  
   177  RUN rpm -ivh /tmp/foo.rpm --upgrade
   178  
   179  RUN test -f /tmp/preremove-proof
   180  RUN cat /tmp/preremove-proof | grep "Upgrade"
   181  
   182  RUN test -f /tmp/postremove-proof
   183  RUN cat /tmp/postremove-proof | grep "Upgrade"
   184  
   185  RUN test -f /tmp/preinstall-proof
   186  RUN cat /tmp/preinstall-proof | grep "Upgrade"
   187  
   188  RUN test -f /tmp/postinstall-proof
   189  RUN cat /tmp/postinstall-proof | grep "Upgrade"
   190  
   191  RUN cat /etc/regular.conf | grep foo=baz
   192  RUN test -f /etc/regular.conf.rpmsave
   193  RUN cat /etc/regular.conf.rpmsave | grep modified
   194  
   195  RUN cat /etc/noreplace.conf | grep modified
   196  RUN test -f /etc/noreplace.conf.rpmnew
   197  RUN cat /etc/noreplace.conf.rpmnew | grep foo=baz
   198  
   199  # ---- release test ----
   200  FROM min AS release
   201  RUN test -e /usr/bin/fake
   202  RUN test -f /etc/foo/whatever.conf
   203  RUN echo wat >> /etc/foo/whatever.conf
   204  RUN rpm -e foo
   205  RUN test -f /etc/foo/whatever.conf.rpmsave
   206  RUN test ! -f /usr/bin/fake
   207  
   208  # ---- directories test ----
   209  FROM test_base AS directories
   210  RUN groupadd test
   211  RUN rpm -ivh /tmp/foo.rpm
   212  RUN test -f /etc/foo/file
   213  RUN test -f /etc/bar/file
   214  RUN test -d /etc/bar
   215  RUN test -d /etc/baz
   216  RUN stat -L -c "%a %U %G" /etc/baz | grep "700 root test"
   217  RUN rpm -e foo
   218  RUN test ! -f /etc/foo/file
   219  RUN test ! -f /etc/bar/file
   220  RUN test -d /etc/foo
   221  RUN test ! -d /etc/bar
   222  RUN test ! -d /etc/baz
   223  
   224  # ---- verify test ----
   225  FROM min AS verify
   226  RUN rpm -V foo
   227  RUN rm /tmp/postinstall-proof
   228  RUN ! rpm -V foo