File: setup.sh

package info (click to toggle)
minirok 0.9.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 372 kB
  • ctags: 378
  • sloc: python: 2,427; xml: 152; cpp: 118; sh: 70; makefile: 45
file content (101 lines) | stat: -rwxr-xr-x 2,175 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/bash

# If $DEBIAN_PREFIX is set, it will be prepended to all locations.
# This is used when building the Debian package.

set -e

##

if ! kde-config 2>/dev/null; then
    echo >&2 "ERROR: could not find kde-config."
    exit 1
fi

##

PREFIX=`kde-config --prefix`
BIN=`kde-config --expandvars --install exe`
APPS=`kde-config --expandvars --install data`
ICONS=`kde-config --expandvars --install icon`
CONFIG=`kde-config --expandvars --install config`
DESKTOP=`kde-config --expandvars --install xdgdata-apps`
MINIROK="$APPS/minirok"
KHOTKEYS="$APPS/khotkeys"
KCONF_UPDATE="$APPS/kconf_update"
KONQUEROR_SERVICE_MENU="$APPS/konqueror/servicemenus"

##

install_file () {
    # path/file path/dir -> path/dir/file
    install_file2 "$1" "$2/`basename $1`"
}

install_file2 () {
    # path/file path/dir/file2 -> path/dir/file2
    install -D -m `mode $1` "$1" "${DEBIAN_PREFIX%%/}/${2##/}"
}

install_symlink () {
    DEST="${DEBIAN_PREFIX%%/}/${2##/}"
    mkdir -p "`dirname $DEST`"
    ln -sf "$1" "$DEST"
}

##

install_icons () {
    ( cd "$1" && find -maxdepth 1 -name '*.png' ) | while read file; do
    	install_file2 "$1/$file" "$2/`echo $file | tr = /`"
    done
}

install_images () {
    for img in images/*.png; do
    	install_file "$img" "$MINIROK/images"
    done
}

install_package () {
    for p in minirok.py minirok/*.py minirok/ui/*.py; do
    	install_file "$p" "$PREFIX/share/minirok/`dirname $p`"
    done
}

install_manpage () {
    if make -s minirok.1; then
    	install_file minirok.1 /usr/share/man/man1
    fi
}

##

mode () {
    if [ -x "$1" ]; then
    	echo 755
    else
    	echo 644
    fi
}

##

case "$1" in
    install)
	install_images
	install_package
	install_manpage
	install_icons images/icons "$ICONS"
	install_file config/minirokrc "$CONFIG"
	install_file config/minirok.desktop "$DESKTOP"
	install_file config/minirok.khotkeys "$KHOTKEYS"
	install_file config/khotkeys_minirok.upd "$KCONF_UPDATE"
	install_file config/minirok_append.desktop "$KONQUEROR_SERVICE_MENU"
	install_symlink "$PREFIX/share/minirok/minirok.py" "$BIN/minirok"
	;;

    *)
	echo "Doing nothing, please pass 'install' as the first argument."
	;;
esac