forked from OSGeo/OSGeoLive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·116 lines (92 loc) · 3.77 KB
/
package.sh
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
#!/bin/sh
#################################################
#
# Purpose: Compress and package the Live DVD image
# Author: Cameron Shorter
#
#################################################
# Copyright (c) 2010 Open Source Geospatial Foundation (OSGeo)
# Copyright (c) 2009 LISAsoft
#
# Licensed under the GNU LGPL.
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 2.1 of the License,
# or any later version. This library 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 Lesser General Public License for more details, either
# in the "LICENSE.LGPL.txt" file distributed with this software or at
# web page "http://www.fsf.org/licenses/lgpl.html".
##################################################
# Prerequisites:
# * Running an Ubuntu or Ubuntu derivative system
# * VMWare Server is installed
# *
DIR=`dirname ${0}`
VERSION=`cat ${DIR}/../VERSION.txt`
PACKAGE_NAME="osgeolive"
#VM_DIR="/var/lib/vmware/Virtual Machines/" # Default directory
VM_DIR="/var/lib/vmware/VirtualMachines/"
#VM_DIR="/mnt/space/arramagong/vm/${VERSION}"
#VM_DIR="/data/space/arramagong/vm/"
VM="osgeolive-${VERSION}"
# Exit if VM doesn't exist
if [ `find "${VM_DIR}/${VM}" -name "*.vmdk" -print | wc -l` -eq 0 ] ; then
echo "Cannot find ${VM_DIR}/${VM}/*.vmdk"
exit 1
fi
echo "===================================================================="
echo "Starting package.sh for version: {$VERSION}"
echo "===================================================================="
echo Disk Usage1:, package.sh start, `df | grep "Filesystem" | sed -e "s/ */,/g"`, date
echo Disk Usage2:, package.sh start, `df | grep " /$" | sed -e "s/ */,/g"`, `date`
echo Disk Usage3:, package.sh start, `du -sh ${VM_DIR}/${VM} | cut -f1` , `date`
echo "Start package.sh. Packaging $VM_DIR/$VM"
date
# Install 7zip
apt-get --assume-yes install p7zip-full
echo "Remove non-core VM files, except *.vmx and *.vmdk"
cd "$VM_DIR/$VM"
for FILE in `ls | grep -v "\.vmdk$" | grep -v "\.vmx$"` ; do
rm -fr $FILE
done
echo Disk Usage3:, after removing non-core VM files, `du -hs ${VM_DIR}/${VM}` , `date`
# Shrink
echo "Shrink the image"
vmware-vdiskmanager -k *.vmdk
echo Disk Usage3:, after shrinking the image, `du -hs ${VM_DIR}/${VM}` , `date`
# Compress
echo "Compress the image using 7z"
cd "${VM_DIR}"
7z a -mx=9 "${PACKAGE_NAME}-${VERSION}.7z" "${PACKAGE_NAME}-${VERSION}"
echo Disk Usage3:, after 7zipping the image, `du -hs ${PACKAGE_NAME}-${VERSION}.7z` , `date`
# if the image is greater than 2 Gig, we need to split the image, as the OSGeo
# server isn't configured to accept files of a greater size.
# Reconstitute with:
# `cat ${PACKAGE_NAME}-${VERSION}.7z[1-9]* > ${PACKAGE_NAME}-${VERSION}.7z
echo "Split the image"
split -d -a 1 -b 1500M ${PACKAGE_NAME}-${VERSION}.7z ${PACKAGE_NAME}-${VERSION}.7z.
#Replaced mv commands with split options to achieve same effect
echo "Add the following lines to"
echo " https://[email protected]/osgeo/livedvd/gisvm/trunk/download/index.html"
echo
echo "<a name='${VERSION}'></a>"
echo "<h3>OSGeo Live GIS - ${VERSION}</h3>"
echo `date "+%d %B %Y"`
echo "<ul>"
for FILE in ${PACKAGE_NAME}-${VERSION}.7z* ; do
MD5SUM=`md5sum ${FILE} | cut -f1 -d" "`
SIZE=`du -h ${FILE} | cut -f1`
echo "<li>"
echo " <a href=\"${FILE}\">$FILE</a>"
echo " <BR>(${SIZE})"
echo " md5sum: $MD5SUM"
echo "</li>"
done
echo "</ul>"
echo
echo Disk Usage1:, package.sh end, `df | grep "Filesystem" | sed -e "s/ */,/g"`, date
echo Disk Usage2:, package.sh end, `df | grep " /$" | sed -e "s/ */,/g"`, `date`
echo Finished package.sh