update for focal, also to support source mirror

This commit is contained in:
Jeffrey Paul 2020-02-15 09:55:25 -08:00
parent 9cbf6878fd
commit 7083e9c0f1
2 changed files with 28 additions and 7 deletions

View File

@ -3,11 +3,27 @@ FROM phusion/baseimage:0.11
VOLUME /var/mirror VOLUME /var/mirror
ENV MIRROR_ARCHITECTURES amd64 ENV MIRROR_ARCHITECTURES amd64
ENV SOURCE_MIRROR ENV UBUNTU_SOURCE_MIRROR
ENV MIRROR_CATEGORIES main,universe,restricted,multiverse ENV MIRROR_CATEGORIES main,universe,restricted,multiverse
ENV UBUNTU_MIRROR_SOURCE archive.ubuntu.com ENV UBUNTU_MIRROR_SOURCE archive.ubuntu.com
ENV UBUNTU_MIRROR_PROJECTS bionic,bionic-updates,bionic-security,bionic-backports,focal,focal-updates,focal-security,focal-backports ENV UBUNTU_MIRROR_PROJECTS bionic,bionic-updates,bionic-security,bionic-backports,focal,focal-updates,focal-security,focal-backports
# The following is the URL populated in /mirrors.txt as used by mirror://
# protocol scheme in sources.list
# the idea is that you can DNS rewrite 'mirrors.ubuntu.com' to this mirror
# and it will return a "list" of mirrors that includes only itself.
# then you can safely use something like the following in your sources.list
# and it will work with max speed on your own dns-rewritten lan and in the
# unmodified datacenter talking to the real mirrors.ubuntu.com:
#
# MURM="main universe restricted multiverse"
# C="$(lsb_release -cs)"
# M="mirror://mirrors.ubuntu.com/mirrors.txt"
# echo "deb $M $C $MURM" > /etc/apt/sources.list.new
# echo "deb $M $C-updates $MURM" >> /etc/apt/sources.list.new
# echo "deb $M $C-backports $MURM" >> /etc/apt/sources.list.new
# echo "deb $M $C-security $MURM" >> /etc/apt/sources.list.new
# mv /etc/apt/sources.list.new /etc/apt/sources.list
ENV THIS_MIRROR_URL http://172.17.0.1/ubuntu/ ENV THIS_MIRROR_URL http://172.17.0.1/ubuntu/
ADD ./sources.list /etc/apt/sources.list ADD ./sources.list /etc/apt/sources.list

View File

@ -4,19 +4,24 @@ set -x
THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)" THISDIR="$(cd $(dirname "$BASH_SOURCE") && pwd -P)"
DST="/var/mirror" DST="/var/mirror"
echo "http://172.17.0.1/ubuntu/" > $DST/mirrors.txt echo "$THIS_MIRROR_URL" > $DST/mirrors.txt
chmod a+r $DST/mirrors.txt chmod a+r $DST/mirrors.txt
mkdir -p "$DST/ubuntu" mkdir -p "$DST/ubuntu"
export GNUPGHOME="/etc/debmirror/ubuntu" export GNUPGHOME="/etc/debmirror/ubuntu"
SOURCEOPT="--nosource"
if [[ ! -z "$UBUNTU_SOURCE_MIRROR" ]]; then
SOURCEOPT="--source"
fi
debmirror \ debmirror \
-a ${MIRROR_ARCHITECTURES:-amd64} \ -a ${MIRROR_ARCHITECTURES} \
--no-source \ $SOURCEOPT \
-s ${MIRROR_CATEGORIES:-main,universe,multiverse,restricted} \ -s ${MIRROR_CATEGORIES} \
-h ${UBUNTU_MIRROR_SOURCE:-archive.ubuntu.com} \ -h ${UBUNTU_MIRROR_SOURCE} \
-d ${UBUNTU_MIRROR_PROJECTS:-focal,focal-updates,focal-security,focal-backports} \ -d ${UBUNTU_MIRROR_PROJECTS} \
--ignore-small-errors \ --ignore-small-errors \
-r /ubuntu \ -r /ubuntu \
--getcontents \ --getcontents \