~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to nbbuild/newbuild/files-info.sh

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
4
 
5
# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
6
 
7
# The contents of this file are subject to the terms of either the GNU General Public
 
8
# License Version 2 only ("GPL") or the Common Development and Distribution
 
9
# License("CDDL") (collectively, the "License"). You may not use this file except in
 
10
# compliance with the License. You can obtain a copy of the License at
 
11
# http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
 
12
# License for the specific language governing permissions and limitations under the
 
13
# License.  When distributing the software, include this License Header Notice in
 
14
# each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP.  Sun
 
15
# designates this particular file as subject to the "Classpath" exception as provided
 
16
# by Sun in the GPL Version 2 section of the License file that accompanied this code.
 
17
# If applicable, add the following below the License Header, with the fields enclosed
 
18
# by brackets [] replaced by your own identifying information:
 
19
# "Portions Copyrighted [year] [name of copyright owner]"
 
20
 
21
# Contributor(s):
 
22
 
23
# The Original Software is NetBeans. The Initial Developer of the Original Software
 
24
# is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
 
25
# Rights Reserved.
 
26
 
27
# If you wish your version of this file to be governed by only the CDDL or only the
 
28
# GPL Version 2, indicate your decision by adding "[Contributor] elects to include
 
29
# this software in this distribution under the [CDDL or GPL Version 2] license." If
 
30
# you do not indicate a single choice of license, a recipient has the option to
 
31
# distribute your version of this file under either the CDDL, the GPL Version 2 or
 
32
# to extend the choice of license to its licensees as provided above. However, if you
 
33
# add GPL Version 2 code and therefore, elected the GPL Version 2 license, then the
 
34
# option applies only if the new code is made subject to such option by the copyright
 
35
# holder.
 
36
 
37
 
 
38
counter=0;
 
39
output_file=./js/files.js
 
40
type digest >> /dev/null 2>&1
 
41
if [ 0 -eq $? ] ; then
 
42
    alg=`type -p digest`
 
43
    alg="$alg -a md5"
 
44
else
 
45
    type md5sum >> /dev/null 2>&1
 
46
    if [ 0 -eq $? ] ; then
 
47
        alg=`type -p md5sum`
 
48
    else 
 
49
        type gmd5sum >> /dev/null 2>&1
 
50
        if [ 0 -eq $? ] ; then
 
51
            alg=`type -p gmd5sum`
 
52
        else
 
53
            type md5 >> /dev/null 2>&1
 
54
            if [ 0 -eq $? ] ; then
 
55
                alg=`type -p md5`
 
56
            fi
 
57
        fi
 
58
    fi
 
59
fi
 
60
if [ -z "$alg" ] ; then
 
61
        echo "Cannot find MD5 calculating programm"
 
62
        exit 1
 
63
else 
 
64
        echo "...getting MD5 with the help of $alg"
 
65
fi
 
66
 
 
67
 
 
68
while [ $# != 0 ] ; do  
 
69
        echo "Target directory : $1"            
 
70
        for nextfile in `ls -1 "$1"` ; do
 
71
                nextfile="$1"/"$nextfile"
 
72
                if [  -f "$nextfile" ] ; then                   
 
73
                        if [ 0 -eq $counter ] ; then
 
74
                                mkdir -p `dirname "$output_file"`
 
75
                                rm -f "$output_file"
 
76
                                echo "file_names = new Array();" >> "$output_file"
 
77
                                echo "file_sizes = new Array();" >> "$output_file"
 
78
                                echo "file_md5s  = new Array();" >> "$output_file"
 
79
                        fi
 
80
                        name=`basename "$nextfile"`
 
81
                        echo 
 
82
                        echo "... file : `basename $nextfile`"
 
83
                        size=`ls -l "$nextfile" | awk ' { print $5 }' 2>/dev/null`
 
84
                        echo "... size : $size"
 
85
                        md5=`$alg "$nextfile" | sed "s/ .*//g"`
 
86
                        echo "...  md5 : $md5"
 
87
                        echo "file_names["$counter"]=\"$name\";" >> "$output_file"
 
88
                        echo "file_sizes["$counter"]=$size;" >> "$output_file"
 
89
                        echo "file_md5s["$counter"]=\"$md5\";" >> "$output_file"
 
90
                        counter=`expr $counter + 1`
 
91
                fi
 
92
        done
 
93
        shift
 
94
done