Skip to content

Commit

Permalink
Image version safely treats slash in branch name (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiluo-msft authored May 12, 2017
1 parent 34449c1 commit 2cfa289
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 0 additions & 3 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/linux-image-3.16.0-4-amd64_*.de
## Update initramfs for booting with squashfs+aufs
cat files/initramfs-tools/modules | sudo tee -a $FILESYSTEM_ROOT/etc/initramfs-tools/modules > /dev/null

IMAGE_VERSION=$(. functions.sh && sonic_get_version)

## Hook into initramfs: change fs type from vfat to ext4 on arista switches
sudo mkdir -p $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/
sed -i -e "s/%%IMAGE_VERSION%%/$IMAGE_VERSION/g" files/initramfs-tools/arista-convertfs
sudo cp files/initramfs-tools/arista-convertfs $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/arista-convertfs
sudo chmod +x $FILESYSTEM_ROOT/etc/initramfs-tools/scripts/init-premount/arista-convertfs
sudo cp files/initramfs-tools/mke2fs $FILESYSTEM_ROOT/etc/initramfs-tools/hooks/mke2fs
Expand Down
5 changes: 3 additions & 2 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ sonic_get_version() {
fi
BUILD_NUMBER=${BUILD_NUMBER:-0}
## Check if we are on tagged commit
## Note: escape the version string by sed: / -> _
if [ "$describe" == "$latest_tag" ]; then
echo "${latest_tag}${dirty}"
echo "${latest_tag}${dirty}" | sed 's/\//_/g'
else
echo "${branch_name}.${BUILD_NUMBER}${dirty:--$(git rev-parse --short HEAD)}"
echo "${branch_name}.${BUILD_NUMBER}${dirty:--$(git rev-parse --short HEAD)}" | sed 's/\//_/g'
fi
}

0 comments on commit 2cfa289

Please sign in to comment.