Skip to content

Commit

Permalink
[docker]: change hardcoded value to DOCKERFS_DIR for docker directory…
Browse files Browse the repository at this point in the history
… on the disk (#269)
  • Loading branch information
lguohan authored Feb 6, 2017
1 parent 2358678 commit 8826beb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ sudo du -hs $FILESYSTEM_ROOT
sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -e boot -e var/lib/docker

## Compress docker files
pushd $FILESYSTEM_ROOT && sudo tar czf $OLDPWD/$FILESYSTEM_DOCKERFS var/lib/docker; popd
pushd $FILESYSTEM_ROOT && sudo tar czf $OLDPWD/$FILESYSTEM_DOCKERFS -C var/lib/docker .; popd

## Compress together with /boot and /var/lib/docker as an installer payload zip file
pushd $FILESYSTEM_ROOT && sudo zip $OLDPWD/$ONIE_INSTALLER_PAYLOAD -r boot/; popd
Expand Down
8 changes: 5 additions & 3 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extract_image() {
rm -rf "$target_path/rw"

## Clean docker directory
rm -rf "$target_path/var"
rm -rf "$target_path/{{ DOCKERFS_DIR }}"

## Unzip the image
unzip -oq "$swipath" -x boot0 -d "$target_path"
Expand All @@ -58,8 +58,10 @@ extract_image() {

## vfat does not support symbol link
if [ $rootfs_type != "vfat" ]; then
## Further extract docker archive
tar xf "$target_path/{{ FILESYSTEM_DOCKERFS }}" -C "$target_path"
mkdir -p "$target_path/{{ DOCKERFS_DIR }}"

## extract docker archive
tar xf "$target_path/{{ FILESYSTEM_DOCKERFS }}" -C "$target_path/{{ DOCKERFS_DIR }}"

## clean up docker archive
rm -f "$target_path/{{ FILESYSTEM_DOCKERFS }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ cmd="mount -t ext4 $root_dev $root_mnt"
run_cmd "$cmd" "$err_msg"

err_msg="Error: extract docker directory"
cmd="[ -f $tmp_mnt/dockerfs.tar.gz ] && rm -rf $tmp_mnt/var && tar xzf $tmp_mnt/dockerfs.tar.gz -C $root_mnt && rm -f $tmp_mnt/dockerfs.tar.gz"
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 }}"
run_cmd "$cmd" "$err_msg"

err_msg="Error: copying files form $tmp_mnt to $root_mnt failed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mount -n -o dirs=${rootmnt}/host/rw:${rootmnt}=ro -t aufs root-aufs ${rootmnt}
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/var/lib/docker ${rootmnt}/var/lib/docker
mount --bind ${rootmnt}/host/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/docker
## Mount the boot directory in the raw partition, bypass the aufs
mkdir -p ${rootmnt}/boot
mount --bind ${rootmnt}/host/boot ${rootmnt}/boot
2 changes: 1 addition & 1 deletion installer/x86_64/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ ${onie_bin} mount -t ext4 -o defaults,rw $demo_dev $demo_mnt || {
unzip $ONIE_INSTALLER_PAYLOAD -d $demo_mnt
if [ -f $demo_mnt/$FILESYSTEM_DOCKERFS ]; then
cd $demo_mnt && tar xf $FILESYSTEM_DOCKERFS; cd $OLDPWD
cd $demo_mnt && mkdir -p $DOCKERFS_DIR && tar xf $FILESYSTEM_DOCKERFS -C $DOCKERFS_DIR; cd $OLDPWD
fi
# Store machine description in target file system
Expand Down
3 changes: 3 additions & 0 deletions onie-image.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ONIE_INSTALLER_PAYLOAD=fs.zip
## Filename for docker file system
FILESYSTEM_DOCKERFS=dockerfs.tar.gz

## docker directory on the root filesystem
DOCKERFS_DIR=docker

## Output file name for onie installer
OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin

Expand Down
5 changes: 4 additions & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ $(DOCKER_LOAD_TARGETS) : $(TARGET_PATH)/%.gz-load : .platform docker-start $$(TA
###############################################################################

# targets for building installers with base image
$(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $(addprefix $(DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL) $(IGB_DRIVER)) $(addprefix $(DEBS_PATH)/,$(SONIC_CONFIG_ENGINE)) $$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS))
$(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform onie-image.conf $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $(addprefix $(DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL) $(IGB_DRIVER)) $(addprefix $(DEBS_PATH)/,$(SONIC_CONFIG_ENGINE)) $$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS))
$(HEADER)
## Pass initramfs and linux kernel explicitly. They are used for all platforms
export initramfs_tools="$(DEBS_PATH)/$(INITRAMFS_TOOLS)"
Expand All @@ -310,6 +310,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform
export installer_start_scrips="$(foreach docker, $($*_DOCKERS),$(addsuffix .sh, $($(docker)_CONTAINER_NAME)))"
export installer_services="$(foreach docker, $($*_DOCKERS),$(addsuffix .service, $($(docker)_CONTAINER_NAME)))"

j2 -f env files/initramfs-tools/union-mount.j2 onie-image.conf > files/initramfs-tools/union-mount
j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs

$(if $($*_DOCKERS),
j2 files/build_templates/sonic_debian_extension.j2 > sonic_debian_extension.sh
chmod +x sonic_debian_extension.sh,
Expand Down

0 comments on commit 8826beb

Please sign in to comment.