-
Notifications
You must be signed in to change notification settings - Fork 18
/
logigsk-buildpackage
600 lines (513 loc) · 17.9 KB
/
logigsk-buildpackage
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
#!/bin/bash
#check if script is run as root
if [ "$(id -u $USER)" != "0" ]; then
echo "Please run as root"
exit 1
fi
#check if needed tools are installed(not perfect)
command -v java >/dev/null 2>&1 || { echo >&2 "This program requires java but it's not installed. Aborting.";}
command -v javac >/dev/null 2>&1 || { echo >&2 "This program requires javac but it's not installed. Aborting.";}
command -v jsvc >/dev/null 2>&1 || { echo >&2 "This program requires jsvc but it's not installed. Aborting.";}
command -v ant >/dev/null 2>&1 || { echo >&2 "This program requires ant but it's not installed. Aborting.";}
command -v dpkg >/dev/null 2>&1 || { echo >&2 "This program requires dpkg but it's not installed. Aborting.";}
case "$1" in
deb)
;;
rpm|*)
alien -r -c -v debian.deb
command -v alien >/dev/null 2>&1 || { echo >&2 "This program requires alien to produce rpm package files, but it's not installed. Aborting.";}
;;
esac
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
#compile the project using apache ant
echo "compiling the project using Apache Ant"
ant -f $DIR -Dnb.internal.action.name=rebuild clean jar
PACKAGE_NAME="logigsk"
PACKAGE_VERSION="1.0.0"
SOURCE_DIR=$PWD
TEMP_DIR="/tmp"
PACKAGE_SERVICE_NAME="logigsk-service"
mkdir -p $TEMP_DIR/tmpscripts/daemon
mkdir -p $TEMP_DIR/debian/DEBIAN
mkdir -p $TEMP_DIR/debian/usr/bin
mkdir -p $TEMP_DIR/debian/usr/share/applications
mkdir -p $TEMP_DIR/debian/usr/share/$PACKAGE_NAME
mkdir -p $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/lib
mkdir -p $TEMP_DIR/debian/usr/share/doc/$PACKAGE_NAME
cat > $TEMP_DIR/tmpscripts/control <<'endmsg'
Package: logigsk
Section: utils
Priority: optional
Maintainer: Mohamad Saada <[email protected]>
Version: 1.0.0
Architecture: all
Depends: default-jre | default-jre | java6-runtime, jarwrapper, jsvc
Description: Logitech G series keyboard configuration utility
LogiGSK is free and open source software for configuring Logitech
G series keyboard leds under Linux operating system.
Homepage: https://github.com/MohamadSaada/LogiGSK
endmsg
cat > $TEMP_DIR/tmpscripts/copyright <<'endmsg'
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: LogiGSK
Source: https://github.com/MohamadSaada/LogiGSK
Files: *
Copyright (C) 2017 Mohamad Saada
Licence: GPL 3+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the full text of the GNU General Public
License version 3 can be found in the file
`/usr/share/common-licenses/GPL-3'.
endmsg
cat > $TEMP_DIR/tmpscripts/99_LogiGSK <<'endmsg'
#!/bin/bash
#This file should be place in /etc/pm/sleep.d/
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
case $1 in
hibernate)
#echo "Nothing to do"
;;
suspend)
#echo "Nothing to do"
;;
thaw)
if [ "$(id -u $USER)" != "0" ]; then
sudo -u $USER "/usr/share/logigsk/LogiGSK" restart
fi
;;
resume)
if [ "$(id -u $USER)" != "0" ]; then
sudo -u $USER "/usr/share/logigsk/LogiGSK" restart
fi
;;
*) #echo "Somebody is calling me totally wrong."
;;
esac
endmsg
cat > $TEMP_DIR/tmpscripts/logigsk <<'endmsg'
#!/bin/sh
java -jar /usr/share/logigsk/LogiGSK.jar
endmsg
cat > $TEMP_DIR/tmpscripts/logigsk-service <<'endmsg'
#!/bin/bash
case $1 in
start)
"/usr/share/logigsk/LogiGSK" start
;;
stop)
"/usr/share/logigsk/LogiGSK" stop
;;
restart)
"/usr/share/logigsk/LogiGSK" restart
;;
install)
if [ "$(id -u)" != "0" ]; then
if [ ! -f "$HOME/.config/autostart/LogiGSK.sh" ]; then
while true; do
read -p "Would you like to add automatic startup of this service? " yn
case $yn in
[Yy]* ) ln -sf /usr/share/logigsk/LogiGSK.sh "$HOME/.config/autostart/LogiGSK.sh"; echo "Successfully added LogiGSK service to automatically startup"; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "LogiGSK service is already set to startup automatically"
fi
fi
;;
uninstall)
if [ "$(id -u)" != "0" ]; then
if [ -L "$HOME/.config/autostart/LogiGSK.sh" ]; then
while true; do
read -p "Would you like to remove automatic startup of this service? " yn
case $yn in
[Yy]* ) rm "$HOME/.config/autostart/LogiGSK.sh"; echo "Successfully removed LogiGSK service from automatic startup"; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "LogiGSK service is not set to startup automatically"
fi
fi
;;
*)
echo "Usage: logigsk-service {start|stop|restart|install|uninstall}" >&2
exit 3
;;
esac
endmsg
cat > $TEMP_DIR/tmpscripts/logigsk.desktop <<'endmsg'
[Desktop Entry]
Encoding=UTF-8
Name=LogiGSK
Categories=Settings;Utility;
Comment=Logitech Keyboard Configuration Tool
Exec=/usr/bin/logigsk
Icon=/usr/share/logigsk/LogiGSK.png
Terminal=false
Type=Application
StartupNotify=true
endmsg
cat > $TEMP_DIR/tmpscripts/LogiGSK.rules <<'endmsg'
#G410 Atlas Spectrum
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c330", MODE="666"
#G610 Orion
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c333", MODE="666"
#G610 Orion
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c338", MODE="666"
#G810 Spectrum
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c331", MODE="666"
#G810 Spectrum
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c337", MODE="666"
#G910 Orion Spark
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c32b", MODE="666"
#G910 Orion Spectrum
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c335", MODE="666"
endmsg
cat > $TEMP_DIR/tmpscripts/LogiGSK.sh <<'endmsg'
#!/bin/bash
"/usr/share/logigsk/LogiGSK" start
endmsg
cat > $TEMP_DIR/tmpscripts/preinst <<'endmsg'
#!/bin/sh
#
# preinst script for LogiGSK
#
set -e
# source debconf library
. /usr/share/debconf/confmodule
# Source dbconfig-common functions
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
. /usr/share/dbconfig-common/dpkg/postinst.pgsql
fi
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
install)
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
if [ "$(id -u $USER)" != "0" ]; then
if [ -f /usr/share/logigsk/LogiGSK ]; then
sudo -H -u $USER "/usr/share/logigsk/LogiGSK" stop
fi
fi
;;
upgrade|abort-upgrade)
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
if [ "$(id -u $USER)" != "0" ]; then
sudo -H -u $USER "/usr/share/logigsk/LogiGSK" stop
fi
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
exit 0
endmsg
cat > $TEMP_DIR/tmpscripts/postinst <<'endmsg'
#!/bin/sh
#
# postinst script for LogiGSK
#
set -e
# source debconf library
. /usr/share/debconf/confmodule
# Source dbconfig-common functions
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
. /usr/share/dbconfig-common/dpkg/postinst.pgsql
fi
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
sudo ln -sf /usr/share/logigsk/LogiGSK.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo ln -sf /usr/share/logigsk/99_LogiGSK /etc/pm/sleep.d/
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
if [ "$(id -u $USER)" != "0" ]; then
HOME=`eval echo ~$USER`
if [ -d "$HOME/.config/autostart/" ]; then
sudo -u $USER ln -sf /usr/share/logigsk/LogiGSK.sh "$HOME/.config/autostart/LogiGSK.sh"
else
echo "failed to setup LogiGSK service startup file in autostart, please refere to website for more details."
fi
sudo -H -u $USER "/usr/share/logigsk/LogiGSK" start
exit 0
else
echo "failed to setup LogiGSK service startup file in autostart, please refere to website for more details."
exit 1
fi
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
endmsg
cat > $TEMP_DIR/tmpscripts/postrm <<'endmsg'
#!/bin/sh
#
# postrm script for LogiGSK
#
set -e
# source debconf library
. /usr/share/debconf/confmodule
# Source dbconfig-common functions
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
. /usr/share/dbconfig-common/dpkg/postinst.pgsql
fi
# summary of how this script can be called:
# * <postrm> `remove'
# * <postrm> `purge'
# * <old-postrm> `upgrade' <new-version>
# * <new-postrm> `failed-upgrade' <old-version>
# * <new-postrm> `abort-install'
# * <new-postrm> `abort-install' <old-version>
# * <new-postrm> `abort-upgrade' <old-version>
# * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
purge)
if [ -L /etc/udev/rules.d/LogiGSK.rules ]; then
sudo rm /etc/udev/rules.d/LogiGSK.rules
sudo udevadm control --reload-rules
fi
if [ -L /etc/pm/sleep.d/99_LogiGSK ]; then
sudo rm /etc/pm/sleep.d/99_LogiGSK
fi
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
if [ "$(id -u $USER)" != "0" ]; then
HOME=`eval echo ~$USER`
if [ -L "$HOME/.config/autostart/LogiGSK.sh" ]; then
sudo rm "$HOME/.config/autostart/LogiGSK.sh"
fi
fi
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
if [ -L /etc/udev/rules.d/LogiGSK.rules ]; then
sudo rm /etc/udev/rules.d/LogiGSK.rules
sudo udevadm control --reload-rules
fi
if [ -L /etc/pm/sleep.d/99_LogiGSK ]; then
sudo rm /etc/pm/sleep.d/99_LogiGSK
fi
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
if [ "$(id -u $USER)" != "0" ]; then
HOME=`eval echo ~$USER`
if [ -L "$HOME/.config/autostart/LogiGSK.sh" ]; then
sudo rm "$HOME/.config/autostart/LogiGSK.sh"
fi
fi
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
endmsg
cat > $TEMP_DIR/tmpscripts/prerm <<'endmsg'
#!/bin/sh
#
# prerm script for LogiGSK
#
set -e
# source debconf library
. /usr/share/debconf/confmodule
# Source dbconfig-common functions
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
. /usr/share/dbconfig-common/dpkg/postinst.pgsql
fi
# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
remove)
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
if [ "$(id -u $USER)" != "0" ]; then
sudo -H -u $USER "/usr/share/logigsk/LogiGSK" stop
fi
;;
upgrade|deconfigure|failed-upgrade)
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
endmsg
cat > $TEMP_DIR/tmpscripts/daemon/LogiGSK <<'endmsg'
#!/bin/sh
if [ "$(id -u)" = "0" ]; then
echo "Please don't run as root"
exit 1
fi
NAME="LogiGSK"
DESC="LogiGSK service"
# Setup variables
# The path to Jsvc
EXEC=/usr/bin/jsvc
# The path to the folder containing the java runtime
#JAVA_HOME=/usr/lib/jvm/default-java
# The path to the folder containing the dameon and other needed libraries
CLASS_PATH_L="/usr/share/logigsk/lib/*.jar"
# The path to the folder containing the executable jar
CLASS_PATH_R="/usr/share/logigsk/LogiGSK.jar"
#Desktop
XDG_DESKTOP_TYPE=KDE
# The fully qualified name of the class to execute
CLASS=Logi.GSeries.Service.LogiGSKService
#The user to run the daemon as
#USER=hammi
# The file that will contain our process identification number (pid) for other scripts/programs that need to access it.
PID=$HOME/.local/share/LogiGSK/LogiGSKService.pid
# System.out writes to this file
LOG_OUT=$HOME/.local/share/LogiGSK/LogiGSKService.out
# System.err writes to this file...
LOG_ERR=$HOME/.local/share/LogiGSK/LogiGSKService.err
jsvc_exec()
{
export DISPLAY=:0
#export XDG_CURRENT_DESKTOP=$XDG_DESKTOP_TYPE
$EXEC -home "$JAVA_HOME" -cp "$CLASS_PATH_L":"$CLASS_PATH_R" -procname $NAME -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $PID $1 $CLASS
}
case "$1" in
start)
echo "Starting the $DESC..."
# Start the service
jsvc_exec
echo "The $DESC has started."
;;
stop)
if [ -f "$PID" ]; then
echo "Stopping the $DESC..."
# Stop the service
jsvc_exec "-stop"
echo "The $DESC has stopped."
else
echo "Daemon not running, no action taken"
fi
;;
restart)
if [ -f "$PID" ]; then
echo "Restarting the $DESC..."
# Stop the service
jsvc_exec "-stop"
# Start the service
jsvc_exec
echo "The $DESC has restarted."
else
echo "Daemon not running, no action taken"
fi
;;
*)
echo "Usage: /usr/share/logigsk/$NAME {start|stop|restart}" >&2
exit 3
;;
esac
endmsg
cp $TEMP_DIR/tmpscripts/control $TEMP_DIR/debian/DEBIAN/
cp $TEMP_DIR/tmpscripts/preinst $TEMP_DIR/debian/DEBIAN/
chmod 755 $TEMP_DIR/debian/DEBIAN/preinst
cp $TEMP_DIR/tmpscripts/postinst $TEMP_DIR/debian/DEBIAN/
chmod 755 $TEMP_DIR/debian/DEBIAN/postinst
cp $TEMP_DIR/tmpscripts/prerm $TEMP_DIR/debian/DEBIAN/
chmod 755 $TEMP_DIR/debian/DEBIAN/prerm
cp $TEMP_DIR/tmpscripts/postrm $TEMP_DIR/debian/DEBIAN/
chmod 755 $TEMP_DIR/debian/DEBIAN/postrm
cp $TEMP_DIR/tmpscripts/logigsk.desktop $TEMP_DIR/debian/usr/share/applications/
chmod 0644 $TEMP_DIR/debian/usr/share/applications/logigsk.desktop
cp $TEMP_DIR/tmpscripts/copyright $TEMP_DIR/debian/usr/share/doc/$PACKAGE_NAME/
chmod 0644 $TEMP_DIR/debian/usr/share/doc/$PACKAGE_NAME/copyright
cp $TEMP_DIR/tmpscripts/LogiGSK.rules $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/
chmod 0644 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/LogiGSK.rules
cp $TEMP_DIR/tmpscripts/LogiGSK.sh $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/
chmod 755 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/LogiGSK.sh
cp $TEMP_DIR/tmpscripts/99_LogiGSK $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/
chmod 755 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/99_LogiGSK
cp $DIR/dist/LogiGSK.jar $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/
chmod 755 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/LogiGSK.jar
cp $DIR/dist/lib/*.jar $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/lib/
chmod 0644 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/lib/*.jar
cp $TEMP_DIR/tmpscripts/daemon/LogiGSK $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/
chmod 755 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/LogiGSK
cp $TEMP_DIR/tmpscripts/$PACKAGE_NAME $TEMP_DIR/debian/usr/bin/
chmod 755 $TEMP_DIR/debian/usr/bin/$PACKAGE_NAME
cp $TEMP_DIR/tmpscripts/$PACKAGE_SERVICE_NAME $TEMP_DIR/debian/usr/bin/
chmod 755 $TEMP_DIR/debian/usr/bin/$PACKAGE_SERVICE_NAME
echo "$PACKAGE_NAME ($PACKAGE_VERSION) trusty; urgency=low" > changelog
echo " * Rebuild" >> changelog
echo " -- Mohamad Saada <[email protected]> `date -R`" >> changelog
gzip -9c changelog > $TEMP_DIR/debian/usr/share/doc/$PACKAGE_NAME/changelog.gz
cp $DIR/src/Logi/GSeries/Keyboard/Resources/Images/GSK_Icon.png $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/LogiGSK.png
chmod 0644 $TEMP_DIR/debian/usr/share/$PACKAGE_NAME/LogiGSK.png
PACKAGE_SIZE=`du -bs $TEMP_DIR/debian | cut -f 1`
PACKAGE_SIZE=$((PACKAGE_SIZE/1024))
echo "Installed-Size: $PACKAGE_SIZE" >> $TEMP_DIR/debian/DEBIAN/control
chown -R root $TEMP_DIR/debian/
chgrp -R root $TEMP_DIR/debian/
cd $TEMP_DIR/
dpkg --build debian
case "$1" in
deb)
mv debian.deb $DIR/$PACKAGE_NAME-$PACKAGE_VERSION.deb
;;
rpm)
alien -r -c -v debian.deb
mv *.rpm $DIR/$PACKAGE_NAME-$PACKAGE_VERSION.rpm
;;
*)
alien -r -c -v debian.deb
mv debian.deb $DIR/$PACKAGE_NAME-$PACKAGE_VERSION.deb
mv *.rpm $DIR/$PACKAGE_NAME-$PACKAGE_VERSION.rpm
;;
esac
rm -r $TEMP_DIR/debian
rm -r $TEMP_DIR/tmpscripts