pypi: support download-mirror

from bandersnatch 5.1.0
see https://github.com/pypa/bandersnatch/releases/tag/5.1.0 for more info
This commit is contained in:
Zenithal 2022-05-03 03:12:50 +08:00
parent a5bf8066aa
commit 80e1221e67
No known key found for this signature in database
GPG Key ID: 1189C659F3D04C1C

15
pypi.sh
View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
set -e set -e
BANDERSNATCH=${BANDERSNATCH:-"/usr/local/bin/bandersnatch"} BANDERSNATCH=${BANDERSNATCH:-"/usr/local/bin/bandersnatch"}
TUNASYNC_UPSTREAM=${TUNASYNC_UPSTREAM_URL:-"https://pypi.org/"} PYPI_MASTER="https://pypi.org/"
TUNASYNC_UPSTREAM=${TUNASYNC_UPSTREAM_URL:-$PYPI_MASTER}
CONF="/tmp/bandersnatch.conf" CONF="/tmp/bandersnatch.conf"
INIT=${INIT:-"0"} INIT=${INIT:-"0"}
@ -12,12 +13,19 @@ fi
echo "Syncing to $TUNASYNC_WORKING_DIR" echo "Syncing to $TUNASYNC_WORKING_DIR"
DOWNLOAD_MIRROR=""
if [[ $TUNASYNC_UPSTREAM != $PYPI_MASTER ]]; then
# see https://github.com/pypa/bandersnatch/pull/928 for more info
DOWNLOAD_MIRROR="download-mirror = ${TUNASYNC_UPSTREAM}"
fi
if [[ $INIT == "0" ]]; then if [[ $INIT == "0" ]]; then
( (
cat << EOF cat << EOF
[mirror] [mirror]
directory = ${TUNASYNC_WORKING_DIR} directory = ${TUNASYNC_WORKING_DIR}
master = ${TUNASYNC_UPSTREAM} master = ${PYPI_MASTER}
${DOWNLOAD_MIRROR}
json = true json = true
timeout = 300 timeout = 300
workers = 5 workers = 5
@ -47,7 +55,8 @@ else
cat > $CONF << EOF cat > $CONF << EOF
[mirror] [mirror]
directory = ${TUNASYNC_WORKING_DIR} directory = ${TUNASYNC_WORKING_DIR}
master = ${TUNASYNC_UPSTREAM} master = ${PYPI_MASTER}
${DOWNLOAD_MIRROR}
json = true json = true
timeout = 15 timeout = 15
workers = 10 workers = 10