1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-05-12 10:36:08 +02:00
nfpm/testdata/acceptance/apk.dockerfile

133 lines
3.5 KiB
Plaintext
Raw Normal View History

FROM alpine AS test_base
feat: apk support (#207) * first attempt at apk, built from Issue #39 * inspector cleanups * read the contrib note, ran linter, fixes made. Noice! * linter went wonky * linter went wonky * fix some lint issues * fix some lint issues * lightweight file validation, while I try to refactor method into smaller chunks * refactorings to get `make ci` to pass. ain't pretty, but hopefully doesn't make things worse. * add ignore file to get workdir created in CI * try to get a successful test run on CI (file sizes differ on CI). * must remember to run liner (make ci) before pushing * Doh! Detect CI via correct env var name * tweak CI expected file sizes * blech. try to get a range of values for CI * better message if value fails conditions * better message if value fails conditions * initial impl of Package interface - just hoping I don't already have the arch mapping backwards. * missed non-altered arch case * ci failures * refactor io.File to Writer * add note about command to test apk install in docker * remove absolute paths from test (prep for replacement with info.Files). * rename test files folder * get ci file size ranges happy after path changes * get ci file size ranges happy after path changes * move COPY towards end, allowing more caching of layers - feedback from @tcurdt * remove Gz from function name * rename combine function * add skipVerify flag to preserve generated .apk file for use in dockerfile manual test. Thanks @tcurdt * make ci is my friend * remove useless comment * start conversion to nfpm.Info * use base64 encoded string for private signing key * remove old runit() method, as we can now test using Default.Package. add some tests lifted from deb_test.go. * duck and cover: register the apk packager * use the metadata from nfpm (does not handle scripts/pre/post, etc) * getting closer to removing size assertions, but not just yet * getting closer to removing size assertions, but not just yet * add niffty import for init - Blank identifier comes to the rescue. Thanks @tcurdt. add apk to overrides parse test. * I will very much enjoy deleting this assertion...soon, soon. * add PrivateKeyFile option, which is subordinate to PrivateKey * move PrivateKey configs to root config struct. expand PrivateKey configs from env vars if set. * provide the user a hint if privatekey config is missing for .apk packager * lovin' the linter now. learning language from linter loudness. didn't know switch could work like that. * add support for 'scripts' in control file * fix control metadata * make signing keyname configurable * goofy size fix * remove temporary test and related files * fix template copy/pasta error * remove old print statements * first take at integration tests. should remove need for --allow-untrusted in `apk add` command. * fix: merge issues, remove signature support Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: lint issues Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: meta Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: datahash seems unused Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: improve test code Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: unused params Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: changelog test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: fix Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: img Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: symlink Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: uneeded deletes Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: symlinks Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Dan Rollo <danrollo@gmail.com>
2020-08-17 22:28:38 +02:00
ARG package
RUN echo "${package}"
feat: apk support (#207) * first attempt at apk, built from Issue #39 * inspector cleanups * read the contrib note, ran linter, fixes made. Noice! * linter went wonky * linter went wonky * fix some lint issues * fix some lint issues * lightweight file validation, while I try to refactor method into smaller chunks * refactorings to get `make ci` to pass. ain't pretty, but hopefully doesn't make things worse. * add ignore file to get workdir created in CI * try to get a successful test run on CI (file sizes differ on CI). * must remember to run liner (make ci) before pushing * Doh! Detect CI via correct env var name * tweak CI expected file sizes * blech. try to get a range of values for CI * better message if value fails conditions * better message if value fails conditions * initial impl of Package interface - just hoping I don't already have the arch mapping backwards. * missed non-altered arch case * ci failures * refactor io.File to Writer * add note about command to test apk install in docker * remove absolute paths from test (prep for replacement with info.Files). * rename test files folder * get ci file size ranges happy after path changes * get ci file size ranges happy after path changes * move COPY towards end, allowing more caching of layers - feedback from @tcurdt * remove Gz from function name * rename combine function * add skipVerify flag to preserve generated .apk file for use in dockerfile manual test. Thanks @tcurdt * make ci is my friend * remove useless comment * start conversion to nfpm.Info * use base64 encoded string for private signing key * remove old runit() method, as we can now test using Default.Package. add some tests lifted from deb_test.go. * duck and cover: register the apk packager * use the metadata from nfpm (does not handle scripts/pre/post, etc) * getting closer to removing size assertions, but not just yet * getting closer to removing size assertions, but not just yet * add niffty import for init - Blank identifier comes to the rescue. Thanks @tcurdt. add apk to overrides parse test. * I will very much enjoy deleting this assertion...soon, soon. * add PrivateKeyFile option, which is subordinate to PrivateKey * move PrivateKey configs to root config struct. expand PrivateKey configs from env vars if set. * provide the user a hint if privatekey config is missing for .apk packager * lovin' the linter now. learning language from linter loudness. didn't know switch could work like that. * add support for 'scripts' in control file * fix control metadata * make signing keyname configurable * goofy size fix * remove temporary test and related files * fix template copy/pasta error * remove old print statements * first take at integration tests. should remove need for --allow-untrusted in `apk add` command. * fix: merge issues, remove signature support Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: lint issues Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: meta Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: datahash seems unused Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: improve test code Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: unused params Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: changelog test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: fix Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: img Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: symlink Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: uneeded deletes Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: symlinks Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Dan Rollo <danrollo@gmail.com>
2020-08-17 22:28:38 +02:00
COPY ${package} /tmp/foo.apk
# ---- minimal test ----
FROM test_base AS min
feat: apk support (#207) * first attempt at apk, built from Issue #39 * inspector cleanups * read the contrib note, ran linter, fixes made. Noice! * linter went wonky * linter went wonky * fix some lint issues * fix some lint issues * lightweight file validation, while I try to refactor method into smaller chunks * refactorings to get `make ci` to pass. ain't pretty, but hopefully doesn't make things worse. * add ignore file to get workdir created in CI * try to get a successful test run on CI (file sizes differ on CI). * must remember to run liner (make ci) before pushing * Doh! Detect CI via correct env var name * tweak CI expected file sizes * blech. try to get a range of values for CI * better message if value fails conditions * better message if value fails conditions * initial impl of Package interface - just hoping I don't already have the arch mapping backwards. * missed non-altered arch case * ci failures * refactor io.File to Writer * add note about command to test apk install in docker * remove absolute paths from test (prep for replacement with info.Files). * rename test files folder * get ci file size ranges happy after path changes * get ci file size ranges happy after path changes * move COPY towards end, allowing more caching of layers - feedback from @tcurdt * remove Gz from function name * rename combine function * add skipVerify flag to preserve generated .apk file for use in dockerfile manual test. Thanks @tcurdt * make ci is my friend * remove useless comment * start conversion to nfpm.Info * use base64 encoded string for private signing key * remove old runit() method, as we can now test using Default.Package. add some tests lifted from deb_test.go. * duck and cover: register the apk packager * use the metadata from nfpm (does not handle scripts/pre/post, etc) * getting closer to removing size assertions, but not just yet * getting closer to removing size assertions, but not just yet * add niffty import for init - Blank identifier comes to the rescue. Thanks @tcurdt. add apk to overrides parse test. * I will very much enjoy deleting this assertion...soon, soon. * add PrivateKeyFile option, which is subordinate to PrivateKey * move PrivateKey configs to root config struct. expand PrivateKey configs from env vars if set. * provide the user a hint if privatekey config is missing for .apk packager * lovin' the linter now. learning language from linter loudness. didn't know switch could work like that. * add support for 'scripts' in control file * fix control metadata * make signing keyname configurable * goofy size fix * remove temporary test and related files * fix template copy/pasta error * remove old print statements * first take at integration tests. should remove need for --allow-untrusted in `apk add` command. * fix: merge issues, remove signature support Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: lint issues Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: meta Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: datahash seems unused Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: improve test code Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: unused params Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: changelog test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: fix Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: img Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: symlink Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: uneeded deletes Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: symlinks Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Dan Rollo <danrollo@gmail.com>
2020-08-17 22:28:38 +02:00
RUN apk add --allow-untrusted /tmp/foo.apk
# ---- symlink test ----
FROM min AS symlink
RUN ls -l /path/to/symlink | grep "/path/to/symlink -> /etc/foo/whatever.conf"
# ---- simple test ----
FROM min AS simple
feat: apk support (#207) * first attempt at apk, built from Issue #39 * inspector cleanups * read the contrib note, ran linter, fixes made. Noice! * linter went wonky * linter went wonky * fix some lint issues * fix some lint issues * lightweight file validation, while I try to refactor method into smaller chunks * refactorings to get `make ci` to pass. ain't pretty, but hopefully doesn't make things worse. * add ignore file to get workdir created in CI * try to get a successful test run on CI (file sizes differ on CI). * must remember to run liner (make ci) before pushing * Doh! Detect CI via correct env var name * tweak CI expected file sizes * blech. try to get a range of values for CI * better message if value fails conditions * better message if value fails conditions * initial impl of Package interface - just hoping I don't already have the arch mapping backwards. * missed non-altered arch case * ci failures * refactor io.File to Writer * add note about command to test apk install in docker * remove absolute paths from test (prep for replacement with info.Files). * rename test files folder * get ci file size ranges happy after path changes * get ci file size ranges happy after path changes * move COPY towards end, allowing more caching of layers - feedback from @tcurdt * remove Gz from function name * rename combine function * add skipVerify flag to preserve generated .apk file for use in dockerfile manual test. Thanks @tcurdt * make ci is my friend * remove useless comment * start conversion to nfpm.Info * use base64 encoded string for private signing key * remove old runit() method, as we can now test using Default.Package. add some tests lifted from deb_test.go. * duck and cover: register the apk packager * use the metadata from nfpm (does not handle scripts/pre/post, etc) * getting closer to removing size assertions, but not just yet * getting closer to removing size assertions, but not just yet * add niffty import for init - Blank identifier comes to the rescue. Thanks @tcurdt. add apk to overrides parse test. * I will very much enjoy deleting this assertion...soon, soon. * add PrivateKeyFile option, which is subordinate to PrivateKey * move PrivateKey configs to root config struct. expand PrivateKey configs from env vars if set. * provide the user a hint if privatekey config is missing for .apk packager * lovin' the linter now. learning language from linter loudness. didn't know switch could work like that. * add support for 'scripts' in control file * fix control metadata * make signing keyname configurable * goofy size fix * remove temporary test and related files * fix template copy/pasta error * remove old print statements * first take at integration tests. should remove need for --allow-untrusted in `apk add` command. * fix: merge issues, remove signature support Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: lint issues Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: meta Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: datahash seems unused Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: improve test code Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: unused params Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: tests Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: changelog test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: fix Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: img Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: symlink Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: uneeded deletes Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: symlinks Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Dan Rollo <danrollo@gmail.com>
2020-08-17 22:28:38 +02:00
RUN test -e /usr/local/bin/fake
RUN test -f /etc/foo/whatever.conf
RUN echo wat >> /etc/foo/whatever.conf
RUN apk del foo
RUN test -f /etc/foo/whatever.conf
RUN test ! -f /usr/local/bin/fake
# ---- no-glob test ----
FROM min AS no-glob
RUN test -d /usr/share/whatever/
RUN test -f /usr/share/whatever/file1
RUN test -f /usr/share/whatever/file2
RUN test -d /usr/share/whatever/folder2
RUN test -f /usr/share/whatever/folder2/file1
RUN test -f /usr/share/whatever/folder2/file2
# ---- complex test ----
FROM min AS complex
RUN test -e /usr/local/bin/fake
RUN test -f /etc/foo/whatever.conf
RUN test -d /usr/share/whatever/
RUN test -d /usr/share/whatever/folder
RUN test -f /usr/share/whatever/folder/file1
RUN test -f /usr/share/whatever/folder/file2
RUN test -d /usr/share/whatever/folder/folder2
RUN test -f /usr/share/whatever/folder/folder2/file1
RUN test -f /usr/share/whatever/folder/folder2/file2
RUN test -d /var/log/whatever
RUN test -d /usr/share/foo
RUN test -d /usr/foo/bar/something
RUN test $(stat -c %a /usr/sbin/fake) -eq 4755
RUN test -f /tmp/preinstall-proof
RUN test -f /tmp/postinstall-proof
RUN test ! -f /tmp/preremove-proof
RUN test ! -f /tmp/postremove-proof
RUN echo wat >> /etc/foo/whatever.conf
RUN apk del foo
RUN test -f /etc/foo/whatever.conf
RUN test ! -f /usr/local/bin/fake
RUN test ! -f /usr/sbin/fake
RUN test -f /tmp/preremove-proof
RUN test -f /tmp/postremove-proof
RUN test ! -d /var/log/whatever
RUN test ! -d /usr/share/foo
RUN test ! -d /usr/foo/bar/something
# ---- signed test ----
FROM test_base AS signed
COPY keys/rsa_unprotected.pub /etc/apk/keys/john@example.com.rsa.pub
RUN apk verify /tmp/foo.apk | grep "/tmp/foo.apk: 0 - OK"
RUN apk add /tmp/foo.apk
# ---- overrides test ----
FROM min AS overrides
RUN test -e /usr/local/bin/fake
RUN test -f /etc/foo/whatever.conf
RUN test ! -f /tmp/preinstall-proof
RUN test -f /tmp/postinstall-proof
RUN test ! -f /tmp/preremove-proof
RUN test ! -f /tmp/postremove-proof
RUN echo wat >> /etc/foo/whatever.conf
RUN apk del foo
RUN test -f /etc/foo/whatever.conf
RUN test ! -f /usr/local/bin/fake
RUN test -f /tmp/preremove-proof
RUN test ! -f /tmp/postremove-proof
# ---- meta test ----
FROM min AS meta
RUN command -v zsh
# ---- env-var-version test ----
FROM min AS env-var-version
ENV EXPECTVER="foo-1.0.0~0.1.b1+git.abcdefgh description:"
RUN apk info foo | grep "foo-" | grep " description:" > found
RUN export FOUND_VER="$(cat found)" && \
echo "Expected: '${EXPECTVER}' :: Found: '${FOUND_VER}'" && \
test "${FOUND_VER}" = "${EXPECTVER}"
# ---- changelog test ----
FROM min AS withchangelog
RUN echo "No Changelog support for apk?"
# ---- upgrade test ----
FROM test_base AS upgrade
ARG oldpackage
RUN echo "${oldpackage}"
COPY ${oldpackage} /tmp/old_foo.apk
RUN apk add --allow-untrusted /tmp/old_foo.apk
RUN test -f /tmp/preinstall-proof
RUN cat /tmp/preinstall-proof | grep "Install"
RUN test -f /tmp/postinstall-proof
RUN cat /tmp/postinstall-proof | grep "Install"
RUN test ! -f /tmp/preupgrade-proof
RUN test ! -f /tmp/postupgrade-proof
RUN echo modified > /etc/regular.conf
RUN echo modified > /etc/noreplace.conf
RUN apk add --allow-untrusted /tmp/foo.apk
RUN test -f /tmp/preupgrade-proof
RUN test -f /tmp/postupgrade-proof