Skip to content

Commit

Permalink
[Build]: Cleanup the reproducible mirrors when build complete (sonic-…
Browse files Browse the repository at this point in the history
…net#9132)

Why I did it
The reproducible build mirrors are only used during the build, the mirrors can be removed after that.
  • Loading branch information
xumia authored and qiluo-msft committed Dec 6, 2021
1 parent 0831635 commit a3f1769
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/sonic-build-hooks/scripts/buildinfo_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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=("$@")
Expand Down
1 change: 1 addition & 0 deletions src/sonic-build-hooks/scripts/post_run_buildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ rm -rf $BUILD_VERSION_PATH/*

# Disable the build hooks
symlink_build_hooks -d
set_reproducible_mirrors -d
1 change: 1 addition & 0 deletions src/sonic-build-hooks/scripts/pre_run_buildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a3f1769

Please sign in to comment.