Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for booting Tianocore/EFI as RW_LEGACY payload #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*~
*.swp
util/
dist.tar.gz
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Install Linux onto your Chromebook. Dual-boot alongside ChromeOS for maximum fle

## status

**Version 3.0.2** See [changelog](#changelog).
**Version 3.1** See [changelog](#changelog).


<a name="usage"></a>
Expand Down Expand Up @@ -81,6 +81,7 @@ Options
-m MIRROR distribution-specific download mirror [primary]
galliumos: ny1.us, va1.us, rb1.fr
-t TARGETDISK target disk (/dev/mmcblk1, /dev/sdb, etc) []
-b BOOTLOADER bootloader (grub-pc, grub-efi-amd64) [(model-dependent)]
-p PACKAGE additional packages to install, may repeat []
kodi, minecraft, steam, etc, see chrx.org for more
(not yet supported on fedora)
Expand Down Expand Up @@ -142,7 +143,6 @@ you can quote the argument, e.g.: `-p "gimp blender inkscape"`.
`chrx -d ubuntu -e standard -r 16.04 -H hal -U dave -p admin-misc`


<!--
<a name="advanced-usage"></a>
### advanced usage

Expand All @@ -151,14 +151,23 @@ There are many good reasons to do so, especially if you'll be doing
a large number of installations. However, setup can be somewhat more
complicated, and instructions are outside the scope of this README.

To point **chrx** at your cache, just set the `CHRX_WEB_ROOT`
environment variable before running the `chrx` script, like this:
To point **chrx** at a local copy, just set the `CHRX_WEB_ROOT`
environment variable after running `bash make-dist.sh` script, like this:

```
export CHRX_WEB_ROOT="http://myserver/chrx"
cd ; curl -O $CHRX_WEB_ROOT/go && sh go
# Auto version dev appended
bash make-dist.sh
# Explicit version no dev appended
CHRX_VERSION=3.3.3 bash make-dist.sh
# manual fetch of local version
export CHRX_WEB_ROOT="http://localhost:8000/"
curl http://$CHRX_WEB_ROOT/dist.tar.gz | sudo tar xzfC - /usr/local && chrx -h
# or just source the convenience script that exports the variable and
# installs chrx, most useful if you already partitioned your disk and
# are adding a new distro or adding more testing to the installer
. fetch-install-from-local.sh
chrx -h | grep -E 'installer.*version'
```
-->

<a name="compatibility"></a>
## compatibility
Expand Down Expand Up @@ -371,5 +380,6 @@ To Jay Lee for [ChrUbuntu](http://chromeos-cr48.blogspot.fr/2013/10/chrubuntu-fo
- **3.0** (20191110): internal improvements for noexec partitions; separate HWID lists to simplify reuse and updates; new, more-complicated, command line :(
- **3.0.1** (20200530): Print useful error message if run with old command-line on older ChromeOS; Ubuntu: do not install Google Chrome by default
- **3.0.2** (20200731): Remove redundant check form RW_LEGACY via mosys
- **3.1** (20201108): Add bootloader selection and default (-b)

<!-- don't forget to update the version numbers at top and in chrx-install! -->
20 changes: 18 additions & 2 deletions chrx-install
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
# chromebook unix installer
#

CHRX_VERSION="3.0.2"
CHRX_VERSION="3.1"

CHRX_OS_DISTRO="galliumos"
CHRX_OS_ENVIRONMENT="desktop"
CHRX_OS_RELEASE="latest"
CHRX_OS_ARCH="amd64"
CHRX_OS_MIRROR="primary"
CHRX_TARGET_DISK=""
CHRX_BOOTLOADER="grub-pc"
CHRX_ADD_PKGS=
CHRX_OS="linux"
CHRX_HOSTNAME="chrx"
Expand Down Expand Up @@ -57,6 +58,7 @@ Options
-m MIRROR distribution-specific download mirror [${CHRX_OS_MIRROR}]
galliumos: ny1.us, va1.us, rb1.fr
-t TARGETDISK target disk (/dev/mmcblk1, /dev/sdb, etc) [${CHRX_TARGET_DISK}]
-b BOOTLOADER bootloader (grub-pc, grub-efi-amd64) [${CHRX_BOOTLOADER}]
-p PACKAGE additional packages to install, may repeat [${CHRX_ADD_PKGS}]
kodi, minecraft, steam, etc, see chrx.org for more
(not yet supported on fedora)
Expand Down Expand Up @@ -744,6 +746,17 @@ validate_config()
if [ "$CHRX_OS_DISTRO" != "galliumos" -a ! -z "$CHRX_OS_MIRROR" ]; then
msg_os_mirror="${ANSI_RED}unknown, will use primary${ANSI_RST}"
fi

case "${CHRX_CPUF}" in
GLK|WHL|CML) CHRX_BOOTLOADER="grub-efi-amd64" ;;
esac

[ -n "$CHRX_BOOTLOADER_ARG" ] && CHRX_BOOTLOADER=$CHRX_BOOTLOADER_ARG

case "${CHRX_BOOTLOADER}" in
grub-pc|grub-efi-amd64) ;;
*) msg_bootloader="${ANSI_RED}invalid${ANSI_RST}" ; FAIL=1 ;;
esac
}

confirm_config()
Expand All @@ -761,6 +774,7 @@ confirm_config()
architecture (-a): ${CHRX_OS_ARCH} ${msg_os_arch}
mirror (-m): ${CHRX_OS_MIRROR} ${msg_os_mirror}
target_disk (-t): ${CHRX_TARGET_DISK}
bootloader (-b): ${CHRX_BOOTLOADER} ${msg_bootloader}
packages (-p): ${CHRX_ADD_PKGS}${msg_os_pkgs}

System Configuration
Expand Down Expand Up @@ -899,6 +913,7 @@ do_install()
export CHRX_TZ CHRX_LOCALE CHRX_USERNAME
export CHRX_TARGET_DISK CHRX_ROOT_PARTITION CHRX_CACHE_DIR CHRX_INSTALL_ROOT
export CHRX_OS_RELEASE CHRX_ADD_PKGS CHRX_CONFIGURE_GRUB_ENABLED
export CHRX_BOOTLOADER
export VERBOSITY VERBOSITY_APTGET VERBOSITY_CURL VERBOSITY_DNF
export ANSI_RED ANSI_YEL ANSI_GRN ANSI_VIO ANSI_BLU ANSI_WHT ANSI_RST
export -f echo_info ## this does not reach the chroot
Expand Down Expand Up @@ -953,7 +968,7 @@ parse_opts()
{
## parse command line options
## TODO: lubuntu[-desktop[-latest]] should be parseable
while getopts ":d:e:r:a:m:t:p:H:U:L:Z:nsyvh" OPTION
while getopts ":d:e:r:a:m:t:b:p:H:U:L:Z:nsyvh" OPTION
do
case "$OPTION" in
d) CHRX_OS_DISTRO=$(downcase $OPTARG) ;;
Expand All @@ -962,6 +977,7 @@ parse_opts()
a) CHRX_OS_ARCH=$(downcase $OPTARG) ;;
m) CHRX_OS_MIRROR=$(downcase $OPTARG) ;;
t) CHRX_TARGET_DISK=$OPTARG ;;
b) CHRX_BOOTLOADER_ARG=$OPTARG ;;
p) CHRX_ADD_PKGS="${CHRX_ADD_PKGS}$(downcase $OPTARG) " ;;
H) CHRX_HOSTNAME=$OPTARG ;;
U) CHRX_USERNAME=$OPTARG ;;
Expand Down
12 changes: 10 additions & 2 deletions dist/chrx-install-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ install_curl()
install_utilities()
{
apt_get_update_if_needed
apt_get_install zram-config grub-pc
apt_get_install zram-config ${CHRX_BOOTLOADER}
}

apt_get_install()
Expand Down Expand Up @@ -612,8 +612,13 @@ install_grub()
echo_title_yel "(skipping chrx grub config)"
fi

case "${CHRX_TARGET_DISK}" in
/dev/sda*) CHRX_EFI_PARTITION="${CHRX_TARGET_DISK}12" ;;
/dev/mmcblk*|/dev/nvme*) CHRX_EFI_PARTITION="${CHRX_TARGET_DISK}p12" ;;
esac
if [[ "$CHRX_BOOTLOADER}" == *efi* ]]; then echo "EFI requested"; EFI_DIR_CMD="--removable --target=x86_64-efi --efi-directory=/boot/efi"; mkdir -p /boot/efi; mount ${CHRX_EFI_PARTITION} /boot/efi; fi
grub-install ${EFI_DIR_CMD:-} --boot-dir=/boot ${CHRX_TARGET_DISK} --force
grub-mkconfig -o /boot/grub/grub.cfg
grub-install ${CHRX_TARGET_DISK} --force

#echo -e "\n${ANSI_GRN}Purging unwanted pkgs.${ANSI_RST}"
#apt-get -y ${VERBOSITY_APTGET} purge openjade openjade1.3 jade tex-common sgml-base
Expand Down Expand Up @@ -648,6 +653,7 @@ fedora_set_selinux_autolabel()
## begin
#echo debug ; bash

do_install() {
case "${CHRX_OS_DISTRO}" in
*ubuntu)
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -741,4 +747,6 @@ esac


add_first_user
}

(return 0 2>/dev/null) && sourced=1 || sourced=0 do_install
13 changes: 13 additions & 0 deletions fetch-install-from-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
cleanup() { pkill python3; }
# Don't want previous `pkill -P $$` which would kill parent session if sourced?
# trap cleanup EXIT
export CHRX_WEB_ROOT="http://localhost:8000/"
python3 -m http.server &
sleep 3 # Lets the webserver start
curl $CHRX_WEB_ROOT/dist.tar.gz | sudo tar xzfC - /usr/local
# Only necessary if tar doesn't preserve permissions
# && sudo chmod +x /usr/local/bin/chrx*
chrx -h
chrx -h | grep -E 'installer.*version'
cleanup
33 changes: 33 additions & 0 deletions make-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -e

# If you specify a version it will get packed into the chrx-install otherwise we append a string to denote it isn't a release build
# NEED_TEST
# pseudo TEST chrx -h | grep -E 'installer.*version'
: ${CHRX_VERSION:=$(grep -E '^CHRX_VERSION=' ./chrx-install | cut -f 2 -d '='| sed -e 's/"//g')-dev}
chrx_src=$(pwd)
build_dir=$(mktemp -d -t chrx.XXX)
cleanup() { rm -rf $build_dir; }
trap cleanup EXIT
echo $build_dir
cd $build_dir
mkdir bin
cp $chrx_src/chrx* ./bin
cp $chrx_src/dist/chrx* ./bin
# NEED_TEST
# Tweak the CHRX_VERSION in chrx-install
sed -i -e '/CHRX_VERSION=/ s/CHRX_VERSION=.*/CHRX_VERSION='$CHRX_VERSION'/' ./bin/chrx-install
# Debug print updated version
grep -E '^CHRX_VERSION=' ./bin/chrx-install
# Make sure they are executable as tar should preserve this on extract
chmod -R +x ./bin
mkdir -p etc/chrx-files
mv ./bin/chrx-devices ./etc/
rm -rf $chrx_src/dist/etc/etc/
cp -r -t ./etc/chrx-files/ $chrx_src/dist/etc/
cd $chrx_src
# NEED_TEST
tar czf dist.tar.gz -C $build_dir $(ls -A $build_dir)
# Debug print contents for comparison to official chrx.org version
echo "Confirm contents"
tar tf dist.tar.gz