github.com/goreleaser/nfpm/v2@v2.44.0/testdata/acceptance/deb.dockerfile (about) 1 FROM debian:trixie AS test_base 2 ARG package 3 RUN echo "${package}" 4 COPY ${package} /tmp/foo.deb 5 6 7 # ---- minimal test ---- 8 FROM test_base AS min 9 RUN dpkg -i /tmp/foo.deb 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 dpkg -r foo 23 RUN test -f /etc/foo/whatever.conf 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 min AS complex 39 RUN apt-cache show /tmp/foo.deb | grep "Depends: bash" 40 RUN apt-cache show /tmp/foo.deb | grep "Suggests: zsh" 41 RUN apt-cache show /tmp/foo.deb | grep "Recommends: fish" 42 RUN test -e /usr/bin/fake 43 RUN test -f /etc/foo/whatever.conf 44 RUN test -d /usr/share/whatever/ 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 /usr/bin/fake2) -eq 4755 60 RUN test -f /tmp/preinstall-proof 61 RUN test -f /tmp/postinstall-proof 62 RUN test ! -f /tmp/preremove-proof 63 RUN test ! -f /tmp/postremove-proof 64 RUN echo wat >> /etc/foo/whatever.conf 65 RUN dpkg -r foo 66 RUN test -f /etc/foo/whatever.conf 67 RUN test ! -f /usr/bin/fake 68 RUN test ! -f /usr/bin/fake2 69 RUN test -f /tmp/preremove-proof 70 RUN test -f /tmp/postremove-proof 71 RUN test ! -d /var/log/whatever 72 RUN test ! -d /usr/share/foo 73 RUN test ! -d /usr/foo/bar/something 74 75 # ---- signed test ---- 76 FROM test_base AS signed 77 COPY keys/pubkey.gpg /usr/share/debsig/keyrings/9890904DFB2EC88A/debsig.gpg 78 RUN apt update -y 79 RUN apt install -y debsig-verify 80 COPY deb.policy.pol /etc/debsig/policies/9890904DFB2EC88A/policy.pol 81 # manually check signature 82 RUN debsig-verify /tmp/foo.deb | grep "debsig: Verified package from 'Test package' (test)" 83 # clear dpkg config as it contains 'no-debsig', now every 84 # package that will be installed must be signed 85 RUN echo "" > /etc/dpkg/dpkg.cfg 86 RUN dpkg -i /tmp/foo.deb 87 88 # ---- signed dpkg-sig test ---- 89 FROM test_base AS dpkg-signed 90 COPY keys/pubkey.gpg /tmp/gpg.key 91 RUN apt update -y 92 RUN apt install -y gnupg 93 RUN gpg --import /tmp/gpg.key 94 RUN gpg --verify /tmp/foo.deb 95 RUN dpkg -i /tmp/foo.deb 96 97 # ---- overrides test ---- 98 FROM min AS overrides 99 RUN test -e /usr/bin/fake 100 RUN test -f /etc/foo/whatever.conf 101 RUN test ! -f /tmp/preinstall-proof 102 RUN test -f /tmp/postinstall-proof 103 RUN test ! -f /tmp/preremove-proof 104 RUN test ! -f /tmp/postremove-proof 105 RUN echo wat >> /etc/foo/whatever.conf 106 RUN dpkg -r foo 107 RUN test -f /etc/foo/whatever.conf 108 RUN test ! -f /usr/bin/fake 109 RUN test -f /tmp/preremove-proof 110 RUN test ! -f /tmp/postremove-proof 111 112 113 # ---- meta test ---- 114 FROM test_base AS meta 115 RUN apt update && apt install -y /tmp/foo.deb 116 RUN command -v zsh 117 118 119 # ---- env-var-version test ---- 120 FROM min AS env-var-version 121 ENV EXPECTVER=" Version: 1.0.0~0.1.b1+git.abcdefgh" 122 RUN dpkg --info /tmp/foo.deb | grep "Version" > found 123 RUN export FOUND_VER="$(cat found)" && \ 124 echo "Expected: '${EXPECTVER}' :: Found: '${FOUND_VER}'" && \ 125 test "${FOUND_VER}" = "${EXPECTVER}" 126 127 128 # ---- changelog test ---- 129 FROM test_base AS withchangelog 130 # the dpkg configuration of the docker 131 # image filters out changelogs by default 132 # so we have to remove that rule 133 RUN apt update -y 134 RUN apt install -y gzip lintian 135 RUN dpkg -i /tmp/foo.deb 136 RUN zcat "/usr/share/doc/foo/changelog.Debian.gz" | grep "Carlos A Becker <pkg@carlosbecker.com>" 137 RUN zcat "/usr/share/doc/foo/changelog.Debian.gz" | grep "note 1" 138 RUN zcat "/usr/share/doc/foo/changelog.Debian.gz" | grep "note 2" 139 RUN zcat "/usr/share/doc/foo/changelog.Debian.gz" | grep "note 3" 140 RUN lintian /tmp/foo.deb > lintian.out 141 RUN test $(grep -c 'debian-changelog-file-missing-or-wrong-name' lintian.out) = 0 142 RUN test $(grep -c 'changelog-not-compressed-with-max-compression' lintian.out) = 0 143 RUN test $(grep -c 'unknown-control-file' lintian.out) = 0 144 RUN test $(grep -c 'package-contains-timestamped-gzip' lintian.out) = 0 145 RUN test $(grep -c 'md5sums-lists-nonexistent-file' lintian.out) = 0 146 RUN test $(grep -c 'file-missing-in-md5sums' lintian.out) = 0 147 RUN test $(grep -c 'syntax-error-in-debian-changelog' lintian.out) = 0 148 RUN test $(grep -c 'no-copyright-file' lintian.out) = 0 149 RUN test $(grep -c 'executable-is-not-world-readable' lintian.out) = 0 150 RUN test $(grep -c 'non-standard-executable-perm' lintian.out) = 0 151 RUN test $(grep -c 'non-standard-file-perm' lintian.out) = 0 152 RUN test $(grep -c 'unknown-section' lintian.out) = 0 153 RUN test $(grep -c 'empty-field' lintian.out) = 0 154 RUN test $(grep -c 'syntax-error-in-debian-changelog' lintian.out) = 0 155 RUN test $(grep -c 'malformed-contact' lintian.out) = 0 156 RUN test $(grep -c 'description-starts-with-package-name' lintian.out) = 0 157 RUN test $(grep -c 'description-starts-with-leading-spaces' lintian.out) = 0 158 159 # ---- rules test ---- 160 FROM min AS rules 161 RUN dpkg -r foo 162 163 # ---- triggers test ---- 164 FROM min AS triggers 165 # simulate another package that activates the trigger 166 RUN dpkg-trigger --by-package foo manual-trigger 167 RUN dpkg --triggers-only foo 168 RUN test -f /tmp/trigger-proof 169 170 # ---- breaks test ---- 171 FROM test_base AS breaks 172 COPY dummy.deb /tmp/dummy.deb 173 # install dummy package 174 RUN dpkg -i /tmp/dummy.deb 175 # make sure foo can't be installed 176 RUN dpkg -i /tmp/foo.deb 2>&1 | grep "foo breaks dummy" 177 # make sure foo can be installed if dummy is not installed 178 RUN dpkg -r dummy 179 RUN dpkg -i /tmp/foo.deb 180 181 182 # ---- predepends test ---- 183 FROM test_base AS predepends 184 COPY dummy.deb /tmp/dummy.deb 185 # install dummy package 186 RUN dpkg --info /tmp/foo.deb | grep "Pre-Depends: less" 187 188 # ---- compression test ---- 189 FROM min AS compression 190 RUN test -e /usr/bin/fake 191 RUN test -f /etc/foo/whatever.conf 192 RUN echo wat >> /etc/foo/whatever.conf 193 RUN dpkg -r foo 194 RUN test ! -f /usr/bin/fake 195 196 # ---- upgrade test ---- 197 FROM test_base AS upgrade 198 ARG oldpackage 199 RUN echo "${oldpackage}" 200 COPY ${oldpackage} /tmp/old_foo.deb 201 RUN dpkg -i /tmp/old_foo.deb 202 203 RUN test -f /tmp/preinstall-proof 204 RUN cat /tmp/preinstall-proof | grep "Install" 205 206 RUN test -f /tmp/postinstall-proof 207 RUN cat /tmp/postinstall-proof | grep "Install" 208 209 RUN dpkg -i /tmp/foo.deb 210 211 RUN test -f /tmp/preremove-proof 212 RUN cat /tmp/preremove-proof | grep "Upgrade" 213 214 RUN test -f /tmp/postremove-proof 215 RUN cat /tmp/postremove-proof | grep "Upgrade" 216 217 RUN test -f /tmp/preinstall-proof 218 RUN cat /tmp/preinstall-proof | grep "Upgrade" 219 220 RUN test -f /tmp/postinstall-proof 221 RUN cat /tmp/postinstall-proof | grep "Upgrade"