diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-29 14:36:26 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-29 14:36:30 -0400 |
commit | 153d299a41b9be4e15dab1ca29bb93a74bd2445d (patch) | |
tree | 96fbfbe7c64f0b3f02f3d755e2b129917785bb98 /old-school/squashfs-size | |
parent | 5f41fb879ca830e5ad3345878e59072f3d6573bc (diff) |
fix paths (in progress)
Diffstat (limited to 'old-school/squashfs-size')
-rwxr-xr-x | old-school/squashfs-size | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/old-school/squashfs-size b/old-school/squashfs-size deleted file mode 100755 index 74b67d7..0000000 --- a/old-school/squashfs-size +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | squashfs_size_ratio() | ||
4 | { | ||
5 | local fn="$1" | ||
6 | #FSIZE="$(stat -c "%s" "$fn")" | ||
7 | word5() { echo $5; } | ||
8 | FSIZE="$(word5 `ls -l "$fn"`)" | ||
9 | echo $(( $FSIZE * 3367 / 1000 )) | ||
10 | } | ||
11 | |||
12 | squashfs_size_magicdb() | ||
13 | { | ||
14 | |||
15 | get() | ||
16 | { | ||
17 | local len=$1 | ||
18 | local off=$2 | ||
19 | local fn="$3" | ||
20 | #local OUT=( $(od -t d$len -N$len -j $off "$fn") ) | ||
21 | #echo "${OUT[1]}" | ||
22 | od -t u$len -N$len -j $off "$fn" | head -n1 | sed 's/.* //' | ||
23 | } | ||
24 | |||
25 | # getReversedEndian() | ||
26 | # { | ||
27 | # local len=$1 | ||
28 | # local off=$2 | ||
29 | # local fn="$3" | ||
30 | # #local B=( $(od -t x$len -N$len -j $off "$fn") ) | ||
31 | # #B="${B[1]}" | ||
32 | # local B="$(od -t x$len -N$len -j $off "$fn" | head -n1 | cut -d' ' -f2)" | ||
33 | # local D= | ||
34 | # local C=$(( $len * 2 )) | ||
35 | # while [ $C -gt 0 ] | ||
36 | # do | ||
37 | # C=$(( $C - 2 )) | ||
38 | # D="$D${B:$C:2}" | ||
39 | # done | ||
40 | # D="0x$D" | ||
41 | # echo $D | ||
42 | # } | ||
43 | getReversedEndian() | ||
44 | { | ||
45 | local len=$1 | ||
46 | local off=$2 | ||
47 | local fn="$3" | ||
48 | local D= | ||
49 | local C=$len | ||
50 | while [ $C -gt 0 ] | ||
51 | do | ||
52 | C=$(( $C - 1 )) | ||
53 | D="$(od -t x1 -N1 -j $(($off+$C)) "$fn" | head -n1 | cut -d' ' -f2)$D" | ||
54 | done | ||
55 | D=$((0x$D)) | ||
56 | echo $D | ||
57 | } | ||
58 | |||
59 | |||
60 | local fn="$1" | ||
61 | |||
62 | local M=$(get 4 0 "$fn") | ||
63 | local N=$(getReversedEndian 4 0 "$fn") | ||
64 | if [ $M -eq 1936814952 ] | ||
65 | then | ||
66 | # Proper endian. | ||
67 | local get=get | ||
68 | elif [ $N -eq 1936814952 ] | ||
69 | then | ||
70 | # Reversed endian. | ||
71 | local get=getReversedEndian | ||
72 | else | ||
73 | error not squashfs | ||
74 | fi | ||
75 | |||
76 | local T=$($get 2 28 "$fn") | ||
77 | if [ $T -lt 3 ] | ||
78 | then | ||
79 | local BC=$($get 4 8 "$fn") | ||
80 | else | ||
81 | local BC=$($get 8 63 "$fn") | ||
82 | fi | ||
83 | |||
84 | echo $BC | ||
85 | } | ||
86 | |||
87 | |||
88 | squashfs_size_ratio "$1" | ||