-
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
Address review comments for pull request #846 #901
Changes from 1 commit
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 |
---|---|---|
|
@@ -14,11 +14,8 @@ | |
|
||
IMAGE_VERSION=$(. functions.sh && sonic_get_version) | ||
|
||
if [ "$IMAGE_TYPE" = "onie" ]; then | ||
echo "Build ONIE installer" | ||
mkdir -p `dirname $OUTPUT_ONIE_IMAGE` | ||
sudo rm -f $OUTPUT_ONIE_IMAGE | ||
|
||
generate_onie_installer_image() | ||
{ | ||
# Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them | ||
rm -rf ./installer/x86_64/platforms/ | ||
mkdir -p ./installer/x86_64/platforms/ | ||
|
@@ -27,6 +24,11 @@ if [ "$IMAGE_TYPE" = "onie" ]; then | |
if [ -f ./device/$VENDOR/$PLATFORM/installer.conf ]; then | ||
cp ./device/$VENDOR/$PLATFORM/installer.conf ./installer/x86_64/platforms/$PLATFORM | ||
fi | ||
|
||
if [ "$IMAGE_TYPE" = "raw" ] && [ -f ./device/$VENDOR/$PLATFORM/nos_to_sonic_grub.cfg ]; then | ||
sed -i -e "s/%%IMAGE_VERSION%%/$IMAGE_VERSION/g" ./device/$VENDOR/$PLATFORM/nos_to_sonic_grub.cfg | ||
echo "IMAGE_VERSION is $IMAGE_VERSION/g" | ||
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. /g? remove? |
||
fi | ||
done | ||
done | ||
|
||
|
@@ -35,6 +37,50 @@ if [ "$IMAGE_TYPE" = "onie" ]; then | |
./onie-mk-demo.sh $TARGET_PLATFORM $TARGET_MACHINE $TARGET_PLATFORM-$TARGET_MACHINE-$ONIEIMAGE_VERSION \ | ||
installer platform/$TARGET_MACHINE/platform.conf $OUTPUT_ONIE_IMAGE OS $IMAGE_VERSION $ONIE_IMAGE_PART_SIZE \ | ||
$ONIE_INSTALLER_PAYLOAD | ||
} | ||
|
||
if [ "$IMAGE_TYPE" = "onie" ]; then | ||
echo "Build ONIE installer" | ||
mkdir -p `dirname $OUTPUT_ONIE_IMAGE` | ||
sudo rm -f $OUTPUT_ONIE_IMAGE | ||
|
||
generate_onie_installer_image | ||
|
||
## Build a raw partition dump image using the ONIE installer that can be | ||
## used to dd' in-lieu of using the onie-nos-installer. Used while migrating | ||
## into SONiC from other NOS. | ||
elif [ "$IMAGE_TYPE" = "raw" ]; then | ||
|
||
echo "Build RAW image" | ||
mkdir -p `dirname $OUTPUT_RAW_IMAGE` | ||
sudo rm -f $OUTPUT_RAW_IMAGE | ||
|
||
generate_onie_installer_image | ||
|
||
echo "Creating SONiC raw partition : $OUTPUT_RAW_IMAGE of size $RAW_IMAGE_DISK_SIZE MB" | ||
fallocate -l "$RAW_IMAGE_DISK_SIZE"M $OUTPUT_RAW_IMAGE | ||
|
||
## Generate a compressed 8GB partition dump that can be used to 'dd' in-lieu of using the onie-nos-installer | ||
## Run the installer | ||
## The 'build' install mode of the installer is used to generate this dump. | ||
sudo chmod a+x $OUTPUT_ONIE_IMAGE | ||
sudo ./$OUTPUT_ONIE_IMAGE | ||
|
||
[ -r $OUTPUT_RAW_IMAGE ] || { | ||
echo "Error : $OUTPUT_RAW_IMAGE not generated!" | ||
exit 1 | ||
} | ||
|
||
gzip $OUTPUT_RAW_IMAGE | ||
|
||
[ -r $OUTPUT_RAW_IMAGE.gz ] || { | ||
echo "Error : gzip $OUTPUT_RAW_IMAGE failed!" | ||
exit 1 | ||
} | ||
|
||
mv $OUTPUT_RAW_IMAGE.gz $OUTPUT_RAW_IMAGE | ||
echo "The compressed raw image is in $OUTPUT_RAW_IMAGE" | ||
|
||
## Use 'aboot' as target machine category which includes Aboot as bootloader | ||
elif [ "$IMAGE_TYPE" = "aboot" ]; then | ||
echo "Build Aboot installer" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Grub config to launch SONiC | ||
# with ONIE boot option | ||
|
||
insmod serial | ||
# Initialize USB-Serial com2 port | ||
serial --unit=1 --speed=9600 | ||
#Serial port config;Defaults: COM1,9600 | ||
serial --unit=0 --speed=9600 | ||
terminal_output serial_com0 | ||
terminal_input serial_com0 | ||
#terminfo added to prevent text wrap issue. | ||
terminfo -g 80x100 serial_com0 | ||
terminfo -g 80x100 serial_com1 | ||
|
||
echo -n "Press Esc to stop autoboot ... " | ||
if sleep --verbose --interruptible 5 ; then | ||
insmod gzio | ||
insmod part_msdos | ||
insmod ext2 | ||
set root='(hd0,gpt8)' | ||
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor | ||
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. please add quiet option to boot linux |
||
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64 | ||
boot | ||
else | ||
menuentry 'SONiC' { | ||
insmod gzio | ||
insmod part_msdos | ||
insmod ext2 | ||
set root='(hd0,gpt8)' | ||
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor | ||
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64 | ||
boot | ||
} | ||
|
||
menuentry 'ONIE' { | ||
insmod force10 | ||
onieboot | ||
} | ||
|
||
menuentry 'DELL-DIAG' { | ||
delldiagboot | ||
} | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Grub config to launch SONiC | ||
# with ONIE boot option | ||
|
||
insmod serial | ||
# Initialize USB-Serial com2 port | ||
serial --unit=1 --speed=9600 | ||
#Serial port config;Defaults: COM1,9600 | ||
serial --unit=0 --speed=9600 | ||
terminal_output serial_com0 | ||
terminal_input serial_com0 | ||
#terminfo added to prevent text wrap issue. | ||
terminfo -g 80x100 serial_com0 | ||
terminfo -g 80x100 serial_com1 | ||
|
||
echo -n "Press Esc to stop autoboot ... " | ||
if sleep --verbose --interruptible 5 ; then | ||
insmod gzio | ||
insmod part_msdos | ||
insmod ext2 | ||
set root='(hd0,gpt8)' | ||
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor | ||
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64 | ||
boot | ||
else | ||
menuentry 'SONiC' { | ||
insmod gzio | ||
insmod part_msdos | ||
insmod ext2 | ||
set root='(hd0,gpt8)' | ||
linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor | ||
initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64 | ||
boot | ||
} | ||
|
||
menuentry 'ONIE' { | ||
insmod force10 | ||
onieboot | ||
} | ||
|
||
menuentry 'DELL-DIAG' { | ||
delldiagboot | ||
} | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,22 @@ | |
# | ||
# By default this script does nothing. | ||
|
||
# If the machine.conf is absent, it indicates that the unit booted | ||
# into SONiC from another NOS. Extract the machine.conf from ONIE. | ||
if [ ! -e /host/machine.conf ]; then | ||
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//') | ||
mkdir -p /mnt/onie-boot | ||
mount $onie_dev /mnt/onie-boot | ||
|
||
if [ ! -e /mnt/onie-boot/onie/grub/grub-machine.cfg ]; then | ||
echo "/mnt/onie-boot/onie/grub/grub-machine.cfg not found" >> /etc/migration.log | ||
else | ||
grep "=" /mnt/onie-boot/onie/grub/grub-machine.cfg > /host/machine.conf | ||
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. this is fragile. check here. https://github.com/opencomputeproject/onie/pull/227/files
|
||
fi | ||
|
||
umount /mnt/onie-boot | ||
fi | ||
|
||
. /host/machine.conf | ||
|
||
echo "install platform dependent packages at the first boot time" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ echo " OK." | |
|
||
# Untar and launch install script in a tmpfs | ||
cur_wd=$(pwd) | ||
export cur_wd | ||
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. not sure you need export this value. 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. cur_wd is the absolute path prefix prior to the user's target. say, /home/padman/test/sonic-buildimage. Since the installer (in a "build" mode) does not have a real device to mount, it will fallback to /tmp/tmp... (based on mktmp -d). When the final sonic-broadcom.bin is created under /tmp... build_image.sh cannot correctly extract the sonic-broadcom.bin if there are parallel builds on the same host... One other way would be to pass the cur_wd equivalent to the installer - but that did not appear to be clean. Exporting cur_wd will ensure that the image gets built only in the specific target dir where the build was invoked. 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. A correction : the cur_wd is actually /sonic (from the Makefile's -w /sonic ) and not the absolute build path.. Nevertheless, this path needs to be passed to the installer so that build_image.sh may directly retrieve it in-place after the "build" mode installation. |
||
archive_path=$(realpath "$0") | ||
tmp_dir=$(mktemp -d) | ||
if [ "$(id -u)" = "0" ] ; then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,25 @@ _trap_push true | |
set -e | ||
cd $(dirname $0) | ||
|
||
if [ -d "/etc/sonic" ]; then | ||
echo "Installing SONiC in SONiC" | ||
install_env="sonic" | ||
elif grep -Fxqs "DISTRIB_ID=onie" /etc/lsb-release > /dev/null | ||
then | ||
echo "Installing SONiC in ONIE" | ||
install_env="onie" | ||
else | ||
echo "Installing SONiC in BUILD" | ||
install_env="build" | ||
fi | ||
|
||
if [ -r ./machine.conf ]; then | ||
. ./machine.conf | ||
fi | ||
|
||
if [ -r ./onie-image.conf ]; then | ||
. ./onie-image.conf | ||
fi | ||
|
||
echo "ONIE Installer: platform: $platform" | ||
|
||
|
@@ -40,7 +57,7 @@ if [ -r /etc/machine.conf ]; then | |
. /etc/machine.conf | ||
elif [ -r /host/machine.conf ]; then | ||
. /host/machine.conf | ||
else | ||
elif [ "$install_env" != "build" ]; then | ||
echo "cannot find machine.conf" | ||
exit 1 | ||
fi | ||
|
@@ -58,26 +75,20 @@ ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="" | |
# Default var/log device size in MB | ||
VAR_LOG_SIZE=4096 | ||
|
||
if [ -d "/etc/sonic" ]; then | ||
echo "Installing SONiC in SONiC" | ||
install_env="sonic" | ||
else | ||
echo "Installing SONiC in ONIE" | ||
install_env="onie" | ||
fi | ||
|
||
[ -r platforms/$onie_platform ] && . platforms/$onie_platform | ||
|
||
# Install demo on same block device as ONIE | ||
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//') | ||
blk_dev=$(echo $onie_dev | sed -e 's/[1-9][0-9]*$//' | sed -e 's/\([0-9]\)\(p\)/\1/') | ||
# Note: ONIE has no mount setting for / with device node, so below will be empty string | ||
cur_part=$(cat /proc/mounts | awk "{ if(\$2==\"/\") print \$1 }" | grep $blk_dev || true) | ||
|
||
[ -b "$blk_dev" ] || { | ||
echo "Error: Unable to determine block device of ONIE install" | ||
exit 1 | ||
} | ||
if [ "$install_env" != "build" ]; then | ||
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//') | ||
blk_dev=$(echo $onie_dev | sed -e 's/[1-9][0-9]*$//' | sed -e 's/\([0-9]\)\(p\)/\1/') | ||
# Note: ONIE has no mount setting for / with device node, so below will be empty string | ||
cur_part=$(cat /proc/mounts | awk "{ if(\$2==\"/\") print \$1 }" | grep $blk_dev || true) | ||
|
||
[ -b "$blk_dev" ] || { | ||
echo "Error: Unable to determine block device of ONIE install" | ||
exit 1 | ||
} | ||
fi | ||
|
||
# If running in ONIE | ||
if [ "$install_env" = "onie" ]; then | ||
|
@@ -108,7 +119,7 @@ else | |
firmware="bios" | ||
fi | ||
|
||
if [ "$install_env" != "sonic" ]; then | ||
if [ "$install_env" = "onie" ]; then | ||
# determine ONIE partition type | ||
onie_partition_type=$(${onie_bin} onie-sysinfo -t) | ||
# demo partition size in MB | ||
|
@@ -310,6 +321,7 @@ demo_install_grub() | |
cat $grub_install_log && rm -f $grub_install_log | ||
exit 1 | ||
} | ||
|
||
rm -f $grub_install_log | ||
|
||
# restore immutable flag on the core.img file as discussed | ||
|
@@ -374,7 +386,7 @@ demo_install_uefi_grub() | |
|
||
image_dir="image-$image_version" | ||
|
||
if [ "$install_env" != "sonic" ]; then | ||
if [ "$install_env" = "onie" ]; then | ||
eval $create_demo_partition $blk_dev | ||
demo_dev=$(echo $blk_dev | sed -e 's/\(mmcblk[0-9]\)/\1p/')$demo_part | ||
|
||
|
@@ -391,7 +403,8 @@ if [ "$install_env" != "sonic" ]; then | |
echo "Error: Unable to mount $demo_dev on $demo_mnt" | ||
exit 1 | ||
} | ||
else | ||
|
||
elif [ "$install_env" = "sonic" ]; then | ||
demo_mnt="/host" | ||
running_sonic_revision=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ") | ||
# Prevent installing existing SONiC if it is running | ||
|
@@ -406,6 +419,15 @@ else | |
rm -rf $f | ||
fi | ||
done | ||
else | ||
demo_mnt="build_raw_image_mnt" | ||
demo_dev=$cur_wd/"%%OUTPUT_RAW_IMAGE%%" | ||
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. in line 44, you have sourced onie-image.conf, which defines OUTPUT_RAW_IMAGE, here you should use that instead of doing sed 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. isn't cur_wd = target? 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. Though onie-image.conf is sourced, the TARGET_MACHINE will be assigned to the default ": ${TARGET_MACHINE:=generic}" resulting in an failed attempt to create sonic-generic.raw rather than sonic-broadcom.raw. The sed expansion is needed to assign the TARGET_MACHINE correctly. |
||
|
||
mkfs.ext4 $demo_dev | ||
|
||
echo "Mounting $demo_dev on $demo_mnt..." | ||
mkdir $demo_mnt | ||
mount -t auto -o loop $demo_dev $demo_mnt | ||
fi | ||
|
||
echo "Installing SONiC to $demo_mnt/$image_dir" | ||
|
@@ -446,7 +468,7 @@ if [ "$VAR_LOG_SIZE" != "0" ]; then | |
mkfs.ext4 -q $demo_mnt/disk-img/var-log.ext4 -F | ||
fi | ||
|
||
if [ "$install_env" != "sonic" ]; then | ||
if [ "$install_env" = "onie" ]; then | ||
# Store machine description in target file system | ||
cp /etc/machine.conf $demo_mnt | ||
|
||
|
@@ -547,7 +569,7 @@ menuentry '$demo_grub_entry' { | |
} | ||
EOF | ||
|
||
if [ "$install_env" != "sonic" ]; then | ||
if [ "$install_env" = "onie" ]; then | ||
# Add menu entries for ONIE -- use the grub fragment provided by the | ||
# ONIE distribution. | ||
$onie_root_dir/grub.d/50_onie_grub >> $grub_cfg | ||
|
@@ -559,7 +581,11 @@ $onie_menuentry | |
EOF | ||
fi | ||
|
||
cp $grub_cfg $onie_initrd_tmp/$demo_mnt/grub/grub.cfg | ||
if [ "$install_env" = "build" ]; then | ||
umount $demo_mnt | ||
else | ||
cp $grub_cfg $onie_initrd_tmp/$demo_mnt/grub/grub.cfg | ||
fi | ||
|
||
cd / | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,11 +83,16 @@ cp onie-image.conf $tmp_installdir | |
# sed. Special chars are: \ / & | ||
EXTRA_CMDLINE_LINUX=`echo $EXTRA_CMDLINE_LINUX | sed -e 's/[\/&]/\\\&/g'` | ||
|
||
output_raw_image=$(cat onie-image.conf | grep OUTPUT_RAW_IMAGE | cut -f2 -d"=") | ||
[ -z "$TARGET_MACHINE" ] && output_raw_image=$(echo $output_raw_image | sed -e 's/$TARGET_MACHINE/$machine/g') | ||
output_raw_image=$(eval echo $output_raw_image) | ||
|
||
# Tailor the demo installer for OS mode or DIAG mode | ||
sed -i -e "s/%%DEMO_TYPE%%/$demo_type/g" \ | ||
-e "s/%%IMAGE_VERSION%%/$image_version/g" \ | ||
-e "s/%%ONIE_IMAGE_PART_SIZE%%/$onie_image_part_size/" \ | ||
-e "s/%%EXTRA_CMDLINE_LINUX%%/$EXTRA_CMDLINE_LINUX/" \ | ||
-e "s@%%OUTPUT_RAW_IMAGE%%@$output_raw_image@" \ | ||
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 see a must you need to do sed here. |
||
$tmp_installdir/install.sh || clean_up 1 | ||
echo -n "." | ||
cp -r $* $tmp_installdir || clean_up 1 | ||
|
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.
the IMAGE_VERSION is not replaced in the nos_to_sonic_grub.cfg, can you check?
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.
In my local build, it is getting reset after make target/sonic-broadcom.raw:
padman@ubuntu-16:/gvob/sdchk$ diff ./sonic-buildimage/device/dell/x86_64-dell_s6100_c2538-r0/nos_to_sonic_grub.cfg.base ./sonic-buildimage/device/dell/x86_64-dell_s6100_c2538-r0/nos_to_sonic_grub.cfg
22,23c22,23
< linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor
< initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64
31,32c31,32
< linux /image-%%IMAGE_VERSION%%/boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda8 rw console=tty0 console=ttyS1,9600n8 loop=image-%%IMAGE_VERSION%%/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor
< initrd /image-%%IMAGE_VERSION%%/boot/initrd.img-3.16.0-4-amd64
padman@ubuntu-16:/gvob/sdchk$