Skip to content

Instantly share code, notes, and snippets.

@stbuehler
Last active January 27, 2020 08:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stbuehler/e3e28732a6244acb47f8bd45e7e3db24 to your computer and use it in GitHub Desktop.
Save stbuehler/e3e28732a6244acb47f8bd45e7e3db24 to your computer and use it in GitHub Desktop.
corretto-jdk repo builder

Build debian repo for corretto jdk

Provides a debian repo for corretto jdk (8, but can be modified for 11).

Also provides an "archive" of all older versions.

Needs

  • reprepro
  • wget
  • bash, egrep, ...

Configuration / Directory layout

  • update.sh (location doesn't matter, but $BASEDIR will do):
    • $BASEDIR: directory containing config and meta data for repo
    • $OUTDIR: contains public http repo data
    • add to crontab
  • $BASEDIR/conf/options
    • replace $keyshortfp with your private keys short fingerprint
    • basedir and outdir from $BASEDIR and $OUTDIR
  • $BASEDIR/conf/distributions
Origin: Corretto-JDK-8
Label: Corretto JDK 8
Codename: corretto-jdk-8
Architectures: amd64
Components: main
Description: "Corretto JDK 8"
SignWith: 0x$keyshortfp
verbose
basedir /home/deb/reprepro/coretto-jdk-8
outdir /srv/archive/coretto-jdk-8
#!/bin/bash
set -e
VERSION=8 # or 11
BASEDIR="/home/deb/reprepro/corretto-jdk-${VERSION}"
OUTDIR="/srv/archive/corretto-jdk-${VERSION}"
DIST=corretto-jdk-${VERSION}
PERM_URL=https://corretto.aws/downloads/latest/amazon-corretto-${VERSION}-x64-linux-jdk.deb
cd "${BASEDIR}"
tmpdir=$(mktemp --tmpdir -d update-corretto-XXXXXXX)
trap 'rm -rf "${tmpdir}"' EXIT
lookup_redirect() {
local url=$1
curl -w "%{url_effective}\n" -I -L -s -S -o /dev/null "${url}"
}
url=$(lookup_redirect "${PERM_URL}")
if [ -z "${url}" ]; then
echo >&2 "Couldn't find link to debian package from ${PERM_URL}"
exit 1
fi
# filename
filename=$(basename "${url}")
if [ -d "${OUTDIR}/pool" ]; then
# only run find if the directory actually exists
if [ -n "$(find "${OUTDIR}/pool" -name "${filename}")" ]; then
# file already in pool
exit 0
fi
fi
wget -q -O "${tmpdir}/${filename}" "${url}"
# keep a copy in archive/
mkdir -p "${OUTDIR}/archive"
cp -a "${tmpdir}/${filename}" "${OUTDIR}/archive/"
# add to repo
reprepro -sss -b "${BASEDIR}" -C "main" includedeb "${DIST}" "${tmpdir}/${filename}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment