Skip to content

Commit 0aae5d4

Browse files
INST-2193 - Fix add locale and set env C.UTF-8
1 parent aa13216 commit 0aae5d4

File tree

8 files changed

+92
-9
lines changed

8 files changed

+92
-9
lines changed

WORKSPACE

+7-6
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ dpkg_src(
3939
arch = "amd64",
4040
distro = "buster",
4141
sha256 = "e096054471ae9a772fa67006cd0d9a0b125bb30443625fb6b66935e2a9331e98",
42-
snapshot = "20210216T023642Z",
42+
snapshot = "20210216T210840Z",
4343
url = "https://snapshot.debian.org/archive",
4444
)
4545

4646
dpkg_src(
4747
name = "debian_buster_security",
48-
package_prefix = "https://snapshot.debian.org/archive/debian-security/20210215T180445Z/",
49-
packages_gz_url = "https://snapshot.debian.org/archive/debian-security/20210215T180445Z/dists/buster/updates/main/binary-amd64/Packages.gz",
50-
sha256 = "666dad92ef97c05f72264ab570ccb4059e6993cc00c823b427a93f1f3349743e",
48+
package_prefix = "https://snapshot.debian.org/archive/debian-security/20210216T201258Z/",
49+
packages_gz_url = "https://snapshot.debian.org/archive/debian-security/20210216T201258Z/dists/buster/updates/main/binary-amd64/Packages.gz",
50+
sha256 = "979b105c890ce629a002d66c79b67381c5b78b4769abbeddad3a57225c1c1159",
5151
)
5252

5353
dpkg_list(
@@ -56,6 +56,7 @@ dpkg_list(
5656
# Version required to skip a security fix to the pre-release library
5757
# TODO: Remove when there is a security fix or dpkg_list finds the recent version
5858
"libc6",
59+
"libc-bin",
5960
"base-files",
6061
"ca-certificates",
6162
"openssl",
@@ -125,8 +126,8 @@ http_file(
125126
http_file(
126127
name = "busybox",
127128
executable = True,
128-
sha256 = "233d850e3927bb99d8fcb9a55930cac0c8ad41eaad6a8fc2b02c4e0f88acf042",
129-
urls = ["https://deepscan.jfrog.io/deepscan/distroless-generic/busybox/busybox-1.32.1.tar.xz"],
129+
sha256 = "9c1cc2735e2ea21c4579be452b313ce4120866a8c2b9dfc45bb7f9bf02d34949",
130+
urls = ["https://deepscan.jfrog.io/deepscan/distroless-generic/busybox/1.32.1-glibc-busybox.tar.xz"],
130131
)
131132

132133
#Added complied and slimed curl binary from source https://github.com/curl/curl/releases

base/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ pkg_tar(
4646

4747
load("@package_bundle//file:packages.bzl", "packages")
4848
load("//cacerts:cacerts.bzl", "cacerts")
49+
load("//locale:locale.bzl", "locale")
4950

5051
cacerts(
5152
name = "cacerts",
5253
deb = packages["ca-certificates"],
5354
)
5455

56+
locale(
57+
name = "locale",
58+
deb = packages["libc-bin"],
59+
)
60+
5561
# Create /tmp, too many things assume it exists.
5662
# tmp.tar has a /tmp with the correct permissions 01777
5763
# A tar is needed because at the moment there is no way to create a
@@ -63,6 +69,7 @@ docker_build(
6369
packages["base-files"],
6470
packages["netbase"],
6571
packages["tzdata"],
72+
packages["libc-bin"],
6673
":cacerts.deb",
6774
],
6875
env = {
@@ -71,6 +78,7 @@ docker_build(
7178
# TODO: We should run update-ca-certifaces, but that requires "openssl rehash"
7279
# which would probably need to be run inside the container
7380
"SSL_CERT_FILE": "/etc/ssl/certs/ca-certificates.crt",
81+
"LANG": "C.UTF-8",
7482
},
7583
tars = [
7684
":passwd",

base/artifactory-sh/BUILD

+6
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ pkg_tar(
6363

6464
load("@package_bundle//file:packages.bzl", "packages")
6565
load("//cacerts:cacerts.bzl", "cacerts")
66+
load("//locale:locale.bzl", "locale")
6667

6768
cacerts(
6869
name = "cacerts",
6970
deb = packages["ca-certificates"],
7071
)
7172

73+
locale(
74+
name = "locale",
75+
deb = packages["libc-bin"],
76+
)
77+
7278
# Create /tmp, too many things assume it exists.
7379
# tmp.tar has a /tmp with the correct permissions 01777
7480
# A tar is needed because at the moment there is no way to create a

base/testdata/debug.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ commandTests:
2626
# Check ps cmd
2727
- name: ps
2828
command: ["ps"]
29-
exitCode: 0
29+
exitCode: 0

java/BUILD

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@ package(default_visibility = ["//visibility:public"])
33
load("@io_bazel_rules_docker//docker:docker.bzl", "docker_build")
44
load("@package_bundle//file:packages.bzl", "packages")
55
load("//cacerts:java.bzl", "cacerts_java")
6+
load("//locale:locale.bzl", "locale")
67
load("@io_bazel_rules_docker//java:image.bzl", "java_image")
78

89
cacerts_java(
910
name = "cacerts_java",
1011
)
1112

13+
locale(
14+
name = "locale",
15+
deb = packages["libc-bin"],
16+
)
17+
1218
docker_build(
1319
name = "java-base",
1420
base = "//cc:debug",
1521
debs = [
1622
packages["zlib1g"],
23+
packages["libc-bin"],
1724
packages["net-tools"],
1825
packages["libprocps7"],
1926
packages["procps"],
@@ -40,8 +47,10 @@ docker_build(
4047
],
4148
stamp = True,
4249
entrypoint = ["/busybox/sh"],
43-
44-
tars = [":cacerts_java"],
50+
env = {
51+
"LANG": "C.UTF-8",
52+
},
53+
tars = [":cacerts_java",":locale",],
4554
)
4655

4756
docker_build(

locale/BUILD

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
sh_binary(
4+
name = "extract_locale",
5+
srcs = ["extract.sh"],
6+
)

locale/extract.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
DEB=$1
6+
OUT_TAR=$2
7+
8+
ar -x "$DEB" data.tar.xz
9+
10+
tar -xf data.tar.xz ./usr/lib/locale/C.UTF-8 ./usr/share/doc/libc-bin/copyright
11+
12+
rm data.tar.xz
13+
14+
# On Mac OS, you need to make sure that GNU Tar is used instead of the BSD tar that is shipped with MacOS.
15+
# To resolve this you can install gnu-tar via Homebrew and symlink it as /usr/local/bin/tar.
16+
tar -c --owner=0 --group=0 -f locale.tar ./usr
17+
18+
mv locale.tar "$OUT_TAR"
19+
20+
rm -rf usr

locale/locale.bzl

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""A rule to unpack c locale from the debian package."""
2+
3+
def _impl(ctx):
4+
ctx.actions.run(
5+
executable = ctx.executable._extract,
6+
arguments = [
7+
ctx.file.deb.path,
8+
ctx.outputs.tar.path,
9+
],
10+
inputs = [ctx.file.deb],
11+
outputs = [ctx.outputs.tar],
12+
)
13+
14+
locale = rule(
15+
attrs = {
16+
"deb": attr.label(
17+
allow_single_file = [".deb"],
18+
mandatory = True,
19+
),
20+
# Implicit dependencies.
21+
"_extract": attr.label(
22+
default = Label("//locale:extract_locale"),
23+
cfg = "host",
24+
executable = True,
25+
allow_files = True,
26+
),
27+
},
28+
executable = False,
29+
outputs = {
30+
"tar": "%{name}.tar",
31+
},
32+
implementation = _impl,
33+
)

0 commit comments

Comments
 (0)