-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateapp
More file actions
executable file
·229 lines (209 loc) · 10.2 KB
/
createapp
File metadata and controls
executable file
·229 lines (209 loc) · 10.2 KB
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
#!/bin/bash
APP_STORE_DIRECTORY="apps"
CATEGORIES_FILE="etc/categories"
get_editor() {
app_name="$1"
creator_file="etc/editor"
if [ -e "$creator_file" ]; then
cat "$creator_file"
else
echo "xdg-open"
fi
}
select_category_pane() {
category_list=()
while read -r category; do
category_list+=("images/categories/$category.png" "<b>$category</b>" "$(cat "etc/categoryinfo/${category}")")
done < "$CATEGORIES_FILE"
selected_category=$(yad --title="Select Category" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>Choose a category</b></big>\nLinStore organises apps by category, which allows users to quickly find related apps easier.\nPlease choose a category for your app:" \
--field="Category:" \
--width="525" --height="550" --center --on-top --borders=10 --columns=1 "${category_list[@]}" \
--list --column="Icon:IMG" --column="Categories" --column="Description" --no-headers \
--button="<b>Cancel</b>!gtk-cancel":1 \
--button="<b>Next</b>!go-next":0 | awk -F '|' '{print $2}')
./api info "$selected_category"
if [ -z "$selected_category" ]; then
exit 1
fi
app_directory="$APP_STORE_DIRECTORY"
# Create or update the app files with the collected information
echo "${selected_category//|/}" | sed 's/<\/\?b>//g' | sed 's/(null)//g' >"$app_directory/category"
# Call the function to create the app with the selected category
create_new_app_pane
}
create_new_app_pane() {
app_directory="$APP_STORE_DIRECTORY"
app_data=$(yad --form \
--title="Create New App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" \
--class="LinStore" \
--text="<big><b>App Details</b></big>\nYour app needs information for LinStore to properly display it.\nEnter the following details for the new $(cat ${app_directory}/category) app:" \
--field=":LBL" "" \
--field="<b>App Name:</b>:ENTRY" "" \
--field="<b>Website:</b>:ENTRY" "" \
--field="<b>Creator:</b>:ENTRY" ""\
--field="<b>Donation link:</b>:ENTRY" ""\
--field=":LBL" "" \
--field="<b>Description:</b>:TXT" "" \
--field=":LBL" "" \
--field="<b>Architectures supported by your app</b>:LBL" "" \
--field="x64 (amd64):CHK" "" \
--field="x86 (i386/x86):CHK" "" \
--field="ARM 32-bit (armv7l):CHK" "" \
--field="ARM 64-bit (aarch64):CHK" "" \
--field=":LBL" "" \
--field="<b>Separate or combined install scripts?</b>:CB" 'Combined (all architectures in one)!Separate' \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Cancel</b>!gtk-cancel":1 \
--button="<b>Next</b>!go-next":0)
if [ -z "$app_data" ]; then
exit 1
fi
./api info "$app_data"
# Extracting values from the form data
app_name=$(echo "$app_data" | awk -F '|' '{print $2}')
website=$(echo "$app_data" | awk -F '|' '{print $3}')
creator=$(echo "$app_data" | awk -F '|' '{print $4}')
donate=$(echo "$app_data" | awk -F '|' '{print $5}')
description=$(echo "$app_data" | awk -F '|' '{print $7}')
install_x64=$(echo "$app_data" | awk -F '|' '{print $10}')
install_x86=$(echo "$app_data" | awk -F '|' '{print $11}')
install_32=$(echo "$app_data" | awk -F '|' '{print $12}')
install_64=$(echo "$app_data" | awk -F '|' '{print $13}')
separate_scripts=$(echo "$app_data" | awk -F '|' '{print $15}')
# Create the app directory
app_directory="$APP_STORE_DIRECTORY/$app_name"
mkdir -p "$app_directory"
mv "$APP_STORE_DIRECTORY/category" "$app_directory/category"
# Create or update the app files with the collected information
echo "$website" >"$app_directory/website"
echo "$creator" >"$app_directory/creator"
echo "$description" >"$app_directory/description"
if [[ "$donate" != "" ]]; then
echo "$donate" >"$app_directory/donate"
fi
# Generate and resize the icon
#icon_file=$(yad --file-selection --title="Select Icon for App" --width="525" --height="550" --center --on-top)
assets_data=$(yad --form \
--title="Create New App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>App Assets</b></big>\nYour app needs assets in LinStore, which is currently limited to the app's logo/icon.\nSelect these assets here:" \
--field=":LBL" "" \
--field="<b>Icon/logo</b>:SFL" "" \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Cancel</b>!gtk-cancel":1 \
--button="<b>Next</b>!go-next":0)
if [ -z "$assets_data" ]; then
exit 1
fi
./api info "$assets_data"
icon_file=$(echo "$assets_data" | awk -F '|' '{print $2}')
if [ -n "$icon_file" ]; then
cp "$icon_file" "$app_directory/icon-original.png"
convert "$icon_file" -resize 64x64 "$app_directory/icon-64.png"
convert "$icon_file" -resize 48x48 "$app_directory/icon-48.png"
convert "$icon_file" -resize 24x24 "$app_directory/icon-24.png"
convert "$icon_file" -resize 16x16 "$app_directory/icon-16.png"
fi
yad --form \
--title="Create New App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>Installer Scripts</b></big>\nYour app has been created!" \
--field=":LBL" "" \
--field="You now need to write an Installer and an Uninstaller script. These are the scripts executed when users click \"Install\" and \"Uninstall\" in LinStore.\n\nIf you would like to create these now, press 'Next'. Else, press 'Cancel'.:LBL" "" \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Cancel</b>!gtk-cancel":1 \
--button="<b>Next</b>!go-next":0 > /dev/null 2>&1
# Create or update the install scripts based on user preferences
if [ $? -eq 0 ]; then
if [[ "$separate_scripts" == "Combined (all architectures in one)" ]]; then
gedit "$app_directory/install" &
else
if [ "$install_x64" == "TRUE" ]; then
gedit "$app_directory/install-x64" &
fi
if [ "$install_x86" == "TRUE" ]; then
gedit "$app_directory/install-x86" &
fi
if [ "$install_32" == "TRUE" ]; then
gedit "$app_directory/install-32" &
fi
if [ "$install_64" == "TRUE" ]; then
gedit "$app_directory/install-64" &
fi
fi
gedit "$app_directory/uninstall"
wait
elif [ $? -eq 252 ]; then
echo $?
fi
yad --form \
--title="Create New App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>Thank you!</b></big>\nThank you for using LinStore's app creation wizard." \
--field=":LBL" "" \
--field="<b>Next Steps:</b>\nSubmit your app for addition to LinStore's app library. You can do this by 'zipping' the new app's directory and uploading it to an issue at <a href='https://github.com/techguy16/LinStore'>our GitHub</a>.\n\nIf you do not wish to do so, you can still distribute your app's zip file by specifying to your users to use LinStore's 'Import App' function.:LBL" "" \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Exit</b>!window-close":0 > /dev/null 2>&1
}
welcome() {
yad --form \
--title="Create New App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>App Creator</b></big>\nWelcome to the LinStore's app creator!" \
--field=":LBL" "" \
--field="<b>What is this?</b>\nThis is a wizard that will guide you through the necessary steps in order to create an app to be displayed in LinStore.\n\nIf you're ready, press 'Next'.\nIf you got here by accident, press 'Cancel'.:LBL" "" \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Cancel</b>!gtk-cancel":1 \
--button="<b>Next</b>!go-next":0 > /dev/null 2>&1
if [ $? -eq 0 ]; then
select_category_pane
elif [ $? -eq 252 ]; then
exit 1
fi
}
import_zip_file() {
#import_file=$(yad --file-selection --title="Select Zip File to Import" --height="550" --width="525" --center --on-top)
import_file=$(yad --form \
--title="Import App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>Import an app</b></big>\nImport an app packaged as a ZIP into LinStore." \
--field=":LBL" "" \
--field="Some app developers distribute ZIP files to let you import into LinStore.\n\nTo import such a ZIP file, select it below and we'll import it for you.:LBL" "" \
--field="<b>ZIP File: </b>:SFL" "" \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Cancel</b>!gtk-cancel":1 \
--button="<b>Next</b>!go-next":0 | awk -F '|' '{print $3}')
echo "$import_file"
if [ -z "$import_file" ]; then
yad --error --title="Error" --text="No file selected for import." --center --on-top --borders=10
return
fi
unzip -o "$import_file" -d "$APP_STORE_DIRECTORY"
yad --form \
--title="Import App" \
--image="images/logo/logo-64.png" --image-on-top \
--window-icon="images/logo/logo-64.png" --class="LinStore" \
--text="<big><b>Success!</b></big>\nYour app has been successfully imported into LinStore." \
--field=":LBL" "" \
--field="You should now be able to find the app in the list of available apps!:LBL" "" \
--width="525" --height="550" --center --on-top --borders=10 --separator="|" \
--button="<b>Close</b>!window-close":0
}
if [ "$1" == "import" ]; then
import_zip_file
elif [ "$1" == "create" ]; then
welcome
else
echo "Invalid argument. Please provide 'create' or 'import'."
exit 1
fi