From 75aa261de85c1ab6087f3f8ba37818e42968e93e Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Mon, 24 Sep 2018 15:36:29 +0200 Subject: [PATCH 1/4] Added handling of keep parameter for install_mender command. Signed-off-by: Dominik Adamski --- convert-stage-4.sh | 20 +++++++++++++------- mender-convert.sh | 4 ++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/convert-stage-4.sh b/convert-stage-4.sh index 0ff1c0a..ac5e8e2 100755 --- a/convert-stage-4.sh +++ b/convert-stage-4.sh @@ -118,23 +118,24 @@ create_client_files() { } get_mender_files_from_upstream() { + mkdir -p $mender_dir echo -e "Downloading inventory & identity scripts..." - wget -q -O $mender_dir/mender-device-identity \ + wget -nc -q -O $mender_dir/mender-device-identity \ $mender_client_repo/$mender_client_revision/support/mender-device-identity - wget -q -O $mender_dir/mender-inventory-bootloader-integration \ + wget -nc -q -O $mender_dir/mender-inventory-bootloader-integration \ $mender_client_repo/$mender_client_revision/support/mender-inventory-bootloader-integration - wget -q -O $mender_dir/mender-inventory-hostinfo \ + wget -nc -q -O $mender_dir/mender-inventory-hostinfo \ $mender_client_repo/$mender_client_revision/support/mender-inventory-hostinfo - wget -q -O $mender_dir/mender-inventory-network \ + wget -nc -q -O $mender_dir/mender-inventory-network \ $mender_client_repo/$mender_client_revision/support/mender-inventory-network - wget -q -O $mender_dir/mender-inventory-os \ + wget -nc -q -O $mender_dir/mender-inventory-os \ $mender_client_repo/$mender_client_revision/support/mender-inventory-os - wget -q -O $mender_dir/mender-inventory-rootfs-type \ + wget -nc -q -O $mender_dir/mender-inventory-rootfs-type \ $mender_client_repo/$mender_client_revision/support/mender-inventory-rootfs-type - wget -q -O $mender_dir/server.crt \ + wget -nc -q -O $mender_dir/server.crt \ $meta_mender_repo/$meta_mender_revision/meta-mender-demo/recipes-mender/mender/files/server.crt } @@ -293,6 +294,7 @@ do_install_mender() { # Clean stuff. detach_device_maps ${mender_disk_mappings[@]} rm -rf $output_dir/sdimg + [[ $keep -eq 0 ]] && { rm -rf $mender_dir; } } PARAMS="" @@ -331,6 +333,10 @@ while (( "$#" )); do tenant_token=$2 shift 2 ;; + -k | --keep) + keep="1" + shift 1 + ;; -h | --help) show_help ;; diff --git a/mender-convert.sh b/mender-convert.sh index 626bec7..fca4675 100755 --- a/mender-convert.sh +++ b/mender-convert.sh @@ -397,6 +397,10 @@ do_install_mender_to_mender_disk_image() { stage_4_args="${stage_4_args} -t ${tenant_token}" fi + if [ -n "${keep}" ]; then + stage_4_args="${stage_4_args} -k" + fi + eval set -- " ${stage_4_args}" export -f create_device_maps From 91ae1fa30185a78012dd00cdac1a565897e5b622 Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Wed, 26 Sep 2018 13:32:14 +0200 Subject: [PATCH 2/4] Added handling of keep parameter for install_bootloader for BB. Signed-off-by: Dominik Adamski --- bbb-convert-stage-5.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bbb-convert-stage-5.sh b/bbb-convert-stage-5.sh index 854fdad..844633b 100755 --- a/bbb-convert-stage-5.sh +++ b/bbb-convert-stage-5.sh @@ -68,10 +68,13 @@ get_kernel_version() { # # $1 - linux kernel version build_env_lock_boot_files() { + local grubenv_git_dir=$grubenv_dir/.git mkdir -p $grubenv_dir mkdir -p $grubenv_build_dir - git clone https://github.com/mendersoftware/grub-mender-grubenv.git $grubenv_dir + if [ ! -d $grubenv_git_dir ]; then + git clone https://github.com/mendersoftware/grub-mender-grubenv.git $grubenv_dir + fi cd $grubenv_dir # Prepare configuration file. @@ -87,22 +90,22 @@ build_env_lock_boot_files() { make make DESTDIR=$grubenv_build_dir install cd $output_dir - rm -rf $grubenv_dir } # Takes following arguments: # # $1 - linux kernel version build_grub_efi() { - local grub_build=$output_dir/grub/build - local grub_repo_vc_dir=$output_dir/grub/.git + grub_dir=$output_dir/grub + local grub_build=$grub_dir/build + local grub_repo_vc_dir=$grub_dir/.git local repo_clean=0 local version=$(echo $1 | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') # Build grub modules for arm platform and executables for the host. if [ ! -d $grub_repo_vc_dir ]; then - git clone git://git.savannah.gnu.org/grub.git $output_dir/grub + git clone git://git.savannah.gnu.org/grub.git $grub_dir local repo_clean=1 fi @@ -251,7 +254,7 @@ do_install_bootloader() { # Clean files. rm -rf $output_dir/sdimg -# [[ $keep -eq 0 ]] && { rm -rf $output_dir; } + [[ $keep -eq 0 ]] && { rm -rf $grubenv_dir $grubenv_build_dir $grub_dir; } echo -e "\nAll done." } From 79995d0d5662669766879e4213760f49281b85dd Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Wed, 26 Sep 2018 13:34:53 +0200 Subject: [PATCH 3/4] Added handling of keep param for do_make_sdimg for RPi3 Signed-off-by: Dominik Adamski --- mender-convert.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mender-convert.sh b/mender-convert.sh index fca4675..f745a33 100755 --- a/mender-convert.sh +++ b/mender-convert.sh @@ -369,6 +369,11 @@ do_make_sdimg_raspberrypi3() { sudo install -d -m 755 ${sdimg_primary_dir}/data set_fstab $device_type + + [[ $keep = "-k" ]] && { rm -f $output_dir/boot.vfat\ + $output_dir/cmdline.txt $output_dir/config.txt\ + $output_dir/rootfs.img; } + } do_install_mender_to_mender_disk_image() { From e9b921d08543f718099cfcbb1a495424a1e97a22 Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Wed, 26 Sep 2018 14:53:03 +0200 Subject: [PATCH 4/4] Added handling of keep param for instal_bootloader for RPi3. Signed-off-by: Dominik Adamski --- rpi3-convert-stage-5.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rpi3-convert-stage-5.sh b/rpi3-convert-stage-5.sh index 55bfb2e..d3078e3 100755 --- a/rpi3-convert-stage-5.sh +++ b/rpi3-convert-stage-5.sh @@ -18,7 +18,8 @@ application_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" files_dir=${application_dir}/files output_dir=${application_dir}/output uboot_dir=${output_dir}/uboot-mender -bin_dir_pi=${output_dir}/bin/raspberrypi +bin_base_dir=${output_dir}/bin +bin_dir_pi=${bin_base_dir}/raspberrypi sdimg_base_dir=$output_dir/sdimg GCC_VERSION="6.3.1" @@ -181,6 +182,9 @@ do_install_bootloader() { detach_device_maps ${mender_disk_mappings[@]} + [[ $keep -eq 0 ]] && { rm -f ${output_dir}/config.txt ${output_dir}/cmdline.txt; + rm -rf $uboot_dir $bin_base_dir $sdimg_base_dir; } + echo -e "\nStage done." }