From 0b64ff5db42121fec07b9e2294af8c46d36aa328 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 8 Feb 2023 15:44:01 -0600 Subject: Initial commit --- examples/emacs | 37 +++++++ examples/golang | 2 + examples/keepassxc | 27 +++++ examples/lieer | 21 ++++ examples/notmuch | 8 ++ examples/tree-sitter | 4 + misc | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 376 insertions(+) create mode 100644 examples/emacs create mode 100644 examples/golang create mode 100644 examples/keepassxc create mode 100644 examples/lieer create mode 100644 examples/notmuch create mode 100644 examples/tree-sitter create mode 100755 misc diff --git a/examples/emacs b/examples/emacs new file mode 100644 index 0000000..e7348db --- /dev/null +++ b/examples/emacs @@ -0,0 +1,37 @@ +# misc :: Emacs -*- bash-ts -*- + +# Variables + +SOURCE=git://git.sv.gnu.org/emacs.git +CHECKOUT=emacs-29 + +CONFIGURE_ARGS=( + --prefix="$MISC_INSTALL_PREFIX" + --with-cairo + --with-file-notification=inotify + --with-imagemagick + --with-json + --with-native-compilation=aot # Emacs 29 + --with-tree-sitter=yes # requires tree-sitter + --with-x + --with-x-toolkit=lucid + --with-xinput2 + --with-xml2 + # --with-xwidgets # requires gtk3 + --without-gconf + --without-gsettings +) + +MISC_DEPENDENCIES=( + tree-sitter +) + +# Plan + +install_deps +repo_pull +repo_ready extraclean + +with_repo ./autogen.sh +configure +make_install bootstrap diff --git a/examples/golang b/examples/golang new file mode 100644 index 0000000..65265be --- /dev/null +++ b/examples/golang @@ -0,0 +1,2 @@ +# golang -*- bash-ts -*- + diff --git a/examples/keepassxc b/examples/keepassxc new file mode 100644 index 0000000..cd3cf42 --- /dev/null +++ b/examples/keepassxc @@ -0,0 +1,27 @@ +# keepassxc -*- bash-ts -*- + +SOURCE=https://github.com/keepassxreboot/keepassxc.git + +# This is a cmake program + +CMAKE_ARGS=( + -DCMAKE_INSTALL_PREFIX="$MISC_INSTALL_PREFIX" + -DCMAKE_BUILD_TYPE="Release" + # Features + -DWITH_XC_AUTOTYPE="ON" # Auto-Type + -DWITH_XC_YUBIKEY="OFF" # YubiKey HMAC-SHA1 authentication support + -DWITH_XC_BROWSER="ON" # KeePassXC-Browser extension support + -DWITH_XC_NETWORKING="ON" # Networking support + -DWITH_XC_SSHAGENT="ON" # SSHAgent support + -DWITH_XC_FDOSECRETS="ON" # Freedesktop.org Secrets Service support + -DWITH_XC_KEESHARE="OFF" # KeeShare group synchronization extension + -DWITH_XC_UPDATECHECK="OFF" # Enable/Disable automatic updating checking +) + +# Plan + +repo_pull latest +repo_ready + +with_repo '{ mkdir build; cd build; cmake "${CMAKE_ARGS[@]}" ..; }' +_make install diff --git a/examples/lieer b/examples/lieer new file mode 100644 index 0000000..6c90e64 --- /dev/null +++ b/examples/lieer @@ -0,0 +1,21 @@ +# lieer -*- bash-ts -*- + +SOURCE=https://github.com/gauteh/lieer + +APT_DEPENDENCIES=( + python3 + libnotmuch-dev + # hopefully pip will install the rest +) + +# Don't error when we don't have a virtualenv. +export PIP_REQUIRE_VIRTUALENV=false + +# Plan + +install_deps +repo_pull +repo_ready + +with_repo pip3 install --user . + diff --git a/examples/notmuch b/examples/notmuch new file mode 100644 index 0000000..00db730 --- /dev/null +++ b/examples/notmuch @@ -0,0 +1,8 @@ +# notmuch -*- bash-ts -*- + +SOURCE=https://git.notmuchmail.org/git/notmuch + +CONFIGURE_ARGS=( + --prefix="$MISC_INSTALL_PREFIX" +) + diff --git a/examples/tree-sitter b/examples/tree-sitter new file mode 100644 index 0000000..55c723e --- /dev/null +++ b/examples/tree-sitter @@ -0,0 +1,4 @@ +# Tree-sitter -*- bash-ts -*- + +SOURCE="https://github.com/tree-sitter/tree-sitter.git" + diff --git a/misc b/misc new file mode 100755 index 0000000..f9aae4c --- /dev/null +++ b/misc @@ -0,0 +1,277 @@ +#!/usr/bin/env bash +# Manually Installed and Source-Compiled + +usage() { + cat >&2 < 0)) || usage 1 + + [[ "$DEBUG" ]] && set -x + + # Variables + MISC_PLAN="$1" + shift + + MISC_FULL_PLAN="$MISC_PLAN_ROOT/$MISC_PLAN" + MISC_REPO="$MISC_REPO_ROOT/$MISC_PLAN" + MISC_DONE= + + SOURCE= + CHECKOUT=master + CONFIGURE_ARGS=() + MISC_DEPENDENCIES=() + APT_DEPENDENCIES=( + build-essential + git + ) + + export LD_LIBRARY_PATH="$MISC_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH" + export PKG_CONFIG_PATH="$MISC_INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" + + # Check that plan exists + [[ -r "$MISC_FULL_PLAN" ]] || + die 2 "Plan not found: \"$MISC_PLAN\"" + + _MISC_PREVIOUS_DIR="$PWD" + trap finish EXIT INT + + if [[ ! "$PWD" == "$MISC_REPO_ROOT" ]]; then + mkdir -p "$MISC_REPO_ROOT" + run cd "$MISC_REPO_ROOT" + fi + + . "$MISC_FULL_PLAN" || + die "$?" "Error executing plan: \"$MISC_PLAN\"" + + # If the recipe is just variables, run the default plan + if [[ -z "$MISC_DONE" ]]; then + install_deps + repo_pull + repo_ready + configure || true # Not always have configure + make install + fi +} + +config() { + MISC_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/misc/misc.sh" + [[ -f "$MISC_CONFIG" ]] && . "$MISC_CONFIG" + + MISC_REPO_ROOT="${MISC_ROOT:-$XDG_DATA_HOME/misc}" + MISC_PLAN_ROOT="${MISC_PLAN_ROOT:-$XDG_CONFIG_HOME/misc}" + MISC_INSTALL_PREFIX="${MISC_INSTALL_PREFIX:-$HOME/.local}" + _ARGS=() + _DRY_RUN=false + _NUKE=false + DEBUG= + while getopts :hdnvr:p:i: opt; do + case "$opt" in + h) usage ;; + n) + _NUKE=true + _ARGS+=(-n) + ;; + d) + _DRY_RUN=true + _ARGS+=(-d) + ;; + v) + DEBUG=true + _ARGS+=(-v) + ;; + r) + MISC_REPO_ROOT="$OPTARG" + _ARGS+=(-r "$OPTARG") + ;; + p) + MISC_PLAN_ROOT="$OPTARG" + _ARGS+=(-p "$OPTARG") + ;; + i) + MISC_INSTALL_PREFIX="$OPTARG" + _ARGS+=(-i "$OPTARG") + ;; + \?) + log "Unknown flag \"-$OPTARG\"" + usage 1 + ;; + esac + done +} + +finish() { + cd "$_MISC_PREVIOUS_DIR" +} + +## Utilities + +say() { # say WORD ... + printf '%s\n' "$*" +} + +log() { # log WORD ... + say "$@" >&2 +} + +die() { # die CODE WORD ... + code="$1" + shift + log "$@" + exit "$code" +} + +run() { # run COMMAND ... + log "$@" + if ! "$_DRY_RUN"; then + eval "$@" + fi +} + +cmd() { # cmd COMMAND ... + log "$@" + if ! "$_DRY_RUN"; then + command "$@" + fi +} + +with_repo() { # with_repo COMMAND ... + ## Run COMMAND in $MISC_REPO. + run cd "$MISC_REPO" || die 4 "No such directory \"$MISC_REPO\"" + run "$@" +} + +## Library + +install_deps() { # install_deps + for dep in "${MISC_DEPENDENCIES[@]}"; do + misc "${_ARGS[@]}" "$dep" || + die 60 "Error installing dependency: \"$dep\"" + done + if command -v apt >/dev/null 2>&1; then + for dep in "${APT_DEPENDENCIES[@]}"; do + # XXX: I don't like how hacky this is. + if [[ "$(apt list --installed "$dep" 2>/dev/null | wc -l)" -lt 2 ]]; then + sudo apt install "$dep" || + die 65 "Error installing dependency: \"$dep\"" + fi + done + fi +} + +repo_pull() { # repo_pull [CHECKOUT] + ## Pull the latest CHECKOUT from $REPO. + MISC_DONE=1 + local source checkout + checkout="${1:-$CHECKOUT}" + + { [[ -n "$SOURCE" ]] || "$_DRY_RUN"; } || + die 10 "No source specified for \"$MISC_PLAN\"" + + if [[ -d "$MISC_REPO" ]]; then + git pull origin "$checkout" || + die "$?" "Error running 'git pull'" + git checkout "$checkout" || + die "$?" "Error running 'git checkout'" + else + _git clone -b "$checkout" "$SOURCE" "$MISC_REPO" || + die "$?" "Error running 'git clone'" + fi +} + +repo_download_extract() { # repo_download_extract + run 'curl -RL "$SOURCE" | tar -zxf-' +} + +repo_ready() { # repo_ready [TARGET ...] + ## Ready $MISC_ for building. + ## If TARGET ... is specified, they're passed to make; otherwise `make + ## clean` is run in the repo directory. + MISC_DONE=1 + { [[ -d "$MISC_REPO" ]] || "$_DRY_RUN"; } || + die 20 "No directory for \"$MISC_PLAN\"" + make "${@:-clean}" + if git status >/dev/null 2>&1; then + git clean -dxf + fi +} + +repo_nuke() { # repo_nuke + ## Fully remove $MISC_FULL_PLAN + { [[ -n "$MISC_REPO" ]] || "$_DRY_RUN"; } || + die 40 "No directory to remove" + run rm -rf "$MISC_REPO" +} + +## Commands (with arguments) + +make() { + MISC_DONE=1 + cmd make \ + -C "$MISC_REPO" \ + PREFIX="$MISC_INSTALL_PREFIX" \ + "$@" +} +_make() { cmd make "$@"; } + +make_install() { + MISC_DONE=1 + if make "$@"; then + make install + else + die 23 "Make error in \"$MISC_PLAN\": $@" + fi +} + +configure() { + MISC_DONE=1 + if (($# == 0)); then + with_repo ./configure "${CONFIGURE_ARGS[@]}" + else + with_repo ./configure "$@" + fi +} + +git() { + cmd git \ + -C "$MISC_REPO" \ + "$@" +} +_git() { cmd git "$@"; } + +tar() { + cmd tar \ + -C "$MISC_REPO" \ + "$@" +} +_tar() { cmd tar "$@"; } + +## Finally ... + +if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then + main "$@" +fi -- cgit 1.4.1-21-gabe81