~mil/sxmo-build

ref: 205ba44ec2e56758df1aa19a306a33d2d32a5e67 sxmo-build/sxmo_build_all.sh -rwxr-xr-x 3.4 KiB
205ba44ePeter John Hartman interactive mode a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh

mkdir -p build-sxmo-dev

cd build-sxmo-dev

set -e

FORCE=0
INTERACTIVE=0
while [ $# -gt 0 ] ; do
	case $1 in
		-h | --help)
			echo "Usage: sxmo_build_all [options]">&2
			echo "Options: --force    Overwrite existing config.h">&2
			echo "--interactive   Prompt">&2
			exit 0 
			;;
		-f | --force) 
			FORCE=1 
			;;
		-i | --interactive) 
			INTERACTIVE=1 
			;;
	esac
	shift
done

echo "Installing build dependencies (permanently, this may prompt for your sudo password)">&2
if [ -f /etc/os-release ]; then
	# freedesktop.org and systemd
	. /etc/os-release
	OS=$NAME
else
	OS="Unknown"
fi

if [ $INTERACTIVE -eq 1 ]; then
	read -p "Any key to continue..."
fi

case $OS in
	"Arch Linux ARM")
		sudo pacman -Syu --needed libxft libx11 libxinerama webkit2gtk \
			xorgproto linux-headers fontconfig freetype2 libxext \
			libinput ncurses base-devel sdl2 ttf-nerd-fonts-mono \
			cmake icu libphonenumber go wayland
		;;
	"Alpine Linux"|postmarketOS)
		sudo apk add libxft-dev libx11-dev libxinerama-dev \
			webkit2gtk-dev xproto linux-headers fontconfig-dev \
			freetype-dev libxext-dev libinput-dev eudev-dev \
			ncurses alpine-sdk coreutils sdl2 sdl2-dev \
			font-fira-mono-nerd cmake icu-dev libphonenumber-dev \
			go wayland-dev
		;;
	"Debian GNU/Linux")
		sudo apt install make gcc libxft-dev libx11-dev \
			libxinerama-dev libwebkit2gtk-4.0-dev x11proto-dev \
			libx11-xcb-dev libxcb-res0-dev libinput-dev \
			libsdl2-dev xdm fonts-firacode cmake libicu-dev \
			libphonenumber-dev golang libwayland-dev
		sudo sed -i '$ a svkbd-mobile-intl &' /etc/X11/xdm/Xsetup
		sudo sed -i '16 i pkill -f svkbd-mobile-intl' /etc/X11/xdm/Xstartup
		sudo sed -i 's/vt7.*/& -nocursor/' /etc/X11/xdm/Xservers
	;;
	*)
		echo "Unknown distribution! Exiting!"
		exit 1
		;;
esac

repos="~mil/sxmo-utils ~mil/sxmo-dwm ~mil/sxmo-dmenu ~mil/lisgd ~mil/sxmo-surf ~mil/sxmo-st ~proycon/svkbd ~proycon/clickclack Orange-OpenSource/pn ~anjan/mnc"

for repo in $repos; do
	echo "Obtaining $repo...">&2
	if [ $INTERACTIVE -eq 1 ]; then
		read -p "Any key to continue..."
	fi
	repodir="$(basename "$repo")"
	if [ -d "$repodir" ]; then
		cd "$repodir"
		git pull --ff-only
	else
		git clone "https://git.sr.ht/$repo" || git clone "https://github.com/$repo"
		cd "$repodir"
	fi
	echo "Building $repo... (may request sudo password)">&2
	if [ -f config.def.h ]; then
		if [ $FORCE -eq 1 ] || [ ! -f config.h ]; then
			cp -f config.def.h config.h
		else
			echo "(leaving old config.h untouched, this could lead to errors: run sxmo_build_all.sh --force if you want to overwrite old config.h files)">&2
		fi
	fi
	if [ "$repo" = "~anjan/mnc" ]; then
		go build mnc.go
		sudo cp -f mnc /usr/bin
	else
		make || cmake -DCMAKE_INSTALL_PREFIX=/usr . && make .
		sudo make PREFIX=/usr install
	fi
	cd ..
done

cd ..

if [ $INTERACTIVE -eq 1 ]; then
	read -p "Any key to continue..."
fi

case $OS in
	"Arch Linux ARM")
		#TODO!
		;;
	"Alpine Linux"|postmarketOS)
		echo "Installing software dependencies (permanently, this may prompt for your sudo password)">&2
		sudo apk add tinydm tinydm-openrc light

		echo "Installing services (permanently)">&2
		sudo tinydm-set-session -f -s /usr/share/xsessions/sxmo.desktop

		set +e

		sudo rc-update add sxmo-setpermissions
		sudo rc-update del xdm # To be compatible with older sxmo versions
		sudo rc-update add tinydm
		;;
	"Debian GNU/Linux")
		#TODO!!
		;;
	*)
		echo "Unknown distribution! Exiting!"
		exit 1
		;;
esac

set +e

echo "All done!"
exit 0