Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xumia committed Nov 18, 2020
1 parent c912a8f commit 5c150bb
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 34 deletions.
3 changes: 0 additions & 3 deletions dockers/docker-base-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ FROM multiarch/debian-debootstrap:arm64-buster
FROM debian:buster
{% endif %}

RUN echo "deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free" >> /etc/apt/sources.list && \
echo "deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free" >> /etc/apt/sources.list

# Clean documentation in FROM image
RUN find /usr/share/doc -depth \( -type f -o -type l \) ! -name copyright | xargs rm || true

Expand Down
2 changes: 2 additions & 0 deletions dockers/docker-base-buster/sources.list
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster mai
deb [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free
deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free
deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster-backports main contrib non-free
deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free
deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free
2 changes: 2 additions & 0 deletions dockers/docker-base-buster/sources.list.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ deb-src [arch=arm64] http://deb.debian.org/debian buster main contrib non-free
deb [arch=arm64] http://security.debian.org buster/updates main contrib non-free
deb-src [arch=arm64] http://security.debian.org buster/updates main contrib non-free
deb [arch=arm64] http://deb.debian.org/debian/ buster-backports main contrib non-free
deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free
deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free
2 changes: 2 additions & 0 deletions dockers/docker-base-buster/sources.list.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ deb-src [arch=armhf] http://deb.debian.org/debian buster main contrib non-free
deb [arch=armhf] http://security.debian.org buster/updates main contrib non-free
deb-src [arch=armhf] http://security.debian.org buster/updates main contrib non-free
deb [arch=armhf] http://deb.debian.org/debian/ buster-backports main contrib non-free
deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster main contrib non-free
deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free
16 changes: 5 additions & 11 deletions files/build/scripts/apt-get
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
INSTALL=
. /usr/local/share/buildinfo/scripts/buildinfo_base.sh

VERSION_FILE="/usr/local/share/buildinfo/base-versions/versions-deb"
VERSION_FILE="/usr/local/share/buildinfo/versions/versions-deb"
if [ "$ENABLE_VERSION_CONTROL_DEB" == "y" ]; then
for para in $@
do
Expand All @@ -13,17 +13,11 @@ if [ "$ENABLE_VERSION_CONTROL_DEB" == "y" ]; then
if [ ! -z "$INSTALL" ]; then
if [[ "$para" == *=* ]]; then
continue
package=$(echo "$para" | cut -d= -f1)
version=$(echo "$para" | cut -d= -f2)
if grep "^${package}=" $VERSION_FILE; then
if ! grep "^${package}==${version}$" $VERSION_FILE; then
EXPECTED_VERSION=$(grep "^${package}=" $VERSION_FILE | cut -d= -f3)
echo "${package}=${version}, expected version is ${EXPECTED_VERSION}"
exit 1
fi
fi
elif [[ "$para" == *=* ]]; then
continue
else
if ! grep "^${package}=" $VERSION_FILE; then
package=$para
if ! grep -q "^${package}=" $VERSION_FILE; then
echo "The version of the package ${package} is not specified."
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions files/build/scripts/buildinfo_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ check_version_control()
ENABLE_VERSION_CONTROL_DEB=$(check_version_control "deb")
ENABLE_VERSION_CONTROL_PY2=$(check_version_control "py2")
ENABLE_VERSION_CONTROL_PY3=$(check_version_control "py3")
ENABLE_VERSION_CONTROL_WEB=$(check_version_control "web")
ENABLE_VERSION_CONTROL_WEB=$(check_version_control "url")
ENABLE_VERSION_CONTROL_GIT=$(check_version_control "git")
ENABLE_VERSION_CONTROL_DCK=$(check_version_control "dck")
ENABLE_VERSION_CONTROL_DCK=$(check_version_control "docker")
7 changes: 3 additions & 4 deletions files/build/scripts/wget
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
COMPONENT=web
VERSION_FILE=$VERSION_PATH/versions-web
BUILD_VERSION_FILE=$BUILD_VERSION_PATH/versions-web
ENABLE_VERSION_CONTROL=$(check_version_control "$COMPONENT")

[ -z $REAL_COMMAND ] && REAL_COMMAND=/usr/bin/wget
PARAS=("$@")
Expand Down Expand Up @@ -73,10 +72,10 @@ process()
fi

real_version=$(get_version "$package_url")
if [ "$ENABLE_VERSION_CONTROL" == "y" ] && [ "$version" != "$real_version" ]; then
if [ "$ENABLE_VERSION_CONTROL_WEB" == "y" ] && [ "$version" != "$real_version" ]; then
return 1
fi
elif [ "$ENABLE_VERSION_CONTROL" == "y" ]; then
elif [ "$ENABLE_VERSION_CONTROL_WEB" == "y" ]; then
return 1
fi

Expand All @@ -85,7 +84,7 @@ process()
echo "$package_url==$real_version" >> ${BUILD_VERSION_FILE}

# If the version is mismatched, exit the wget/curl
if [ "$ENABLE_VERSION_CONTROL" == "y" ] && [ "$version" != "$real_version" ]; then
if [ "$ENABLE_VERSION_CONTROL_WEB" == "y" ] && [ "$version" != "$real_version" ]; then
return 1
fi

Expand Down
6 changes: 3 additions & 3 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ PACKAGE_URL_PREFIX ?= https://packages.trafficmanager.net/public/packages
# TRUSTED_GPG_URLS - the trusted gpgs, separated by comma
TRUSTED_GPG_URLS = https://packages.trafficmanager.net/debian/public_key.gpg,https://packages.microsoft.com/keys/microsoft.asc

# SONIC_VERSION_CONTROL_COMPONENTS - Valid values: none|all|components..., the components consist of one or multiple: deb,py2,py3,web,git,dck, seperated by comma
# SONIC_VERSION_CONTROL_COMPONENTS - Valid values: none|all|components..., the components consist of one or multiple: deb,py2,py3,url,git,docker, seperated by comma
# none : disable the version control
# all : enable the version control for all components
# deb : debian packages
# py2 : python2 packages
# py3 : python3 pakcages
# web : web packages, downloaded by wget, curl
# url : web packages, downloaded by wget, curl
# git : git repositories, donloaded by git clone
# dck : docker base images
# docker: docker base images
SONIC_VERSION_CONTROL_COMPONENTS ?= none
7 changes: 2 additions & 5 deletions scripts/prepare_docker_buildinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ARCH=$3
DOCKERFILE_TARGE=$4
DISTRO=$5

[ -z "$BUILD_SLAVE" ] && BUILD_SLAVE=n
[ -z "$DOCKERFILE_TARGE" ] && DOCKERFILE_TARGE=$DOCKERFILE
DOCKERFILE_PATH=$(dirname "$DOCKERFILE_TARGE")
BUILDINFO_PATH="${DOCKERFILE_PATH}/buildinfo"
Expand All @@ -27,11 +28,6 @@ ENV OLDPATH=$PATH
ENV PATH="/usr/local/share/buildinfo/scripts:$PATH"
RUN pre_run_buildinfo'

DOCKERFILE_POST_SCRIPT="RUN post_run_buildinfo"
[ "$BUILD_SLAVE" != "y" ] && DOCKERFILE_POST_SCRIPT="$DOCKERFILE_POST_SCRIPT
ENV PATH=\$OLDPATH"


# Add the auto-generate code if it is not added in the target Dockerfile
if [ ! -f $DOCKERFILE_TARGE ] || ! grep -q "Auto-Generated for buildinfo" $DOCKERFILE_TARGE; then
# Insert the docker build script before the RUN command
Expand All @@ -41,6 +37,7 @@ if [ ! -f $DOCKERFILE_TARGE ] || ! grep -q "Auto-Generated for buildinfo" $DOCKE

# Append the docker build script at the end of the docker file
echo "RUN post_run_buildinfo" >> $TEMP_FILE
[ -z "$BUILD_SLAVE" ] && BUILD_SLAVE=n
[ "$BUILD_SLAVE" != "y" ] && echo "ENV PATH=\$OLDPATH" >> $TEMP_FILE

cat $TEMP_FILE > $DOCKERFILE_TARGE
Expand Down
15 changes: 9 additions & 6 deletions scripts/versions_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def dump_to_path(self, file_path, config=False, priority=999):
os.makedirs(file_path)
filename = self.get_filename()
if config and self.ctype == 'deb':
none_config_file_path = os.path.join(file_path, filename)
self.dump_to_file(none_config_file_path, False, priority)
filename = VERSION_DEB_PREFERENCE
file_path = os.path.join(file_path, filename)
self.dump_to_file(file_path, config, priority)
Expand Down Expand Up @@ -135,9 +137,10 @@ def get_order_keys(self):
arch = ''
return (self.ctype, dist, arch)

def clean_info(self, clean_dist=True, clean_arch=True):
if clean_dist and self.ctype != 'deb':
self.dist = ALL_DIST
def clean_info(self, clean_dist=True, clean_arch=True, force=False):
if clean_dist:
if force or self.ctype != 'deb':
self.dist = ALL_DIST
if clean_arch:
self.arch = ALL_ARCH

Expand Down Expand Up @@ -296,9 +299,9 @@ def filter(self, ctypes=[]):
components.append(component)
self.components = components

def clean_info(self, clean_dist=True, clean_arch=True):
def clean_info(self, clean_dist=True, clean_arch=True, force=False):
for component in self.components:
component.clean_info(clean_dist=clean_dist, clean_arch=clean_arch)
component.clean_info(clean_dist=clean_dist, clean_arch=clean_arch, force=force)

def clone(self, ctypes=None, exclude_ctypes=None):
components = []
Expand Down Expand Up @@ -633,7 +636,7 @@ def generate(self):
default_module = VersionModule()
default_module.load(default_module_path, filter_dist=args.distribution, filter_arch=args.architecture)
config = module.get_config_module(default_module, args.distribution, args.architecture)
config.clean_info()
config.clean_info(force=True)
config.dump(args.target_path, config=True, priority=args.priority)

if __name__ == "__main__":
Expand Down

0 comments on commit 5c150bb

Please sign in to comment.