various build script improvements and fixes
This commit is contained in:
parent
a67bb493af
commit
16000d09e2
|
@ -23,6 +23,8 @@ A clear and concise description of what you expected to happen.
|
|||
**Screenshots / Photos**
|
||||
If applicable, add screenshots or photos to help explain your problem.
|
||||
|
||||
If you are reporting an issue with the build process, please run the scripts in debug mode by putting `DEBUG=1` before the build commmand, like `sudo DEBUG=1 ./build_complete.sh`.
|
||||
|
||||
**Target Chrome OS Device (please complete the following information):**
|
||||
- Board Name (e.g. dedede)
|
||||
- Device Name (e.g. drawcia)
|
||||
|
|
|
@ -72,6 +72,7 @@ PRs and contributions are welcome to help implement these features.
|
|||
### Prerequisites:
|
||||
- A separate Linux PC for the build process (preferably something Debian-based)
|
||||
- WSL2 is supported if you are on Windows
|
||||
- Github Codespaces is not supported at the moment
|
||||
- A USB drive that is at least 8GB in size
|
||||
- At least 20GB of free disk space
|
||||
- An x86-based Chromebook
|
||||
|
|
|
@ -10,6 +10,7 @@ print_help() {
|
|||
echo " quiet - Don't use progress indicators which may clog up log files."
|
||||
echo " desktop - The desktop environment to install. This defaults to 'xfce'. Valid options include:"
|
||||
echo " gnome, xfce, kde, lxde, gnome-flashback, cinnamon, mate, lxqt"
|
||||
echo " data_dir - The working directory for the scripts. This defaults to ./data"
|
||||
}
|
||||
|
||||
assert_root
|
||||
|
@ -20,13 +21,14 @@ compress_img="${args['compress_img']}"
|
|||
rootfs_dir="${args['rootfs_dir']}"
|
||||
quiet="${args['quiet']}"
|
||||
desktop="${args['desktop']-'xfce'}"
|
||||
data_dir="${args['data_dir']}"
|
||||
|
||||
needed_deps="wget python3 unzip zip git debootstrap cpio binwalk pcregrep cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
|
||||
needed_deps="wget python3 unzip zip git debootstrap cpio binwalk pcregrep cgpt mkfs.ext4 mkfs.ext2 fdisk rsync depmod findmnt"
|
||||
if [ "$(check_deps "$needed_deps")" ]; then
|
||||
#install deps automatically on debian and ubuntu
|
||||
if [ -f "/etc/debian_version" ]; then
|
||||
echo "attempting to install build deps"
|
||||
apt-get install wget python3-all unzip zip debootstrap cpio binwalk pcregrep cgpt rsync pv -y
|
||||
apt-get install wget python3-all unzip zip debootstrap cpio binwalk pcregrep cgpt rsync kmod pv -y
|
||||
fi
|
||||
assert_deps "$needed_deps"
|
||||
fi
|
||||
|
@ -45,6 +47,12 @@ board="$1"
|
|||
shim_url="https://dl.darkn.bio/api/raw/?path=/SH1mmer/$board.zip"
|
||||
boards_url="https://chromiumdash.appspot.com/cros/fetch_serving_builds?deviceCategory=ChromeOS"
|
||||
|
||||
if [ -z "$data_dir" ]; then
|
||||
data_dir="$base_dir/data"
|
||||
else
|
||||
data_dir="$(realpath -m "$data_dir")"
|
||||
fi
|
||||
|
||||
echo "downloading list of recovery images"
|
||||
reco_url="$(wget -qO- --show-progress $boards_url | python3 -c '
|
||||
import json, sys
|
||||
|
@ -59,11 +67,11 @@ print(reco_url)
|
|||
' $board)"
|
||||
echo "found url: $reco_url"
|
||||
|
||||
shim_bin="$base_dir/data/shim_$board.bin"
|
||||
shim_zip="$base_dir/data/shim_$board.zip"
|
||||
reco_bin="$base_dir/data/reco_$board.bin"
|
||||
reco_zip="$base_dir/data/reco_$board.zip"
|
||||
mkdir -p "$base_dir/data"
|
||||
shim_bin="$data_dir/shim_$board.bin"
|
||||
shim_zip="$data_dir/shim_$board.zip"
|
||||
reco_bin="$data_dir/reco_$board.bin"
|
||||
reco_zip="$data_dir/reco_$board.zip"
|
||||
mkdir -p "$data_dir"
|
||||
|
||||
download_and_unzip() {
|
||||
local url="$1"
|
||||
|
@ -107,6 +115,9 @@ download_and_unzip $shim_url $shim_zip $shim_bin
|
|||
if [ ! "$rootfs_dir" ]; then
|
||||
rootfs_dir="$(realpath -m data/rootfs_$board)"
|
||||
desktop_package="task-$desktop-desktop"
|
||||
if [ "$(findmnt -T "$rootfs_dir/dev")" ]; then
|
||||
sudo umount -l $rootfs_dir/* 2>/dev/null || true
|
||||
fi
|
||||
rm -rf $rootfs_dir
|
||||
mkdir -p $rootfs_dir
|
||||
|
||||
|
@ -122,13 +133,13 @@ echo "patching debian rootfs"
|
|||
retry_cmd ./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir "quiet=$quiet"
|
||||
|
||||
echo "building final disk image"
|
||||
final_image="$base_dir/data/shimboot_$board.bin"
|
||||
final_image="$data_dir/shimboot_$board.bin"
|
||||
rm -rf $final_image
|
||||
retry_cmd ./build.sh $final_image $shim_bin $rootfs_dir "quiet=$quiet"
|
||||
echo "build complete! the final disk image is located at $final_image"
|
||||
|
||||
if [ "$compress_img" ]; then
|
||||
image_zip="$base_dir/data/shimboot_$board.zip"
|
||||
image_zip="$data_dir/shimboot_$board.zip"
|
||||
echo "compressing disk image into a zip file"
|
||||
zip -j $image_zip $final_image
|
||||
echo "finished compressing the disk file"
|
||||
|
|
|
@ -23,7 +23,7 @@ print_help() {
|
|||
}
|
||||
|
||||
assert_root
|
||||
assert_deps "realpath debootstrap"
|
||||
assert_deps "realpath debootstrap findmnt"
|
||||
assert_args "$2"
|
||||
parse_args "$@"
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
create_loop() {
|
||||
local loop_device=$(losetup -f)
|
||||
if [ ! -b "$loop_device" ]; then
|
||||
#we might run out of loop devices, see https://stackoverflow.com/a/66020349
|
||||
local major=$(grep loop /proc/devices | cut -c3)
|
||||
local number="$(echo "$loop_device" | grep -Eo '[0-9]+' | tail -n1)"
|
||||
mknod $loop_device b $major $number
|
||||
fi
|
||||
losetup -P $loop_device "${1}"
|
||||
echo $loop_device
|
||||
}
|
||||
|
@ -65,10 +71,18 @@ partition_disk() {
|
|||
}
|
||||
|
||||
safe_mount() {
|
||||
umount $2 2> /dev/null || /bin/true
|
||||
rm -rf $2
|
||||
mkdir -p $2
|
||||
mount $1 $2
|
||||
local source="$1"
|
||||
local dest="$2"
|
||||
local opts="$3"
|
||||
|
||||
umount $dest 2> /dev/null || /bin/true
|
||||
rm -rf $dest
|
||||
mkdir -p $dest
|
||||
if [ "$opts" ]; then
|
||||
mount $source $dest -o $dest
|
||||
else
|
||||
mount $source $dest
|
||||
fi
|
||||
}
|
||||
|
||||
create_partitions() {
|
||||
|
|
|
@ -44,7 +44,7 @@ systemctl enable kill-frecon.service
|
|||
|
||||
#install base packages
|
||||
if [ -z "$disable_base_pkgs" ]; then
|
||||
apt-get install -y cloud-utils zram-tools sudo command-not-found
|
||||
apt-get install -y cloud-utils zram-tools sudo command-not-found bash-completion
|
||||
|
||||
#set up zram
|
||||
echo "ALGO=lzo" >> /etc/default/zramswap
|
||||
|
|
Loading…
Reference in New Issue