summarylogtreecommitdiffstats
path: root/gorsync-git.install
blob: 00378f5de1bc3c604030f069c34ff21b8d120078 (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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
post_install() {
    :
#!/usr/bin/env sh

# !!! This script is a part of distribution packaging system !!!
# !!! Each line of this script was tested and debugged on Linux 32bit, Linux 64bit, FreeBSD !!!
# !!! Change with great care, do not break it !!!

SCHEMA_FILE="org.d2r2.gorsync.gschema.xml"

get_gsettings_schema_file()
{
    local EMBEDDED
    # ***** !!!!! DO NOT REMOVE THIS COMMENT BLOCK - HEREDOC WILL BE POSTED HERE !!!!! *****
    # AUTOMATICALLY_REPLACED_WITH_EMBEDDED_XML_FILE_DECLARATION
    # ***** !!!!! DO NOT REMOVE THIS COMMENT BLOCK - HEREDOC WILL BE POSTED HERE !!!!! *****
    if [ ${#EMBEDDED} -le 0 ]; then
        cat "gsettings/${SCHEMA_FILE}"
    else
        echo "${EMBEDDED}"
    fi
}


# if [ -z  "$1" ]; then
    PREFIX=/usr
    OS_LOWERCASE=$(echo "$OSTYPE" | tr "[:upper:]" "[:lower:]")
    # FreeBSD
    if [ "$OS_LOWERCASE" = "freebsd" ]; then
        PREFIX="${PREFIX}/local"
    # Linux OS
    # elif [[ "$OSTYPE" == "linux-gnu" ]]; then
    # Mac OSX
    # elif [[ "$OSTYPE" == "darwin"* ]]; then
    # POSIX compatibility layer and Linux environment emulation for Windows
    # elif [[ "$OSTYPE" == "cygwin" ]]; then
    # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
    # elif [[ "$OSTYPE" == "msys" ]]; then
    # Windows
    # elif [[ "$OSTYPE" == "win32" ]]; then
    # else
            # Unknown.
    fi
# else
#    export PREFIX=$1
# fi

if [ "$(id -u)" != "0" ]; then
    # Make sure only root can run our script
    echo "This script must be run as root" 1>&2
    exit 1
fi

# Check availability of required commands
# COMMANDS="install glib-compile-schemas glib-compile-resources msgfmt desktop-file-validate gtk-update-icon-cache"
COMMANDS="install glib-compile-schemas glib-compile-resources msgfmt desktop-file-validate gtk-update-icon-cache"
# if [ "$PREFIX" = '/usr' ] || [ "$PREFIX" = "/usr/local" ]; then
#     COMMANDS="$COMMANDS xdg-desktop-menu"
# fi
# PACKAGES="coreutils glib2 glib2 gettext desktop-file-utils gtk-update-icon-cache xdg-utils"
PACKAGES="coreutils glib2 glib2 gettext desktop-file-utils gtk-update-icon-cache xdg-utils"
i=0
for COMMAND in $COMMANDS; do
    type $COMMAND >/dev/null 2>&1 || {
        j=0
        for PACKAGE in $PACKAGES; do
            if [ $i = $j ]; then
                break
            fi
            j=$(( $j + 1 ))
        done
        echo "Your system is missing command $COMMAND, please install $PACKAGE"
        exit 1
    }
    i=$(( $i + 1 ))
done

SCHEMA_PATH=${PREFIX}/share/glib-2.0/schemas
echo "Installing gsettings schema to ${SCHEMA_PATH}"

# Copy and compile schema
echo "Copying and compiling schema..."
install -d ${SCHEMA_PATH}
# install -m 644 gsettings/${SCHEMA_FILE} ${SCHEMA_PATH}/
echo "$(get_gsettings_schema_file)" > ${SCHEMA_PATH}/${SCHEMA_FILE}
chmod 0644 ${SCHEMA_PATH}/${SCHEMA_FILE}
# Redirect output to /dev/null help on some linux distributions (redhat), which produce
# lot of warnings about "Schema ... are depricated." not related to application.
glib-compile-schemas ${SCHEMA_PATH}/ 2>/dev/null

}


pre_remove() {
    :
#!/usr/bin/env sh

# !!! This script is a part of distribution packaging system !!!
# !!! Each line of this script was tested and debugged on Linux 32bit, Linux 64bit, FreeBSD !!!
# !!! Change with great care, do not break it !!!

# if [ -z  "$1" ]; then
    PREFIX=/usr

    # FreeBSD
    if [ $(echo "$OSTYPE" | tr "[:upper:]" "[:lower:]") == "freebsd" ]; then
        PREFIX="${PREFIX}/local"
    # Linux OS
    # elif [[ "$OSTYPE" == "linux-gnu" ]]; then
    # Mac OSX
    # elif [[ "$OSTYPE" == "darwin"* ]]; then
    # POSIX compatibility layer and Linux environment emulation for Windows
    # elif [[ "$OSTYPE" == "cygwin" ]]; then
    # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
    # elif [[ "$OSTYPE" == "msys" ]]; then
    # Windows
    # elif [[ "$OSTYPE" == "win32" ]]; then
    # else
            # Unknown.
    fi
# else
#    export PREFIX=$1
# fi

if [ "$(id -u)" != "0" ]; then
    # Make sure only root can run our script
    echo "This script must be run as root" 1>&2
    exit 1
fi

SCHEMA_PATH=${PREFIX}/share/glib-2.0/schemas
echo "Uninstalling gsettings schema from ${SCHEMA_PATH}"

rm ${SCHEMA_PATH}/org.d2r2.gorsync.gschema.xml
# Redirect output to /dev/null help on some linux distributions (redhat), which produce
# lot of warnings about "Schema ... are depricated." not related to application.
glib-compile-schemas ${SCHEMA_PATH}/ 2>/dev/null

}