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
|
#!/bin/bash
usage()
{
cat << EOF
Usage: $0 [[-h]|[-p INSTALLATION_DIRECTORY]? [-v]*]
This script will install Create Background Slideshow, a wallpaper slideshow
creator for the GNOME desktop, to /usr/local by default, or to the directory
passed with the -p flag.
OPTIONS:
-h Shows this message
-p Specifies installation directory
-v Be more verbose (use -v -v for extra verbosity)
EOF
}
PREFIX=/usr/local
VERBOSE=
while getopts "hp:v" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
p)
PREFIX=$OPTARG
;;
v)
VERBOSE=$VERBOSE+1
;;
?)
usage
exit
;;
esac
done
## ==== CREATE DIRECTORIES =============================================
if [[ $VERBOSE -ge 1 ]]
then
echo "Creating required directories..."
fi
LOC_DIR=share/crebs/locale
# Create directories if they don't already exist
for DIR in bin \
share \
share/applications \
share/man \
share/man/man1 \
share/crebs \
share/crebs/glade \
share/crebs/lib \
share/crebs/lib/crebs \
$LOC_DIR
do
if [[ ! -d $PREFIX/$DIR ]]
then
if [[ $VERBOSE -ge 2 ]]
then
echo " $PREFIX/$DIR..."
fi
mkdir $PREFIX/$DIR
fi
done
### Create localisation directories
for LOC in af ar ast bg cs cy da de dv el en_GB eo es fi fr gl he hu id io it ja ko lt lv ms nb nl pl pt pt_BR ro ru sr sv tr uk zh_TW
do
if [[ ! -d $PREFIX/$LOC_DIR/$LOC ]]
then
if [[ $VERBOSE -ge 2 ]]
then
echo " $PREFIX/$LOC_DIR/$LOC..."
fi
mkdir $PREFIX/$LOC_DIR/$LOC
fi
if [[ ! -d $PREFIX/$LOC_DIR/$LOC/LC_MESSAGES ]]
then
if [[ $VERBOSE -ge 2 ]]
then
echo " $PREFIX/$LOC_DIR/$LOC/LC_MESSAGES..."
fi
mkdir $PREFIX/$LOC_DIR/$LOC/LC_MESSAGES
fi
done
## ============================================= CREATE DIRECTORIES ====
## ==== COPY FILES =====================================================
if [[ $VERBOSE -ge 1 ]]
then
echo "Copying files..."
fi
# Copy the files
for DIR in bin \
share/applications \
share/man/man1 \
share/crebs/glade \
share/crebs/lib/crebs
do
if [[ $VERBOSE -ge 2 ]]
then
echo " $DIR/*..."
fi
cp crebs/$DIR/* $PREFIX/$DIR/
done
### Copy the localisation files
for LOC in af ar ast bg cs cy da de dv el en_GB eo es fi fr gl he hu id io it ja ko lt lv ms nb nl pl pt pt_BR ro ru sr sv tr uk zh_TW
do
if [[ $VERBOSE -ge 2 ]]
then
echo " $LOC_DIR/$LOC/LC_MESSAGES/*..."
fi
cp crebs/$LOC_DIR/$LOC/LC_MESSAGES/* $PREFIX/$LOC_DIR/$LOC/LC_MESSAGES/
done
## ===================================================== COPY FILES ====
## ==== REMOVE FILES ===================================================
if [[ $VERBOSE -ge 1 ]]
then
echo "Removing old files..."
fi
# Copy the files
for OLD_FILE in share/crebs/lib/crebs/conf.py \
share/crebs/lib/crebs/conf.pyc \
share/crebs/lib/crebs/defaults.py \
share/crebs/lib/crebs/defaults.pyc \
share/crebs/lib/crebs/files.py \
share/crebs/lib/crebs/files.pyc \
share/crebs/lib/crebs/info.py \
share/crebs/lib/crebs/info.pyc
do
if [[ $VERBOSE -ge 2 ]]
then
echo " $OLD_FILE..."
fi
if [[ -e $PREFIX/$OLD_FILE ]]
then
rm $PREFIX/$OLD_FILE
fi
done
## =================================================== REMOVE FILES ====
## ==== REGISTER APPLICATION ===========================================
if [[ $VERBOSE -ge 1 ]]
then
echo "Updating desktop database..."
fi
# Register CreBS as an application for its MIME types
update-desktop-database
## =========================================== REGISTER APPLICATION ====
if [[ $VERBOSE -ge 1 ]]
then
echo "Finished."
fi
|