-
Notifications
You must be signed in to change notification settings - Fork 14
/
flist.sh
93 lines (79 loc) · 1.96 KB
/
flist.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
#!/bin/bash
# NOTE this is adapted from an old version from original cubietruck! Mar 26 2014 flist
# Go thru .tar.gz, .tar.bz2 in dir and list them to flist-file
function process () {
#set -x
args="$*"
echo $args
# if doing rezip, renice bzip2
renice +1 `pidof bzip2` 2>/dev/null
# Preserve existing output
if [ -e "flist--$bn.txt" ]; then
echo "o Skipped $bn"
else
echo "Processing $bn"
if [ "$compr" = "" ]; then
time tar tvf $i > flist--$bn.txt 2>flist-errors--$bn.txt
else
time $compr -cd $args |tar tvf - >flist--$bn.txt 2>flist-errors--$bn.txt
fi
fi
}
#function processbz2 () {
# args=$*
# echo $args
# time tar tjvf $args > flist--$bn
#}
# If compare string not match any actual filename, move on
for i in *.tar.gz; do
[ "$i" == "*.tar.gz" ] && break;
bn=`basename $i .tar.gz`
compr=gzip
process $i
done
for i in *.tar1.gz; do
[ "$i" == "*.tar1.gz" ] && break;
bn=`basename $i .tar1.gz`
compr=gzip
process $i
done
for i in *.tgz; do
[ "$i" == "*.tgz" ] && break;
bn=`basename $i .tgz`
compr=gzip
process $i
done
for i in *.tar.bz2; do
[ "$i" == "*.tar.bz2" ] && break;
bn=`basename $i .tar.bz2`
compr=bzip2
process $i
done
for i in *.tar.lzop; do
[ "$i" == "*.tar.lzop" ] && break;
bn=`basename $i .tar.lzop`
compr=lzop
process $i
done
for i in *.tar1.lzop; do
[ "$i" == "*.tar1.lzop" ] && break;
bn=`basename $i .tar1.lzop`
compr=lzop
process $i
done
for i in *.tar; do
[ "$i" == "*.tar" ] && break;
bn=`basename $i .tar`
compr=""
process $i
# time tar tvf $i > flist--$bn.txt
done
for i in *.tar1; do
[ "$i" == "*.tar1" ] && break;
bn=`basename $i .tar1`
compr=""
process $i
# time tar tvf $i > flist--$bn.txt
done
# Cleanup
find . -type f -name flist-errors\* -empty -print -delete