~chambln/dots

d9335e5b42190bf50e49407188a13e2387a22bb7 — Gregory Chamberlain 4 days ago 65a99ab
Add ks with a few packages
A pkgs/ks/.local/share/ks/main.txt => pkgs/ks/.local/share/ks/main.txt +6 -0
@@ 0,0 1,6 @@
bspwm - Binary space partitioning window manager
janet - Functional and imperative Lisp-like language and bytecode interpreter
xdgmenu - Launch XDG desktop entries with dmenu
kakoune - A vim-inspired, selection-oriented code editor
scdoc - Small man page generator
xonotic - the free and fast arena shooter

A pkgs/ks/.local/share/ks/main/bspwm/add => pkgs/ks/.local/share/ks/main/bspwm/add +5 -0
@@ 0,0 1,5 @@
#!/bin/sh -e

cd ./bspwm
make
make PREFIX="$PREFIX" install

A pkgs/ks/.local/share/ks/main/bspwm/depends => pkgs/ks/.local/share/ks/main/bspwm/depends +8 -0
@@ 0,0 1,8 @@
make
libxcb-ewmh-dev
libxcb-icccm4-dev
libxcb-keysyms1-dev
libxcb-randr0-dev
libxcb-shape0-dev
libxcb-util0-dev
libxcb-xinerama0-dev

A pkgs/ks/.local/share/ks/main/bspwm/remove => pkgs/ks/.local/share/ks/main/bspwm/remove +4 -0
@@ 0,0 1,4 @@
#!/bin/sh -e

cd ./bspwm
make PREFIX="$PREFIX" uninstall

A pkgs/ks/.local/share/ks/main/bspwm/sources => pkgs/ks/.local/share/ks/main/bspwm/sources +1 -0
@@ 0,0 1,1 @@
https://github.com/baskerville/bspwm bspwm git

A pkgs/ks/.local/share/ks/main/janet/add => pkgs/ks/.local/share/ks/main/janet/add +4 -0
@@ 0,0 1,4 @@
#!/bin/sh -e

cd ./janet
make PREFIX="$PREFIX" install

A pkgs/ks/.local/share/ks/main/janet/depends => pkgs/ks/.local/share/ks/main/janet/depends +1 -0
@@ 0,0 1,1 @@
make

A pkgs/ks/.local/share/ks/main/janet/remove => pkgs/ks/.local/share/ks/main/janet/remove +4 -0
@@ 0,0 1,4 @@
#!/bin/sh -e

cd ./janet
make PREFIX="$PREFIX" uninstall

A pkgs/ks/.local/share/ks/main/janet/sources => pkgs/ks/.local/share/ks/main/janet/sources +1 -0
@@ 0,0 1,1 @@
https://github.com/janet-lang/janet janet git

A pkgs/ks/.local/share/ks/main/kakoune/add => pkgs/ks/.local/share/ks/main/kakoune/add +4 -0
@@ 0,0 1,4 @@
#!/bin/sh

cd ./kakoune
make PREFIX="$PREFIX" install

A pkgs/ks/.local/share/ks/main/kakoune/depends => pkgs/ks/.local/share/ks/main/kakoune/depends +11 -0
@@ 0,0 1,11 @@
asciidoc-base
asciidoc-common
docbook-xsl
libboost-regex-dev
libboost-regex1.67-dev
libboost-regex1.67.0
libboost1.67-dev
libxml2-utils
sgml-base
xml-core
xsltproc

A pkgs/ks/.local/share/ks/main/kakoune/remove => pkgs/ks/.local/share/ks/main/kakoune/remove +4 -0
@@ 0,0 1,4 @@
#!/bin/sh

cd ./kakoune
make PREFIX="$PREFIX" uninstall

A pkgs/ks/.local/share/ks/main/kakoune/sources => pkgs/ks/.local/share/ks/main/kakoune/sources +1 -0
@@ 0,0 1,1 @@
https://github.com/mawww/kakoune kakoune git

A pkgs/ks/.local/share/ks/main/scdoc/add => pkgs/ks/.local/share/ks/main/scdoc/add +5 -0
@@ 0,0 1,5 @@
#!/bin/sh

cd ./scdoc
make
make PREFIX="$PREFIX" install

A pkgs/ks/.local/share/ks/main/scdoc/depends => pkgs/ks/.local/share/ks/main/scdoc/depends +0 -0
A pkgs/ks/.local/share/ks/main/scdoc/remove => pkgs/ks/.local/share/ks/main/scdoc/remove +5 -0
@@ 0,0 1,5 @@
#!/bin/sh

cd ./scdoc
make
make PREFIX="$PREFIX" uninstall

A pkgs/ks/.local/share/ks/main/scdoc/sources => pkgs/ks/.local/share/ks/main/scdoc/sources +1 -0
@@ 0,0 1,1 @@
https://git.sr.ht/~sircmpwn/scdoc scdoc git

A pkgs/ks/.local/share/ks/main/xdgmenu/add => pkgs/ks/.local/share/ks/main/xdgmenu/add +4 -0
@@ 0,0 1,4 @@
#!/bin/sh -e

cd ./xdgmenu
make PREFIX="$PREFIX" install

A pkgs/ks/.local/share/ks/main/xdgmenu/depends => pkgs/ks/.local/share/ks/main/xdgmenu/depends +1 -0
@@ 0,0 1,1 @@
make

A pkgs/ks/.local/share/ks/main/xdgmenu/remove => pkgs/ks/.local/share/ks/main/xdgmenu/remove +4 -0
@@ 0,0 1,4 @@
#!/bin/sh -e

cd ./xdgmenu
make PREFIX="$PREFIX" uninstall

A pkgs/ks/.local/share/ks/main/xdgmenu/sources => pkgs/ks/.local/share/ks/main/xdgmenu/sources +1 -0
@@ 0,0 1,1 @@
https://git.sr.ht/~chambln/xdgmenu xdgmenu git

A pkgs/ks/.local/share/ks/main/xonotic/add => pkgs/ks/.local/share/ks/main/xonotic/add +29 -0
@@ 0,0 1,29 @@
#!/bin/sh -eu

unzip -o ./xonotic-*.zip
cd ./Xonotic

mkdir -p "$PREFIX"/bin "$PREFIX"/share/applications

cat > "$PREFIX"/bin/xonotic <<EOF
#!/bin/sh -e
cd "$PWD"
./xonotic-linux64-sdl
EOF
chmod +x "$PREFIX"/bin/xonotic

cat > "$PREFIX"/share/applications/xonotic.desktop <<EOF
[Desktop Entry]
Name=Xonotic
Comment=A networked 3D first person shooter game with high-quality graphic effects
Comment[de]=Ein netzwerkfähiges 3D Ego-Shooter Spiel mit aufwändigen Grafikeffekten
Comment[fr_FR]=Un Ego-Shooter en 3D pouvant être joué en réseau
Comment[pl_PL]=Gra sieciowa 3D, strzelanka, w pierwszej osobie z efektami graficznymi wysokiej jakosci
Comment[ro_RO]=Un joc 3D cu împuşcături, perspectivă personală şi efecte grafice de înaltă calitate
Exec=xonotic
Icon=xonotic
Terminal=false
Type=Application
Categories=Game;ArcadeGame;
Keywords=shooter;3D;multiplayer;singleplayer;first-person;action;
EOF

A pkgs/ks/.local/share/ks/main/xonotic/depends => pkgs/ks/.local/share/ks/main/xonotic/depends +1 -0
@@ 0,0 1,1 @@
unzip

A pkgs/ks/.local/share/ks/main/xonotic/remove => pkgs/ks/.local/share/ks/main/xonotic/remove +5 -0
@@ 0,0 1,5 @@
#!/bin/sh -eu

rm -f "$PREFIX"/bin/xonotic \
      "$PREFIX"/share/applications/xonotic.desktop \
      ./Xonotic

A pkgs/ks/.local/share/ks/main/xonotic/sources => pkgs/ks/.local/share/ks/main/xonotic/sources +1 -0
@@ 0,0 1,1 @@
https://dl.xonotic.org/xonotic-0.8.2.zip xonotic-0.8.2.zip archive

A pkgs/ks/bin/ks => pkgs/ks/bin/ks +90 -0
@@ 0,0 1,90 @@
#!/bin/sh -eu

USAGE="Usage: ${0##*/} [-aru] PACKAGE..."
PREFIX=${PREFIX:-$HOME/.local}
DATA=${XDG_DATA_HOME:-$PREFIX/share}/${0##*/}

die() {
    printf '%s: %s\n' "${0##*/}" "$1" >&2
    exit "${2-1}"
}

match() {
    for pattern; do
        awk -v p="^$pattern\$" '$1 ~ p' "$DATA/main.txt"
    done
}

helper() {
    while IFS=' ' read -r pkg _; do
        [ -e "$DATA/main/$pkg" ] || die "No such package ‘$pkg’"
        set -- "$@" "$pkg"
    done

    case $upgrade in u)
        deps=
        for pkg; do
            while IFS=' ' read -r dep _; do
                deps="$deps $dep"
            done < "$DATA/main/$pkg/depends"
        done
        case $deps in ?*)
            sudo apt-get update
            sudo apt-get install -y $deps
        esac
    esac

    for pkg; do (
        mkdir -p "$DATA/src/$pkg"
        cd "$DATA/src/$pkg" >/dev/null 2>&1

        case $remove  in r) remove  "$pkg"; esac
        case $upgrade in u) upgrade "$pkg"; esac
        case $add     in a) add     "$pkg"; esac
    ) done
}

upgrade() {
    while read -r src dst method; do
        case $method in
            git)
                if [ -e "$dst" ]; then
                    git -C "$dst" pull --ff-only
                else
                    git clone "$src" "$dst"
                fi
                ;;
            archive)
                curl -# -C - --create-dirs -o "$dst" "$src"
                ;;
            *) die "Unknown method ‘$method’"
        esac
    done < "$DATA/main/$pkg/sources"
}

add() {
    PREFIX="$PREFIX" "$DATA/main/$pkg/add"
}

remove() {
    PREFIX="$PREFIX" "$DATA/main/$pkg/remove"
}

add=-
remove=-
upgrade=-
while getopts ahru OPT; do
    case $OPT in
        a) add=a ;;
        h) die "$USAGE" 0 ;;
        r) remove=r ;;
        u) upgrade=u ;;
        ?) die "$USAGE" 2 ;;
    esac
done
shift $((OPTIND - 1))

case $remove$upgrade$add in
    ---) match "${@:-.*}" ;;
    ???) match "$@" | helper ;;
esac