-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.save
189 lines (186 loc) · 7.1 KB
/
build.save
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
#!/bin/bash
#I'm trying to get this out ASAP, so commenting will be brief
#Build tool for the use of anyone
#at least until i get around to something more complicated when i get time
clear
echo "Welcome to EzTheme, version 0.1.0"
echo "This tool was built for RippedThemer and my boy Alex"
echo "special thanks to ipadkid358"
#bc apparently you could just route echo to a text file this whole damn time
echo ""
echo "Choose an option:"
#Option 1, what I spent the entire time working on the script
echo "[1] Build a package from scratch"
#Option 2, extract a .zip file to a directory and build it as a .deb
#This option works for all packages, not just themes
echo "[2] Extract and package from a .zip file"
read option
if [[ $option == "2" ]]; then
echo "drag and drop the .zip file into your terminal"
read zip
echo ""
echo "Please type your desired package name"
echo "{Reccomended format: [package name]_[version]"
read zipname
#The following command is silenced because it is
#removing directories that may or may not exist
#If they don't exist it will throw an error
rm -r ~/eztheme/"$zipname" 2>/dev/null
#making our directories
mkdir ~/eztheme/"$zipname"
mkdir ~/eztheme/packaged_themes 2>/dev/null
#unzipping the .zip to a directory
unzip "${zip//\'}" -d ~/eztheme/"$zipname"
#Setting proper permissions for the necessary build files and folder
chmod 755 ~/eztheme/"$zipname"/DEBIAN
chmod 755 ~/eztheme/"$zipname"/DEBIAN/*
#the actual packager
dpkg-deb -Zgzip -b ~/eztheme/"$zipname"
#moving it to keep consistency
mv ~/eztheme/*.deb ~/eztheme/packaged_themes
echo ""
echo "Ok! Your .deb has been packaged!"
echo "It is in ~/eztheme/packaged_themes!"
exit
fi
echo "First things first, let me get eveything in shape"
echo "What is them name of this theme?"
read name
echo "What is the version?"
read version
echo "Let me see if the directories are there..."
echo ""
shopt -s nullglob
#clears a variable. described further a few lines down
d=n
for path in ~/eztheme/"$name"_*/
do
#this code is executed only if a matching directory for our theme exists
#this makes it easier to copy existing assets and change upon existing build
echo "It is! Saves us some time"
#copies our old icon theme to a new directory
#so it wont conflict with how I built the script
cp -a ~/eztheme/"$name"_*/ ~/eztheme/"$name".old/
mv ~/eztheme/"$name"_* ~/eztheme/"$name"_"$version"
#this variable here tells the rest of the script whether or not that file was found
#really only used in the if statement 4 lines down
d=y
break
done
#uses our variable d here
#human translation:
#if the directories don't yet exist, then we must create the neccesary directories
#I'm good at bash, trust me
if [[ $d != "y" ]]; then
echo "It's not there."
echo "Let's fix that"
#where the .debs are stored
#these are silent bc I'm too lazy to deal with situations in which they already exist
mkdir ~/eztheme 2>/dev/null
mkdir ~/eztheme/packaged_themes 2>/dev/null
#where the previous raw folder is stored
mkdir ~/eztheme/"$name".old
#the directories we need to package the .deb
mkdir ~/eztheme/"$name"_"$version"
mkdir ~/eztheme/"$name"_"$version"/Applications
mkdir ~/eztheme/"$name"_"$version"/Applications/"$name".app
mkdir ~/eztheme/"$name"_"$version"/Library
mkdir ~/eztheme/"$name"_"$version"/Library/Themes
mkdir ~/eztheme/"$name"_"$version"/DEBIAN
#finding out where we are
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#moving necessary resources and setting proper permissions
cp $DIR/preinst ~/eztheme/"$name"_"$version"/DEBIAN/preinst
cp $DIR/postinst ~/eztheme/"$name"_"$version"/DEBIAN/postinst
cp $DIR/control ~/eztheme/"$name"_"$version"/DEBIAN/control
fi
#Check to see if they want to clear out old themes
echo "Would you like to clear out your old theme folders? [y/n]"
read clear
if [[ $clear == "y" ]]
then
echo "Are you sure? [y/n]"
read ishavengayforrachel
# Don't ask
if [[ $ishavenisgayforrachel == "y" ]]; then
rm -r ~/eztheme/"$name"_"$version"/Library/Themes/*
echo "Deleted :)"
fi
fi
#straight moving the root folder in
#This has been changed for using multiple themes (like alts) since, ya know, there are usually more than one
#We'll have to see how it works!
#Mandatory theme copy for first run instance
if [[ $d != "y" ]]; then
echo "Go ahead and drag the .theme folders into the terminal"
echo ""
cp=y
else
echo "Would you like to update or add the icon themes? [y/n]"
read cp
fi
#while loop so you can infinitely add icon themes
while [[ $cp == "y" ]]
do
echo "Drag and drop your theme folder and press enter:"
read dir
echo ""
#fancy copy just overwrites our old theme and keeps our directory structures
#actually, why the fuck is it destructive?
#I'll fix this
cp -rfa "${dir//\'}" ~/eztheme/"$name"_"$version"/Library/Themes/
echo "Alright! everything's in!"
echo "Would you like to add or change anymore? [y/n]"
read cp
done
echo "Would you like to change or add the package icon [y/n]?"
read ico
echo ""
#if then statements determines if you want to change it. y and Y for case sensitivity"
if [[ $ico == "y" ]] || [[ $ico == "Y" ]]; then
echo "Okay! drag and drop that file in and press enter like before"
read icon
echo ""
echo "Alright! Got it, copying it in now."
#first we rename the old to remove conflicts if it exists
#this is silent so that if there is not an existing folder the user does not get an error
#there really isn't any threat for the error.
mv ~/eztheme/"$name"_"$version"/Applications/"$name".app/icon.png ~/eztheme/"$name"_"$version"/Applications/"$name".app/icon-old.png 2>/dev/null
#copies the icon and changes the name to match our control file
cp -rf "$icon" ~/eztheme/"$name"_"$version"/Applications/"$name".app/icon.png
echo "done!"
else
echo "Alright!"
fi
#speaking of control file
# echo ""
# echo "I am going to open the 'control' file."
# echo "This file is a little too advanced for me to parse, since I'm not too well versed with that using bash"
# echo "You can get everything updated as you need. Press Ctrl + O (omega), then enter to save the file"
# echo "From there press Ctrl + X to exit nano"
# echo "Everything should be obvious :)"
# echo "if not, the README.md has a nice little description of everything in the control file"
# echo "when you're ready press any key"
#just a silent function to detect key input
# read -n 1 -s
# nano ~/eztheme/"$name"_"$version"/DEBIAN/control
rm ~/eztheme/"$name"_"$version"/DEBIAN/control
echo Authour
clear
echo "I'm starting the compile"
#quick permissions for our friend the compiler
chmod 755 ~/eztheme/"$name"_"$version"/DEBIAN/
chmod 755 ~/eztheme/"$name"_"$version"/DEBIAN/*
#DO THE THING
dpkg-deb -Zgzip -b ~/eztheme/"$name"_"$version"
#moving the .deb to a folder so it wont conflict with the script
#also benefits tidiness
mv ~/eztheme/"$name"*.deb ~/eztheme/packaged_themes/
echo "All done! The .deb is stored in ~/eztheme/packaged_themes/"
echo "Have a nice day!"
#quit the script
exit
# This script will automatically credit itself with a postinst message that you can see in Cydia
# If you do not want this, I am creating ways around it :-)
# But unfortunately I have a life and school, so I will need time
# You can ask Ripped Themer all about that ;-P