From 2f876f4b12e58458a669d5d981face172ad70f76 Mon Sep 17 00:00:00 2001 From: Roman Mohr Date: Thu, 15 Nov 2018 17:17:11 +0100 Subject: [PATCH] Ensure that additional tars are passed through in a correct fashion --- rpm/rpm.bzl | 2 +- test/BUILD | 6 ++++++ test/configs/allinone.yaml | 5 ++++- test/configs/image_with_extra_tar.yaml | 21 +++++++++++++++++++++ testdata/BUILD | 16 ++++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/configs/image_with_extra_tar.yaml diff --git a/rpm/rpm.bzl b/rpm/rpm.bzl index a870f90..9fdb1f0 100644 --- a/rpm/rpm.bzl +++ b/rpm/rpm.bzl @@ -30,7 +30,7 @@ def _rpms_impl(ctx, rpms = None): ) tars = [finaltar] if ctx.attr.tars: - tars = tars + ctx.attr.tars + tars = tars + ctx.files.tars return _container.image.implementation(ctx, tars = tars) _rpms_layer = rule( diff --git a/test/BUILD b/test/BUILD index cc05870..4a44b93 100644 --- a/test/BUILD +++ b/test/BUILD @@ -23,3 +23,9 @@ container_test( configs = ["configs/allinone.yaml"], image = "//testdata:allinone_no_base", ) + +container_test( + name = "image_with_extra_tar_test", + configs = ["configs/image_with_extra_tar.yaml"], + image = "//testdata:image_with_extra_tar", +) diff --git a/test/configs/allinone.yaml b/test/configs/allinone.yaml index 9d8359d..62dd68c 100644 --- a/test/configs/allinone.yaml +++ b/test/configs/allinone.yaml @@ -11,4 +11,7 @@ fileExistenceTests: - name: 'readme from ca-certificates' path: '/usr/share/pki/ca-trust-source/README' shouldExist: true - permissions: '-rw-r--r--' \ No newline at end of file + permissions: '-rw-r--r--' +- name: '/etc/test/foo should be there' + path: '/etc/test/foo' + shouldExist: false diff --git a/test/configs/image_with_extra_tar.yaml b/test/configs/image_with_extra_tar.yaml new file mode 100644 index 0000000..fcd2454 --- /dev/null +++ b/test/configs/image_with_extra_tar.yaml @@ -0,0 +1,21 @@ +schemaVersion: '2.0.0' +fileExistenceTests: +- name: 'ldconfig binary from glibc' + path: '/sbin/ldconfig' + shouldExist: true + permissions: '-rwxr-xr-x' +- name: 'rpm database file' + path: '/var/lib/rpm/Packages' + shouldExist: true + permissions: '-rw-r--r--' +- name: 'readme from ca-certificates should not be there' + path: '/usr/share/pki/ca-trust-source/README' + shouldExist: false +- name: '/foo should be there' + path: '/foo' + shouldExist: true + permissions: '-rw-r--r--' +- name: '/etc/test/foo should be there' + path: '/etc/test/foo' + shouldExist: true + permissions: '-rw-r--r--' \ No newline at end of file diff --git a/testdata/BUILD b/testdata/BUILD index ad993f7..726ae02 100644 --- a/testdata/BUILD +++ b/testdata/BUILD @@ -1,5 +1,7 @@ package(default_visibility = ["//visibility:public"]) +load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") + load( "@io_bazel_rules_docker//container:container.bzl", "container_image", @@ -38,3 +40,17 @@ rpm_image( base = ":files_base", rpms = ["@glibc//file"], ) + +rpm_image( + name = "image_with_extra_tar", + base = ":files_base", + rpms = ["@glibc//file"], + tars = [":foo_tar"], +) + +pkg_tar( + name = "foo_tar", + srcs = ["foo"], + mode = "0o644", + package_dir = "/etc/test", +)