Skip to content

Commit 2fe1c37

Browse files
committed
Post-install: Created unified scheme for installation from git upstream sources
~/.comforts-git now covers all use cases previously held by the following obsolete scripts, which differed only slightly in their operation, their functionality has been superceded as follows: * .once.d/11-utilities-git.sh => .once/10-git-upstream.sh * .once.d/10-dwm-install.sh => .config/dwm/pre-run * .once.d/12-gnu-nano.sh => .config/nano/{pre,post}-run ~/.conforts-git entries prepended with *asterisk will be mirrored to ~/.config Software installed this way can use existing pre-run and post-run scripts to customize installation without writing bespoke scripts for every new use case. Regression: ~/.local/bin/startx The only benefit to having a separate suckless install script would be the ability to compile new changes upon running startx, but this went completely unused in the 4 months since being written.
1 parent a2ee335 commit 2fe1c37

File tree

11 files changed

+106
-128
lines changed

11 files changed

+106
-128
lines changed

.comforts-git

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
## ~/.comforts-git: essential upstream utilities
1+
## ~/.comforts-git: essential and *persistent upstream git utilities
22

3+
*https://git.suckless.org/dwm
4+
*https://git.suckless.org/dmenu
5+
6+
https://github.com/ritave/xeventbind
37
https://github.com/microsounds/kagami
48
https://github.com/dylanaraps/pfetch
59
https://github.com/sjmulder/trickle
6-
https://github.com/ritave/xeventbind
10+
11+
*https://git.savannah.gnu.org/git/nano

.config/dwm/pre-run

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
# apply dwm patches
4+
if [ -d patches ]; then
5+
for g in patches/*.diff; do
6+
echo "[patch] $g..."
7+
patch < $g || exit 1
8+
done
9+
fi
10+

.config/nano/post-run

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
3+
# inject custom syntax rules for C-like languages
4+
INSTALL="$HOME/.local"
5+
share="$INSTALL/share/nano"
6+
mv "$share/extra/debian.nanorc" "$share"
7+
rm -f "$share/markdown.nanorc"
8+
for f in c javascript; do
9+
syn="$share/$f.nanorc"
10+
{ rm "$syn"
11+
sed "/^comment/r $share/stdc.syntax" > "$syn"
12+
} < "$syn"
13+
done

.config/nano/pre-run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
3+
# required for automake
4+
[ ! -d 'gnulib' ] && ./autogen.sh

.local/bin/startx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
#!/usr/bin/env sh
22

3-
# X server configuration
4-
5-
# conditionally recompile dwm/dmenu
6-
for f in dwm dmenu; do
7-
if ! bin="$(which $f)" > /dev/null || \
8-
! is-newer "$bin" ~/.config/$f/config.h; then
9-
~/.once.d/10-dwm-install.sh
10-
break
11-
fi
12-
done
3+
# X server runtime configuration
134

145
# ~/.config/xorg/*.conf
156
# force xorg.conf on specific hardware to fix screen tearing

.once.d/01-install-essential.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ for f in $(cat ~/.comforts | sed 's/#.*$//g'); do
2626
done
2727

2828
# force completely unattended install
29-
3029
echo "$pkgs" | xargs sudo $env apt-get -y install || exit 1
3130
sudo apt-get clean

.once.d/10-dwm-install.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

.once.d/10-git-upstream.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env sh
2+
3+
# install utilities from git upstream sources described in ~/.comforts-git
4+
# note: git repos must have a makefile, ./configure script (optional) and
5+
# the typical 'make install PREFIX=...' metaphor to build correctly
6+
7+
# persistent install mode
8+
# git sources prepended with *asterisk will be mirrored to ~/.config/${URL##*/}
9+
# persistent install mode also allows for configuration hacks in the form of
10+
# pre-run and post-run scripts located in their dedicated ~/.config directory
11+
# eg. you want to apply patches, mangle the install after installation, etc.
12+
13+
INSTALL="$HOME/.local"
14+
PERSIST="$HOME/.config"
15+
16+
finish() {
17+
rm -rf "$TMP"
18+
echo 'Done.'
19+
exit
20+
}
21+
22+
IFS='
23+
'
24+
for f in $(cat ~/.comforts-git); do
25+
unset persist
26+
case "${f%${f#?}}" in
27+
\#*) continue;; # comments
28+
\*) f="${f#?}"; persist=1;; # persistent install
29+
esac
30+
31+
prog="${f##*/}"; prog="${prog%.*}" # derive dir name
32+
printf '\e[1m%s\e[0m\n' "[upstream] Installing '$prog' from '$f'"
33+
34+
# git clone and cd
35+
# persistently installed utils can have pre-existing files
36+
# perform git clone manually
37+
case $persist in
38+
1) # rebuild git dir in place and/or pull
39+
trap - 0 1 2 3 6
40+
TMP="$PERSIST/$prog"
41+
mkdir -p "$TMP" && cd "$TMP"
42+
if ! git status > /dev/null 2>&1; then
43+
git init
44+
git remote add origin "$f"
45+
fi
46+
git fetch --tags origin master || exit 1;;
47+
*) # git clone and discard afterward
48+
trap finish 0 1 2 3 6
49+
TMP="$(mk-tempdir)"
50+
git clone --tags "$f" "$TMP" || exit 1
51+
cd "$TMP"
52+
esac
53+
54+
# checkout latest and install
55+
git reset --hard && git checkout master
56+
57+
[ -x "$TMP/pre-run" ] && ./pre-run # pre-run hacks
58+
if [ -x "$TMP/configure" ]; then # autoconf configure
59+
./configure --prefix="$INSTALL" --sysconfdir='/dev/null'
60+
fi
61+
make install PREFIX="$INSTALL" || exit 1
62+
[ -x "$TMP/post-run" ] && ./post-run # post-run hacks
63+
[ ! -z "$persist" ] || { cd .. && rm -rf "$TMP"; }
64+
done

.once.d/11-utilities-git.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

.once.d/12-gnu-nano.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)