aboutsummaryrefslogtreecommitdiff
path: root/tools/mkdist.sh
blob: 98f985cf3d733dcf772e31af3ec49412f226fadc (plain)
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
#!/bin/sh -e

out() { printf '%s\n' "$@" >&2 ;}
die() { printf '\033[1;31mERR: \033[m%s\n' "$@" >&2; exit 1;}

case "$1" in ''|-*)
    die "Run this script by calling 'make dist' from the" \
        "root repository directory"
esac

fossil stat >/dev/null 2>&1 || {
    printf '\033[1;31mERR: \033[m%s\n' \
        "Distribution tarballs can only be generated using the Fossil repository." \
        "Exiting..." >&2
    exit 1
}

basedir=cpt-$1
mkdir -p "$basedir"

fossil ls | while read -r file; do
    case "$file" in
        */*) mkdir -p "$basedir/${file%/*}"
    esac
    cp "$file" "$basedir/$file"
done

cp docs/cpt.info "$basedir/docs/cpt.info"

pax -w "$basedir" | xz -zT 0 > "$basedir.tar.xz"
rm -rf -- "$basedir"