File: generate_tarball

package info (click to toggle)
ocaml-doc 4.11-2
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 20,580 kB
  • sloc: sh: 37; makefile: 11
file content (57 lines) | stat: -rwxr-xr-x 1,426 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
#!/bin/bash
#
# This script prepares a tarbaill for ocaml-doc package by downloading
# OCaml's upstream documentation from caml.inria.fr
#
# It needs tar and curl.

set -e

ver="$1"
dir=`mktemp -d "ocaml-doc-XXXXXXXXX"`
finaldir="ocaml-doc-$ver"
tmp=`mktemp -d "ocaml-doc-tmp-XXXXXXXXX"`
url="http://caml.inria.fr/pub/distrib/ocaml-${ver}"
dl="curl -#"

function tarxf() {
  top=`tar tzf $1/$3 | sed -e 's@/.*@@' | uniq`
  tar xf $1/$3 -C $2
  mv $2/$top $4
}

function msg() {
  echo "I: $1"
}

function usage() {
  echo "Usage: $0 MAJOR_VERSION.MINOR_VERSION"
  exit 1
}

test -z $ver && usage

# Downloading documentation
msg "Downloading documentation in $dir ($tmp)"
$dl "$url/ocaml-${ver}-refman.info.tar.gz" -o $dir/info.tar.gz
$dl "$url/ocaml-${ver}-refman-html.tar.gz" -o $dir/html.tar.gz
$dl "$url/ocaml-${ver}-refman.pdf" -P $dir -o $dir/refman.pdf
$dl "$url/ocaml-${ver}-refman.txt" -P $dir -o $dir/refman.txt

# Extracting tarballs
msg "Extracting downloaded traballs"
mkdir -p $finaldir
tarxf $dir $tmp info.tar.gz $finaldir/ocaml.info
tarxf $dir $tmp html.tar.gz $finaldir/ocaml.html
cp $dir/refman.pdf $finaldir/ocaml-${ver}-refman.pdf
gzip --to-stdout $dir/refman.txt > $finaldir/ocaml-${ver}-refman.txt.gz

# Building final tarball
msg "Building final tarball in ../ocaml-doc-${ver}.tar.gz"
tar czvf ../ocaml-doc-${ver}.tar.gz $finaldir

# Cleaning
msg "Cleaning..."
rm -rf $dir
rm -rf $tmp
rm -rf $finaldir