Skip to content

Commit

Permalink
Add BOOT_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
denismosolov committed Sep 6, 2019
1 parent 2515652 commit e920c21
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ Specifies the chroot environment to be used instead of creating a new one.

Note, that the parameter conflicts with `CREATE_ONLY_CHROOT`.

##### BOOT_DIR=""

Specifies the source directory for the boot partition. Pieman ignores the boot section of pieman.yml if `BOOT_DIR` is specified.
Please note, this parameter is suitable for FAT boot partitions only.

##### PROJECT_NAME="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"

Each image is built in in the context of some project. The parameter allows specifying the project name. By default, the name is a randomly generated UUID 32-character string.
Expand Down
62 changes: 39 additions & 23 deletions bootstrap/14-boot-partition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,47 @@

check_if_variable_is_set SOURCE_DIR

# Get the files, which must present on the boot partition, from different
# sources and put them in the directory specified via BOOT.
boot="`get_attr ${OS} boot`"
for f in ${boot}; do
if [ ! -z `echo ${f} | egrep "^https://|^http://|^ftp://"` ]; then
info "downloading ${f} to ${BOOT}"
wget -q -O ${BOOT}/`basename ${f}` ${f}
elif [[ ${f:0:1} == "/" ]]; then
# Split the name of the target file or directory into two parts:
# original name and copy name.
IFS=':' read -ra FILE_NAMES <<< "${R}/${f}"

info "copying ${FILE_NAMES[0]} to ${BOOT}"

if [ -z ${FILE_NAMES[1]} ]; then
# If the name of the copy is not specified, use the original one.
cp -r ${FILE_NAMES[0]} ${BOOT}
if [ ! -z ${BOOT_DIR} ] && [ -d ${BOOT_DIR} ]; then
info "using ${BOOT_DIR} as a source for the boot partition."
cp -r --preserve "${BOOT_DIR}"/. ${BOOT}
else
# Get the files, which must present on the boot partition, from different
# sources and put them in the directory specified via BOOT.
boot="`get_attr ${OS} boot`"
for f in ${boot}; do
if [ ! -z `echo ${f} | egrep "^https://|^http://|^ftp://"` ]; then
info "downloading ${f} to ${BOOT}"
wget -q -O ${BOOT}/`basename ${f}` ${f}
elif [[ ${f:0:1} == "/" ]]; then
# Split the name of the target file or directory into two parts:
# original name and copy name.
IFS=':' read -ra FILE_NAMES <<< "${R}/${f}"

info "copying ${FILE_NAMES[0]} to ${BOOT}"

if [ -z ${FILE_NAMES[1]} ]; then
# If the name of the copy is not specified, use the original one.
cp -r ${FILE_NAMES[0]} ${BOOT}
else
info "`basename ${FILE_NAMES[0]}` was renamed into ${FILE_NAMES[1]}"
cp -r ${FILE_NAMES[0]} ${BOOT}/${FILE_NAMES[1]}
fi
else
info "`basename ${FILE_NAMES[0]}` was renamed into ${FILE_NAMES[1]}"
cp -r ${FILE_NAMES[0]} ${BOOT}/${FILE_NAMES[1]}
info "copying `dirname ${YML_FILE}`/${f} to ${BOOT}"
cp ${SOURCE_DIR}/${f} ${BOOT}
fi
done

if [ "${BUILD_TYPE}" = "${IMAGE_CLASSIC}" ]; then
if [[ "${DEVICE}" == "opi-pc-plus" ]]; then
"${TOOLSET_FULL_PATH}/uboot-${UBOOT_VER}"/mkimage -C none -A arm -T script -d "${PIEMAN_DIR}"/files/opi/boot-pc-plus.cmd "${BOOT}"/boot.scr
fi

if [[ "${DEVICE}" == "opi-zero" ]]; then
"${TOOLSET_FULL_PATH}/uboot-${UBOOT_VER}"/mkimage -C none -A arm -T script -d "${PIEMAN_DIR}"/files/opi/boot-zero.cmd "${BOOT}"/boot.scr
fi
else
info "copying `dirname ${YML_FILE}`/${f} to ${BOOT}"
cp ${SOURCE_DIR}/${f} ${BOOT}
fi
done

fi

send_request_to_bsc_server PREPARED_BOOT_PARTITION_CODE
12 changes: 3 additions & 9 deletions pieman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def_bool_var ALLOW_UNAUTHENTICATED false

def_var BASE_DIR ""

def_var BOOT_DIR ""

def_var BUILD_DIR "build"

def_bool_var COMPRESS_WITH_BZIP2 false
Expand Down Expand Up @@ -323,15 +325,7 @@ case "${BUILD_TYPE}" in

mount "${LOOP_DEV}p1" "${MOUNT_POINT}"

if [[ "${DEVICE}" == "opi-pc-plus" ]]; then
"${TOOLSET_FULL_PATH}/uboot-${UBOOT_VER}"/mkimage -C none -A arm -T script -d "${PIEMAN_DIR}"/files/opi/boot-pc-plus.cmd "${BOOT}"/boot.scr
fi

if [[ "${DEVICE}" == "opi-zero" ]]; then
"${TOOLSET_FULL_PATH}/uboot-${UBOOT_VER}"/mkimage -C none -A arm -T script -d "${PIEMAN_DIR}"/files/opi/boot-zero.cmd "${BOOT}"/boot.scr
fi

rsync -a "${BOOT}"/ "${MOUNT_POINT}"
rsync -a --no-o --no-g "${BOOT}"/ "${MOUNT_POINT}"

umount "${MOUNT_POINT}"

Expand Down

0 comments on commit e920c21

Please sign in to comment.