This repository has been archived by the owner on Jun 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
arch-deployer
230 lines (209 loc) · 11.6 KB
/
arch-deployer
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
#!/bin/sh
ARCH=$(uname -m)
MIRROR="https://archlinux.org/packages"
#CHAOTICAUR="https://builds.garudalinux.org/repos/chaotic-aur/" # UNCOMMENT TO ENABLE THE SUPPORT FOR AUR PACKAGES (CHAOTIC AUR)
case "$1" in
-h|--help ) echo '
╭━━━┳━━━┳━━━┳╮╱╭╮╭━━━┳━━━┳━━━┳╮╱╱╭━━━┳╮╱╱╭┳━━━┳━━━╮
┃╭━╮┃╭━╮┃╭━╮┃┃╱┃┃╰╮╭╮┃╭━━┫╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃╭━━┫╭━╮┃
┃┃╱┃┃╰━╯┃┃╱╰┫╰━╯┃╱┃┃┃┃╰━━┫╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭┫╰━━┫╰━╯┃
┃╰━╯┃╭╮╭┫┃╱╭┫╭━╮┃╱┃┃┃┃╭━━┫╭━━┫┃╱╭┫┃╱┃┃╰╮╭╯┃╭━━┫╭╮╭╯
┃╭━╮┃┃┃╰┫╰━╯┃┃╱┃┃╭╯╰╯┃╰━━┫┃╱╱┃╰━╯┃╰━╯┃╱┃┃╱┃╰━━┫┃┃╰╮
╰╯╱╰┻╯╰━┻━━━┻╯╱╰╯╰━━━┻━━━┻╯╱╱╰━━━┻━━━╯╱╰╯╱╰━━━┻╯╰━╯
A SCRIPT TO BULK DOWNLOAD AN ARCH LINUX PACKAGE WITH ALL ITS DEPENDENCIES
TO BE CONVERTED IN APPIMAGE. ADD THE NAME OF A PROGRAM FROM THE ARCH
LINUX REPOSITORIES. "CHAOTIC-AUR" SUPPORT CAN BE ENABLED TOO.
USAGE:
arch-deployer $PROGRAM (download a program)
arch-deployer -v (show the version)
arch-deployer -h (show this message)
ARCH-DEPLOYER TAKES ALL THE PACKAGES FROM HTTPS://ARCHLINUX.ORG/PACKAGES
TO ENABLE "AUR", UNCOMMENT THE LINE 5 OF THE ARCH-DEPLOYER MAIN SCRIPT.
AUR PACKAGES ARE TAKEN FROM "CHAOTIC-AUR" INSTEAD, AT
HTTPS://BUILDS.GARUDALINUX.ORG/REPOS/CHAOTIC-AUR
SITE: HTTPS://GITHUB.COM/IVAN-HC/ARCH-DEPLOYER
SEE ALSO: HTTPS://GITHUB.COM/IVAN-HC/AM-APPLICATION-MANAGER
';;
-v|--version ) echo "1.0.0";;
'' ) echo "" && echo ' PLEASE ADD THE NAME OF A PROGRAM FROM THE ARCH LINUX REPOSITORIES' && echo "" &&
echo ' USAGE: arch-deployer $PROGRAM' && echo "" &&
echo ' VISIT https://archlinux.org/packages TO SEE THE PACKAGES AVAILABLE' && echo "" ;;
* ) for APP in $1; do
if ls ./$APP/$APP.AppDir; then
echo "" && echo '############################################################################' && echo "" &&
echo ' The '$APP'.AppDir already exists! '
sleep 2
break
else
# DOWNLOADING THE APPLICATION
mkdir -p ./$1
cd ./$1
for REPO in { "core" "extra" "community" "multilib" }; do
wget ${MIRROR}/${REPO}/${ARCH}/$APP/download && mv ./download ./$APP.tar.zst;
wget -r -A $APP-*.tar.zst -nd ${CHAOTICAUR}/${ARCH}/ && break
done
tar fx ./*.tar.zst
# READ AND/OR EDIT THE DEPENDENCES LIST
DEP=$( cat ./.PKGINFO | grep "depend" | grep -v "makedepend" | grep -v "optdepend" | cut -c 10- )
MAKEDEP=$( cat ./.PKGINFO | grep "makedepend" | cut -c 14- )
echo $DEP | tr ' ' '\n' >> DEP
echo $MAKEDEP | tr ' ' '\n' >> DEP
awk '{ print "\""$0"\""}' DEP
echo "" && echo "############################################################################" && echo ""
while true; do
read -r -p " DO YOU WISH TO ADD OTHER PACKAGES TO THE LIST (y/N)?" response
case $response in
[Yy]* ) echo "" && echo ' OPENING THE "DEP" FILE USING YOUR DEFAULT TEXT EDITOR' && xdg-open DEP && echo "" &&
while true; do
read -r -p " PRESS ENTER TO CONTINUE" response
case $response in
* ) echo "" && echo " THE FOLLOWING PACKAGES WILL BE DOWNLOADED:" && echo "" && awk '{ print "\""$0"\""}' DEP && echo "" && break;
esac
done;;
[Nn]*|* ) echo "" && echo " OK, LET'S GO!" && echo "" && break;;
esac
done
# DOWNLOAD AND EXTRACT THE DEPENDENCE'S PACKAGES TO THE APPDIR
ARGS=$( cat ./DEP )
for DEPENDENCES in ${ARGS} ; do
for REPO in { "core" "extra" "community" "multilib" }; do
wget ${MIRROR}/${REPO}/${ARCH}/$DEPENDENCES/download && mv ./download ./$DEPENDENCES.tar.zst;
wget -r -A $DEPENDENCES-*.tar.zst -nd ${CHAOTICAUR}/${ARCH}/ && break
done
done
for f in *.tar.zst; do
tar xf "$f";
done
mkdir ./$APP.AppDir
mv ./bin ./$APP.AppDir/ 2>/dev/null
mv ./boot ./$APP.AppDir/ 2>/dev/null
mv ./dev ./$APP.AppDir/ 2>/dev/null
mv ./etc ./$APP.AppDir/ 2>/dev/null
mv ./lib ./$APP.AppDir/ 2>/dev/null
mv ./lib64 ./$APP.AppDir/ 2>/dev/null
mv ./libx32 ./$APP.AppDir/ 2>/dev/null
mv ./media ./$APP.AppDir/ 2>/dev/null
mv ./mnt ./$APP.AppDir/ 2>/dev/null
mv ./opt ./$APP.AppDir/ 2>/dev/null
mv ./proc ./$APP.AppDir/ 2>/dev/null
mv ./run ./$APP.AppDir/ 2>/dev/null
mv ./sbin ./$APP.AppDir/ 2>/dev/null
mv ./srv ./$APP.AppDir/ 2>/dev/null
mv ./sys ./$APP.AppDir/ 2>/dev/null
mv ./tmp ./$APP.AppDir/ 2>/dev/null
mv ./usr ./$APP.AppDir/ 2>/dev/null
mv ./var ./$APP.AppDir/ 2>/dev/null
# DOWNLOADING LIBUNIONPRELOAD
wget https://github.com/project-portable/libunionpreload/releases/download/amd64/libunionpreload.so
chmod a+x libunionpreload.so
mv ./libunionpreload.so ./$APP.AppDir/ 2>/dev/null
# DOWNLOADING APPIMAGETOOL (TO EXPORT THE APPDIR TO AN APPIMAGE)
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$ARCH.AppImage
mv ./appimagetool-$ARCH.AppImage ./appimagetool
chmod a+x ./appimagetool
# CREATING THE APPRUN SCRIPT
function1="'^Exec=.*'"
function2="'s|%.||g'"
echo '#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
export UNION_PRELOAD="${HERE}"
export LD_PRELOAD="${HERE}/libunionpreload.so"
export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/sbin/:"${HERE}"/usr/games/:"${HERE}"/bin/:"${HERE}"/opt/'$1'/:"${HERE}"/sbin/:"${PATH}"
export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/'$1'/:"${HERE}"/usr/lib64/'$1'/:"${HERE}"/usr/lib32/'$1'/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}"
export PYTHONPATH="${HERE}"/usr/share/pyshared/:"${HERE}"/usr/lib/python*/:"${PYTHONPATH}"
export PYTHONHOME="${HERE}"/usr/:"${HERE}"/usr/lib/python*/
export XDG_DATA_DIRS="${HERE}"/usr/share/:"${HERE}"/usr/share/'$1'/:"${XDG_DATA_DIRS}"
export PERLLIB="${HERE}"/usr/share/perl5/:"${HERE}"/usr/lib/perl5/:"${PERLLIB}"
export GSETTINGS_SCHEMA_DIR="${HERE}"/usr/share/glib-2.0/schemas/:"${GSETTINGS_SCHEMA_DIR}"
export QT_PLUGIN_PATH="${HERE}"/usr/lib/qt4/plugins/:"${HERE}"/usr/lib/'$1'/:"${HERE}"/usr/lib64/'$1'/:"${HERE}"/usr/lib32/'$1'/:"${HERE}"/usr/lib/i386-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib32/qt4/plugins/:"${HERE}"/usr/lib64/qt4/plugins/:"${HERE}"/usr/lib/qt5/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib32/qt5/plugins/:"${HERE}"/usr/lib64/qt5/plugins/:"${QT_PLUGIN_PATH}"
EXEC=$(grep -e '$function1' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e '$function2')
exec ${EXEC} "$@"' >> AppRun
chmod a+x AppRun
mv ./AppRun ./$APP.AppDir/
# TRY TO COPY ICON AND LAUNCHER INTO THE APPDIR
initials=$(echo $APP | head -c 2)
cp ./$APP.AppDir/usr/share/icons/hicolor/22x22/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/24x24/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/32x32/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/48x48/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/64x64/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/128x128/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/256x256/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/512x512/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/icons/hicolor/scalable/apps/*$initials* ./$APP.AppDir/ 2>/dev/null
cp ./$APP.AppDir/usr/share/applications/*$initials* ./$APP.AppDir/ 2>/dev/null
cd ..
echo "" && echo '############################################################################' && echo "" &&
echo "" && echo ' The '$APP'.AppDir is ready! '
echo ' You may check it for issues to fix before you export it to an AppImage.' && echo "" && sleep 2 &&
echo '############################################################################' && echo ""
fi
done
echo "" &&
sleep 1
# CHECK THE APPDIR (QUESTION)
while true; do
read -r -p " DO YOU WISH TO CHECK THE $APP.AppDir FIRST (Y/n)?" response
case $response in
[Nn]* ) break;;
[Yy]*|* ) echo ""; echo "############################################################################" &&
echo "" && echo " Opening the $APP.AppDir directory!" && sleep 1 && echo "" &&
echo " Exec the AppRun (command './AppRun') to test if everything works!" && sleep 1 &&
xdg-open ./$APP/$APP.AppDir && echo "" && break;;
esac
done
# DOWNLOAD OTHER PACKAGES (IF NEEDED)
while true; do
read -r -p " DO YOU WISH TO ADD OTHER PACKAGES (Y,n)?" response
case $response in
[Nn]* ) while true; do
read -r -p " DO YOU WISH TO EXPORT THE $APP.AppDir TO AN APPIMAGE (Y/n)?" response
case $response in
[Nn]* ) echo ""; echo "" && echo '############################################################################' && echo "" &&
echo ' THANK YOU FOR USING ARCH-DEPLOYER!' && echo "" && sleep 1 &&
echo "" && echo " SITE: https://github.com/ivan-hc/AM-application-manager" && echo "" &&
echo '############################################################################'; echo ""; exit;;
[Yy]*|* ) echo ""; ARCH=$(uname -m) ./$APP/appimagetool -n ./$APP/$APP.AppDir 2>/dev/null &&
mv *.AppImage $(xdg-user-dir DESKTOP) 2>/dev/null; echo "" &&
echo "############################################################################" &&
echo "" && echo " $APP HAS BEEN EXPORTED ON YOUR DESKTOP!" && sleep 2 && echo "" &&
echo " REPEAT THIS OPERATION IN CASE THE APPIMAGE DOESN'T WORK:" && sleep 1 && echo "" >&2;;
esac
done && exit;;
[Yy]*|* ) while true; do
read -r -p " PLEASE, ENTER THE PACKAGE NAME (or leave empty to continue): " packagename
case $packagename in
'' ) break;;
* ) for var in $packagename; do
chmod -R 777 ./$APP/$APP.AppDir
cd ./$APP/$APP.AppDir
for REPO in { "core" "extra" "community" "multilib" }; do
wget ${MIRROR}/${REPO}/${ARCH}/$packagename/download && mv ./download ./$packagename.tar.zst
wget -r -A $packagename-*.tar.zst -nd ${CHAOTICAUR}/${ARCH}/ && break
done
tar xf $packagename.tar.zst;
chmod -R 777 ./*
rm -R -f ./2 ./.BUILDINFO ./.MTREE ./.PKGINFO ./*.tar.zst
unset $packagename
echo "" >2; done;;
esac
done
esac
# EXPORT THE APPDIR TO AN APPIMAGE
while true; do
read -r -p " Do you wish to export $APP.AppDir to an AppImage (Y/n)?" response
case $response in
[Nn]* ) break;;
[Yy]*|* ) echo ""; ARCH=$(uname -m) ./$APP/appimagetool -n ./$APP/$APP.AppDir 2>/dev/null &&
mv *.AppImage $(xdg-user-dir DESKTOP) 2>/dev/null; echo "" &&
echo "############################################################################" &&
echo "" && echo " $APP has been exported on your desktop!" && sleep 2 && echo "" &&
echo " Repeat this operation in case the AppImage doesn't work:" && sleep 1 && echo "" >&2;;
esac
done
echo "" && echo '############################################################################' && echo "" &&
echo ' THANK YOU FOR USING ARCH-DEPLOYER!' && echo "" && sleep 1 && echo ' PLEASE CONSIDER SUBMITTING YOUR APPLICATION TO "AM"' &&
echo "" && echo " SITE: HTTPS://GITHUB.COM/IVAN-HC/AM-APPLICATION-MANAGER" && echo "" &&
echo '############################################################################'; echo ""; exit
done
esac