Bug 899506

Summary: netcfg's rename of HOSTNAME breaks
Product: [openSUSE] openSUSE Tumbleweed Reporter: Stephan Kulow <coolo>
Component: NetworkAssignee: Tomáš Chvátal <tchvatal>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P1 - Urgent CC: behlert, fcrozat, mls, mrmazda, mrueckert, ohering
Version: 201409*Flags: coolo: SHIP_STOPPER+
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stephan Kulow 2014-10-02 11:57:15 UTC
this is either a dup of 883999 or caused by the fix of it - I just don't know

But this is what happens while duping from 13.1 in openqa:
https://openqa.opensuse.org/tests/25566/modules/zdup/steps/16
Comment 1 Petr Gajdos 2014-10-02 13:07:23 UTC
I tried with plain rpm -Uhv to go from 18.1.2 to 25.1 without success in reproducing this issue. Even zypper dup works on changeroot with /etc/HOSTNAME change and also unchanged.

Michael, would you have an idea what's wrong? /etc/HOSTNAME was regular file and now it is symbolic link to /etc/hostname.

Relevant parts of scriptlets:

%pre
if [ "0$1" -ge "2" ]; then
  if [ -f /etc/HOSTNAME -a ! -L /etc/HOSTNAME ]; then
    if [ -f /etc/hostname ]; then
      mv /etc/hostname /etc/hostname.rpmsave
    fi
    ln -f /etc/HOSTNAME /etc/HOSTNAME.rpmsave
    rm /etc/HOSTNAME
  fi
fi

%post
if [ -f /etc/HOSTNAME.rpmsave -a ! -L /etc/HOSTNAME.rpmsave ]; then
  cp -a /etc/HOSTNAME.rpmsave /etc/hostname
fi

Discussion is in yet referenced bug 883999.
Comment 2 Petr Gajdos 2014-10-02 14:12:19 UTC
Tried an update on live 13.1:
1. created fully patched 13.1
2. create temp-repo dir with netcfg-11.5-25.1 in it; 
3. add temp-repo as zypper repo
3. zypper dup

This went without any error.
Comment 3 Petr Gajdos 2014-10-02 14:33:03 UTC
On the same system I have downgraded netcfg back to 11.5-18.1.2 and then subscribed to http://download.opensuse.org/factory/repo/oss/
and did zypper dup.

It is updating without errors so far and netcfg was updated to 25.1 correctly yet.
Comment 4 Michael Schröder 2014-10-02 14:33:33 UTC
I guess you must not remove the old /etc/HOSTNAME. I think the error happens when rpm tries to rename the old /etc/HOSTNAME file to /etc/HOSTNAME.rpmxxx. It tries to do this because at the time the file fates are decided the preinstall script is not run.

So when you then mess with the system in the preinstall script, rpm's expectations are no longer valid.

So I would remove the "rm /etc/HOSTNAME" line.
Comment 5 Petr Gajdos 2014-10-02 18:34:07 UTC
Michael, that makes sense, thanks!
Comment 7 Bernhard Wiedemann 2014-10-02 19:00:23 UTC
This is an autogenerated message for OBS integration:
This bug (899506) was mentioned in
https://build.opensuse.org/request/show/253698 Factory / netcfg
Comment 9 Michael Schröder 2014-10-03 17:20:25 UTC
Good news:

1) I can easily reproduce the problem. But only with Factory's rpm version.

2) I can confirm that it's the rpmsave rename that breaks the update.

3) Your new netcfg version works.

As the rpm in SLE-12 does not care about the failing rpmsave rename, it's IMHO ok to not have a fixed version in SLE-12. But Stefan needs to decide this.
Comment 10 Petr Gajdos 2014-10-05 18:25:49 UTC
(In reply to Michael Schroeder from comment #9)
> Good news:
> 
> 1) I can easily reproduce the problem. But only with Factory's rpm version.
> 
> 2) I can confirm that it's the rpmsave rename that breaks the update.
> 
> 3) Your new netcfg version works.
> 
> As the rpm in SLE-12 does not care about the failing rpmsave rename, it's
> IMHO ok to not have a fixed version in SLE-12. But Stefan needs to decide
> this.

Thats really verry good news, thanks!
Comment 11 Stephan Kulow 2014-10-06 10:44:58 UTC
And I'm very happy that my instict told me not to copy the rpm to 13.2 - 13.2's dup tests did not show the problem :)
Comment 13 Stefan Behlert 2014-10-07 09:16:19 UTC
No showstopper for SLE 12.
Comment 14 Petr Gajdos 2014-10-07 09:20:29 UTC
Fixed.
Comment 15 Petr Gajdos 2014-10-08 07:18:05 UTC
*** Bug 899517 has been marked as a duplicate of this bug. ***
Comment 16 Marcus Rückert 2014-11-12 17:41:45 UTC
This fix is incomplete you have to remove the HOSTNAME.rpmsave. Otherwise every upgrade of the netcfg package will restore HOSTNAME.rpmsave again and thus overwrite changes done by the admin in the meantime.
Comment 17 Petr Gajdos 2014-11-13 16:44:23 UTC
HOSTNAME.rpmsave restored??

I do not understand I am afraid :(.

I guess we can drop whole migration nonsense anyway now? I. e. dummy netcfg could ship only /etc/hostname, nothing more? 

Or, would it be possible to not do migration on the rpm level? Btw. who needs /etc/HOSTNAME link at all? 

Really, really confused.
Comment 18 Marcus Rückert 2014-11-13 16:51:14 UTC
You currently have:
```
if [ -f /etc/HOSTNAME.rpmsave -a ! -L /etc/HOSTNAME.rpmsave ]; then
  cp -a /etc/HOSTNAME.rpmsave /etc/hostname
fi
```

You want:
```
if [ -f /etc/HOSTNAME.rpmsave -a ! -L /etc/HOSTNAME.rpmsave ]; then
  cp -a /etc/HOSTNAME.rpmsave /etc/hostname
  rm /etc/HOSTNAME.rpmsave
fi
```
Comment 19 Michael Schröder 2014-11-13 16:56:48 UTC
I think darix just wants you to add a

rm -f /etc/HOSTNAME.rpmsave

after the cp statement in the post scriptlet.

(And maybe he also complains a bit about you using .rpmsave as suffix, as that's also what rpm uses and so there can be an old HOSTNAME.rpmsave file in the system from some old rpm run...)
Comment 20 Marcus Rückert 2014-11-13 17:07:07 UTC
and all the other scripts with a similar fashion should have the rm call.
Comment 22 Tomáš Chvátal 2014-12-01 16:58:12 UTC
Hopefully fixed in the Base:System and sent to Factory.
Comment 23 Bernhard Wiedemann 2014-12-01 18:00:26 UTC
This is an autogenerated message for OBS integration:
This bug (899506) was mentioned in
https://build.opensuse.org/request/show/263637 Factory / netcfg
Comment 24 Bernhard Wiedemann 2014-12-08 09:00:35 UTC
This is an autogenerated message for OBS integration:
This bug (899506) was mentioned in
https://build.opensuse.org/request/show/264371 13.2 / netcfg
Comment 25 Swamp Workflow Management 2014-12-15 09:05:37 UTC
openSUSE-RU-2014:1633-1: An update that has three recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 858908,887039,899506
CVE References: 
Sources used:
openSUSE 13.2 (src):    netcfg-11.5-24.5.1