mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Split lib/image-helpers.sh
This commit is contained in:
25
lib/functions/rootfs/apt-install.sh
Normal file
25
lib/functions/rootfs/apt-install.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
install_deb_chroot()
|
||||
{
|
||||
|
||||
local package=$1
|
||||
local variant=$2
|
||||
local transfer=$3
|
||||
local name
|
||||
local desc
|
||||
if [[ ${variant} != remote ]]; then
|
||||
name="/root/"$(basename "${package}")
|
||||
[[ ! -f "${SDCARD}${name}" ]] && cp "${package}" "${SDCARD}${name}"
|
||||
desc=""
|
||||
else
|
||||
name=$1
|
||||
desc=" from repository"
|
||||
fi
|
||||
|
||||
display_alert "Installing${desc}" "${name/\/root\//}"
|
||||
[[ $NO_APT_CACHER != yes ]] && local apt_extra="-o Acquire::http::Proxy=\"http://${APT_PROXY_ADDR:-localhost:3142}\" -o Acquire::http::Proxy::localhost=\"DIRECT\""
|
||||
# when building in bulk from remote, lets make sure we have up2date index
|
||||
chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -yqq $apt_extra --no-install-recommends install $name" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
|
||||
[[ $? -ne 0 ]] && exit_with_error "Installation of $name failed" "${BOARD} ${RELEASE} ${BUILD_DESKTOP} ${LINUXFAMILY}"
|
||||
[[ ${variant} == remote && ${transfer} == yes ]] && rsync -rq "${SDCARD}"/var/cache/apt/archives/*.deb ${DEB_STORAGE}/
|
||||
|
||||
}
|
||||
31
lib/functions/rootfs/customize.sh
Normal file
31
lib/functions/rootfs/customize.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
customize_image()
|
||||
{
|
||||
|
||||
# for users that need to prepare files at host
|
||||
[[ -f $USERPATCHES_PATH/customize-image-host.sh ]] && source "$USERPATCHES_PATH"/customize-image-host.sh
|
||||
|
||||
call_extension_method "pre_customize_image" "image_tweaks_pre_customize" << 'PRE_CUSTOMIZE_IMAGE'
|
||||
*run before customize-image.sh*
|
||||
This hook is called after `customize-image-host.sh` is called, but before the overlay is mounted.
|
||||
It thus can be used for the same purposes as `customize-image-host.sh`.
|
||||
PRE_CUSTOMIZE_IMAGE
|
||||
|
||||
cp "$USERPATCHES_PATH"/customize-image.sh "${SDCARD}"/tmp/customize-image.sh
|
||||
chmod +x "${SDCARD}"/tmp/customize-image.sh
|
||||
mkdir -p "${SDCARD}"/tmp/overlay
|
||||
# util-linux >= 2.27 required
|
||||
mount -o bind,ro "$USERPATCHES_PATH"/overlay "${SDCARD}"/tmp/overlay
|
||||
display_alert "Calling image customization script" "customize-image.sh" "info"
|
||||
chroot "${SDCARD}" /bin/bash -c "/tmp/customize-image.sh $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP $ARCH"
|
||||
CUSTOMIZE_IMAGE_RC=$?
|
||||
umount -i "${SDCARD}"/tmp/overlay >/dev/null 2>&1
|
||||
mountpoint -q "${SDCARD}"/tmp/overlay || rm -r "${SDCARD}"/tmp/overlay
|
||||
if [[ $CUSTOMIZE_IMAGE_RC != 0 ]]; then
|
||||
exit_with_error "customize-image.sh exited with error (rc: $CUSTOMIZE_IMAGE_RC)"
|
||||
fi
|
||||
|
||||
call_extension_method "post_customize_image" "image_tweaks_post_customize" << 'POST_CUSTOMIZE_IMAGE'
|
||||
*post customize-image.sh hook*
|
||||
Run after the customize-image.sh script is run, and the overlay is unmounted.
|
||||
POST_CUSTOMIZE_IMAGE
|
||||
}
|
||||
Reference in New Issue
Block a user