File: package

package info (click to toggle)
synfig 1.5.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 59,132 kB
  • sloc: cpp: 109,639; sh: 6,121; makefile: 1,458; csh: 243; perl: 238; python: 124; ruby: 73
file content (292 lines) | stat: -rwxr-xr-x 7,461 bytes parent folder | download | duplicates (3)
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
#! /bin/csh -ef
# this file was originally distributed by Apple in the Developer Tools package 
#it is distributed under the Apple Open Source License
set version=0.2
set prog = `/usr/bin/basename $0`
set usage = "Usage: $prog [-f] root-dir info-file [tiff-file] [-d dest-dir] [-r resource-dir] [-traditional | -gnutar] [-bzip]"
set noglob

if (-x /usr/bin/mkbom) then
    set mkbom=/usr/bin/mkbom
    set lsbom=/usr/bin/lsbom
else
    set mkbom=/usr/etc/mkbom
    set lsbom=/usr/etc/lsbom
endif

if (-x /usr/bin/awk) then
    set awk=/usr/bin/awk
else
    set awk=/bin/awk
endif
set bzip2=`which bzip2`
set gnutar=/usr/bin/gnutar
set tar=/usr/bin/tar
set pax=/bin/pax

# gather parameters
if ($#argv == 0) then
    echo $usage
    exit(1)
endif
unset usebzip
while ( $#argv > 0 )
    switch ( $argv[1] )
	case -d:
	    if ( $?destDir ) then
		echo ${prog}: dest-dir parameter already set to ${destDir}.
		echo $usage
		exit(1)
	    else if ( $#argv < 2 ) then
		echo ${prog}: -d option requires destination directory.
		echo $usage
		exit(1)
	    else
		set destDir = $argv[2]
		shift; shift
		breaksw
	    endif
	case -f:
	    if ( $?rootDir ) then
		echo ${prog}: root-dir parameter already set to ${rootDir}.
		echo $usage
		exit(1)
	    else if ( $#argv < 2 ) then
		echo ${prog}: -f option requires package root directory.
		echo $usage
		exit(1)
	    else
		set rootDir = $argv[2]
		set fflag
		shift; shift
		breaksw
	    endif
	case -r:
	    if ( $?resDir ) then
		echo ${prog}: resource-dir parameter already set to ${resDir}.
		echo $usage
		exit(1)
	    else if ( $#argv < 2 ) then
		echo ${prog}: -r option requires package resource directory.
		echo $usage
		exit(1)
	    else
		set resDir = $argv[2]
		shift; shift
		breaksw
	    endif
	case -traditional:
            echo using standard tar
	    set usetar
            unset usegnutar
	    unset usepax
	    breaksw
        case -gnutar:
	    echo using gnutar
	    set usegnutar
            unset usepax
	    unset usetar
            shift
	case -bzip:
	    if (-x $bzip2) then
	    	set usebzip
                echo using bzip compression
	    else
		echo COMPRESSION ERROR: You can not use BZIP2 you do not have it installed
		exit(1)
	    endif
            shift
            breaksw
	case -*:
	    echo ${prog}: Unknown option: $argv[1]
	    echo $usage
	    exit(1)
	case *.info:
	    if ( $?info ) then
		echo ${prog}: info-file parameter already set to ${info}.
		echo $usage
		exit(1)
	    else
		set info = "$argv[1]"
		shift
		breaksw
	    endif
	case *.tiff:
	    if ( $?tiff ) then
		echo ${prog}: tiff-file parameter already set to ${tiff}.
		echo $usage
		exit(1)
	    else
		set tiff = "$argv[1]"
		shift
		breaksw
	    endif
	default:
	    if ( $?rootDir ) then
		echo ${prog}: unrecognized parameter: $argv[1]
		echo $usage
		exit(1)
	    else
		set rootDir = "$argv[1]"
		shift
		breaksw
	    endif
    endsw
end

# check for mandatory parameters
if ( ! $?rootDir ) then
    echo ${prog}: missing root-dir parameter.
    echo $usage
    exit(1)
else if ( ! $?info) then
    echo ${prog}: missing info-file parameter.
    echo $usage
    exit(1)
endif

# destDir gets default value if unset on command line
if ( $?destDir ) then
    /bin/mkdir -p $destDir
else
    set destDir = .
endif

# derive the root name for the package from the root name of the info file
set root = `/usr/bin/basename $info .info`

# create package directory
set pkg = ${destDir}/${root}.pkg
echo Generating Installer package $pkg ...
if ( -e $pkg ) /bin/rm -rf $pkg
/bin/mkdir -p -m 755 $pkg
/bin/mkdir -p -m 755 $pkg/Contents
/bin/mkdir -p -m 755 $pkg/Contents/Resources
/bin/mkdir -p -m 755 $pkg/Contents/Resources/English.lproj/
echo "gxpmpkg2" >$pkg/Contents/PkgInfo
chmod 755 $pkg/Contents/PkgInfo
# (gnu)tar/pax and compress root directory to package archive
echo -n "	creating package archive ... "
if ( $?fflag ) then
    set pkgTop = ${rootDir:t}
    set parent = ${rootDir:h}
    if ( "$parent" == "$pkgTop" ) set parent = "."
else
    set parent = $rootDir
    set pkgTop = .    
endif
if ( $?usetar ) then
    set pkgArchive = $pkg/Contents/Resources/$root.tar.Z
    (cd $parent; $tar -w $pkgTop) | /usr/bin/tar -f -c > $pkgArchive
else if ( $?usegnutar ) then
     if ( $?usebzip ) then
         set pkgArchive = $pkg/Contents/Resources/$root.tar.bz2
         (cd $parent; $gnutar c $pkgTop) | $bzip2 -f -c > $pkgArchive
     else 
          set pkgArchive = $pkg/Contents/Resources/$root.tar.gz
          (cd $parent; $gnutar zcf $pkgArchive $pkgTop)
     endif
else
    set pkgArchive = $pkg/Contents/Resources/$root.pax.gz
    (cd $parent; $pax -w -z -x cpio $pkgTop) > $pkgArchive
endif
/bin/chmod 755 $pkgArchive
echo done.

# copy info file to package
set pkgInfo = $pkg/Contents/Resources/English.lproj/$root.info
echo -n "	copying ${info:t} ... "
/bin/cp $info $pkgInfo
/bin/chmod 755 $pkgInfo
echo done.

# copy tiff file to package
if ( $?tiff ) then
    set pkgTiff = $pkg/$root.tiff
    echo -n "	copying ${tiff:t} ... "
    /bin/cp $tiff $pkgTiff
    /bin/chmod 444 $pkgTiff
    echo done.
endif

# copy resources to package
if ( $?resDir ) then
    echo -n "	copying ${resDir:t} ... "

    # don't want to see push/pop output
    pushd $resDir > /dev/null
	# get lists of resources. We'll want to change
	# permissions on just these things later.
        set directoriesInResDir = `find . -type d | grep -v -e .git`
        set filesInResDir = `find . -type f | grep -v -e .git`
    popd > /dev/null

    # copy the resource directory contents into the package directory
    foreach resFile (`cd $resDir && find . | grep -v -e .git`)
	cp -r "$resDir/$resFile" "$pkg/Contents/Resources"
    end

    pushd $pkg/Contents/Resources > /dev/null
	# Change all directories to +r+x, except the package
	# directory itself
        foreach resFileItem ($directoriesInResDir)
            if ( $resFileItem != "." ) then
                chmod 755 "$resFileItem"
            endif
        end
	# change all flat files to read only
        foreach resFileItem ($filesInResDir)
            if ( $resFileItem != "./.DS_Store" ) then
            chmod 755 "$resFileItem"
	    endif
        end
    popd > /dev/null

    echo done.
endif

# generate bom file
set pkgBom = $pkg/Contents/Resources/$root.bom
echo -n "	generating bom file ... "
/bin/rm -f $pkgBom
if ( $?fflag ) then
    $mkbom $parent $pkgBom >& /dev/null
else
    $mkbom $rootDir $pkgBom >& /dev/null
endif
/bin/chmod 444 $pkgArchive
echo done.
	
# generate sizes file
set pkgSizes = $pkg/Contents/Resources/$root.sizes
echo -n "	generating sizes file ... "

# compute number of files in package
set numFiles = `$lsbom -s $pkgBom | /usr/bin/wc -l`

# compute package size when compressed
@ compressedSize = `/usr/bin/du -k -s $pkg | $awk '{print $1}'`
@ compressedSize += 3		# add 1KB each for sizes, location, status files

@ infoSize = `/bin/ls -s $pkgInfo | $awk '{print $1}'`
@ bomSize = `/bin/ls -s $pkgBom | $awk '{print $1}'`
if ( $?tiff ) then
    @ tiffSize = `/bin/ls -s $pkgTiff | $awk '{print $1}'`
else
    @ tiffSize = 0
endif 

@ installedSize = `/usr/bin/du -k -s $rootDir | $awk '{print $1}'`
@ installedSize += $infoSize + $bomSize + $tiffSize + 3

# echo size parameters to sizes file
echo NumFiles $numFiles             >  $pkgSizes
echo InstalledSize $installedSize   >> $pkgSizes
echo CompressedSize $compressedSize >> $pkgSizes
echo done.
echo " ... finished generating $pkg."

exit(0)

# end package