File: unpack_examples.sh.in

package info (click to toggle)
wxwidgets3.0 3.0.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 120,808 kB
  • ctags: 118,010
  • sloc: cpp: 889,420; makefile: 52,980; ansic: 21,933; sh: 5,603; python: 2,935; xml: 1,534; perl: 281
file content (64 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download | duplicates (4)
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
#!/bin/bash
#
# Unpack compressed examples from the packaged documentation
# into a directory where the user can compile and/or run them.

set -e

WX_EXAMPLES_DIR="/usr/share/doc/wx=V-examples/examples"

usage() {
    echo "$0 [subdir [subdir] ...] dest_dir"
    echo "    subdir   - a subdir of $WX_EXAMPLES_DIR to unpack."
    echo "    dest_dir - location for the unpacked examples."
    echo
    echo "If no subdirs are supplied explicitly, all examples will be unpacked."
    exit 1
}

if [ $# -lt 1 ]; then
    usage
fi 

while [ $# -gt 1 ]; do
    SUBDIRS="$SUBDIRS $1"
    shift
done

DESTDIR="$1"

if [ -e "$DESTDIR" ]; then
    echo "Destination $DESTDIR already exists. Cowardly exiting."
    exit 2
fi

if [ -z "$SUBDIRS" ]; then
    for d in $(cd "$WX_EXAMPLES_DIR" 2> /dev/null && ls -d * 2> /dev/null); do
        [ -d "$WX_EXAMPLES_DIR/$d" ] && SUBDIRS="$SUBDIRS $d"
    done
else
    for d in $SUBDIRS; do
    	if [ -d "$WX_EXAMPLES_DIR/$d" ]; then
	    _SUBDIRS="$d"
	else
	    echo "Subdir $WX_EXAMPLES_DIR/$d does not exist.  Skipping."
	fi
    done
    SUBDIRS="$_SUBDIRS"
fi

if [ -z "$SUBDIRS" ]; then
    echo "Nothing to copy from $WX_EXAMPLES_DIR.  Aborting."
    exit 1
fi

mkdir -p "$DESTDIR"
for d in $SUBDIRS; do
    echo "Copying $WX_EXAMPLES_DIR/$d to $DESTDIR"
    cp -pr "$WX_EXAMPLES_DIR/$d" "$DESTDIR"
done

echo -n "Unpacking... "
find "$DESTDIR" -name "*.gz" \! -name "*.dxf.gz" \! -name "*.dat.gz" -print0 | xargs -0 gunzip
echo "done."