Update to support newer Archiso design
This commit is contained in:
parent
7ad610eaf3
commit
637673085f
17 changed files with 310 additions and 129 deletions
46
build-iso
46
build-iso
|
|
@ -1,43 +1,13 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
# Prep build env
|
||||
rsync -ahvPS /usr/share/archiso/configs/releng/ temp/
|
||||
echo 'bc' > temp/packages.both
|
||||
rm temp/airootfs/etc/systemd/scripts/choose-mirror
|
||||
rm temp/airootfs/etc/systemd/system/choose-mirror.service
|
||||
rm temp/airootfs/etc/systemd/system/etc-pacman.d-gnupg.mount
|
||||
rm temp/airootfs/etc/systemd/system/pacman-init.service
|
||||
rm temp/airootfs/etc/udev/rules.d/81-dhcpcd.rules
|
||||
rmdir --ignore-fail-on-non-empty temp/airootfs/etc/udev/rules.d
|
||||
rmdir --ignore-fail-on-non-empty temp/airootfs/etc/udev
|
||||
cp mac-dgpu-disable-tool temp/airootfs/root/
|
||||
printf "\x07\x00\x00\x00\x01\x00\x00\x00" \
|
||||
> temp/airootfs/root/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9
|
||||
chown -R root:root temp
|
||||
# Check if running as root
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
echo "This script should be run as root."
|
||||
echo "Aborted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Adjust boot menus
|
||||
sed -i 's/timeout 3/timeout 1/' temp/efiboot/loader/loader.conf
|
||||
sed -i 's/Arch Linux archiso x86_64/Mac dGPU Disable Tool/' temp/efiboot/loader/entries/*
|
||||
|
||||
sed -i '/BACKGROUND/d' temp/syslinux/*
|
||||
echo 'PROMPT 1' >> temp/syslinux/archiso_head.cfg
|
||||
echo 'TIMEOUT 1' >> temp/syslinux/archiso_head.cfg
|
||||
echo 'DEFAULT arch64' >> temp/syslinux/archiso_head.cfg
|
||||
sed -i -r 's/Arch Linux( \(x86_64\)|)( live medium|)/Mac dGPU Disable Tool/' temp/syslinux/*
|
||||
sed -i '/allows/d' temp/syslinux/*
|
||||
|
||||
# Add nomodeset boot option
|
||||
sed -i -r 's/^(options.*)$/\1 nomodeset/' temp/efiboot/loader/entries/archiso*
|
||||
sed -i -r 's/^(APPEND arch.*)$/\1 nomodeset/' temp/syslinux/*cfg
|
||||
|
||||
# Modify live env
|
||||
echo '' >> temp/airootfs/etc/motd
|
||||
sed -i '/mirror/d' temp/airootfs/root/customize_airootfs.sh
|
||||
sed -i '/usermod/d' temp/airootfs/root/customize_airootfs.sh
|
||||
sed -i '/ssh/d' temp/airootfs/root/customize_airootfs.sh
|
||||
echo 'echo "~/mac-dgpu-disable-tool" >> /root/.bashrc' \
|
||||
>> temp/airootfs/root/customize_airootfs.sh
|
||||
|
||||
temp/build.sh -N dgpu -L DGPU -v
|
||||
# Build ISO
|
||||
mkarchiso -w /tmp/archiso-tmp-dgpu -o . -v profile
|
||||
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
SOURCE=/root/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9
|
||||
DEST=/sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9
|
||||
needs_nvram_reset="no"
|
||||
|
||||
# Colors
|
||||
CLEAR='\033[0m'
|
||||
RED='\033[31m'
|
||||
GREEN='\033[32m'
|
||||
YELLOW='\033[33m'
|
||||
ORANGE='\033[31;1m'
|
||||
BLUE='\033[34m'
|
||||
|
||||
# Functions
|
||||
function beep () {
|
||||
echo -ne '\007'
|
||||
}
|
||||
function beeps_bad () {
|
||||
# SOS-like?
|
||||
beep
|
||||
sleep 0.25s
|
||||
beep
|
||||
sleep 0.25s
|
||||
beep
|
||||
|
||||
sleep 0.5s
|
||||
|
||||
beep
|
||||
sleep 0.5s
|
||||
beep
|
||||
sleep 0.5s
|
||||
beep
|
||||
|
||||
sleep 0.5s
|
||||
|
||||
beep
|
||||
sleep 0.25s
|
||||
beep
|
||||
sleep 0.25s
|
||||
beep
|
||||
}
|
||||
function beeps_good () {
|
||||
# Two quick beeps
|
||||
beep
|
||||
sleep 0.25s
|
||||
beep
|
||||
}
|
||||
|
||||
echo '## Mac dGPU Disable Tool ##'
|
||||
echo ''
|
||||
|
||||
# Check for current variables
|
||||
for prefix in gfx gpu; do
|
||||
for var in /sys/firmware/efi/efivars/${prefix}*; do
|
||||
# The test below is to avoid empty or nonexistent paths
|
||||
if [[ -e "${var}" ]]; then
|
||||
echo -e "${YELLOW}Detected:${CLEAR} $var"
|
||||
needs_nvram_reset="yes"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo ""
|
||||
if [[ ! -e "/sys/firmware/efi/efivars" ]]; then
|
||||
# Probably booted legacy
|
||||
echo -e "${RED}ERROR:${CLEAR} EFIVARS not found"
|
||||
beeps_bad
|
||||
elif cmp "$SOURCE" "$DEST" >/dev/null 2>&1; then
|
||||
# EFI var matches desired state
|
||||
echo -e "${GREEN}Discrete GPU already disabled${CLEAR}"
|
||||
beeps_good
|
||||
elif [[ "$needs_nvram_reset" == "yes" ]]; then
|
||||
# One or more gfx/gpu EFI vars detected
|
||||
echo -e "${RED}ERROR:${CLEAR} Detected the above EFIVARS"
|
||||
echo -e "Please reboot and reset the NVRAM"
|
||||
beeps_bad
|
||||
else
|
||||
# No gfx/gpu EFI vars detected so we can apply the fix
|
||||
cp "$SOURCE" "$DEST"
|
||||
chattr +i "$DEST"
|
||||
umount /sys/firmware/efi/efivars
|
||||
sync
|
||||
echo -e "${GREEN}Discrete GPU successfully disabled${CLEAR}"
|
||||
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
||||
beeps_good
|
||||
fi
|
||||
echo ""
|
||||
read -p "Press Enter to poweroff the system... " -r unusedvar
|
||||
poweroff
|
||||
1
mac-dgpu-disable-tool
Symbolic link
1
mac-dgpu-disable-tool
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
profile/airootfs/root/mac-dgpu-disable-tool
|
||||
70
profile/airootfs/etc/mkinitcpio.conf
Normal file
70
profile/airootfs/etc/mkinitcpio.conf
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# vim:set ft=sh
|
||||
# MODULES
|
||||
# The following modules are loaded before any boot hooks are
|
||||
# run. Advanced users may wish to specify all system modules
|
||||
# in this array. For instance:
|
||||
# MODULES=(piix ide_disk reiserfs)
|
||||
MODULES=()
|
||||
|
||||
# BINARIES
|
||||
# This setting includes any additional binaries a given user may
|
||||
# wish into the CPIO image. This is run last, so it may be used to
|
||||
# override the actual binaries included by a given hook
|
||||
# BINARIES are dependency parsed, so you may safely ignore libraries
|
||||
BINARIES=()
|
||||
|
||||
# FILES
|
||||
# This setting is similar to BINARIES above, however, files are added
|
||||
# as-is and are not parsed in any way. This is useful for config files.
|
||||
FILES=()
|
||||
|
||||
# HOOKS
|
||||
# This is the most important setting in this file. The HOOKS control the
|
||||
# modules and scripts added to the image, and what happens at boot time.
|
||||
# Order is important, and it is recommended that you do not change the
|
||||
# order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for
|
||||
# help on a given hook.
|
||||
# 'base' is _required_ unless you know precisely what you are doing.
|
||||
# 'udev' is _required_ in order to automatically load modules
|
||||
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
|
||||
# Examples:
|
||||
## This setup specifies all modules in the MODULES setting above.
|
||||
## No raid, lvm2, or encrypted root is needed.
|
||||
# HOOKS=(base)
|
||||
#
|
||||
## This setup will autodetect all modules for your system and should
|
||||
## work as a sane default
|
||||
# HOOKS=(base udev autodetect block filesystems)
|
||||
#
|
||||
## This setup will generate a 'full' image which supports most systems.
|
||||
## No autodetection is done.
|
||||
# HOOKS=(base udev block filesystems)
|
||||
#
|
||||
## This setup assembles a pata mdadm array with an encrypted root FS.
|
||||
## Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
|
||||
# HOOKS=(base udev block mdadm encrypt filesystems)
|
||||
#
|
||||
## This setup loads an lvm2 volume group on a usb device.
|
||||
# HOOKS=(base udev block lvm2 filesystems)
|
||||
#
|
||||
## NOTE: If you have /usr on a separate partition, you MUST include the
|
||||
# usr, fsck and shutdown hooks.
|
||||
HOOKS=(base udev modconf archiso block filesystems)
|
||||
|
||||
# COMPRESSION
|
||||
# Use this to compress the initramfs image. By default, gzip compression
|
||||
# is used. Use 'cat' to create an uncompressed image.
|
||||
#COMPRESSION="gzip"
|
||||
#COMPRESSION="bzip2"
|
||||
#COMPRESSION="lzma"
|
||||
#COMPRESSION="xz"
|
||||
#COMPRESSION="lzop"
|
||||
#COMPRESSION="lz4"
|
||||
#COMPRESSION="zstd"
|
||||
|
||||
# COMPRESSION_OPTIONS
|
||||
# Additional options for the compressor
|
||||
#COMPRESSION_OPTIONS=()
|
||||
11
profile/airootfs/etc/mkinitcpio.d/linux.preset
Normal file
11
profile/airootfs/etc/mkinitcpio.d/linux.preset
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# mkinitcpio preset file for the 'linux' package on archiso
|
||||
|
||||
PRESETS=('archiso')
|
||||
|
||||
ALL_kver='/boot/vmlinuz-linux'
|
||||
ALL_config='/etc/mkinitcpio.conf'
|
||||
|
||||
archiso_image="/boot/initramfs-linux.img"
|
||||
1
profile/airootfs/etc/shadow
Normal file
1
profile/airootfs/etc/shadow
Normal file
|
|
@ -0,0 +1 @@
|
|||
root::14871::::::
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux
|
||||
1
profile/airootfs/root/.profile
Normal file
1
profile/airootfs/root/.profile
Normal file
|
|
@ -0,0 +1 @@
|
|||
/root/mac-dgpu-disable-tool
|
||||
Binary file not shown.
49
profile/airootfs/root/mac-dgpu-disable-tool
Executable file
49
profile/airootfs/root/mac-dgpu-disable-tool
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
SOURCE=/root/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9
|
||||
DEST=/sys/firmware/efi/efivars/gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9
|
||||
needs_nvram_reset="no"
|
||||
|
||||
# Colors
|
||||
CLEAR='\033[0m'
|
||||
RED='\033[31m'
|
||||
GREEN='\033[32m'
|
||||
YELLOW='\033[33m'
|
||||
ORANGE='\033[31;1m'
|
||||
BLUE='\033[34m'
|
||||
|
||||
# Check for current variables
|
||||
for prefix in gfx gpu; do
|
||||
for var in /sys/firmware/efi/efivars/${prefix}*; do
|
||||
# The test below is to avoid empty or nonexistent paths
|
||||
if [[ -e "${var}" ]]; then
|
||||
echo -e "${YELLOW}Detected:${CLEAR} $var"
|
||||
needs_nvram_reset="yes"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo ""
|
||||
if [[ ! -e "/sys/firmware/efi/efivars" ]]; then
|
||||
# Probably booted legacy
|
||||
echo -e "${RED}ERROR:${CLEAR} EFIVARS not found"
|
||||
elif cmp "$SOURCE" "$DEST" >/dev/null 2>&1; then
|
||||
# EFI var matches desired state
|
||||
echo -e "${GREEN}Discrete GPU already disabled${CLEAR}"
|
||||
elif [[ "$needs_nvram_reset" == "yes" ]]; then
|
||||
# One or more gfx/gpu EFI vars detected
|
||||
echo -e "${RED}ERROR:${CLEAR} Detected the above EFIVARS"
|
||||
echo -e "Please reboot and reset the NVRAM"
|
||||
else
|
||||
# No gfx/gpu EFI vars detected so we can apply the fix
|
||||
cp "$SOURCE" "$DEST"
|
||||
chattr +i "$DEST"
|
||||
sync
|
||||
umount /sys/firmware/efi/efivars
|
||||
echo -e "${GREEN}Discrete GPU successfully disabled${CLEAR}"
|
||||
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
||||
fi
|
||||
echo ""
|
||||
read -p "Press Enter to poweroff the system... " -r unusedvar
|
||||
poweroff
|
||||
2
profile/bootstrap_packages.x86_64
Normal file
2
profile/bootstrap_packages.x86_64
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
arch-install-scripts
|
||||
base
|
||||
7
profile/efiboot/loader/entries/dgpu.conf
Normal file
7
profile/efiboot/loader/entries/dgpu.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
title Mac dGPU Disable Tool
|
||||
linux /%INSTALL_DIR%/boot/x86_64/vmlinuz-linux
|
||||
initrd /%INSTALL_DIR%/boot/x86_64/initramfs-linux.img
|
||||
options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nomodeset
|
||||
5
profile/efiboot/loader/loader.conf
Normal file
5
profile/efiboot/loader/loader.conf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
timeout 0
|
||||
default dgpu.conf
|
||||
11
profile/packages.x86_64
Normal file
11
profile/packages.x86_64
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
base
|
||||
#cloud-init
|
||||
linux
|
||||
mkinitcpio
|
||||
mkinitcpio-archiso
|
||||
#openssh
|
||||
#qemu-guest-agent
|
||||
syslinux
|
||||
#virtualbox-guest-utils-nox
|
||||
102
profile/pacman.conf
Normal file
102
profile/pacman.conf
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#
|
||||
# /etc/pacman.conf
|
||||
#
|
||||
# See the pacman.conf(5) manpage for option and repository directives
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#
|
||||
# GENERAL OPTIONS
|
||||
#
|
||||
[options]
|
||||
# The following paths are commented out with their default values listed.
|
||||
# If you wish to use different paths, uncomment and update the paths.
|
||||
#RootDir = /
|
||||
#DBPath = /var/lib/pacman/
|
||||
#CacheDir = /var/cache/pacman/pkg/
|
||||
#LogFile = /var/log/pacman.log
|
||||
#GPGDir = /etc/pacman.d/gnupg/
|
||||
#HookDir = /etc/pacman.d/hooks/
|
||||
HoldPkg = pacman glibc
|
||||
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
|
||||
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
|
||||
#CleanMethod = KeepInstalled
|
||||
Architecture = auto
|
||||
|
||||
# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
|
||||
#IgnorePkg =
|
||||
#IgnoreGroup =
|
||||
|
||||
#NoUpgrade =
|
||||
#NoExtract =
|
||||
|
||||
# Misc options
|
||||
#UseSyslog
|
||||
#Color
|
||||
#TotalDownload
|
||||
# We cannot check disk space from within a chroot environment
|
||||
#CheckSpace
|
||||
#VerbosePkgLists
|
||||
|
||||
# By default, pacman accepts packages signed by keys that its local keyring
|
||||
# trusts (see pacman-key and its man page), as well as unsigned packages.
|
||||
SigLevel = Required DatabaseOptional
|
||||
LocalFileSigLevel = Optional
|
||||
#RemoteFileSigLevel = Required
|
||||
|
||||
# NOTE: You must run `pacman-key --init` before first using pacman; the local
|
||||
# keyring can then be populated with the keys of all official Arch Linux
|
||||
# packagers with `pacman-key --populate archlinux`.
|
||||
|
||||
#
|
||||
# REPOSITORIES
|
||||
# - can be defined here or included from another file
|
||||
# - pacman will search repositories in the order defined here
|
||||
# - local/custom mirrors can be added here or in separate files
|
||||
# - repositories listed first will take precedence when packages
|
||||
# have identical names, regardless of version number
|
||||
# - URLs will have $repo replaced by the name of the current repo
|
||||
# - URLs will have $arch replaced by the name of the architecture
|
||||
#
|
||||
# Repository entries are of the format:
|
||||
# [repo-name]
|
||||
# Server = ServerName
|
||||
# Include = IncludePath
|
||||
#
|
||||
# The header [repo-name] is crucial - it must be present and
|
||||
# uncommented to enable the repo.
|
||||
#
|
||||
|
||||
# The testing repositories are disabled by default. To enable, uncomment the
|
||||
# repo name header and Include lines. You can add preferred servers immediately
|
||||
# after the header, and they will be used before the default mirrors.
|
||||
|
||||
#[testing]
|
||||
#Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
[core]
|
||||
Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
[extra]
|
||||
Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
#[community-testing]
|
||||
#Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
[community]
|
||||
Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
# If you want to run 32 bit applications on your x86_64 system,
|
||||
# enable the multilib repositories as required here.
|
||||
|
||||
#[multilib-testing]
|
||||
#Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
#[multilib]
|
||||
#Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
# An example of a custom package repository. See the pacman manpage for
|
||||
# tips on creating your own repositories.
|
||||
#[custom]
|
||||
#SigLevel = Optional TrustAll
|
||||
#Server = file:///home/custompkgs
|
||||
19
profile/profiledef.sh
Normal file
19
profile/profiledef.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
iso_name="dgpu"
|
||||
iso_label="DGPU_$(date +%Y-%m-%d)"
|
||||
iso_publisher="https://github.com/2Shirt/Mac-dGPU-Disable-Tool"
|
||||
iso_application="Mac dGPU Disable Tool"
|
||||
iso_version="$(date +%Y-%m-%d)"
|
||||
install_dir="dgpu"
|
||||
buildmodes=('iso')
|
||||
bootmodes=('bios.syslinux.mbr' 'bios.syslinux.eltorito' 'uefi-x64.systemd-boot.esp' 'uefi-x64.systemd-boot.eltorito')
|
||||
arch="x86_64"
|
||||
pacman_conf="pacman.conf"
|
||||
airootfs_image_type="squashfs"
|
||||
airootfs_image_tool_options=('-comp' 'xz' '-Xbcj' 'x86' '-b' '1M' '-Xdict-size' '1M')
|
||||
file_permissions=(
|
||||
["/etc/shadow"]="0:0:400"
|
||||
["/root/mac-dgpu-disable-tool"]="0:0:700"
|
||||
)
|
||||
8
profile/syslinux/syslinux-dgpu.cfg
Normal file
8
profile/syslinux/syslinux-dgpu.cfg
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
LABEL dgpu
|
||||
MENU LABEL Mac dGPU Disable Tool
|
||||
LINUX /%INSTALL_DIR%/boot/%ARCH%/vmlinuz-linux
|
||||
INITRD /%INSTALL_DIR%/boot/%ARCH%/initramfs-linux.img
|
||||
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nomodeset
|
||||
12
profile/syslinux/syslinux.cfg
Normal file
12
profile/syslinux/syslinux.cfg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
SERIAL 0 115200
|
||||
UI menu.c32
|
||||
MENU TITLE dGPU Tool
|
||||
MENU CLEAR
|
||||
|
||||
DEFAULT dgpu
|
||||
TIMEOUT 0
|
||||
|
||||
INCLUDE syslinux-dgpu.cfg
|
||||
Loading…
Reference in a new issue