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." } 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..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() { @@ -397,6 +402,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 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." }