-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
archimage-cli
299 lines (256 loc) · 11 KB
/
archimage-cli
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/usr/bin/env bash
VERSION="3.4.4"
DIR="$( cd "$( dirname "$0" )" && pwd )"
# Function to show the help message
function _help() {
echo -e "\n ArchImage CLI v$VERSION \n\n A command line interface to build AppImages based on JuNest, the lightweight\n Arch Linux based distro that runs, without root privileges, on top of any\n other Linux distro."
echo -e "\n USAGE:\n\n archimage-cli [OPTION]\n archimage-cli [OPTION] [PROGRAM]\n"
echo -e " OPTIONS:\n\n -h,--help Shows this message.\n -v,--version Shows the version.\n -b,--build Create the script to build the AppImage.\n -s,--sync Update archimage-cli to the latest version."
echo -e "\n SITES: \n\n - https://github.com/IVAN-HC \n\n - https://github.com/IVAN-HC/ARCHIMAGE \n\n - https://github.com/FSQUILLACE/JUNEST\n"
}
# Function to update this script
function _sync() {
cd "$DIR" || exit 1
echo -ne " ◆ Synchronizing Archimage CLI v$(./archimage-cli -v)...\r"; sleep 0.5
wget -q https://raw.githubusercontent.com/ivan-hc/ArchImage/main/archimage-cli -O ~/.cache/archimage-cli && chmod a+x ~/.cache/archimage-cli;
mv ~/.cache/archimage-cli ./archimage-cli; echo " ◆ ArchImage CLI is now updated to the version $(./archimage-cli -v) "
}
# FUNCTIONS TO CUSTOMIZE THE SCRIPTS
function _usr_bin_executable_name() {
echo -e "\n---------------------------------------------------------------------------\n"
read -r -ep '◆ NAME THE MAIN EXECUTABLE IN "$PATH", OR LEAVE BLANK IF IT IS THE SAME: ' response
case $response in
'')
;;
*)
mv ./"$APP"-junest.sh ./"$APP"-junest.sh.old
sed -n '1,4p' ./"$APP"-junest.sh.old >> ./"$APP"-junest.sh
echo 'BIN="'"$response"'"' >> ./"$APP"-junest.sh
sed -n '6,20000000p' ./"$APP"-junest.sh.old >> ./"$APP"-junest.sh
rm -f ./"$APP"-junest.sh.old;;
esac
}
function _add_dependences() {
read -r -ep "◆ ADD (OPTIONAL) DEPENDENCES OR LEAVE BLANK: " RESPONSE
case $RESPONSE in
*)
mv ./"$APP"-junest.sh ./"$APP"-junest.sh.old
sed -n '1,5p' ./"$APP"-junest.sh.old >> ./"$APP"-junest.sh
echo 'DEPENDENCES="'"$RESPONSE"'"' >> ./"$APP"-junest.sh
sed -n '7,20000000p' ./"$APP"-junest.sh.old >> ./"$APP"-junest.sh
rm -f ./"$APP"-junest.sh.old;;
esac
}
function _include_all_dependences() {
echo "◆ Automatic library checking should be more than enough. However..."
read -r -ep " DO YOU WANT TO INCLUDE ALL DEPENDENCES? THE PACKAGE MAY BE BLOATED (y,N) " yn
case $yn in
[Yy]* )
sed -i 's/#rsync -av/rsync -av/g' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _enable_chaoticaur() {
echo -e "\n---------------------------------------------------------------------------\n"
read -r -ep "◆ DO YOU WANT TO ENABLE CHAOTIC-AUR (y,N)? " yn
case $yn in
[Yy]* )
sed -i 's/###_enable_chaoticaur/_enable_chaoticaur/g' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _enable_basicstuff() {
read -r -ep "◆ DO YOU WANT TO INCLUDE BINUTILS AND GZIP (y,N)? " yn
case $yn in
[Yy]* )
sed -i 's/#BASICSTUFF/BASICSTUFF/g' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _enable_compilers(){
read -r -ep "◆ DO YOU WANT TO INCLUDE THE BASE-DEVEL PACKAGE AND COMPILE FROM AUR (y,N)? " yn
case $yn in
[Yy]* )
sed -i 's/#COMPILERS/COMPILERS/g' ./"$APP"-junest.sh
sed -i '/-- gpg --keyserver/ s/^#*//' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _keywords_to_save_in_usr_bin() {
read -r -ep "◆ LIST BINARIES TO SAVE IN /usr/bin OR LEAVE BLANK $(echo -e '\n DO NOT ADD ASTERISKS, THEY ARE ALREADY PROVIDED IN THE SCRIPT\n:') " savebins
case "$savebins" in
'')
;;
*)
sed -i 's/#_savebins/_savebins/g' ./"$APP"-junest.sh
sed -i "s/SAVEBINSPLEASE/$savebins/g" ./"$APP"-junest.sh
;;
esac
}
function _keywords_to_save_in_usr_share() {
read -r -ep "◆ LIST DIRECTORIES TO SAVE IN /usr/share OR LEAVE BLANK $(echo -e '\n DO NOT ADD ASTERISKS, THEY ARE ALREADY PROVIDED IN THE SCRIPT\n:') " saveshare
case "$saveshare" in
'')
;;
*)
sed -i 's/#_saveshare/_saveshare/g' ./"$APP"-junest.sh
sed -i "s/SAVESHAREPLEASE/$saveshare/g" ./"$APP"-junest.sh
;;
esac
}
function _keywords_to_save_in_usr_lib() {
read -r -ep "◆ LIST LIBRARIES AND DIRECTORIES TO SAVE IN /usr/lib OR LEAVE BLANK $(echo -e '\n DO NOT ADD ASTERISKS, THEY ARE ALREADY PROVIDED IN THE SCRIPT\n:') " savelibs
case "$savelibs" in
'')
;;
*)
sed -i 's/#_libkeywords/_libkeywords/g' ./"$APP"-junest.sh
sed -i "s/SAVELIBSPLEASE/$savelibs/g" ./"$APP"-junest.sh
;;
esac
}
function _include_swrast() {
read -r -ep "◆ DO YOU WANT TO INCLUDE THE /usr/lib/dri/swrast_dri.so DRIVER (y,N)? " yn
case $yn in
[Yy]* )
sed -i 's/#_include_swrast_dri/_include_swrast_dri/g' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _include_audio_keywords() {
read -r -ep "◆ DO YOU WISH TO ADD KEYWORDS IN /usr/lib TO ENABLE THE AUDIO (y,N)?" yn
case $yn in
[Yy]* )
sed -i 's/LIBSAVED="/LIBSAVED="alsa jack pipewire pulse /g' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _include_internet_keywords() {
read -r -ep "◆ I RECOMMEND TO USE CA-CERTIFICATES TRYING TO ENABLE THE INTERNET $(echo -e '\n DO YOU WISH TO ADD IT INTO THE SCIPT (y,N)?') " yn
case $yn in
[Yy]* )
sed -i 's/DEPENDENCES="/DEPENDENCES="ca-certificates /g' ./"$APP"-junest.sh
sed -i 's/BINSAVED="/BINSAVED="certificates /g' ./"$APP"-junest.sh
sed -i 's/#_binlibs/_binlibs/g' ./"$APP"-junest.sh
sed -i 's/SHARESAVED="/SHARESAVED="certificates /g' ./"$APP"-junest.sh
sed -i 's/#_saveshare/_saveshare/g' ./"$APP"-junest.sh
sed -i 's/LIBSAVED="/LIBSAVED="pk p11 /g' ./"$APP"-junest.sh
sed -i 's/#_mvlibs/_mvlibs/g' ./"$APP"-junest.sh
sed -i 's/#_liblibs/_liblibs/g' ./"$APP"-junest.sh;;
[Nn]*|* )
;;
esac
}
function _select_libraries() {
read -r -ep "◆ DO YOU WISH TO SELECT LIBRARIES TO SAVE (y,N)?" yn
case $yn in
[Yy]* )
sed -i 's/#_binlibs/_binlibs/g' ./"$APP"-junest.sh
sed -i 's/#_liblibs/_liblibs/g' ./"$APP"-junest.sh
sed -i 's/#_mvlibs/_mvlibs/g' ./"$APP"-junest.sh
echo -e "\n---------------------------------------------------------------------------\n"
_include_swrast
echo -e "\n---------------------------------------------------------------------------\n"
_keywords_to_save_in_usr_lib
echo -e "\n---------------------------------------------------------------------------\n"
_include_audio_keywords
echo -e "\n---------------------------------------------------------------------------\n"
_include_internet_keywords
;;
[Nn]*|* )
;;
esac
}
case "$1" in
'')
echo -e "\n ArchImage CLI requires an argument, run -h for more info.\n";;
--help|-h)
_help
;;
--build|-b)
while [ -n "$1" ]; do
cd "$(xdg-user-dir DESKTOP)" || exit 1
case "$2" in
'')
echo -e "\n USAGE: archimage-cli -b [PROGRAM]\n"
exit;;
*)
APP="$2"
wget -q https://raw.githubusercontent.com/ivan-hc/ArchImage/main/sample-next-junest.sh -O "$APP"-junest.sh
sed -i "s#APP=SAMPLE#APP=$APP#g" "$APP"-junest.sh
_usr_bin_executable_name
echo -e "\n---------------------------------------------------------------------------\n"
_add_dependences
echo -e "\n---------------------------------------------------------------------------\n"
_include_all_dependences
echo -e "\n---------------------------------------------------------------------------\n"
echo -e '◆ Choose to finish using a standard configuration with the bare minimum or'
echo -e ' continue by customizing the script as much as possible (default).\n'
echo -e ' The standard configuration includes a package availability check in the'
echo -e ' Arch User Repository (if so, enable AUR and installs "binutils", "gzip"'
echo -e ' and "basedevel", all of them are only required to compile from and will'
echo -e ' not be included in the AppImage package), the AUR is enabled, installs'
echo -e ' "ca-certificates", includes keywords for the internet connections and '
echo -e ' audio trying to enable them.'
echo -e ' The file "/usr/lib/dri/swrast_dri.so" will NOT be included if not needed.\n'
echo -e ' Choose "N" or leave blank instead to continue customization (RECOMMENDED).\n'
read -r -ep " DO YOU WISH TO USE A STANDARD CONFIGURATION (y,N)? " yn
case $yn in
[Yy]* )
sed -i 's/#_binlibs/_binlibs/g' ./"$APP"-junest.sh # CHECK LIBRARIES RELATED TO BINARIES
sed -i 's/#_liblibs/_liblibs/g' ./"$APP"-junest.sh # CHECK LIBRARIES RELATED TO OTHER LIBRARIES
sed -i 's/#_mvlibs/_mvlibs/g' ./"$APP"-junest.sh # MV ALL LIBRARIES SAVED IN THE COMMANDS ABOVE AND BELOW
sed -i 's/#_libkeywords/_libkeywords/g' ./"$APP"-junest.sh # CHECK LIBRARIES RELATED TO KEYWORD SAVED BELOW
sed -i 's/LIBSAVED="/LIBSAVED="alsa jack pipewire pulse /g' ./"$APP"-junest.sh # SAVE KEYWORDS RELATED TO AUDIO
sed -i 's/DEPENDENCES="/DEPENDENCES="ca-certificates /g' ./"$APP"-junest.sh # INSTALL CA-CERTIFICATES
sed -i 's/BINSAVED="/BINSAVED="certificates /g' ./"$APP"-junest.sh # SAVE CA-CERTIFICATES IN /usr/bin
sed -i 's/#_savebins/_savebins/g' ./"$APP"-junest.sh # SAVE KEYWORDS IN /usr/bin
sed -i 's/#_binlibs/_binlibs/g' ./"$APP"-junest.sh # CHECK LIBRARIES RELATED TO BINARIES IN /usr/bin
sed -i 's/SHARESAVED="/SHARESAVED="certificates /g' ./"$APP"-junest.sh # SAVE CA-CERTIFICATES IN /usr/share
sed -i 's/#_saveshare/_saveshare/g' ./"$APP"-junest.sh # SAVE KEYWORDS IN /usr/share
sed -i 's/LIBSAVED="/LIBSAVED="pk p11 /g' ./"$APP"-junest.sh # SAVE SOME KEYWORDS NEEDED FOR INTERNET
if curl --output /dev/null --silent --fail -r 0-0 https://aur.archlinux.org/packages/"$APP" 2> /dev/null; then
sed -i 's/#BASICSTUFF/BASICSTUFF/g' ./"$APP"-junest.sh # INSTALL BINUTILS AND GZIP
sed -i 's/#COMPILERS/COMPILERS/g' ./"$APP"-junest.sh # INSTALL BASE-DEVEL
sed -i '/-- gpg --keyserver/ s/^#*//' ./"$APP"-junest.sh # ENABLE AUR GPG VALIDATION
fi
;;
[Nn]*|* )
echo -e "\n---------------------------------------------------------------------------\n"
_enable_chaoticaur
echo -e "\n---------------------------------------------------------------------------\n"
_enable_basicstuff
echo -e "\n---------------------------------------------------------------------------\n"
_enable_compilers
echo -e "\n---------------------------------------------------------------------------\n"
_keywords_to_save_in_usr_bin
echo -e "\n---------------------------------------------------------------------------\n"
_keywords_to_save_in_usr_share
echo -e "\n---------------------------------------------------------------------------\n"
_select_libraries
;;
esac
esac
echo -e "\n---------------------------------------------------------------------------\n"
chmod a+x ./"$APP"-junest.sh
echo -e " THE SCRIPT IS READY, RUN IT TO CREATE AN APPIMAGE! \n"
echo -e "\n SUGGESTIONS:\n\n - from line titled 'REMOVE SOME BLOATWARES', add a list of items to be\n deleted to avoid an excess in the size of the final AppImage archive.\n"
exit
done
;;
--sync|-s)
_sync
;;
--version|-v)
echo "$VERSION"
;;
*)
echo -e "\n Unknown option '$1', run -h for more info.\n"
;;
esac