-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppRun
executable file
·226 lines (204 loc) · 5.94 KB
/
AppRun
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
#!/bin/bash
#__help_message__
help()
{
echo "Welcome to use Appimage2Deb Kitchen!"
echo "> Appimage2Deb 1.0b20201214"
echo "> Copyright (c) 2021 xRetia Labs"
echo ""
echo "About xRetia Labs"
echo "> The xRetia Labs is apart of FC-SYSTEM which working for opensource project."
echo "> Copyright (c) 2012-2020 FC-SYSTEM (dfc643.github.io)"
echo ""
echo ""
echo "Required:"
echo " -n | --name <package_name> what's the name of your package?"
echo " -v | --version <version> which version of your package?"
echo " -a | --arch <architecture> which architecture of your software made?"
echo " x86: i386, amd64"
echo " ARM: armel, armhf, arm64"
echo " MIPS: mips, mips64el, mipsel"
echo " ppc64el, s390x, all"
echo " -f | --file-appimage <path> full path of your appimage executable"
echo ""
echo "Options:"
echo " --no-sandbox yes disable sandbox for appimage executable"
echo " -h | --help show this help message"
echo ""
}
#__check_args_user_given__
check_args()
{
if [ ! -f $A2DFILE ]
then
echo "Appimage2Deb: **Error**: The specified *.AppImage file was not found!"
echo "> A2DFILE: $A2DFILE"
exit 1
fi
if [ "$A2DNAME" = "" ]
then
echo "Appimage2Deb: **Error**: You must give a name for your package, but '$A2DNAME' you given."
exit 1
fi
if [ "$A2DARCH" = "" ]
then
echo "Appimage2Deb: **Error**: You must specify architecture for your package, just like i386, amd64, mipsel etc."
exit 1
fi
if [ "$A2DVER" = "" ]
then
echo "Appimage2Deb: **Error**: You must specify version for your package, just like '1.0b20201214'."
exit 1
fi
}
#__config_edit__
config_edit()
{
CONFIG="$3"
sed -i "s#$1=.*#$1=$2#g" $CONFIG
}
#------------------------Start-Menu---------------------------
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-f|--file-appimage)
A2DFILE="$2"
shift # past argument
shift # past value
;;
-n|--name)
A2DNAME="$2"
shift # past argument
shift # past value
;;
-a|--arch)
A2DARCH="$2"
shift # past argument
shift # past value
;;
--no-sandbox)
if [ "$1" = "--no-sandbox" ]; then
A2DSAND="yes"
else
A2DSAND=""
fi
shift # past argument
shift # past value
;;
-v|--version)
A2DVER="$2"
shift # past argument
shift # past value
;;
-h|--help)
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
A2DHELP="yes"
else
A2DHELP=""
fi
shift # past argument
shift # past value
;;
--default)
DEFAULT=YES
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
#-------------------------End-Menu----------------------------
#__show_help__
if [ "$A2DHELP" = "yes" ]
then
help
exit 1
fi
#__step_1__
A2DSEED="App2Deb_$(date +%s)"
A2DCURDIR=$(pwd)
A2DDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
check_args
A2DFILE=$(realpath $A2DFILE)
#__show_info__
echo "Welcome to use Appimage2Deb Kitchen!"
echo "> Appimage2Deb 1.0b20201214"
echo "> Copyright (c) 2021 xRetia Labs"
echo ""
echo "********************************************************************************"
echo "APPIMAGE = ${A2DFILE}"
echo "PACKAGE NAME = ${A2DNAME}"
echo "ARCHITECTURE = ${A2DARCH}"
echo "VERSION = ${A2DVER}"
echo "RANDOM SEED = ${A2DSEED}"
echo "********************************************************************************"
echo ""
#__remove_old_create_new_seed__
printf "%-60s" "* preparing working directory ..."
rm -rf /tmp/App2Deb_*
mkdir /tmp/$A2DSEED
cd /tmp/$A2DSEED
printf "%20s\n" "[ OK ]"
#__create_deb_structure__
printf "%-60s" "* creating deb package directory structures ..."
A2DSEEDPKG="/tmp/$A2DSEED/CONTENTS/opt/durapps/a2d-packages/$A2DNAME"
A2DSEEDDESK="/tmp/$A2DSEED/CONTENTS/usr/share/applications"
cp -R $A2DDIR/a2d/* /tmp/$A2DSEED/
mkdir -p $A2DSEEDPKG
cp $A2DFILE $A2DSEEDPKG/base.AppImage
chmod +x $A2DSEEDPKG/base.AppImage
printf "%20s\n" "[ OK ]"
#__get_icon_from_appimage__
printf "%-60s" "* extracting application icon from appimage ..."
chmod +x $A2DFILE
$A2DFILE --appimage-extract >/dev/null 2>&1
cp squashfs-root/*.svg $A2DSEEDPKG/$A2DNAME.svg >/dev/null 2>&1
cp squashfs-root/*.png $A2DSEEDPKG/$A2DNAME.png >/dev/null 2>&1
printf "%20s\n" "[ OK ]"
#__get_desktop_from_appimage__
printf "%-60s" "* extracting application desktop from appimage ..."
cp squashfs-root/*.desktop $A2DSEEDDESK/$A2DNAME.desktop >/dev/null 2>&1
if [ "$A2DSAND" = "yes" ]
then
config_edit "Exec" "/opt/durapps/a2d-packages/$A2DNAME/base.AppImage --no-sandbox" $A2DSEEDDESK/$A2DNAME.desktop
else
config_edit "Exec" "/opt/durapps/a2d-packages/$A2DNAME/base.AppImage" $A2DSEEDDESK/$A2DNAME.desktop
fi
if [ -f $A2DSEEDPKG/$A2DNAME.svg ]
then
config_edit "Icon" "/opt/durapps/a2d-packages/$A2DNAME/$A2DNAME.svg" $A2DSEEDDESK/$A2DNAME.desktop
else
config_edit "Icon" "/opt/durapps/a2d-packages/$A2DNAME/$A2DNAME.png" $A2DSEEDDESK/$A2DNAME.desktop
fi
#config_edit "Name" "$A2DNAME" $A2DSEEDDESK/$A2DNAME.desktop
chmod +x $A2DSEEDDESK/$A2DNAME.desktop
printf "%20s\n" "[ OK ]"
#__debian_control__
printf "%-60s" "* generating deb package information ..."
rm -rf /tmp/$A2DSEED/DEBIAN/control
cat <<EOF > /tmp/$A2DSEED/DEBIAN/control
Package: $A2DNAME
Version: $A2DVER
Architecture: $A2DARCH
Description:
Depends:
Maintainer: spark-store
EOF
printf "%20s\n" "[ OK ]"
#__create_deb__
printf "%-60s" "* deb packaging is in-progress ..."
$A2DDIR/deb-build.sh -c gzip >/dev/null 2>&1
mv /tmp/$A2DSEED/*.deb $A2DCURDIR/
printf "%20s\n" "[ OK ]"
#__clean__
printf "%-60s" "* cleanning working directory ..."
cd $A2DCURDIR/
rm -rf /tmp/App2Deb_*
printf "%20s\n" "[ OK ]"
echo "Appimage2Deb: Package Generated Successfully!"
exit 0