File: split-cabs.sh

package info (click to toggle)
cabextract 1.11-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,884 kB
  • sloc: ansic: 5,826; sh: 5,331; perl: 462; makefile: 88
file content (49 lines) | stat: -rwxr-xr-x 1,672 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
#!/bin/sh
# creates a good mix of standalone folders, folders that
# split backwards, split forwards, and split both ways,
# with differing numbers of files in each
dd if=/dev/urandom of=small1.bin  bs=2000  count=1 2>/dev/null
dd if=/dev/urandom of=small2.bin  bs=8000  count=1 2>/dev/null
dd if=/dev/urandom of=medium1.bin bs=40000 count=1 2>/dev/null
dd if=/dev/urandom of=medium2.bin bs=50000 count=1 2>/dev/null
dd if=/dev/urandom of=small3.bin  bs=128   count=1 2>/dev/null
dd if=/dev/urandom of=medium3.bin bs=40000 count=1 2>/dev/null

# force differing case: wine will write the cab files as "split-1.cab"
# but the cab file will have "Split-1.CAB" embedded in it
touch split-1.cab split-2.cab split-3.cab split-4.cab split-5.cab

cat >directives.txt <<EOF
.Set DiskLabelTemplate="Split cabinet file */5"
.Set DiskDirectoryTemplate=.
.Set CabinetNameTemplate=Split-*.CAB
.Set ClusterSize=1
.Set MaxDiskSize=30000
.Set Cabinet=ON
.Set Compress=ON
; use the "reserved space" feature to check cabextract handles it
.Set ReservePerCabinetSize=100
.Set ReservePerFolderSize=50
.Set ReservePerDataBlockSize=10
small1.bin
.New Folder
small2.bin
medium1.bin
medium2.bin
small3.bin
medium3.bin
EOF

wine makecab.exe /F directives.txt

# makecab.exe messes up and writes "previous file is split-2.cab" instead of
# "previous file is split-3.cab" into header of split-4.cab
sed -e 's/Split-2.CAB/Split-3.CAB/' \
    -e 's!Split cabinet file 2/5!Split cabinet file 3/5!' \
    -i split-4.cab  

# check these against each other
cabextract -t split-1.cab
md5sum small1.bin small2.bin medium1.bin medium2.bin small3.bin medium3.bin

rm *.bin directives.txt setup.inf setup.rpt