~ubuntu-branches/ubuntu/precise/dbconfig-common/precise

« back to all changes in this revision

Viewing changes to dpkg/postinst

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2008-07-05 01:07:31 UTC
  • mfrom: (15 hardy)
  • mto: (8.1.4 squeeze)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20080705010731-fl8ewjzk9fjkz8ab
* fix for package failing to purge, thanks to Michael Tautschnig for
  reporting this (closes: #476949).
* rc bugfix, high urgency upload.
* a few more more bugs/fixes from Niko Tyni:
  - fix for empty substitution in dbc_upgrade_error (closes: #473028).
  - ensure TODO gets installed, since the docs reference it (closes: #472946).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
### load up common variables and functions
3
3
###
4
4
dbc_go(){
5
 
        local importing_from_non_dbc upgrading reconfiguring f tsubstfile upgrades_pending dumpfile _dbc_asuser reinstall
 
5
        local importing_from_non_dbc upgrading reconfiguring f tsubstfile upgrades_pending dbc_dumpfile _dbc_asuser reinstall
6
6
 
7
7
        . /usr/share/dbconfig-common/dpkg/common
8
 
        dbc_debug "(postinst) dbc_go() $@"
 
8
        _dbc_debug "(postinst) dbc_go() $@"
9
9
        dbc_config $@
10
10
 
11
11
        ###
62
62
                # don't perform the following block of code during upgrades
63
63
                if [ ! "$upgrading" ]; then
64
64
                        ###
 
65
                        ### first things first, see if the database client package is installed,
 
66
                        ### and in case of failure provide a more sensible error message.
 
67
                        ###
 
68
                        dbc_detect_installed_dbtype $dbc_dbtype || dbc_missing_db_package_error $dbc_dbclientpackage
 
69
                        [ "$dbc_tried_again" ] && return 0
 
70
 
 
71
                        ###
 
72
                        ### next, if we're connecting to a local database,
 
73
                        ### see if the database server package is installed,
 
74
                        ### and in case of failure provide a more sensible error message.
 
75
                        ###
 
76
                        if [ "$dbc_method" = "unix socket" ]; then
 
77
                                $dbc_db_installed_cmd || dbc_missing_db_package_error $dbc_dbpackage
 
78
                                [ "$dbc_tried_again" ] && return 0
 
79
                        fi
 
80
 
 
81
                        ###
65
82
                        ### now, create the app user account
66
83
                        ###
67
84
                        $dbc_createuser_cmd || dbc_install_error "creating user"
77
94
                        ### populate the database
78
95
                        ###
79
96
                        # sqlfile is the file to use for installing the database
80
 
                        dbc_sqlfile=$dbc_share/data/$dbc_package/install/$dbc_dbtype
81
 
                        dbc_sqlfile_adm=$dbc_share/data/$dbc_package/install-dbadmin/$dbc_dbtype
82
 
                        dbc_scriptfile=$dbc_share/scripts/$dbc_package/install/$dbc_dbtype
 
97
                        dbc_sqlfile=$dbc_share/data/$dbc_basepackage/install/$dbc_dbtype
 
98
                        dbc_sqlfile_adm=$dbc_share/data/$dbc_basepackage/install-dbadmin/$dbc_dbtype
 
99
                        dbc_scriptfile=$dbc_share/scripts/$dbc_basepackage/install/$dbc_dbtype
83
100
                        if [ -f "$dbc_scriptfile" ]; then
84
101
                                dbc_logpart "populating database via scriptfile... "
85
102
                                if ! sh -c "$dbc_scriptfile $*"; then
149
166
                                if [ "$dbc_upgrade" != "true" ]; then return 0; fi
150
167
 
151
168
                                # get the admin password if it's needed
152
 
                                if [ ! "$dbc_frontend" ]; then
153
 
                                        if [ ! "$dbc_dbtype" = "pgsql" ] || [ ! "$dbc_authmethod_admin" = "ident" ]; then
154
 
                                                dbc_get_admin_pass
 
169
                                if echo "$dbc_authenticated_dbtypes" | grep -q "$dbc_dbtype"; then
 
170
                                        if [ ! "$dbc_frontend" ]; then
 
171
                                                if [ ! "$dbc_dbtype" = "pgsql" ] || [ ! "$dbc_authmethod_admin" = "ident" ]; then
 
172
                                                        dbc_get_admin_pass
 
173
                                                fi
155
174
                                        fi
156
175
                                fi
157
176
 
158
177
                                # this is the file into which upgrade backups go
159
 
                                dumpfile=/var/cache/dbconfig-common/backups/${dbc_package}_${dbc_oldversion}.$dbc_dbtype        
160
 
                                dbc_logline "creating database backup in $dumpfile"
 
178
                                dbc_dumpfile=/var/cache/dbconfig-common/backups/${dbc_package}_${dbc_oldversion}.$dbc_dbtype    
 
179
                                dbc_logline "creating database backup in $dbc_dumpfile"
161
180
                                # backup before we upgrade
162
181
                                _dbc_asuser=""
163
 
                                $dbc_dump_cmd $dumpfile
 
182
                                $dbc_dump_cmd $dbc_dumpfile || dbc_upgrade_error "backing up the old database"
164
183
                        fi
165
184
 
166
185
                        # now perform the updates
188
207
_dbc_find_upgrades(){
189
208
        local f s sqldir admsqldir scriptdir upgradedirs pending sorted placed tlist
190
209
        # check for new upgrades in these three locations
191
 
        sqldir=$dbc_share/data/$dbc_package/upgrade/$dbc_dbtype
192
 
        admsqldir=$dbc_share/data/$dbc_package/upgrade-dbadmin/$dbc_dbtype
193
 
        scriptdir=$dbc_share/scripts/$dbc_package/upgrade/$dbc_dbtype
 
210
        sqldir=$dbc_share/data/$dbc_basepackage/upgrade/$dbc_dbtype
 
211
        admsqldir=$dbc_share/data/$dbc_basepackage/upgrade-dbadmin/$dbc_dbtype
 
212
        scriptdir=$dbc_share/scripts/$dbc_basepackage/upgrade/$dbc_dbtype
194
213
 
195
214
        for f in $sqldir $admsqldir $scriptdir; do
196
215
                if [ -d "$f" ]; then
200
219
 
201
220
        if [ ! "$upgradedirs" ]; then return 0; fi
202
221
 
203
 
        for f in `find $upgradedirs -type f -print0 | \
 
222
        for f in `find $upgradedirs -xtype f -print0 | \
204
223
              xargs --no-run-if-empty -0 -n1 basename | sort -n | uniq`; do
205
224
                if dpkg --compare-versions $dbc_oldversion lt $f; then
206
225
                        pending="$pending $f"
250
269
##
251
270
_dbc_apply_upgrades(){
252
271
        local f vers sqlfile admsqlfile scriptfile
253
 
        dbc_debug "_dbc_apply_upgrades() $@"
 
272
        _dbc_debug "_dbc_apply_upgrades() $@"
254
273
        # check for new upgrades in these three locations
255
274
        vers="$1"
256
 
        sqlfile="$dbc_share/data/$dbc_package/upgrade/$dbc_dbtype/$vers"
257
 
        admsqlfile="$dbc_share/data/$dbc_package/upgrade-dbadmin/$dbc_dbtype/$vers"
258
 
        scriptfile="$dbc_share/scripts/$dbc_package/upgrade/$dbc_dbtype/$vers"
 
275
        sqlfile="$dbc_share/data/$dbc_basepackage/upgrade/$dbc_dbtype/$vers"
 
276
        admsqlfile="$dbc_share/data/$dbc_basepackage/upgrade-dbadmin/$dbc_dbtype/$vers"
 
277
        scriptfile="$dbc_share/scripts/$dbc_basepackage/upgrade/$dbc_dbtype/$vers"
259
278
 
260
279
 
261
280
        # now go through script updates