Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 5.5.32
    • Fix Version/s: 5.5.34
    • Component/s: None
    • Labels:
    • Environment:
      CentOS 6

      Description

      If the default /etc/my.cnf file has been modified, removing the MariaDB-Server RPM will change /etc/my.cnf to /etc/my.cnf.rpm.save:

      [root@dev-160-18 ~]#  rpm -e --noscripts --nodeps $(rpm -qa | grep MariaDB)
      warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave
      [root@dev-160-18 ~]# 
      

      This is unexpected behavior, as Oracle MySQL packages do not do this (tested with Oracle MySQL 5.6.13). Oracle MySQL will leave the /etc/my.cnf file alone:

      [root@dev-160-18 ~]# rpm -e --nodeps $(rpm -qa|grep MySQL)
      [root@dev-160-18 ~]# ls -la /etc/my*
      -rw-r--r--. 1 root root 281 Aug 27 06:16 /etc/my.cnf
      [root@dev-160-18 ~]# 
      

      It was suggested that the "no replace" option be specified in the RPM spec file. But I don't know about packaging so that might not be the correct configuration option.

      Thanks!

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            simon.mudd Simon J Mudd added a comment -

            MySQL 5.6.5's spec file has:

            %ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf

            You may or may not want to behave the same but at least:

            %config(noreplace) %{_sysconfdir}/my.cnf

            Looking at some postfix packages I built some time ago I used a similar:

            %attr(0644, root, root) %verify(not md5 size mtime) %config(noreplace) %{_sysconfdir}/postfix/main.cf

            The intention should be clear: do not overwrite a configuration file once it exists...

            Show
            simon.mudd Simon J Mudd added a comment - MySQL 5.6.5's spec file has: %ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf You may or may not want to behave the same but at least: %config(noreplace) %{_sysconfdir}/my.cnf Looking at some postfix packages I built some time ago I used a similar: %attr(0644, root, root) %verify(not md5 size mtime) %config(noreplace) %{_sysconfdir}/postfix/main.cf The intention should be clear: do not overwrite a configuration file once it exists...
            Hide
            serg Sergei Golubchik added a comment -

            We have %config(noreplace) on all config files, including /etc/my.cnf and it's not replaced when you install MariaDB. When you uninstall it the standard rpm behavior seems to be to rename the file to .rpmsave.

            MySQL doesn't do it, because MySQL rpm packages don't include /etc/my.cnf, as far as I can see (it's marked as %ghost in the spec file).

            Show
            serg Sergei Golubchik added a comment - We have %config(noreplace) on all config files, including /etc/my.cnf and it's not replaced when you install MariaDB. When you uninstall it the standard rpm behavior seems to be to rename the file to .rpmsave. MySQL doesn't do it, because MySQL rpm packages don't include /etc/my.cnf, as far as I can see (it's marked as %ghost in the spec file).
            Hide
            simon.mudd Simon J Mudd added a comment - - edited

            It's been a while since I've been doing rpm packaging but yes, %ghost means iirc that the file may be there, or may not, and don't overwrite it it will simply not get touched. That's the required setup, because removing the package (required because you don't allows "inline upgrades") then removes the config.

            So without this entry you need to do:
            backup /etc/my.cnf
            rpm -e <old_package>
            copy /etc/my.cnf from backed up copy
            rpm -ivh .... (or yum install ...)

            IIRC (I've forgotten now) this came from doing a MariaDB 5.5 to MariaDB 10 upgrade. rpm is intended to allow you to do upgrades without uninstalling the old package and probably in this case a major version upgrade like this should be possible [for example by running mysql_upgrade with the -s option].)

            In essence what we want is the simplest upgrade path possible the current setup means that if you have to remove the package the configuration file gets renamed so on a newly installed package it will not be used.

            Show
            simon.mudd Simon J Mudd added a comment - - edited It's been a while since I've been doing rpm packaging but yes, %ghost means iirc that the file may be there, or may not, and don't overwrite it it will simply not get touched. That's the required setup, because removing the package (required because you don't allows "inline upgrades") then removes the config. So without this entry you need to do: backup /etc/my.cnf rpm -e <old_package> copy /etc/my.cnf from backed up copy rpm -ivh .... (or yum install ...) IIRC (I've forgotten now) this came from doing a MariaDB 5.5 to MariaDB 10 upgrade. rpm is intended to allow you to do upgrades without uninstalling the old package and probably in this case a major version upgrade like this should be possible [for example by running mysql_upgrade with the -s option] .) In essence what we want is the simplest upgrade path possible the current setup means that if you have to remove the package the configuration file gets renamed so on a newly installed package it will not be used.
            Hide
            alien AL13N added a comment -

            imho %config(noreplace) is the right way to go

            when you remove it, it gets .rpmsave 'd, but if you upgrade, this should keep your my.cnf file, (if it has modifications).

            it should be tested which version upgrades actually has this issue

            also, if you actually do rpm -e && rpm -ivh then you might have this issue, but why not doing rpm -Uvh ??? /me is confused...

            Show
            alien AL13N added a comment - imho %config(noreplace) is the right way to go when you remove it, it gets .rpmsave 'd, but if you upgrade, this should keep your my.cnf file, (if it has modifications). it should be tested which version upgrades actually has this issue also, if you actually do rpm -e && rpm -ivh then you might have this issue, but why not doing rpm -Uvh ??? /me is confused...
            Hide
            oden Oden Eriksson added a comment -

            AL13N is correct.

            The user should not uninstall and then install the package, either use "rpm -Uvh" or "rpm -Fvh", but the preferred way is to use "yum upgrade" which will take care of the whole transaction.

            Show
            oden Oden Eriksson added a comment - AL13N is correct. The user should not uninstall and then install the package, either use "rpm -Uvh" or "rpm -Fvh", but the preferred way is to use "yum upgrade" which will take care of the whole transaction.
            Hide
            serg Sergei Golubchik added a comment -

            This is expected behavior. When a package is removed, the 'rpm' tool automatically removes all non-modified config files, and renames modified ones to '*.rpmsave'. We cannot influence that.

            You can consider doing some of the following:
            1. Use "rpm -U" for upgrading not "rpm -e && rpm -i"
            2. Even better, use "yum upgrade"
            3. Independently from the above, don't modify my.cnf, but instead put all your settings into a separate file inside /etc/my.cnf.d/ directory — it will never be changed or renamed by the 'rpm' tool.

            Show
            serg Sergei Golubchik added a comment - This is expected behavior. When a package is removed, the 'rpm' tool automatically removes all non-modified config files, and renames modified ones to '*.rpmsave'. We cannot influence that. You can consider doing some of the following: 1. Use "rpm -U" for upgrading not "rpm -e && rpm -i" 2. Even better, use "yum upgrade" 3. Independently from the above, don't modify my.cnf, but instead put all your settings into a separate file inside /etc/my.cnf.d/ directory — it will never be changed or renamed by the 'rpm' tool.

              People

              • Assignee:
                serg Sergei Golubchik
                Reporter:
                wfong Will Fong
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: