[Build]: Cleanup the reproducible mirrors when build complete (#9132)

Why I did it
The reproducible build mirrors are only used during the build, the mirrors can be removed after that.
This commit is contained in:
xumia 2021-12-02 09:04:40 +08:00
parent 0cecab27fa
commit 2177a68b36
3 changed files with 19 additions and 0 deletions

View File

@ -11,6 +11,7 @@ POST_VERSION_PATH=$BUILDINFO_PATH/post-versions
VERSION_DEB_PREFERENCE=$BUILDINFO_PATH/versions/01-versions-deb
WEB_VERSION_FILE=$VERSION_PATH/versions-web
BUILD_WEB_VERSION_FILE=$BUILD_VERSION_PATH/versions-web
REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/debian'
. $BUILDINFO_PATH/config/buildinfo.config
@ -59,6 +60,22 @@ check_if_url_exist()
fi
}
# Enable or disable the reproducible mirrors
set_reproducible_mirrors()
{
# Remove the charater # in front of the line if matched
local expression="s/^#\(.*$REPR_MIRROR_URL_PATTERN\)/\1/"
if [ "$1" = "-d" ]; then
# Add the charater # in front of the line if match
expression="s/^deb.*$REPR_MIRROR_URL_PATTERN/#\0/"
fi
local mirrors="/etc/apt/sources.list $(ls /etc/apt/sources.list.d/)"
for mirror in $mirrors; do
sed -i "$expression" "$mirror"
done
}
download_packages()
{
local parameters=("$@")

View File

@ -12,3 +12,4 @@ rm -rf $BUILD_VERSION_PATH/*
# Disable the build hooks
symlink_build_hooks -d
set_reproducible_mirrors -d

View File

@ -10,6 +10,7 @@ mkdir -p $LOG_PATH
[ -d $PRE_VERSION_PATH ] && rm -rf $PRE_VERSION_PATH
collect_version_files $PRE_VERSION_PATH
symlink_build_hooks
set_reproducible_mirrors
chmod -R a+rw $BUILDINFO_PATH