Skip to content

Commit

Permalink
consistent updaters
Browse files Browse the repository at this point in the history
Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed May 22, 2024
1 parent f155111 commit 4e79ba5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ENV SSL_VER="1.1.1w" \
PQ_VER="11.12" \
SQLITE_VER="3450100" \
PROTOBUF_VER="25.2" \
SCCACHE_VERSION="0.8.0" \
SCCACHE_VER="0.8.0" \
CC=musl-gcc \
PREFIX=/musl \
PATH=/usr/local/bin:/root/.cargo/bin:$PATH \
Expand All @@ -74,10 +74,10 @@ RUN cd /tmp && \
rm -rf *

# Install prebuilt sccache based on platform
RUN curl -sSL https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-aarch64-unknown-linux-musl.tar.gz | tar xz && \
mv sccache-v${SCCACHE_VERSION}-*-unknown-linux-musl/sccache /usr/local/bin/ && \
RUN curl -sSL https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VER}/sccache-v${SCCACHE_VER}-aarch64-unknown-linux-musl.tar.gz | tar xz && \
mv sccache-v${SCCACHE_VER}-*-unknown-linux-musl/sccache /usr/local/bin/ && \
chmod +x /usr/local/bin/sccache && \
rm -rf sccache-v${SCCACHE_VERSION}-*-unknown-linux-musl
rm -rf sccache-v${SCCACHE_VER}-*-unknown-linux-musl

# Set up a prefix for musl build libraries, make the linker's job of finding them easier
# Primarily for the benefit of postgres.
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ENV SSL_VER="1.1.1w" \
PQ_VER="11.12" \
SQLITE_VER="3450100" \
PROTOBUF_VER="25.2" \
SCCACHE_VERSION="0.8.0" \
SCCACHE_VER="0.8.0" \
CC=musl-gcc \
PREFIX=/musl \
PATH=/usr/local/bin:/root/.cargo/bin:$PATH \
Expand All @@ -73,10 +73,10 @@ RUN cd /tmp && \
rm -rf *

# Install prebuilt sccache based on platform
RUN curl -sSL https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz | tar xz && \
mv sccache-v${SCCACHE_VERSION}-*-unknown-linux-musl/sccache /usr/local/bin/ && \
RUN curl -sSL https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VER}/sccache-v${SCCACHE_VER}-x86_64-unknown-linux-musl.tar.gz | tar xz && \
mv sccache-v${SCCACHE_VER}-*-unknown-linux-musl/sccache /usr/local/bin/ && \
chmod +x /usr/local/bin/sccache && \
rm -rf sccache-v${SCCACHE_VERSION}-*-unknown-linux-musl
rm -rf sccache-v${SCCACHE_VER}-*-unknown-linux-musl

# Set up a prefix for musl build libraries, make the linker's job of finding them easier
# Primarily for the benefit of postgres.
Expand Down
36 changes: 19 additions & 17 deletions update_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def rustup_version():
#'PQ': pkgver('postgresql-old-upgrade'), # see https://github.com/clux/muslrust/issues/81
'SQLITE': convert_sqlite_version(pkgver('sqlite')),
'SSL': convert_openssl_version(pkgver('openssl-1.1')),
'SCCACHE': pkgver('sccache'),
'PROTOBUF': pkgver('protobuf'),
'ZLIB': pkgver('zlib'),
'RUSTUP': rustup_version()
Expand All @@ -95,20 +96,21 @@ def rustup_version():
for prefix in PACKAGES:
print('{}_VER="{}"'.format(prefix, PACKAGES[prefix]))

# Update Dockerfile
fname = 'Dockerfile'
# Open a different file for the destination to update Dockerfile atomically
src = open(fname, 'r')
dst = open(f'{fname}.new', 'w')

# Iterate over each line in Dockerfile, replacing any *_VER variables with the most recent version
for line in src:
for prefix in PACKAGES:
version = PACKAGES[prefix]
line = re.sub(r'({}_VER=)\S+'.format(prefix), r'\1"{}"'.format(version), line)
dst.write(line)

# Close original and new Dockerfile then overwrite the old with the new
src.close()
dst.close()
os.rename(f'{fname}.new', fname)
# Update Dockerfiles
for arch in ["x86_64", "arm64"]:
fname = f'./Dockerfile.{arch}'
# Open a different file for the destination to update Dockerfile atomically
src = open(fname, 'r')
dst = open(f'{fname}.new', 'w')

# Iterate over each line in Dockerfile, replacing any *_VER variables with the most recent version
for line in src:
for prefix in PACKAGES:
version = PACKAGES[prefix]
line = re.sub(r'({}_VER=)\S+'.format(prefix), r'\1"{}"'.format(version), line)
dst.write(line)

# Close original and new Dockerfile then overwrite the old with the new
src.close()
dst.close()
os.rename(f'{fname}.new', fname)

0 comments on commit 4e79ba5

Please sign in to comment.