File: build_package.sh

package info (click to toggle)
vmg 3.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,528 kB
  • sloc: pascal: 5,160; cpp: 605; sh: 278; lex: 105; ansic: 68; makefile: 37
file content (257 lines) | stat: -rwxr-xr-x 5,287 bytes parent folder | download
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/bin/sh
#
# This script generates packages for the Virtual Magnifying Glass
#

##################################
# Constants
##################################

PRODUCT="Virtual Magnifying Glass"
VERSION="3.8.1"
OS="linux"

TARGET_DIR="./magnifier-$OS-$VERSION/"
TARGET_TAR="magnifier-$OS-$VERSION.tar"
TARGET_ZIP="magnifier-$VERSION.zip"

MANUALS_DIR="docs"
MANUALS="README-EN.rtf README-PT.rtf README-EN.pdf README-PT.pdf"

RESOURCES="topleft.bmp topright.bmp bottomleft.bmp bottomright.bmp top.bmp left.bmp bottom.bmp right.bmp icon3.ico icon3.png cecae.bmp feusp.bmp vmg.bmp lupa.bmp usplegal.bmp"

SCRIPTS="install.sh uninstall.sh"

DEBIAN_DIR=vmg_3.8.1_amd64

##################################
# Builds a binary tar package
##################################
BuildBinary ()
{
  # Goes to the root directory of the magnifier
  
  cd ..

  # Builds the software

  ./make.sh

  strip --strip-all magnifier

  # Creates main directory

  mkdir $TARGET_DIR

  # Copies files to the directory

  cp $RESOURCES $TARGET_DIR

  cp $SCRIPTS $TARGET_DIR

  mkdir $TARGET_DIR/$MANUALS_DIR

  cd $MANUALS_DIR

  cp $MANUALS ../$TARGET_DIR/$MANUALS_DIR 

  cd ..
  
  cp ./magnifier $TARGET_DIR
  
  cp build/vmg.desktop $TARGET_DIR
  
  
  # Creates the archive

  tar -cvf $TARGET_TAR $TARGET_DIR

  bzip2 $TARGET_TAR

  # Clean up

  rm -rf $TARGET_DIR

  ./clean.sh

  cd build

  return
}


##################################
# Creates a source zip package
##################################
SourcePackage ()
{
  # Goes to the root directory of the magnifier

  cd ..

  # Clean up

  echo "Clean up"
  ./clean.sh
  rm -rf ../magnifier-$VERSION/

  # We use SVN export to get rid of the heavy svn files
  # copies all files to a new temporary directory

  echo "svn export ./ ../magnifier-$VERSION/"
  svn export ./ ../magnifier-$VERSION/

  # Creates the package

  echo "zip -rv ../$TARGET_ZIP ../magnifier-$VERSION/"
  zip -rv ../$TARGET_ZIP ../magnifier-$VERSION/

  # Clean up

  echo "Clean up"
  rm -rf ../magnifier-$VERSION/
  cd build

  return
}

##################################
# Set up the RPM build environment
##################################
CreateRPMEnvironment ()
{
  # Creates the directory structure

  mkdir $HOME/RPM
  mkdir $HOME/RPM/BUILD # This directory is utilized by RPM to build the package.
  mkdir $HOME/RPM/RPMS # Here you can find binary RPMs after you build them.
  mkdir $HOME/RPM/SOURCES # Place your compressed tar files and patches here.
  mkdir $HOME/RPM/SPECS # Place all your spec files here.
  mkdir $HOME/RPM/SRPMS # Here you can find source RPMs after you build them. 

  # rpmbuild environment file

  touch $HOME/.rpmmacros

  echo "%_topdir                /home/felipe/RPM/" >> $HOME/.rpmmacros
  echo "%_tmppath               /home/felipe/tmp" >> $HOME/.rpmmacros
  echo "" >> $HOME/.rpmmacros
  echo "%_signature             gpg" >> $HOME/.rpmmacros
  echo "%_gpg_name              Mandrakelinux" >> $HOME/.rpmmacros
  echo "%_gpg_path              ~/.gnupg" >> $HOME/.rpmmacros

  # Spec file

  cp magnifier.spec $HOME/RPM/SPECS/

  # Zip file

  cp ../../$TARGET_ZIP $HOME/RPM/SOURCES/

  return
}

##################################
# Builds a binary and source RPM package
##################################
RPMPackage ()
{
  # Set up the RPM build environment
  CreateRPMEnvironment

  # now build it
  echo "rpmbuild -ba --clean $HOME/RPM/SPECS/magnifier.spec"
  rpmbuild -ba --clean $HOME/RPM/SPECS/magnifier.spec

  return
}

##################################
# Creates a Debian package
##################################
DebianPackage ()
{
  # Goes to the root directory of the magnifier

  cd ..

  # Builds the software

  ./make.sh

  strip --strip-all magnifier

  # Returns to build dir

  cd build
  
  mkdir $DEBIAN_DIR
  mkdir $DEBIAN_DIR/usr
  mkdir $DEBIAN_DIR/usr/bin
  mkdir $DEBIAN_DIR/usr/share
  mkdir $DEBIAN_DIR/usr/share/magnifier
  mkdir $DEBIAN_DIR/usr/share/applications
  mkdir $DEBIAN_DIR/DEBIAN
  cp control $DEBIAN_DIR/DEBIAN/  
  cd ..
  cp ./magnifier build/$DEBIAN_DIR/usr/bin/vmg
  cp $RESOURCES build/$DEBIAN_DIR/usr/share/magnifier
  cd $MANUALS_DIR
  cp $MANUALS ../build/$DEBIAN_DIR/usr/share/magnifier
  cd ..
  cd build
  cp vmg.desktop $DEBIAN_DIR/usr/share/applications
  dpkg-deb --build --root-owner-group $DEBIAN_DIR
  
  # Clean up
  echo "Clean up"
  rm -rf $DEBIAN_DIR
  cd ..
  ./clean.sh
  cd build
  
  return
}


##################################
# Main section
##################################

echo "========================================================"
echo "    Virtual Magnifying Glass build script"
echo "========================================================"
echo ""
echo " Please select which package you would like to build:"
echo ""
echo " 1 > Linux Gtk2 binary tar.bz2 package"
echo " 2 > FreeBSD Gtk2 binary tar.bz2 package"
echo " 3 > Source .zip package"
echo " 4 > RPM package (source and binary)"
echo " 5 > Debian package"
echo " 0 > Exit"

read command

case $command in

  1) BuildBinary;;

  2) OS="freebsd"
     TARGET_DIR="./magnifier-$OS-$VERSION/"
     TARGET_TAR="magnifier-$OS-$VERSION.tar"

     BuildBinary;;

  3) SourcePackage;;

  4) RPMPackage;;

  5) DebianPackage;;

  0) exit 0;;

  *) echo "Invalid command"
     exit 0;;

esac