Add missing live-macos branch

This was not being pushed from a testing MacBook so I'm adding it all
at once. This is unfinished, still needs scripts to prep the working
macOS env from which the live env is built.

El Capitan code is likely to be dropped completely. Installing or
compiling dependencies in brew is problematic at this point.
This commit is contained in:
2Shirt 2021-03-26 01:18:08 -06:00
parent ae42634a8e
commit 5b4139e3c8
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
10 changed files with 399 additions and 0 deletions

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Buttons</key>
<array>
<dict>
<key>BundlePath</key>
<string>/Applications/iTerm.app</string>
<key>DescriptionKey</key>
<string>Hardware Diagnostics</string>
<key>Path</key>
<string>/Applications/iTerm.app/Contents/MacOS/iTerm2</string>
<key>TitleKey</key>
<string>WizardKit: Hardware Diagnostics</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/Applications/Utilities/Disk Utility.app</string>
<key>DescriptionKey</key>
<string>Repair or erase a volume.</string>
<key>Path</key>
<string>/Applications/Utilities/Disk Utility.app/Contents/MacOS/Disk Utility</string>
<key>TitleKey</key>
<string>Disk Utility</string>
</dict>
</array>
<key>Menu</key>
<array>
<dict>
<key>BundlePath</key>
<string>/Applications/Utilities/Firmware Password Utility.app</string>
<key>Path</key>
<string>/Applications/Utilities/Firmware Password Utility.app/Contents/MacOS/Firmware Password Utility</string>
<key>TitleKey</key>
<string>Firmware Password Utility</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/System/Library/CoreServices/Applications/Network Utility.app</string>
<key>Path</key>
<string>/System/Library/CoreServices/Applications/Network Utility.app/Contents/MacOS/Network Utility</string>
<key>TitleKey</key>
<string>Network Utility</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/System/Library/CoreServices/Applications/RAID Utility.app</string>
<key>Path</key>
<string>/System/Library/CoreServices/Applications/RAID Utility.app/Contents/MacOS/RAID Utility</string>
<key>Show If</key>
<dict>
<key>Selector</key>
<string>shouldShowRAIDUtility</string>
</dict>
<key>TitleKey</key>
<string>RAID Utility</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/Applications/Utilities/Terminal.app</string>
<key>Path</key>
<string>/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal</string>
<key>TitleKey</key>
<string>Terminal</string>
</dict>
</array>
</dict>
</plist>

Binary file not shown.

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Buttons</key>
<array>
<dict>
<key>BundlePath</key>
<string>/Applications/iTerm-2.app</string>
<key>DescriptionKey</key>
<string>Hardware Diagnostics</string>
<key>Path</key>
<string>/Applications/iTerm-2.app/Contents/MacOS/iTerm2</string>
<key>TitleKey</key>
<string>WizardKit: Hardware Diagnostics</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/Applications/Utilities/Disk Utility.app</string>
<key>DescriptionKey</key>
<string>Repair or erase a volume.</string>
<key>Path</key>
<string>/Applications/Utilities/Disk Utility.app/Contents/MacOS/Disk Utility</string>
<key>TitleKey</key>
<string>Disk Utility</string>
</dict>
</array>
<key>Menu</key>
<array>
<dict>
<key>BundlePath</key>
<string>/Applications/Utilities/Firmware Password Utility.app</string>
<key>Path</key>
<string>/Applications/Utilities/Firmware Password Utility.app/Contents/MacOS/Firmware Password Utility</string>
<key>TitleKey</key>
<string>Firmware Password Utility</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/System/Library/CoreServices/Applications/Network Utility.app</string>
<key>Path</key>
<string>/System/Library/CoreServices/Applications/Network Utility.app/Contents/MacOS/Network Utility</string>
<key>TitleKey</key>
<string>Network Utility</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/System/Library/CoreServices/Applications/RAID Utility.app</string>
<key>Path</key>
<string>/System/Library/CoreServices/Applications/RAID Utility.app/Contents/MacOS/RAID Utility</string>
<key>Show If</key>
<dict>
<key>Selector</key>
<string>shouldShowRAIDUtility</string>
</dict>
<key>TitleKey</key>
<string>RAID Utility</string>
</dict>
<dict>
<key>BundlePath</key>
<string>/Applications/Utilities/Terminal.app</string>
<key>Path</key>
<string>/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal</string>
<key>TitleKey</key>
<string>Terminal</string>
</dict>
</array>
</dict>
</plist>

16
setup/macos/aliases Normal file
View file

@ -0,0 +1,16 @@
alias cdtmp='cd "$(mktemp -d)"'
alias du='du -sch'
alias fix-perms='find -type d -exec chmod 755 "{}" \; && find -type f -exec chmod 644 "{}" \;'
alias less='less -S'
alias mkdir='mkdir -p'
alias mv='mv -nv'
alias q1=' ls -1'
alias q1a=' ls -1A'
alias q=' ls -lh'
alias qa=' ls -lAh'
alias qs=' ls'
alias qsa=' ls -A'
alias rm='rm -v'
alias rmdirs='find -depth -mindepth 1 -type d -exec rmdir "{}" --ignore-fail-on-non-empty \;'
alias tmux='tmux -f /etc/tmux.conf -S /Volumes/RAM_Disk/.tmux.socket'
alias vim='vim -u /.vimrc'

14
setup/macos/bashrc Normal file
View file

@ -0,0 +1,14 @@
export HOME=/Volumes/RAM_Disk
# Set Locale
LC_ALL=en_US.UTF-8; export LC_ALL
LANG=en_US.UTF-8; export LANG
# Set PATH
for p in /usr{/local/opt/{e2fsprogs,ruby,util-linux},/local,}/{bin,sbin}; do
PATH="${p}:${PATH}"
done
export PATH
# Aliases
source /.aliases

Binary file not shown.

25
setup/macos/live-macos-startup Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
#
## Init macOS env
# Set Locale
LC_ALL=en_US.UTF-8; export LC_ALL
LANG=en_US.UTF-8; export LANG
# Set PATH
for p in /usr{/local/opt/{e2fsprogs,ruby,util-linux},/local,}/{bin,sbin}; do
PATH="${p}:${PATH}"
done
export PATH
# Create and mount RAMDisk
if ! [ -d /Volumes/RAM_Disk ]; then
diskutil erasevolume HFS+ RAM_Disk $(hdiutil attach -nomount ram://524288)
fi
cd /Volumes/RAM_Disk
# Stay awake
caffeinate -id &
# Run cmd
"$1"

100
setup/macos/update-base-image Executable file
View file

@ -0,0 +1,100 @@
#!/bin/bash
#
## Update BaseImage for use as WK
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
# Prep
echo "Initializing..."
BASE_IMAGE="$1"
IMAGE_DEV="$(hdiutil attach "${BASE_IMAGE}" | grep -Eo '(/dev/disk[0-9]+)\b')"
OS_VERSION="$(ls /Volumes/*Base\ System | grep -E 'OS X|macOS' | sed -E 's/Install (OS X|macOS) (.*)\.app/\2/')"
OUT_NAME="${HOME}/Desktop/WK ${OS_VERSION} ($(date +"%Y-%m-%d"))"
WK_PATH="/Volumes/WK_UFD"
# Convert to a 4 GB R/W image
echo "Creating read-write copy of the ${OS_VERSION} Base System image..."
hdiutil create -srcdevice "${IMAGE_DEV}s1" -format UDSB "${OUT_NAME}.sparsebundle"
hdiutil detach "${IMAGE_DEV}"
hdiutil resize -size 4g "${OUT_NAME}.sparsebundle"
hdiutil attach "${OUT_NAME}.sparsebundle"
diskutil rename "OS X Base System" "WK_UFD"
# Remove Install app
echo "Removing Install app..."
rm -R "${WK_PATH}"/Install*.app
# Update Utilities menu
echo "Updating Utilities menu..."
if [[ "${OS_VERSION}" == "El Capitan" ]]; then
cp -a "El Capitan/Utilities.plist" "${WK_PATH}/System/Installation/CDIS/OS X Utilities.app/Contents/Resources/Utilities.plist"
else
cp -a Utilities.plist "${WK_PATH}/System/Installation/CDIS/macOS Utilities.app/Contents/Resources/Utilities.plist"
fi
# Homebrew
echo "Installing Hombrew..."
mkdir -p "${WK_PATH}/usr/local/bin"
ln -s python3 "${WK_PATH}/usr/local/bin/python"
rsync -aS /opt/ "${WK_PATH}/opt"/
rsync -aS --exclude='.git*' /usr/local/{Cellar,Frameworks,Homebrew,bin,etc,include,lib,libexec,opt,sbin,share,var} "${WK_PATH}/usr/local"/
# Fonts
echo "Installing Fonts..."
cp -a /Library/Fonts/Inconsolata*ttf "${WK_PATH}/System/Library/Fonts"/
# iTerm2
echo "Installing iTerm2..."
if [[ "${OS_VERSION}" == "El Capitan" ]]; then
rsync -aS /Applications/iTerm.app "${WK_PATH}/Applications"/
rsync -aS "El Capitan/com.googlecode.iterm2.plist" "${WK_PATH}/var/root/Library/Preferences"/
else
rsync -aS /Applications/iTerm-2.app "${WK_PATH}/Applications"/
rsync -aS com.googlecode.iterm2.plist "${WK_PATH}/var/root/Library/Preferences"/
rsync -aS /usr/lib/lib{apr,expat,ffi}* /Volumes/WK_UFD/usr/lib/
rsync -aS /System/Library/Frameworks/{MetalKit,Quartz*}.framework "${WK_PATH}/System/Library/Frameworks"/
fi
cp -a ../linux/include/airootfs/etc/skel/.tmux.conf "${WK_PATH}/etc/tmux.conf"
rsync -aS /System/Library/Colors/System.clr "${WK_PATH}/System/Library/Colors"/
rsync -aS /System/Library/Frameworks/{Scripting,ScriptingBridge,LocalAuthentication}.framework "${WK_PATH}/System/Library/Frameworks"/
rsync -aS /usr/bin/locale "${WK_PATH}/usr/bin"/
rsync -aLS /usr/share/locale/en_US.UTF-8 "${WK_PATH}/usr/share/locale"/
# pipes-sh
echo "Installing pipes.sh..."
cp -a /usr/bin/tput "${WK_PATH}/usr/bin"/
# Timezones
if [[ ! -d "/var/db/timezone" ]]; then
echo "Installing timezones..."
rsync -aS /var/db/timezone "${WK_PATH}/var/db"/
fi
# zsh
echo "Installing zsh..."
cp -a /bin/zsh "${WK_PATH}/bin"/
rsync -aS /usr/lib/zsh "${WK_PATH}/usr/lib"/
rsync -aS /usr/share/zsh "${WK_PATH}/usr/share"/
rsync -aS /usr/local/share/zsh "${WK_PATH}/usr/local/share"/
# Misc
cp -a aliases "${WK_PATH}/.aliases"
cp -a bashrc "${WK_PATH}/etc/profile"
cp -a vimrc "${WK_PATH}/.vimrc"
cp -a zshrc "${WK_PATH}/etc/zshenv"
# WizardKit
echo "Installing WizardKit env..."
touch "${WK_PATH}/.wk-live-macos"
ln -s /Volumes/RAM_Disk/Logs "${WK_PATH}/var/root/Logs"
cp -a ../../images/macOS.png "${WK_PATH}/usr/local/wallpaper.png"
rsync -aS /usr/bin/{env,killall} "${WK_PATH}/usr/bin"/
rsync -aS live-macos-startup ../../scripts/ "${WK_PATH}/usr/local/bin"/
# Convert to compressed read-only image
#echo "Converting to read-only image..."
#hdiutil convert -format UDZO -o "${OUT_NAME}.sparsebundle" "${OUT_NAME}.dmg"
# TODO

81
setup/macos/vimrc Normal file
View file

@ -0,0 +1,81 @@
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
" 2Shirt Stuff
set autoindent " align the new line indent with the previous line
set expandtab " insert spaces when hitting TABs
set nowrap " I'd rather manually wrap than manually unwrap
set shiftround " round indent to multiple of 'shiftwidth'
set shiftwidth=2 " operation >> indents 2 columns; << unindents 2 columns
set softtabstop=2 " insert/delete 2 spaces when hitting a TAB/BACKSPACE
set tabstop=2 " an hard TAB displays as 2 columns
" Python Stuff.
au FileType python set textwidth=79 " lines longer than 79 columns will be broken
au FileType python call matchadd('ColorColumn', '\%80v')
" Do wrap stuff
au FileType mail set wrap
au FileType text set wrap
" Enable code folding
set foldmethod=indent
" Keep all folds open when a file is opened
augroup OpenAllFoldsOnFileOpen
autocmd!
autocmd BufRead * normal zR
augroup END
" macOS stuff
set backspace=indent,eol,start
set ruler

25
setup/macos/zshrc Normal file
View file

@ -0,0 +1,25 @@
export HOME=/Volumes/RAM_Disk
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export EDITOR='vim'
export VISUAL='vim'
export PAGER='less'
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_DIRS="/etc/xdg"
export XDG_CONFIG_HOME="/"
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
export XDG_DATA_HOME="$HOME/.local/share"
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
path=(
/usr/local/opt/{e2fsprogs,ruby,util-linux}/{bin,sbin}
/usr/local/{bin,sbin}
$path
)
## Load aliases
. "/.aliases"