-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Shengqi Chen <[email protected]>
- Loading branch information
1 parent
818c033
commit f7df7b1
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
# requires: debmirror | ||
set -e | ||
set -o pipefail | ||
|
||
_here=$(dirname $(realpath $0)) | ||
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}" |