File: replace-files.prerm

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (52 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download | duplicates (2)
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
###
# Functions to propose changes in configuration files
###
# Replace an exsting file with the proposed one
replace_file () {
    file=$1
    if [ -e $file ] ; then
        cp $file ${file}.gforge-old
    fi
    mv ${file}.gforge-new $file
}

# Propose a replacement to the user
propose_update () {
    file=$1
    mode=$2
    template=gforge/shared/replace_file_$mode
    if [ ! -e ${file}.gforge-new ] ; then
        echo "${file} already configured, not changing."
    elif diff -q ${file} ${file}.gforge-new > /dev/null 2>&1 ; then
        # Old file and new file are identical
        rm -f ${file}.gforge-new
    else
        db_fset $template seen false
        db_subst $template file $file
        db_input high $template || true
        db_go || true
        db_get $template || true
        case "$RET" in
            "true")
                echo >&2 "Replacing file $file with changed version"
                replace_file $file
                ;;
            "false")
                db_fset gforge/shared/file_changed seen false
                db_subst gforge/shared/file_changed file $file
                db_input high gforge/shared/file_changed || true
                db_go || true
                ;;
        esac
    fi
}

# Same, but for installation
propose_update_install () {
    propose_update $1 install
}

# Same, but for de-installation
propose_update_remove () {
    propose_update $1 remove
}