Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kellyyeh/sonic-buildimage
Browse files Browse the repository at this point in the history
…into HEAD
  • Loading branch information
kellyyeh committed Mar 13, 2023
2 parents 9040653 + 5f4d063 commit 1be6c2e
Show file tree
Hide file tree
Showing 440 changed files with 31,957 additions and 5,836 deletions.
35 changes: 35 additions & 0 deletions .azure-pipelines/azure-pipelines-UpgrateVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,32 @@ parameters:
- mellanox

stages:
- stage: Prepare
jobs:
- job: Prepare
steps:
- script: |
DEFAULT_MIRROR_URL_PREFIX=http://packages.trafficmanager.net
DEBIAN_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian/latest/timestamp)
DEBIAN_SECURITY_TIMESTAMP=$(curl $DEFAULT_MIRROR_URL_PREFIX/snapshot/debian-security/latest/timestamp)
echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP"
echo "##vso[task.setvariable variable=DEBIAN_TIMESTAMP;isOutput=true]$DEBIAN_TIMESTAMP"
echo "##vso[task.setvariable variable=DEBIAN_SECURITY_TIMESTAMP;isOutput=true]$DEBIAN_SECURITY_TIMESTAMP"
name: SetVersions
displayName: 'Set snapshot versions'
- stage: Build
dependsOn: Prepare
variables:
- name: CACHE_MODE
value: none
- name: VERSION_CONTROL_OPTIONS
value: 'SONIC_VERSION_CONTROL_COMPONENTS='
- name: SKIP_CHECKOUT
value: true
- name: DEBIAN_TIMESTAMP
value: $[ stageDependencies.Prepare.Prepare.outputs['SetVersions.DEBIAN_TIMESTAMP'] ]
- name: DEBIAN_SECURITY_TIMESTAMP
value: $[ stageDependencies.Prepare.Prepare.outputs['SetVersions.DEBIAN_SECURITY_TIMESTAMP'] ]
- template: .azure-pipelines/template-variables.yml@buildimage
jobs:
- template: azure-pipelines-build.yml
Expand All @@ -56,6 +76,21 @@ stages:
buildOptions: '${{ variables.VERSION_CONTROL_OPTIONS }} ENABLE_DOCKER_BASE_PULL=n SONIC_BUILD_JOBS=$(nproc) ENABLE_IMAGE_SIGNATURE=y'
preSteps:
- template: .azure-pipelines/template-clean-sonic-slave.yml@buildimage
- checkout: self
submodules: recursive
fetchDepth: 0
path: s
displayName: 'Checkout code'
- script: |
echo "DEBIAN_TIMESTAMP=$DEBIAN_TIMESTAMP, DEBIAN_SECURITY_TIMESTAMP=$DEBIAN_SECURITY_TIMESTAMP"
if [ "$MIRROR_SNAPSHOT" == y ]; then
mkdir -p target/versions/default/
echo "debian==$DEBIAN_TIMESTAMP" > target/versions/default/versions-mirror
echo "debian-security==$DEBIAN_SECURITY_TIMESTAMP" >> target/versions/default/versions-mirror
cat target/versions/default/versions-mirror
fi
displayName: 'Set snapshot versions'
- stage: UpgradeVersions
jobs:
- job: UpgradeVersions
Expand Down
5 changes: 3 additions & 2 deletions .azure-pipelines/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ jobs:
platform_rpc: nephos

buildSteps:
- template: template-skipvstest.yml
- template: .azure-pipelines/template-skipvstest.yml@buildimage
- template: .azure-pipelines/template-daemon.yml@buildimage
- bash: |
set -ex
if [ $(GROUP_NAME) == vs ]; then
Expand Down Expand Up @@ -168,4 +169,4 @@ jobs:
make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).bin
fi
displayName: "Build sonic image"
- template: check-dirty-version.yml
- template: .azure-pipelines/check-dirty-version.yml@buildimage
4 changes: 2 additions & 2 deletions .azure-pipelines/azure-pipelines-image-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
jobFilters: ${{ parameters.jobFilters }}
jobVariables: ${{ parameters.jobVariables }}
preSteps:
- template: cleanup.yml
- template: .azure-pipelines/cleanup.yml@buildimage
- ${{ parameters.preSteps }}
- script: |
if [ -n "$(CACHE_MODE)" ] && echo $(PLATFORM_AZP) | grep -E -q "^(vs|broadcom|mellanox|marvell-armhf)$"; then
Expand Down Expand Up @@ -67,6 +67,6 @@ jobs:
artifactName: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'
publishPrefix: '$(Build.DefinitionName)/$(Build.SourceBranchName)/$(GROUP_NAME)'
- ${{ parameters.postSteps }}
- template: cleanup.yml
- template: .azure-pipelines/cleanup.yml@buildimage
jobGroups: ${{ parameters.jobGroups }}
buildSteps: ${{ parameters.buildSteps }}
4 changes: 1 addition & 3 deletions .azure-pipelines/azure-pipelines-repd-build-variables.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
variables:
${{ if eq(variables['Build.Reason'],'PullRequest') }}:
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=$([[ "$(System.PullRequest.TargetBranch)" =~ ^20[2-9][0-9]{3}$ ]] && echo deb,py2,py3,web,git,docker)'
${{ elseif ne(variables['Build.SourceBranchName'],'master') }}:
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
${{ else }}:
VERSION_CONTROL_OPTIONS: ''
VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
7 changes: 7 additions & 0 deletions .azure-pipelines/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
steps:
- script: |
set -x
# kill daemon process
ps $(cat /tmp/azp_daemon_kill_docker_pid)
sudo kill $(cat /tmp/azp_daemon_kill_docker_pid)
rm /tmp/azp_daemon_kill_docker_pid
if sudo [ -f /var/run/march/docker.pid ] ; then
pid=`sudo cat /var/run/march/docker.pid` ; sudo kill $pid
fi
Expand All @@ -11,4 +17,5 @@ steps:
pid=`sudo cat dockerfs/var/run/docker.pid` ; sudo kill $pid
fi
sudo rm -rf $(ls -A1)
condition: always()
displayName: "Clean Workspace"
11 changes: 10 additions & 1 deletion .azure-pipelines/official-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ schedules:
- master
- 202012

resources:
repositories:
- repository: buildimage
type: github
name: sonic-net/sonic-buildimage
ref: master
endpoint: sonic-net

trigger: none
pr: none

Expand All @@ -20,7 +28,8 @@ stages:
variables:
- name: CACHE_MODE
value: cache
- template: azure-pipelines-repd-build-variables.yml
- template: .azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage
- template: .azure-pipelines/template-variables.yml@buildimage
jobs:
- template: azure-pipelines-build.yml
parameters:
Expand Down
24 changes: 24 additions & 0 deletions .azure-pipelines/template-daemon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
steps:
- bash: |
(
while true
do
sleep 120
now=$(date +%s)
pids=$(ps -C docker -o pid,etime,args | grep "docker build" | cut -d" " -f2)
for pid in $pids
do
start=$(date --date="$(ls -dl /proc/$pid --time-style full-iso | awk '{print$6,$7}')" +%s)
time_s=$(($now-$start))
if [[ $time_s -gt $(DOCKER_BUILD_TIMEOUT) ]]; then
echo =========== $(date +%F%T) $time_s &>> target/daemon.log
ps $pid &>> target/daemon.log
sudo kill $pid
fi
done
done
) &
daemon_pid=$!
ps $daemon_pid
echo $daemon_pid >> /tmp/azp_daemon_kill_docker_pid
displayName: start daemon to kill hang docker
2 changes: 2 additions & 0 deletions .azure-pipelines/template-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ variables:
SONIC_BUILD_RETRY_COUNT: 3
SONIC_BUILD_RETRY_INTERVAL: 600
DOCKER_BUILDKIT: 0
DOCKER_BUILD_TIMEOUT: 3600
MIRROR_SNAPSHOT: y
8 changes: 8 additions & 0 deletions .github/workflows/automerge_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
echo PR: $(($i+1))/$count, URL: $url, createdAt: $created_at, now: $(date -u +"%FT%TZ")
[[ "$url" == "" ]] && continue
[[ $created_at > $(date --date "1 hour ago" -u +"%FT%TZ") ]] && continue
# only check automerge PR.
cat prs.log | jq -r ".[$i].labels[].name" | grep automerge || continue
checks=$(cat prs.log | jq ".[$i].statusCheckRollup")
checks_count=$(echo $checks | jq 'length')
echo Checks count: $checks_count
Expand All @@ -38,9 +41,14 @@ jobs:
check=$(echo $checks | jq ".[$j]")
state=$(echo $check | jq -r '.state')
conclusion=$(echo $check | jq -r '.conclusion')
name=$(echo $check | jq -r '.name')
# EasyCLA success flag: state=SUCCESS
# Others success flag: conclusion in SUCCESS,NEUTRAL
# Ignore Azure.sonic-buildimage stage check result. It may be set continueOnError
echo "$name" | grep "Azure.sonic-buildimage (" && continue
# Ignore Semgrep, it has issues.
[[ "$name" == "Semgrep" ]] && continue
if [[ "$state" == "SUCCESS" ]];then
# check pass
continue
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- opened
- reopened
branches:
- master
- '202012'
- '202[1-9][0-9][0-9]'
- '20[3-9][0-9][0-9][0-9]'
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@
[submodule "src/sonic-mgmt-framework"]
path = src/sonic-mgmt-framework
url = https://github.com/sonic-net/sonic-mgmt-framework
[submodule "Switch-SDK-drivers"]
path = platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers
url = https://github.com/Mellanox/Switch-SDK-drivers
[submodule "src/sonic-ztp"]
path = src/sonic-ztp
url = https://github.com/sonic-net/sonic-ztp
Expand Down
51 changes: 31 additions & 20 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
# * GZ_COMPRESS_PROGRAM: Select pigz to reduce build time
# * Default: gzip
# * Values: pigz,gzip
# * UNATTENDED: Don't wait for interactive input from terminal, setting this
# * value to anything will enable it
# * Default: unset
# * Value: y
#
###############################################################################

Expand Down Expand Up @@ -495,6 +499,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \
MDEBUG=$(MDEBUG) \
PASSWORD=$(PASSWORD) \
USERNAME=$(USERNAME) \
CHANGE_DEFAULT_PASSWORD=$(CHANGE_DEFAULT_PASSWORD) \
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \
SONIC_USE_DOCKER_BUILDKIT=$(SONIC_USE_DOCKER_BUILDKIT) \
VS_PREPARE_MEM=$(VS_PREPARE_MEM) \
Expand Down Expand Up @@ -555,6 +560,7 @@ endif

export MIRROR_URLS
export MIRROR_SECURITY_URLS
export SONIC_VERSION_CONTROL_COMPONENTS

%:: | sonic-build-hooks
ifneq ($(filter y, $(MULTIARCH_QEMU_ENVIRON) $(CROSS_BUILD_ENVIRON)),)
Expand Down Expand Up @@ -610,23 +616,28 @@ init :

.ONESHELL : reset
reset :
$(Q)echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
$(Q)read ans && (
if [ $$ans == y ]; then
echo "Resetting local repository. Please wait...";
sudo rm -rf fsroot*;
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
echo "Stopping march $(CONFIGURED_ARCH) docker"
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
sudo rm -f /var/run/march/docker.pid || true
fi
git clean -xfdf;
git reset --hard;
git submodule foreach --recursive 'git clean -xfdf || true';
git submodule foreach --recursive 'git reset --hard || true';
git submodule foreach --recursive 'git remote update || true';
git submodule update --init --recursive;
echo "Reset complete!";
else
echo "Reset aborted";
fi )
$(Q)echo && (
if [ -z "$(UNATTENDED)" ]; then
echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
@read ans
else
ans=y
fi
if [ $$ans == y ]; then
echo "Resetting local repository. Please wait...";
sudo rm -rf fsroot*;
if [ "$(MULTIARCH_QEMU_ENVIRON)" == y ] && [[ "$(CONFIGURED_ARCH)" == "armhf" || "$(CONFIGURED_ARCH)" == "arm64" ]]; then
echo "Stopping march $(CONFIGURED_ARCH) docker"
sudo kill -9 `sudo cat /var/run/march/docker.pid` || true
sudo rm -f /var/run/march/docker.pid || true
fi
git clean -xfdf;
git reset --hard;
git submodule foreach --recursive 'git clean -xfdf || true';
git submodule foreach --recursive 'git reset --hard || true';
git submodule foreach --recursive 'git remote update || true';
git submodule update --init --recursive;
echo "Reset complete!";
else
echo "Reset aborted";
fi )
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
*static analysis*:

[![Total alerts](https://img.shields.io/lgtm/alerts/g/Azure/sonic-buildimage.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-buildimage/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Azure/sonic-buildimage.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Azure/sonic-buildimage/context:python)

*master builds*:

[![Barefoot](https://dev.azure.com/mssonic/build/_apis/build/status/barefoot/Azure.sonic-buildimage.official.barefoot?branchName=master&label=Barefoot)](https://dev.azure.com/mssonic/build/_build/latest?definitionId=146&branchName=master)
Expand Down
23 changes: 9 additions & 14 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ stages:

- stage: Build
pool: sonicbld
variables:
INSTALL_DEBUG_TOOLS: y
dependsOn: []
jobs:
- template: .azure-pipelines/azure-pipelines-build.yml
Expand Down Expand Up @@ -174,8 +176,7 @@ stages:
section: part-2

- job: t0_testbedv2
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
displayName: "kvmtest-t0 by TestbedV2"
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
Expand All @@ -188,8 +189,7 @@ stages:
MAX_WORKER: $(T0_INSTANCE_NUM)

- job: t0_2vlans_testbedv2
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
displayName: "kvmtest-t0-2vlans by TestbedV2"
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
Expand Down Expand Up @@ -252,8 +252,7 @@ stages:
vmtype: ceos

- job: t1_lag_testbedv2
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
displayName: "kvmtest-t1-lag by TestbedV2"
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
Expand Down Expand Up @@ -319,8 +318,7 @@ stages:

- job: multi_asic_testbedv2
displayName: "kvmtest-multi-asic-t1-lag by TestbedV2"
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
continueOnError: false
Expand All @@ -334,8 +332,7 @@ stages:
NUM_ASIC: 4

- job: dualtor_testbedv2
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
displayName: "kvmtest-dualtor-t0 by TestbedV2"
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
Expand All @@ -350,8 +347,7 @@ stages:

- job: sonic_t0_testbedv2
displayName: "kvmtest-t0-sonic by TestbedV2"
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
continueOnError: false
Expand All @@ -368,8 +364,7 @@ stages:

- job: wan_testbedv2
displayName: "kvmtest-wan by TestbedV2"
pool:
vmImage: 'ubuntu-20.04'
pool: ubuntu-20.04
timeoutInMinutes: 240
condition: and(succeeded(), eq(variables.BUILD_IMG_RUN_TESTBEDV2_TEST, 'YES'))
continueOnError: false
Expand Down
10 changes: 10 additions & 0 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,16 @@ sudo LANG=C chroot $FILESYSTEM_ROOT umount /proc || true
## Prepare empty directory to trigger mount move in initramfs-tools/mount_loop_root, implemented by patching
sudo mkdir $FILESYSTEM_ROOT/host


if [[ "$CHANGE_DEFAULT_PASSWORD" == "y" ]]; then
## Expire default password for exitsing users that can do login
default_users=$(cat $FILESYSTEM_ROOT/etc/passwd | grep "/home"| grep ":/bin/bash\|:/bin/sh" | awk -F ":" '{print $1}' 2> /dev/null)
for user in $default_users
do
sudo LANG=C chroot $FILESYSTEM_ROOT passwd -e ${user}
done
fi

## Compress most file system into squashfs file
sudo rm -f $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS
## Output the file system total size for diag purpose
Expand Down
Loading

0 comments on commit 1be6c2e

Please sign in to comment.