-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathgzip.sh
More file actions
executable file
·53 lines (45 loc) · 1.17 KB
/
Copy pathgzip.sh
File metadata and controls
executable file
·53 lines (45 loc) · 1.17 KB
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
#!/bin/sh
#
# This script is only necessary if you have a *very* old gzip.
#
GZIP_DL="https://ftp.gnu.org/gnu/gzip"
GZIP_XZ="gzip-1.12.tar.xz"
GZIP_DIR="$(basename $GZIP_XZ .tar.xz)"
GZIP_URL="$GZIP_DL/$GZIP_XZ"
ORIGIN_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
# Dont continue on error.
set -e
# Help text.
if [ "$1" = '-h' ]; then
echo >&2 "Usage: $0 [clean]"
echo >&2
echo >&2 'Specify "clean" to remove gzip, otherwise it will be downloaded and built.'
exit 1
fi
# Optional cleanup if requested.
if [ "$1" = 'clean' ]; then
rm -fv "$ORIGIN_DIR/gzip" "$ORIGIN_DIR/gunzip" "$ORIGIN_DIR/zcat"
rm -rfv "$GZIP_DIR"
rm -fv "$ORIGIN_DIR/$GZIP_XZ"
exit
fi
# Download gzip.
if [ ! -f "$GZIP_XZ" ]; then
wget "$GZIP_URL"
fi
# Extract gzip.
if [ ! -d "$GZIP_DIR" ]; then
xzcat "$GZIP_XZ" | tar xf -
fi
# Compile gzip.
if [ ! -x "$GZIP_DIR/gzip" ]; then
cd "$GZIP_DIR" && ./configure && gmake -j$(nproc)
cd "$ORIGIN_DIR"
fi
# Copy compiled binaries to working directory.
copy() {
test ! -x "$2" && cp -v "$1" "$2"
}
copy "$GZIP_DIR/gzip" "$ORIGIN_DIR/gzip"
copy "$GZIP_DIR/gunzip" "$ORIGIN_DIR/gunzip"
copy "$GZIP_DIR/zcat" "$ORIGIN_DIR/zcat"