-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SONiC-to-SONiC update #464
Changes from 7 commits
444f603
48c0816
abca80b
057c414
638fd81
6aaf7b4
cf97eae
faaf106
6e10e66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,14 +42,14 @@ parse_environment_config() { | |
|
||
extract_image() { | ||
## Remove all the other unnecssary files except swi file, boot-config | ||
for f in $(ls -A $target_path); do | ||
for f in $(ls -A $target_path/image-%%IMAGE_VERSION%%); do | ||
if [ $f != "${swipath##*/}" ] && [ $f != "boot-config" ]; then | ||
rm -rf "$target_path/$f" | ||
rm -rf "$target_path/image-%%IMAGE_VERSION%%/$f" | ||
fi | ||
done | ||
|
||
## Unzip the image | ||
unzip -oq "$swipath" -x boot0 -d "$target_path" | ||
unzip -oq "$swipath" -x boot0 -d "$target_path/image-%%IMAGE_VERSION%%" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to create this path. I tested, and here are the errors.
|
||
|
||
## Remove installer swi as it has lots of redundunt contents | ||
rm -f $swipath | ||
|
@@ -59,19 +59,19 @@ extract_image() { | |
|
||
## vfat does not support symbol link | ||
if [ $rootfs_type != "vfat" ]; then | ||
mkdir -p "$target_path/{{ DOCKERFS_DIR }}" | ||
mkdir -p "$target_path/image-%%IMAGE_VERSION%%/{{ DOCKERFS_DIR }}" | ||
|
||
## extract docker archive | ||
tar xf "$target_path/{{ FILESYSTEM_DOCKERFS }}" -C "$target_path/{{ DOCKERFS_DIR }}" | ||
tar xf "$target_path/image-%%IMAGE_VERSION%%/{{ FILESYSTEM_DOCKERFS }}" -C "$target_path/image-%%IMAGE_VERSION%%/{{ DOCKERFS_DIR }}" | ||
|
||
## clean up docker archive | ||
rm -f "$target_path/{{ FILESYSTEM_DOCKERFS }}" | ||
rm -f "$target_path/image-%%IMAGE_VERSION%%/{{ FILESYSTEM_DOCKERFS }}" | ||
else | ||
echo "/mnt/flash is $rootfs_type, extract {{ FILESYSTEM_DOCKERFS }} in later stage" | ||
fi | ||
|
||
## replace with boot swi | ||
mv "$target_path/{{ ABOOT_BOOT_IMAGE }}" "$swipath" | ||
mv "$target_path/image-%%IMAGE_VERSION%%/{{ ABOOT_BOOT_IMAGE }}" "$swipath" | ||
|
||
## sync disk operations | ||
sync | ||
|
@@ -124,8 +124,8 @@ echo "rw loop=fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor quiet | |
platform_specific | ||
|
||
# use extra parameters from kernel-params hook if the file exists | ||
if [ -f "$target_path/$kernel_params" ]; then | ||
cat "$target_path/$kernel_params" >>/tmp/append | ||
if [ -f "$target_path/image-%%IMAGE_VERSION%%/$kernel_params" ]; then | ||
cat "$target_path/image-%%IMAGE_VERSION%%/$kernel_params" >>/tmp/append | ||
fi | ||
|
||
# setting root partition if not overridden by kernel-params | ||
|
@@ -137,15 +137,15 @@ fi | |
|
||
# check the hash file in the image, and determine to install or just skip | ||
GIT_REVISION=$(unzip -p "$swipath" .imagehash) | ||
LOCAL_IMAGEHASH=$(cat $target_path/.imagehash 2>/dev/null || true) | ||
LOCAL_IMAGEHASH=$(cat $target_path/image-%%IMAGE_VERSION%%/.imagehash 2>/dev/null || true) | ||
if [ "$GIT_REVISION" != "$LOCAL_IMAGEHASH" ]; then | ||
extract_image | ||
write_machine_config | ||
fi | ||
|
||
# chainloading using kexec | ||
initrd_path="$target_path/$initrd" | ||
kernel_path="$target_path/$kernel" | ||
initrd_path="$target_path/image-%%IMAGE_VERSION%%/$initrd" | ||
kernel_path="$target_path/image-%%IMAGE_VERSION%%/$kernel" | ||
cmdline="$(tr '\n' ' ' </tmp/append)" | ||
|
||
kexec --load --initrd="$initrd_path" --append="$cmdline" "$kernel_path" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,7 +191,7 @@ cmd="mount -t ext4 $root_dev $root_mnt" | |
run_cmd "$cmd" "$err_msg" | ||
|
||
err_msg="Error: extract docker directory" | ||
cmd="[ -f $tmp_mnt/{{ FILESYSTEM_DOCKERFS }} ] && rm -rf $root_mnt/{{ DOCKERFS_DIR }} && mkdir $root_mnt/{{ DOCKERFS_DIR }} && tar xzf $tmp_mnt/{{ FILESYSTEM_DOCKERFS }} -C $root_mnt/{{ DOCKERFS_DIR }} && rm -f $tmp_mnt/{{ FILESYSTEM_DOCKERFS }}" | ||
cmd="[ -f $tmp_mnt/image-%%IMAGE_VERSION%%/{{ FILESYSTEM_DOCKERFS }} ] && rm -rf $root_mnt/image-%%IMAGE_VERSION%%/{{ DOCKERFS_DIR }} && mkdir $root_mnt/image-%%IMAGE_VERSION%%/{{ DOCKERFS_DIR }} && tar xzf $tmp_mnt/image-%%IMAGE_VERSION%%/{{ FILESYSTEM_DOCKERFS }} -C $root_mnt/image-%%IMAGE_VERSION%%/{{ DOCKERFS_DIR }} && rm -f $tmp_mnt/image-%%IMAGE_VERSION%%/{{ FILESYSTEM_DOCKERFS }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about having a temporary variable apply here. |
||
run_cmd "$cmd" "$err_msg" | ||
|
||
err_msg="Error: copying files form $tmp_mnt to $root_mnt failed" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,18 @@ case $1 in | |
esac | ||
|
||
## Mount the aufs file system: rw layer over squashfs | ||
mkdir -p ${rootmnt}/host/rw | ||
mount -n -o dirs=${rootmnt}/host/rw:${rootmnt}=ro -t aufs root-aufs ${rootmnt} | ||
image_dir=$(cat /proc/cmdline | sed -e 's/BOOT_IMAGE=\/\(.*\)\/boot\(.*\)/\1/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aboot0 does not pass BOOT_IMAGE in the cmdline, need to add that. |
||
mkdir -p ${rootmnt}/host/$image_dir/rw | ||
mount -n -o dirs=${rootmnt}/host/$image_dir/rw:${rootmnt}=ro -t aufs root-aufs ${rootmnt} | ||
## Check if the root block device is still there | ||
[ -b ${ROOT} ] || mdev -s | ||
## Mount the raw partition again | ||
mount ${ROOT} ${rootmnt}/host | ||
## Mount the working directory of docker engine in the raw partition, bypass the aufs | ||
mkdir -p ${rootmnt}/var/lib/docker | ||
mount --bind ${rootmnt}/host/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/docker | ||
mount --bind ${rootmnt}/host/$image_dir/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/docker | ||
## Mount the boot directory in the raw partition, bypass the aufs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this change is going to break the arista aboot image. if you search DOCKERFS_DIR, it is also used in files/initramfs-tools/arista-convertfs.j2 and files/Aboot/boot0.j2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not need this commit to support sonic-to-sonic on arista aboot platform, but it is better not to break the existing func. |
||
mkdir -p ${rootmnt}/boot | ||
mount --bind ${rootmnt}/host/boot ${rootmnt}/boot | ||
mount --bind ${rootmnt}/host/$image_dir/boot ${rootmnt}/boot | ||
## Mount loop device for /var/log | ||
[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding image-%%IMAGE_VERSION%% everywhere it could be cleaner to just define a variable and use it instead of target_path where needs be.
image_path="$target_path/image-%%IMAGE_VERSION%%"