diff --git a/img-gen.sh b/img-gen.sh index 0ce031e3..fae6a468 100755 --- a/img-gen.sh +++ b/img-gen.sh @@ -11,49 +11,48 @@ fdisk -l "${IMAGE_FILE}" LOOPX=$(sudo losetup -f) sudo losetup -P "${LOOPX}" "${IMAGE_FILE}" -echo "Mounting image file" -mkdir -p "/tmp/p1" -mkdir -p "/tmp/p3" -sudo mount ${LOOPX}p1 "/tmp/p1" -sudo mount ${LOOPX}p3 "/tmp/p3" +echo "Mounting Image File" +sudo rm -rf "/tmp/files/p1" +sudo rm -rf "/tmp/files/p3" +sudo mkdir -p "/tmp/files/p1" +sudo mkdir -p "/tmp/files/p3" +sudo mount ${LOOPX}p1 "/tmp/files/p1" +sudo mount ${LOOPX}p3 "/tmp/files/p3" echo "Get Buildroot" read -rp 'Version (2023.02.x): ' br_version [ -z "${br_version}" ] && br_version="2023.02.x" -getBuildroot "${br_version}" "br" -[ ! -f "br/bzImage-arc" ] || [ ! -f "br/initrd-arc" ] && return 1 +[[ ! -f "br/bzImage-arc" || ! -f "br/initrd-arc" ]] && getBuildroot "${br_version}" "br" +[[ ! -f "br/bzImage-arc" || ! -f "br/initrd-arc" ]] && return 1 VERSION=$(date +'%y.%-m.dev') echo "${VERSION}" >files/p1/ARC-VERSION echo "${VERSION}" >VERSION sed 's/^ARC_VERSION=.*/ARC_VERSION="'${VERSION}'"/' -i files/initrd/opt/arc/include/consts.sh -echo "Repack initrd" -cp -f "br/bzImage-arc" "/tmp/p3/bzImage-arc" -repackInitrd "br/initrd-arc" "files/initrd" "/tmp/p3/initrd-arc" +read -rp "Build: ${VERSION}? Press ENTER to continue" -# Get extractor, LKM, addons and Modules -getExtractor "files/p3/extractor" -getLKMs "files/p3/lkms" true -getAddons "files/p3/addons" true -getExtensions "files/p3/extensions" true -getModules "files/p3/modules" true -getConfigs "files/p3/configs" true -getPatches "files/p3/patches" true +echo "Repack initrd" +sudo cp -f "br/bzImage-arc" "/tmp/files/p3/bzImage-arc" +repackInitrd "br/initrd-arc" "files/initrd" "/tmp/files/p3/initrd-arc" echo "Copying files" -sudo cp -Rf "files/p1/"* "/tmp/p1" -sudo cp -Rf "files/p3/"* "/tmp/p3" - -read -r -p "Subrepos loaded. Press ENTER to continue" +sudo cp -Rf "files/p1/"* "/tmp/files/p1" +sudo cp -Rf "files/p3/"* "/tmp/files/p3" +# Get extractor, LKM, addons and Modules +getExtractor "/tmp/files/p3/extractor" +getLKMs "/tmp/files/p3/lkms" true +getAddons "/tmp/files/p3/addons" true +getExtensions "/tmp/files/p3/extensions" true +getModules "/tmp/files/p3/modules" true +getConfigs "/tmp/files/p3/configs" true +getPatches "/tmp/files/p3/patches" true sync -echo "Unmount image file" -sudo umount "/tmp/p1" -sudo umount "/tmp/p3" -rmdir "/tmp/p1" -rmdir "/tmp/p3" +echo "Unmount Image File" +sudo umount "/tmp/files/p1" +sudo umount "/tmp/files/p3" sudo losetup --detach ${LOOPX}