Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automate OL8 updates #488

Open
wants to merge 5 commits into
base: jbr21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions jb/project/docker/mkdocker_aarch64.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/bin/bash

set -euxo pipefail
set -euo pipefail

# This script creates a Docker image suitable for building AArch64 variant

docker build --platform=linux/aarch64 -t jetbrains/runtime:oraclelinux8_aarch64 -f Dockerfile.oraclelinux .
docker build \
--platform=linux/aarch64 \
-t registry.jetbrains.team/p/jbre/containers/oraclelinux8_aarch64:latest \
--no-cache \
-f Dockerfile.oraclelinux .

# NB: the resulting container can (and should) be used without the network
# connection (--network none) during build in order to reduce the chance
Expand Down
6 changes: 5 additions & 1 deletion jb/project/docker/mkdocker_musl_aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -euxo pipefail

# This script creates a Docker image suitable for building musl AArch64 variant

docker build --platform=linux/aarch64 -t jetbrains/runtime:alpine14_aarch64 -f Dockerfile.alpine .
docker build \
--platform=linux/aarch64 \
-t registry.jetbrains.team/p/jbre/containers/alpine14_aarch64:latest \
--no-cache \
-f Dockerfile.alpine .

# NB: the resulting container can (and should) be used without the network
# connection (--network none) during build in order to reduce the chance
Expand Down
6 changes: 5 additions & 1 deletion jb/project/docker/mkdocker_musl_x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -euxo pipefail

# This script creates a Docker image suitable for building musl x64 variant

docker build --platform=linux/amd64 -t jetbrains/runtime:alpine14_x64 -f Dockerfile.alpine .
docker build \
--platform=linux/amd64 \
-t registry.jetbrains.team/p/jbre/containers/alpine14_x64:latest \
--no-cache \
-f Dockerfile.alpine .

# NB: the resulting container can (and should) be used without the network
# connection (--network none) during build in order to reduce the chance
Expand Down
8 changes: 7 additions & 1 deletion jb/project/docker/mkdocker_x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ set -euxo pipefail

# This script creates a Docker image suitable for building x64 variant

docker build --platform=linux/amd64 -t jetbrains/runtime:oraclelinux8_x64 -f Dockerfile.oraclelinux .
docker build \
--platform=linux/amd64 \
-t registry.jetbrains.team/p/jbre/containers/oraclelinux8_x64:latest \
--no-cache \
-f Dockerfile.oraclelinux .



# NB: the resulting container can (and should) be used without the network
# connection (--network none) during build in order to reduce the chance
Expand Down
6 changes: 5 additions & 1 deletion jb/project/docker/mkdocker_x86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -euxo pipefail

# This script creates a Docker image suitable for building x86 variant

docker build --platform=linux/i386 -t jetbrains/runtime:ubuntu2004_x86 -f Dockerfile.ubuntu.x86 .
docker build \
--platform=linux/i386 \
-t registry.jetbrains.team/p/jbre/containers/ubuntu2004_x86:latest \
--no-cache \
-f Dockerfile.ubuntu.x86 .

# NB: the resulting container can (and should) be used without the network
# connection (--network none) during build in order to reduce the chance
Expand Down
60 changes: 60 additions & 0 deletions jb/project/docker/update_docker_oraclelinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

function fatal {
echo "FATAL ERROR: " $1
exit 1
}

DOCKERFILE=Dockerfile.oraclelinux
YUM_EXTRA=--enablerepo=ol8_codeready_builder
DATE=$(date +"%Y-%m-%d")

echo "Checking for updates on $DATE..."

yum install -q -y yum-utils
yum makecache $YUM_EXTRA
[ $? != 0 ] && fatal "yum makecache"

UPDATES=$(yum check-update -q -C 2>/dev/null | awk '/^\S/ {print $1}' | sed 's/\.[^.]*$//')

NUPDATES=0
for P in $UPDATES; do ((NUPDATES++)); done
[ $NUPDATES -eq 0 ] && echo "NO UPDATES on $DATE" && exit 0

echo "NEED TO UPDATE IMAGE"
echo "$NUPDATES packages updated: " $UPDATES

[ ! -f $DOCKERFILE ] && fatal "no $DOCKERFILE"

DNUPDATES=0
for P in $UPDATES; do
N=$(grep -c "$P-[0-9]" $DOCKERFILE)
[ $N -gt 1 ] && fatal "More than one match for $P in $DOCKERFILE, can't create a patch"
DP=$(grep "$P-[0-9]" $DOCKERFILE)
if [ -n "$DP" ]; then
((DNUPDATES++))
fi
done

[ $DNUPDATES -eq 0 ] && echo "No need to update $DOCKERFILE" && exit 0

F=${DOCKERFILE}.new
rm -f $F
cp $DOCKERFILE $F
[ $? != 0 ] && fatal "copying $DOCKERFILE"

for P in $UPDATES; do
DP=$(grep "$P-[0-9]" $DOCKERFILE | awk '{print $1}')
if [ -n "$DP" ]; then
LATEST=$(repoquery -q $YUM_EXTRA --latest-limit=1 --queryformat="%{name}-%{version}-%{release}" $P)
[ -z "$LATEST" ] && fatal "Can't determine the latest version of $P"
echo "$DP -> $LATEST"
sed -i "s/\b$DP\b/$LATEST/g" "$F"
fi
done

diff $DOCKERFILE $F > /dev/null 2>&1
[ $? -eq 0 ] && echo "No changes to $DOCKERFILE, just update the image" && exit 0

echo "Apply this patch to $DOCKERFILE:"
diff -C 3 $DOCKERFILE $F