[ovs-dev] Bug#681880: [bug 681880 3/3] debian: Move database from /etc/openvswitch to /var/lib/openvswitch.

Ansis Atteka aatteka at nicira.com
Fri Jul 27 00:07:31 UTC 2012


On Thu, Jul 26, 2012 at 4:47 PM, Ansis Atteka <aatteka at nicira.com> wrote:

>
>
> On Thu, Jul 26, 2012 at 2:48 PM, Ben Pfaff <blp at nicira.com> wrote:
>
>> Debian bug #681880.
>> CC: 681880 at bugs.debian.org
>> Reported-by: Bastian Blank <waldi at debian.org>
>> Signed-off-by: Ben Pfaff <blp at nicira.com>
>> ---
>>  REPORTING-BUGS                     |    2 +-
>>  debian/automake.mk                 |    1 +
>>  debian/openvswitch-switch.dirs     |    1 +
>>  debian/openvswitch-switch.postinst |   15 +++++++++++
>>  debian/openvswitch-switch.postrm   |    4 +-
>>  debian/openvswitch-switch.prerm    |   50
>> ++++++++++++++++++++++++++++++++++++
>>  6 files changed, 70 insertions(+), 3 deletions(-)
>>  create mode 100755 debian/openvswitch-switch.prerm
>>
>> diff --git a/REPORTING-BUGS b/REPORTING-BUGS
>> index 86510d2..af0096b 100644
>> --- a/REPORTING-BUGS
>> +++ b/REPORTING-BUGS
>> @@ -32,7 +32,7 @@ The following are also handy sometimes:
>>            your OS (e.g. "Centos 5.0").
>>
>>          * The contents of the vswitchd configuration database (usually
>> -          /etc/openvswitch/conf.db).
>> +          /etc/openvswitch/conf.db or /var/lib/openvswitch/conf.db).
>>
>>          * The output of "ovs-dpctl show".
>>
>> diff --git a/debian/automake.mk b/debian/automake.mk
>> index b6cb12e..b025cdd 100644
>> --- a/debian/automake.mk
>> +++ b/debian/automake.mk
>> @@ -44,6 +44,7 @@ EXTRA_DIST += \
>>         debian/openvswitch-switch.manpages \
>>         debian/openvswitch-switch.postinst \
>>         debian/openvswitch-switch.postrm \
>> +       debian/openvswitch-switch.prerm \
>>         debian/openvswitch-switch.template \
>>         debian/openvswitch-switch.links \
>>         debian/openvswitch-test.dirs \
>> diff --git a/debian/openvswitch-switch.dirs
>> b/debian/openvswitch-switch.dirs
>> index 0b1f281..ccbbbf7 100644
>> --- a/debian/openvswitch-switch.dirs
>> +++ b/debian/openvswitch-switch.dirs
>> @@ -1,2 +1,3 @@
>>  /etc/openvswitch
>> +/var/lib/openvswitch
>>
> A nitpick - maybe keep alphabetic sequence?
>
>>  /usr/share/openvswitch/switch
>> diff --git a/debian/openvswitch-switch.postinst
>> b/debian/openvswitch-switch.postinst
>> index 7b9d7bc..38e1eee 100755
>> --- a/debian/openvswitch-switch.postinst
>> +++ b/debian/openvswitch-switch.postinst
>> @@ -33,6 +33,21 @@ case "$1" in
>>                  fi
>>              done
>>         fi
>>
> +
>> +       # Ensure that /etc/openvswitch/conf.db links to
>> /var/lib/openvswitch,
>> +       # moving an existing file if there is one.
>> +       #
>> +       # Ditto for .conf.db.~lock~.
>> +       for base in conf.db .conf.db.~lock~; do
>> +           new=/var/lib/openvswitch/$base
>> +           old=/etc/openvswitch/$base
>> +           if test -f $old && test ! -e $new; then
>> +               mv $old $new
>> +           fi
>> +           if test ! -e $old && test ! -h $old; then
>> +               ln -s $new $old
>> +           fi
>> +       done
>>
> The code above will break fresh install, because here we would create
> a dangling symlink /etc/openvswitch/conf.db ->
> /var/lib/openvswitch/conf.db.
>
> But later, when we call upgrade_db() from ovs-ctl, then the ovsdb-tool
> would try to create
> the database in /etc/openvswitch/conf.db, not in
> /var/lib/openvswitch/conf.db. And that will
> fail.
>
My apologies, I forgot to apply 2/3 patch before reviewing.

>          ;;
>>
>
>>      abort-upgrade|abort-remove|abort-deconfigure)
>> diff --git a/debian/openvswitch-switch.postrm
>> b/debian/openvswitch-switch.postrm
>> index 88bf9fc..ff4ae4a 100755
>> --- a/debian/openvswitch-switch.postrm
>> +++ b/debian/openvswitch-switch.postrm
>> @@ -21,8 +21,8 @@ set -e
>>
>>  case "$1" in
>>      purge)
>> -        rm -f /etc/openvswitch/conf.db
>> -        rm -f /etc/openvswitch/.conf.db.~lock~
>> +        rm -f /etc/openvswitch/conf.db /etc/openvswitch/.conf.db.~lock~
>> +        rm -f /var/lib/openvswitch/conf.db
>> /var/lib/openvswitch/.conf.db.~lock~
>>          rm -f /etc/default/openvswitch-switch
>>          rm -f /var/log/openvswitch/ovs-vswitchd.log* || true
>>          rm -f /var/log/openvswitch/ovsdb-server.log* || true
>> diff --git a/debian/openvswitch-switch.prerm
>> b/debian/openvswitch-switch.prerm
>> new file mode 100755
>> index 0000000..9221ef1
>> --- /dev/null
>> +++ b/debian/openvswitch-switch.prerm
>> @@ -0,0 +1,50 @@
>> +#!/bin/sh
>> +# prerm script for openvswitch-switch
>> +#
>> +# see: dh_installdeb(1)
>> +
>> +set -e
>> +
>> +# summary of how this script can be called:
>> +#        * <prerm> `remove'
>> +#        * <old-prerm> `upgrade' <new-version>
>> +#        * <new-prerm> `failed-upgrade' <old-version>
>> +#        * <conflictor's-prerm> `remove' `in-favour' <package>
>> <new-version>
>> +#        * <deconfigured's-prerm> `deconfigure' `in-favour'
>> +#          <package-being-installed> <version> `removing'
>> +#          <conflicting-package> <version>
>> +# for details, see http://www.debian.org/doc/debian-policy/ or
>> +# the debian-policy package
>> +
>> +
>> +case "$1" in
>> +    upgrade)
>> +        # Ensure that conf.db and its lockfile in /etc/openvswitch are
>> not
>> +        # dangling symlinks, because this caused ovsdb-server to hang at
>> +        # startup in versions of OVS older than 1.4.2+git20120612-7.
>> +        for base in conf.db .conf.db.~lock~; do
>> +            fn=/etc/openvswitch/$base
>> +            if test -h $fn && test ! -e $fn; then
>> +                rm -f $fn
>> +            fi
>> +        done
>> +        ;;
>> +
>> +    remove|deconfigure)
>> +    ;;
>> +
>> +    failed-upgrade)
>> +    ;;
>> +
>> +    *)
>> +        echo "prerm called with unknown argument \`$1'" >&2
>> +        exit 1
>> +    ;;
>> +esac
>> +
>> +# dh_installdeb will replace this with shell code automatically
>> +# generated by other debhelper scripts.
>> +
>> +#DEBHELPER#
>> +
>> +exit 0
>> --
>> 1.7.2.5
>> _______________________________________________
>> dev mailing list
>> dev at openvswitch.org
>> http://openvswitch.org/mailman/listinfo/dev
>>
>
> Thanks,
> Ansis
>

Looks good to me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20120726/c84244a5/attachment-0003.html>


More information about the dev mailing list