Support SONiC Reproduceable Build-debian/pip/web packages#5718
Support SONiC Reproduceable Build-debian/pip/web packages#5718xumia merged 18 commits intosonic-net:masterfrom
Conversation
|
This pull request introduces 4 alerts when merging 32fa8dc into 7d4ab42 - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging b1443cc into 7d4ab42 - view on LGTM.com new alerts:
|
files/build/scripts/apt-get
Outdated
| @@ -0,0 +1,35 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Could you add comments to explain the purpose and usage of this script?
My understanding is that they are hooks based on the vanilla executables. So:
- What is the new feature?
- Any new command line arguments?
- How to call vanilla ones? #Closed
There was a problem hiding this comment.
It should be the old draft script, it will print error message if version control enabled and the version is not set. #Closed
|
See #5786 #Resolved |
|
This pull request introduces 1 alert when merging c912a8f into 1ba583c - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging 5c150bb into 2fe79c2 - view on LGTM.com new alerts:
|
| POST_VERSION_PATH=$BUILDINFO_PATH/post-versions | ||
| VERSION_DEB_PREFERENCE=$BUILDINFO_PATH/versions/01-versions-deb | ||
|
|
||
| . $BUILDINFO_PATH/config/buildinfo.config |
There was a problem hiding this comment.
buildinfo.config [](start = 25, length = 16)
I cannot find this file in this PR, or in the design doc. #Closed
There was a problem hiding this comment.
It is created in scripts/generate_buildinfo_config.sh as the config settings for wget/curl/pip. #Resolved
files/build/scripts/apt-get
Outdated
| fi | ||
|
|
||
|
|
||
| /usr/bin/apt-get $@ |
There was a problem hiding this comment.
/usr/bin/apt-get [](start = 0, length = 16)
Could you not hard code this path for vanilla executables? #Closed
| fi | ||
|
|
||
| sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "dpkg -i /usr/local/share/buildinfo/sonic-build-hooks_1.0_all.deb" | ||
| sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "apt-mark hold sonic-build-hooks" |
There was a problem hiding this comment.
apt-mark hold sonic-build-hooks [](start = 50, length = 31)
I plan to fix the issue in #6159
So you don't need this line after my PR merged. #Closed
| sudo LANG=C chroot $FILESYSTEM_ROOT mount | ||
|
|
||
| ## Install the trusted gpg public keys | ||
| [ -d $TRUSTED_GPG_DIR ] && [ ! -z "$(ls $TRUSTED_GPG_DIR)" ] && sudo cp $TRUSTED_GPG_DIR/* ${FILESYSTEM_ROOT}/etc/apt/trusted.gpg.d/ |
There was a problem hiding this comment.
Is it better to install gpg file by curl | sudo apt-key add -.
There is an example in sonic-slave-buster/Dockerfile.j2 #Closed
There was a problem hiding this comment.
See another comment in scrpts/prepare_docker_buildinfo.sh
In reply to: 539809352 [](ancestors = 539809352)
build_debian.sh
Outdated
| sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -e boot -e var/lib/docker -e $PLATFORM_DIR | ||
|
|
||
| scripts/collect_host_image_version_files.sh $TARGET_PATH $FILESYSTEM_ROOT | ||
| sudo LANG=C chroot $FILESYSTEM_ROOT set_build_hooks -d |
There was a problem hiding this comment.
This line is already covered by above line. #Closed
There was a problem hiding this comment.
| fi | ||
| docker create --name $DOCKER_CONTAINER --entrypoint /bin/bash $DOCKER_IMAGE | ||
| docker cp -L $DOCKER_CONTAINER:/etc/os-release $TARGET_VERSIONS_PATH/ > /dev/null 2>&1 | ||
| docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/pre-versions $TARGET_VERSIONS_PATH/ > /dev/null 2>&1 |
There was a problem hiding this comment.
/dev/null 2>&1 [](start = 95, length = 16)
Why redirect stdout and stderr? They are useful #Closed
| fi | ||
| docker create --name $DOCKER_CONTAINER --entrypoint /bin/bash $DOCKER_IMAGE | ||
| docker cp -L $DOCKER_CONTAINER:/etc/os-release $TARGET_VERSIONS_PATH/ > /dev/null 2>&1 | ||
| docker cp -L $DOCKER_CONTAINER:/usr/local/share/buildinfo/pre-versions $TARGET_VERSIONS_PATH/ > /dev/null 2>&1 |
There was a problem hiding this comment.
pre [](start = 58, length = 3)
{pre,post}- #Closed
There was a problem hiding this comment.
scripts/prepare_docker_buildinfo.sh
Outdated
| DOCKERFILE_PRE_SCRIPT='# Auto-Generated for buildinfo | ||
| COPY ["buildinfo", "/usr/local/share/buildinfo"] | ||
| RUN dpkg -i /usr/local/share/buildinfo/sonic-build-hooks_1.0_all.deb | ||
| RUN cp -rf /usr/local/share/buildinfo/trusted.gpg.d/* /etc/apt/trusted.gpg.d/ |
There was a problem hiding this comment.
cp -rf /usr/local/share/buildinfo/trusted.gpg.d/* /etc/apt/trusted.gpg.d/ [](start = 4, length = 73)
Is it better to install gpg file by curl | sudo apt-key add -.
There is an example in sonic-slave-buster/Dockerfile.j2 #Closed
There was a problem hiding this comment.
It is not good enough to copy several time when build each docker image. But it should has less impact. I do not use it for several reasons as below:
- The curl is not a required package, as a web package it has lot of dependent packages. We want to control all packages including the curl itself.
- We may have several gpg files, any one can add more flexibly.
In reply to: 539815009 [](ancestors = 539815009)
There was a problem hiding this comment.
When you enable this feature in future, I think you need a place to download the gpg files sometime during the build process.
I agree we should not install many packages inside a docker image just for a one time curl.
How about download outside docker build, and COPY into the image?
In reply to: 540038466 [](ancestors = 540038466,539815009)
| [ -z "$DISTRO" ] && DISTRO=jessie | ||
| fi | ||
|
|
||
| DOCKERFILE_PRE_SCRIPT='# Auto-Generated for buildinfo |
There was a problem hiding this comment.
DOCKERFILE_PRE_SCRIPT [](start = 0, length = 21)
If gpg comment is right, then DOCKERFILE_PRE_SCRIPT has only 2 command lines. Suggest move them into docker-base, docker-slave's Dockerfile as plaintext. No need to manipulate Dockerfile here. #Closed
There was a problem hiding this comment.
| VERSION_DEB_PREFERENCE=$BUILD_VERSIONS_PATH/01-versions-deb | ||
|
|
||
| # Enable the build hooks | ||
| set_build_hooks |
There was a problem hiding this comment.
Better name: symlink_hooks #Closed
There was a problem hiding this comment.
scripts/prepare_docker_buildinfo.sh
Outdated
| DOCKERFILE_PRE_SCRIPT='# Auto-Generated for buildinfo | ||
| COPY ["buildinfo", "/usr/local/share/buildinfo"] | ||
| RUN dpkg -i /usr/local/share/buildinfo/sonic-build-hooks_1.0_all.deb | ||
| COPY ["buildinfo/trusted.gpg.d/*", "/etc/apt/trusted.gpg.d/"] |
There was a problem hiding this comment.
COPY [](start = 0, length = 4)
Move the download process into above deb package #Resolved
scripts/prepare_docker_buildinfo.sh
Outdated
| awk -v text="${DOCKERFILE_PRE_SCRIPT}" -v linenumber=$LINE_NUMBER 'NR==linenumber{print text}1' $DOCKERFILE > $TEMP_FILE | ||
|
|
||
| # Append the docker build script at the end of the docker file | ||
| echo "RUN post_run_buildinfo" >> $TEMP_FILE |
There was a problem hiding this comment.
echo [](start = 4, length = 4)
Corner case: $TEMP_FILE may be not end with \n #Closed
|
retest vsimage please |
4 similar comments
|
retest vsimage please |
|
retest vsimage please |
|
retest vsimage please |
|
retest vsimage please |
)" This reverts commit 55a7075.
…ages (sonic-net#5718)"" This reverts commit 17497a6.
- Why I did it
Support SONiC Reproduceable Build, see design doc: sonic-net/SONiC#684
Features:
Collect the version information to the folder target/versions when building any targets
Sample commands:
make configure PLATFORM=broadcom
make target/sonic-aboot-broadcom.swi
Support to freeze the versions after build by command: make freeze
Sample 1: Initialize the versions or rebuild the versions
make freeze OPTIONS="-r"
Sample 2: Freeze and merge the versions to current distribution and the architecture
make freeze
Sample 3: Merge the current target versions to all distributions and all architectures
make freeze OPTIONS="-d -a"
You can add the version change by: git add files/build/versions
In most cases, simply run "make freeze" to freeze the versions.
Control the version in build, change the configuration file rules/config
SONIC_VERSION_CONTROL_COMPONENTS=all
To upgrade the version configuration, just build any targets, then freeze your versions.
Sample commands:
make configure SONIC_VERSION_CONTROL_COMPONENTS=none PLATFORM=broadcom
make SONIC_VERSION_CONTROL_COMPONENTS=none target/sonic-aboot-broadcom.swi
make freeze OPTIONS="-d -a"
- How I did it
- How to verify it
Sample commands:
make configure PLATFORM=broadcom
make target/sonic-aboot-broadcom.swi
make freeze
You can see no version change in files/build/versions, git status files/build/versions.
The version files are in target/versions, you can find and verify all the version changes for all the build targets.
- Which release branch to backport (provide reason below if selected)
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)