Skip to content
36 changes: 18 additions & 18 deletions extensions/allwinner-kernel-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ function extension_finish_config__prepare_megous_patches() {
patch_dir_megous="${patch_dir_base}/patches.megous"
patch_dir_tmp="${patch_dir_base}/patches.megi"

if [[ -d ${patch_dir_base} ]]; then
if [[ -d "${patch_dir_base}" ]]; then
display_alert "allwinner-kernel-bump" "Found existing kernel patch directory" "info"
if [[ "${OVERWRITE_PATCHDIR:-no}" == "yes" ]]; then
display_alert "allwinner-kernel-bump" "Removing as requested. Any manual changes will get overwritten" "info"
rm -rf ${patch_dir_base}
rm -rf "${patch_dir_base}"
else
display_alert "allwinner-kernel-bump" "Skipping kernel patch directory creation" "info"
return 0
Expand All @@ -59,38 +59,38 @@ function extension_finish_config__prepare_megous_patches() {
run_host_command_logged mkdir -pv "${git_bundles_dir}"
run_host_command_logged rm "${bundle_file}" || true
do_with_retries 5 axel "--output=${bundle_file}" "${bundle_url}"
run_host_command_logged git -C ${kernel_work_dir} fetch ${bundle_file} '+refs/heads/*:refs/remotes/megous/*'
run_host_command_logged git -C "${kernel_work_dir}" fetch "${bundle_file}" '+refs/heads/*:refs/remotes/megous/*'

display_alert "allwinner-kernel-bump" "Initializing kernel patch directory using previous kernel patch dir" "info"
run_host_command_logged cp -aR ${PREV_KERNEL_PATCH_DIR} ${patch_dir_base}
run_host_command_logged cp -aR "${PREV_KERNEL_PATCH_DIR}" "${patch_dir_base}"

# Removing older copy of megous patches and series.conf file
run_host_command_logged rm -rf ${patch_dir_base}/patches.megous/*
run_host_command_logged rm -f ${patch_dir_base}/series.{conf,megous}
run_host_command_logged rm -rf "${patch_dir_base}"/patches.megous/*
run_host_command_logged rm -f "${patch_dir_base}"/series.{conf,megous}

display_alert "allwinner-kernel-bump" "Extracting latest Megous patches" "info"
megous_trees=("a83t-suspend" "af8133j" "anx" "audio" "axp" "cam" "drm"
"err" "fixes" "mbus" "modem" "opi3" "pb" "pinetab" "pp" "ppkb" "samuel"
"speed" "tbs-a711" "ths")

run_host_command_logged mkdir -p ${patch_dir_megous} ${patch_dir_tmp}
run_host_command_logged mkdir -p "${patch_dir_megous}" "${patch_dir_tmp}"

for tree in ${megous_trees[@]}; do
run_host_command_logged "${SRC}"/tools/mk_format_patch ${kernel_work_dir} master..megous/${tree}-${KERNEL_MAJOR_MINOR} ${patch_dir_megous} sufix=megi
run_host_command_logged cp ${patch_dir_megous}/* ${patch_dir_tmp}
run_host_command_logged cat ${patch_dir_base}/series.megous ">>" ${patch_dir_base}/series.megi
for tree in "${megous_trees[@]}"; do
run_host_command_logged "${SRC}"/tools/mk_format_patch "${kernel_work_dir}" "master..megous/${tree}-${KERNEL_MAJOR_MINOR}" "${patch_dir_megous}" sufix=megi
run_host_command_logged cp "${patch_dir_megous}"/* "${patch_dir_tmp}"
run_host_command_logged cat "${patch_dir_base}/series.megous" ">>" "${patch_dir_base}/series.megi"
done

run_host_command_logged cp ${patch_dir_tmp}/* ${patch_dir_megous}
run_host_command_logged mv ${patch_dir_base}/series.megi ${patch_dir_base}/series.megous
run_host_command_logged rm -rf ${patch_dir_tmp} ${patch_dir_base}/series.megi
run_host_command_logged cp "${patch_dir_tmp}"/* "${patch_dir_megous}"
run_host_command_logged mv "${patch_dir_base}/series.megi" "${patch_dir_base}/series.megous"
run_host_command_logged rm -rf "${patch_dir_tmp}" "${patch_dir_base}/series.megi"

# Disable previously disabled patches
grep '^-' ${PREV_KERNEL_PATCH_DIR}/series.megous | awk -F / '{print $NF}' | xargs -I {} sed -i "/\/{}/s/^/-/g" ${patch_dir_base}/series.megous
grep '^-' "${PREV_KERNEL_PATCH_DIR}/series.megous" | awk -F / '{print $NF}' | xargs -I {} sed -i "/\/{}/s/^/-/g" "${patch_dir_base}/series.megous"

display_alert "allwinner-kernel-bump" "Generating series.conf file" "info"
run_host_command_logged cat ${patch_dir_base}/series.megous ">>" ${patch_dir_base}/series.conf
run_host_command_logged cat ${patch_dir_base}/series.fixes ">>" ${patch_dir_base}/series.conf
run_host_command_logged cat ${patch_dir_base}/series.armbian ">>" ${patch_dir_base}/series.conf
run_host_command_logged cat "${patch_dir_base}/series.megous" ">>" "${patch_dir_base}/series.conf"
run_host_command_logged cat "${patch_dir_base}/series.fixes" ">>" "${patch_dir_base}/series.conf"
run_host_command_logged cat "${patch_dir_base}/series.armbian" ">>" "${patch_dir_base}/series.conf"
fi
}
8 changes: 4 additions & 4 deletions extensions/cloud-init/cloud-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ function pre_customize_image__inject_cloud_init_config() {
display_alert "Extension: ${EXTENSION}: Configuring" "cloud-init" "info"
local config_src="${EXTENSION_DIR}/config"
local config_dst="${SDCARD}/etc/cloud/cloud.cfg.d"
run_host_command_logged cp ${config_src}/* $config_dst
run_host_command_logged cp "${config_src}"/* "${config_dst}"

# Provide default cloud-init files
display_alert "Extension: ${EXTENSION}: Defaults" "cloud-init" "info"
local defaults_src="${EXTENSION_DIR}/defaults"
local defaults_dst="${SDCARD}/boot"
run_host_command_logged cp ${defaults_src}/* $defaults_dst
run_host_command_logged cp "${defaults_src}"/* "${defaults_dst}"
return 0
}

Expand All @@ -59,8 +59,8 @@ function pre_customize_image__disable_armbian_first_run() {
display_alert "Extension: ${EXTENSION}: Disabling" "armbian firstrun" "info"

# Clean up default profile and network
rm -f ${SDCARD}/etc/profile.d/armbian-check-first-*
rm -f ${SDCARD}/etc/netplan/armbian-*
rm -f "${SDCARD}"/etc/profile.d/armbian-check-first-*
rm -f "${SDCARD}"/etc/netplan/armbian-*

# remove any networkd config leftover from armbian build
rm -f "${SDCARD}"/etc/systemd/network/*.network || true
Expand Down
63 changes: 31 additions & 32 deletions extensions/image-output-abl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,72 @@ function add_host_dependencies__abl_host_deps() {
function post_build_image__900_convert_to_abl_img() {
[[ -z $version ]] && exit_with_error "version is not set"

if [ ! -z "$UEFI_GRUB_TARGET" ]; then
if [[ -n "$UEFI_GRUB_TARGET" ]]; then
display_alert "Ignore" "${EXTENSION}" "info"
return 0
fi

if [ ! -z "$BOOTFS_TYPE" ]; then
if [[ -n "$BOOTFS_TYPE" ]]; then
return 0
fi

display_alert "Converting image $version to rootfs" "${EXTENSION}" "info"
declare -g ROOTFS_IMAGE_FILE="${DESTIMG}/${version}.rootfs.img"
rootfs_start_sector=$(gdisk -l ${DESTIMG}/${version}.img | grep rootfs | awk '{print $2}')
rootfs_end_sector=$(gdisk -l ${DESTIMG}/${version}.img | grep rootfs | awk '{print $3}')
rootfs_start_sector=$(gdisk -l "${DESTIMG}/${version}.img" | grep rootfs | awk '{print $2}')
rootfs_end_sector=$(gdisk -l "${DESTIMG}/${version}.img" | grep rootfs | awk '{print $3}')
old_rootfs_image_mount_dir=${DESTIMG}/rootfs-old
new_rootfs_image_mount_dir=${DESTIMG}/rootfs-new
mkdir -p ${old_rootfs_image_mount_dir} ${new_rootfs_image_mount_dir}
truncate --size=9728M ${ROOTFS_IMAGE_FILE}
mkfs.ext4 -F ${ROOTFS_IMAGE_FILE}
new_rootfs_image_uuid=$(blkid -s UUID -o value ${ROOTFS_IMAGE_FILE})
old_image_loop_device=$(losetup -f -P --show ${DESTIMG}/${version}.img)
old_rootfs_image_uuid=$(blkid -s UUID -o value ${old_image_loop_device}p1)
mount ${old_image_loop_device}p1 ${old_rootfs_image_mount_dir}
mount ${ROOTFS_IMAGE_FILE} ${new_rootfs_image_mount_dir}
cp -rfp ${old_rootfs_image_mount_dir}/* ${new_rootfs_image_mount_dir}/
umount ${old_rootfs_image_mount_dir}
losetup -d ${old_image_loop_device}
rm ${DESTIMG}/${version}.img
mkdir -p "${old_rootfs_image_mount_dir}" "${new_rootfs_image_mount_dir}"
truncate --size=9728M "${ROOTFS_IMAGE_FILE}"
mkfs.ext4 -F "${ROOTFS_IMAGE_FILE}"
new_rootfs_image_uuid=$(blkid -s UUID -o value "${ROOTFS_IMAGE_FILE}")
old_image_loop_device=$(losetup -f -P --show "${DESTIMG}/${version}.img")
old_rootfs_image_uuid=$(blkid -s UUID -o value "${old_image_loop_device}p1")
mount "${old_image_loop_device}p1" "${old_rootfs_image_mount_dir}"
mount "${ROOTFS_IMAGE_FILE}" "${new_rootfs_image_mount_dir}"
cp -rfp "${old_rootfs_image_mount_dir}"/* "${new_rootfs_image_mount_dir}"/
umount "${old_rootfs_image_mount_dir}"
losetup -d "${old_image_loop_device}"
rm "${DESTIMG}/${version}.img"
display_alert "Replace root partition uuid from ${old_rootfs_image_uuid} to ${new_rootfs_image_uuid} in /etc/fstab" "${EXTENSION}" "info"
sed -i "s|${old_rootfs_image_uuid}|${new_rootfs_image_uuid}|g" ${new_rootfs_image_mount_dir}/etc/fstab
source ${new_rootfs_image_mount_dir}/boot/armbianEnv.txt
sed -i "s|${old_rootfs_image_uuid}|${new_rootfs_image_uuid}|g" "${new_rootfs_image_mount_dir}/etc/fstab"
source "${new_rootfs_image_mount_dir}/boot/armbianEnv.txt"
declare -g bootimg_cmdline="${BOOTIMG_CMDLINE_EXTRA} root=UUID=${new_rootfs_image_uuid} slot_suffix=${abl_boot_partition_label#boot} ${extraargs}"

if [ ${#ABL_DTB_LIST[@]} -ne 0 ]; then
if [[ ${#ABL_DTB_LIST[@]} -ne 0 ]]; then
display_alert "Going to create abl kernel boot image" "${EXTENSION}" "info"
gzip -c ${new_rootfs_image_mount_dir}/boot/vmlinuz-*-* > ${DESTIMG}/Image.gz
gzip -c "${new_rootfs_image_mount_dir}"/boot/vmlinuz-*-* > "${DESTIMG}/Image.gz"
for dtb_name in "${ABL_DTB_LIST[@]}"; do
display_alert "Creatng abl kernel boot image with dtb ${dtb_name} and cmdline ${bootimg_cmdline} " "${EXTENSION}" "info"
cat ${DESTIMG}/Image.gz ${new_rootfs_image_mount_dir}/usr/lib/linux-image-*/qcom/${dtb_name}.dtb > ${DESTIMG}/Image.gz-${dtb_name}
cat "${DESTIMG}/Image.gz" "${new_rootfs_image_mount_dir}"/usr/lib/linux-image-*/qcom/"${dtb_name}.dtb" > "${DESTIMG}/Image.gz-${dtb_name}"
/usr/bin/mkbootimg \
--kernel ${DESTIMG}/Image.gz-${dtb_name} \
--ramdisk ${new_rootfs_image_mount_dir}/boot/initrd.img-*-* \
--kernel "${DESTIMG}/Image.gz-${dtb_name}" \
--ramdisk "${new_rootfs_image_mount_dir}"/boot/initrd.img-*-* \
--base 0x0 \
--second_offset 0x00f00000 \
--cmdline "${bootimg_cmdline}" \
--kernel_offset 0x8000 \
--ramdisk_offset 0x1000000 \
--tags_offset 0x100 \
--pagesize 4096 \
-o ${DESTIMG}/${version}.boot_${dtb_name}.img
-o "${DESTIMG}/${version}.boot_${dtb_name}.img"
done
display_alert "Creatng abl kernel boot recovery image with dtb ${ABL_DTB_LIST[0]}" "${EXTENSION}" "info"
cat ${DESTIMG}/Image.gz ${new_rootfs_image_mount_dir}/usr/lib/linux-image-*/qcom/${dtb_name}.dtb > ${DESTIMG}/Image.gz-${dtb_name}
/usr/bin/mkbootimg \
--kernel ${DESTIMG}/Image.gz-${ABL_DTB_LIST[0]} \
--ramdisk ${new_rootfs_image_mount_dir}/boot/initrd.img-*-* \
--kernel "${DESTIMG}/Image.gz-${ABL_DTB_LIST[0]}" \
--ramdisk "${new_rootfs_image_mount_dir}"/boot/initrd.img-*-* \
--base 0x0 \
--second_offset 0x00f00000 \
--kernel_offset 0x8000 \
--ramdisk_offset 0x1000000 \
--tags_offset 0x100 \
--pagesize 4096 \
-o ${DESTIMG}/${version}.boot_recovery.img
-o "${DESTIMG}/${version}.boot_recovery.img"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
fi

umount ${new_rootfs_image_mount_dir}
rm -rf ${new_rootfs_image_mount_dir}
e2fsck -p -f ${ROOTFS_IMAGE_FILE}
resize2fs -M ${ROOTFS_IMAGE_FILE}
umount "${new_rootfs_image_mount_dir}"
rm -rf "${new_rootfs_image_mount_dir}"
e2fsck -p -f "${ROOTFS_IMAGE_FILE}"
resize2fs -M "${ROOTFS_IMAGE_FILE}"
return 0
}
24 changes: 12 additions & 12 deletions extensions/lvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function extension_prepare_config__prepare_lvm() {

function post_create_partitions__setup_lvm() {
# Setup LVM on the partition, ROOTFS
parted -s ${SDCARD}.raw -- set ${rootpart} lvm on
parted -s "${SDCARD}.raw" -- set "${rootpart}" lvm on
display_alert "LVM Partition table created" "${EXTENSION}" "info"
parted -s ${SDCARD}.raw -- print >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1
parted -s "${SDCARD}.raw" -- print >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1
}

function prepare_root_device__create_volume_group() {
Expand All @@ -52,25 +52,25 @@ function prepare_root_device__create_volume_group() {

# Create the PV VG and VOL
display_alert "LVM Creating VG" "${rootdevice}" "info"
check_loop_device ${rootdevice}
pvcreate ${rootdevice}
check_loop_device "${rootdevice}"
pvcreate "${rootdevice}"
wait_for_disk_sync "wait for pvcreate to sync"
vgcreate ${LVM_VG_NAME} ${rootdevice}
vgcreate "${LVM_VG_NAME}" "${rootdevice}"
add_cleanup_handler cleanup_lvm
wait_for_disk_sync "wait for vgcreate to sync"
# Note that devices wont come up automatically inside docker
lvcreate -Zn --name root --size ${volsize}M ${LVM_VG_NAME}
lvcreate -Zn --name root --size "${volsize}M" "${LVM_VG_NAME}"
vgmknodes
lvs >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1
rootdevice=/dev/mapper/${LVM_VG_NAME}-root
lvs >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1

rootdevice="/dev/mapper/${LVM_VG_NAME}-root"
display_alert "LVM created volume group - root device ${rootdevice}" "${EXTENSION}" "info"
}

function format_partitions__format_lvm() {
# Label the root volume
e2label /dev/mapper/${LVM_VG_NAME}-root armbi_root
blkid | grep ${LVM_VG_NAME} >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1
e2label "/dev/mapper/${LVM_VG_NAME}-root" armbi_root
blkid | grep "${LVM_VG_NAME}" >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1
display_alert "LVM labeled partitions" "${EXTENSION}" "info"
}

Expand All @@ -79,6 +79,6 @@ function post_umount_final_image__cleanup_lvm(){
}

function cleanup_lvm() {
vgchange -a n ${LVM_VG_NAME} >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1 || true
vgchange -a n "${LVM_VG_NAME}" >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1 || true
display_alert "LVM deactivated volume group" "${EXTENSION}" "info"
}
12 changes: 6 additions & 6 deletions extensions/uwe5622-allwinner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ function post_family_config__add_uwe5622_modules() {

function post_family_tweaks__enable_uwe5622_services() {
# install and enable Bluetooth
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable aw859a-bluetooth.service >/dev/null 2>&1"
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable aw859a-wifi.service >/dev/null 2>&1"
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable aw859a-bluetooth.service >/dev/null 2>&1"
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable aw859a-wifi.service >/dev/null 2>&1"
}

function post_family_tweaks_bsp__add_uwe5622_services() {
run_host_command_logged mkdir -p $destination/lib/systemd/system/
run_host_command_logged cp $SRC/packages/bsp/sunxi/aw859a-bluetooth.service $destination/lib/systemd/system/
run_host_command_logged cp $SRC/packages/bsp/sunxi/aw859a-wifi.service $destination/lib/systemd/system/
run_host_command_logged install -m 755 $SRC/packages/blobs/bt/hciattach/hciattach_opi_${ARCH} $destination/usr/bin/hciattach_opi
run_host_command_logged mkdir -p "${destination}/lib/systemd/system/"
run_host_command_logged cp "${SRC}/packages/bsp/sunxi/aw859a-bluetooth.service" "${destination}/lib/systemd/system/"
run_host_command_logged cp "${SRC}/packages/bsp/sunxi/aw859a-wifi.service" "${destination}/lib/systemd/system/"
run_host_command_logged install -m 755 "${SRC}/packages/blobs/bt/hciattach/hciattach_opi_${ARCH}" "${destination}/usr/bin/hciattach_opi"
}
Loading
Loading