Skip to content

Commit

Permalink
debian-elts: Use apt-sync instead of debmirror
Browse files Browse the repository at this point in the history
Signed-off-by: Harry Chen <i@harrychen.xyz>
  • Loading branch information
Harry-Chen committed Dec 3, 2023
1 parent 19f6f97 commit 3719b58
Showing 1 changed file with 45 additions and 27 deletions.
72 changes: 45 additions & 27 deletions debian-elts.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
#!/bin/bash
# requires: debmirror
set -e
set -o pipefail

_here=$(dirname $(realpath $0))
function join { local IFS=","; echo "$*"; }
apt_sync="${_here}/apt-sync.py"
function join_by { local IFS="$1"; shift; echo "$*"; }

# standard tunasync env
UPSTREAM=${TUNASYNC_UPSTREAM_URL:-"https://deb.freexian.com/extended-lts"}
BASE_PATH="${TUNASYNC_WORKING_DIR}"
APT_URL=${TUNASYNC_UPSTREAM_URL:-"https://deb.freexian.com/extended-lts"}

# parse APT_URL to different parts
proto="$(printf "$APT_URL" | grep :// | sed -e's,^\(.*://\).*,\1,g')"
url="$(printf ${APT_URL/$proto/})"
host="$(printf $url | cut -d/ -f1)"
path="/$(printf $url | grep / | cut -d/ -f2-)"

# override by env if needed
APT_HOST=${DEBMIRROR_HOST:-$host}
APT_PROTO=${DEBMIRROR_PROTO:-$proto}
APT_PATH=${DEBMIRROR_PATH:-$path}
APT_KEYRING_FILE=${DEBMIRROR_APT_KEYRING:-"https://deb.freexian.com/extended-lts/archive-key.gpg"}

# leave all possible values here
# debmirror will only download the intersection of provided options and the repo provides
ARCHES=(amd64 i386 armhf armel arm64)
DIST=(jessie stretch)

# download keyring
keyring_file="/tmp/freexian.$RANDOM.kbx"
wget "$APT_KEYRING_FILE" -O "$keyring_file"

debmirror -a $(join "${ARCHES[@]}") -d $(join "${DIST[@]}") -h "$APT_HOST" -r "$APT_PATH" --method ${APT_PROTO} -v --keyring "$keyring_file" --diff mirror --rsync-extra none --i18n --getcontents "${BASE_PATH}"
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM

# see https://www.freexian.com/lts/extended/ for possible values
codenames=(jessie stretch)
components=(main,contrib,non-free main,contrib,non-free)
architectures=(i386,amd64,armhf,armel i386,amd64,armhf)

"$apt_sync" --delete "${UPSTREAM}" "$(join_by , "${codenames[@]}")" "$(join_by : "${components[@]}")" "$(join_by : "${architectures[@]}")" "$BASE_PATH"

"${_here}/helpers/size-sum.sh" $REPO_SIZE_FILE --rm


# =================== old script using debmirror ===================
# requires: debmirror
# function join { local IFS=","; echo "$*"; }

# # standard tunasync env
# BASE_PATH="${TUNASYNC_WORKING_DIR}"
# APT_URL=${TUNASYNC_UPSTREAM_URL:-"https://deb.freexian.com/extended-lts"}

# # parse APT_URL to different parts
# proto="$(printf "$APT_URL" | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# url="$(printf ${APT_URL/$proto/})"
# host="$(printf $url | cut -d/ -f1)"
# path="/$(printf $url | grep / | cut -d/ -f2-)"

# # override by env if needed
# APT_HOST=${DEBMIRROR_HOST:-$host}
# APT_PROTO=${DEBMIRROR_PROTO:-$proto}
# APT_PATH=${DEBMIRROR_PATH:-$path}
# APT_KEYRING_FILE=${DEBMIRROR_APT_KEYRING:-"https://deb.freexian.com/extended-lts/archive-key.gpg"}

# # leave all possible values here
# # debmirror will only download the intersection of provided options and the repo provides
# ARCHES=(amd64 i386 armhf armel arm64)
# DIST=(jessie stretch)

# # download keyring
# keyring_file="/tmp/freexian.$RANDOM.kbx"
# wget "$APT_KEYRING_FILE" -O "$keyring_file"

# debmirror -a $(join "${ARCHES[@]}") -d $(join "${DIST[@]}") -h "$APT_HOST" -r "$APT_PATH" --method ${APT_PROTO} -v --keyring "$keyring_file" --diff mirror --rsync-extra none --i18n --getcontents "${BASE_PATH}"

0 comments on commit 3719b58

Please sign in to comment.