Skip to content

Commit

Permalink
[Build] Remove the additional space character in the mirrors.list file (
Browse files Browse the repository at this point in the history
#13812)

Why I did it
Fix all mirror is commented out in sources.list in slave image issue. It will have an issue when installing more packages in the slave container.

It will add additional space character after running add-apt-repository command.

For example:
The original config in /etc/apt/sources.list

#deb [arch=amd64] http://deb.debian.org/debian/ bullseye main contrib non-free
Run the following command:

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian bullseye stable"
Then the setting changed to: (added a new space character after #)

# deb [arch=amd64] http://deb.debian.org/debian/ bullseye main contrib non-free
How I did it
Fix the regex string to add the space pattern. After fixed, whether there is a space character or not, it will not be an issue.

How to verify it
  • Loading branch information
xumia committed Feb 15, 2023
1 parent 8a4d1b5 commit a3225e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sonic-build-hooks/scripts/buildinfo_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ get_version_cache_option()
set_reproducible_mirrors()
{
# Remove the charater # in front of the line if matched
local expression="s/^#\(.*$REPR_MIRROR_URL_PATTERN\)/\1/"
local expression="s/^#\s*\(.*$REPR_MIRROR_URL_PATTERN\)/\1/"
# Add the character # in front of the line, if not match the URL pattern condition
local expression2="/^#*deb.*$REPR_MIRROR_URL_PATTERN/! s/^#*deb/#&/"
local expression3="\$a#SET_REPR_MIRRORS"
if [ "$1" = "-d" ]; then
# Add the charater # in front of the line if match
expression="s/^deb.*$REPR_MIRROR_URL_PATTERN/#\0/"
# Remove the character # in front of the line, if not match the URL pattern condition
expression2="/^#*deb.*$REPR_MIRROR_URL_PATTERN/! s/^#(#*deb)/\1/"
expression2="/^#*deb.*$REPR_MIRROR_URL_PATTERN/! s/^#\s*(#*deb)/\1/"
expression3="/#SET_REPR_MIRRORS/d"
fi

Expand Down

0 comments on commit a3225e6

Please sign in to comment.