summaryrefslogtreecommitdiff
path: root/devel/qt5/files/pkg-change.in
blob: 6a49140ffa8786dfb9c084cc99c851d30c0563dc (plain) (blame)
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
#!/bin/sh
##
## ### PROCESSING
##
## This file is processed three ways:
## - to replace %%variables%% with the intended values
## - to replace @tag with ## or blank as appropriate
## - to filter out lines containing ##
##
## The resulting "minified" script is used as pkg-install or pkg-deinstall
## script in the package.
##
## Lines with @tag at the beginning should be read as conditional;
## multiple @tags are read as "and", so the **rest** of the line
## only ends up in the resulting script when all the @tags are true.
##
## The file is formatted with lots of spaces between the @tags and script
## so that the shell-script itself can be read in column 24,
## e.g.                 v--- here
##
## To read the script, try `grep -v '##' pkg-change.in | cut -c 25-`
##
##
## ### ABOUT
##
## A Qt module should be listed in QtCore/qconfig-modules.h only once,
## and only if that is needed (e.g. if it has a qconfig-*.h of its own).
## In case 1 (listed), update the target file by appending and sorting:
##  - echo the new line and existing contents if any
##  - .. pipe to sort -u
##  - .. then move the sorted-uniqued output to the config-modules.h
## In case 2 (unlisted), update the target file by deleting a line
##
## Removing QtCore *may* leave behind an empty file, and in that case
## clean up the config file and directories entirely.
##
## A module with versionable binaries (like "designer" which might have
## a Qt4, Qt5 and Qt6 version).
##
##
## On deinstall, we need QT_INCDIR separately, so define variables $qi and $qc
## differently from install (which needs only $qc).
@deinstall              qi="%%QT_INCDIR%%"
@deinstall              qc="$qi/QtCore/qconfig-modules.h"
@install                qc="%%QT_INCDIR%%/QtCore/qconfig-modules.h"
                        qm="%%QT_MODNAME%%"
##
## Distinguish the pkg step and call the relevant shell functions defined above.
##
                        case $2 in
@install                POST-INSTALL)
##
## Add the line #include qconfig-<this module>.h to the global
## qconfig-modules.h; afterwards that global file exists.
##
## We might be adding to a non-existent file, which is why there
## is the slightly-weird construction with a subshell piping to sort.
##
@install@need_add           { echo "#include <QtCore/modules/qconfig-$qm.h>"
@install@need_add             [ -f "$qc" ] && /bin/cat "$qc"
@install@need_add           } | /usr/bin/sort -u -o "$qc.new"
@install@need_add           /bin/mv "$qc.new" "$qc"
##
## This removes the line that #includes qconfig-<this module>.h
## from the global qconfig-modules.h; afterwards, that global file exists
## although it may be empty.
##   (This code is identical in install- and deinstall-scripts, unconditional in deinstall)
##
@install@need_remove        [ \! -e "$qc" ] && touch "$qc"
@install@need_remove        sed -i "" "/qconfig-$qm\.h/ d" "$qc"
@install                    ;;
@deinstall              POST-DEINSTALL)
##
## This removes the line that #includes qconfig-<this module>.h
## from the global qconfig-modules.h; afterwards, that global file exists
## although it may be empty.
##   (This code is identical in install- and deinstall-scripts, unconditional in deinstall)
##
@deinstall                  [ \! -e "$qc" ] && touch "$qc"
@deinstall                  sed -i "" "/qconfig-$qm\.h/ d" "$qc"
##
## When qtcore is removed, the whole config dir can go away as well ..
##
@deinstall                  [ \! -e "$qi/QtCore/qconfig.h" ] && \
@deinstall                  [ \! -s "$qc" ] && (
@deinstall                     rm -f "$qc"
@deinstall                     rmdir "$qi/QtCore"
@deinstall                     rmdir "$qi"
@deinstall                  ) > /dev/null 2>&1
##
## .. but if it isn't removed, that's ok: suppress a non-zero exit code.
##
@deinstall                  :
@deinstall                  ;;
                        esac