Bug 246389

Summary: yast2 update empties /dev
Product: [openSUSE] openSUSE 10.3 Reporter: Hans-Peter Holler <holler>
Component: YaST2Assignee: Lukas Ocilka <locilka>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Major    
Priority: P5 - None CC: andreas.hanke, dmacvicar, locilka
Version: Alpha 1   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: /var/log/YaST2/y2log
YaST2logs.tgz
yast2updatetrace.tgz

Description Hans-Peter Holler 2007-02-16 17:14:56 UTC
With yast2-2.15.8-2 and yast2-update-2.15.2-6 from alpha 1 a system update in a running system with "yast2 update" deletes almost all files in /dev.

Seen with inst sources:
- directly used iso file
- loop-mounted iso file used as directory
- dvd burned from iso file.

Booting from the dvd and doing the update works.

iso file: 10.2 GM deltaapplied with 10.3 Alpha 1 delta iso.
Comment 1 Hans-Peter Holler 2007-02-16 17:22:55 UTC
Created attachment 119704 [details]
/var/log/YaST2/y2log

The log shows no activities in /dev
Comment 2 Andreas Hanke 2007-02-16 17:33:06 UTC
Could be a duplicate of bug 244937.
Comment 3 Andreas Jaeger 2007-02-16 18:13:16 UTC
No, this is not a duplicate.  This is the result of removing the devs.rpm package.

We are mounting /dev on tmpfs for some time.

But let the experts look at it ;-)
Comment 4 Lukas Ocilka 2007-02-16 18:40:52 UTC
Yes, I can confirm that this is not a duplicate of bug 244937, that 'functionality' (bug) has been added later (and there are no logs that would indicate the same or similar behavior as in that bug - clients/inst_kickoff.ycp).

However, the attached y2log seems to be only part of the y2log that contains all needed information.

Could, you, please attach also other logs? At least y2log-1 and y2log-2 from /var/log/YaST2 directory? It might be better to gzip that file (cp y2log-1 y2log-1a; gzip y2log-1a).
Comment 5 Lukas Ocilka 2007-02-16 18:43:27 UTC
And please attach also /var/lib/YaST2/failed_packages file, thanks.
Comment 6 Lukas Ocilka 2007-02-16 18:46:56 UTC
And maybe /var/log/YaST2/y2logRPM as well :)
Or the whole /var/log/YaST2/ directory, if you don't mind.
Comment 7 Olaf Hering 2007-02-16 21:40:52 UTC
why is the old /dev being removed anyway?
we want to get rid of devs.rpm in the rpmdb, not on the hard drive...
Comment 8 Hans-Peter Holler 2007-02-16 21:58:57 UTC
Created attachment 119759 [details]
YaST2logs.tgz

ok, these are the contents of /var/log/YaST2 and /var/lib/YaST2

These logs are from this scenario: I ran "yast2 update" against my up to date system. So no package to update, delete, install.
I simply do the system update expecting that there's nothing to do. But straight after clicking on the "Start Update" button almost all files in /dev are removed.
Comment 9 Hans-Peter Holler 2007-02-16 22:05:54 UTC
Created attachment 119760 [details]
yast2updatetrace.tgz

I straced "yast2 update"
Please look at the lines with unlinkat(3
Comment 12 Michael Andres 2007-02-19 11:32:03 UTC
YaST calls the update algorithm and requests to tag unmaintained packages to be deleted. The devs package is dropped. The devs package was taged to delete.

From zypp point of view the bug is INVALID.

==> to Jiri/Lucas. This is 'FATE-301903 Dropping devs.rpm'.
Comment 13 Hans-Peter Holler 2007-02-19 11:53:41 UTC
Maybe this change in inst_kickoff.ycp helps (don't know whether Mode:update_in_running_system() exists. Take it as pseudo code):

    // Feature #301903, bugzilla #244937
    if (Mode::update()) {
	// When upgrading system, remove devs.rpm if installed
	LocalCommand (sformat (
	    "/bin/rpm --root '%1' -q 'devs' && /bin/rpm --nodeps --root '%1' -e 'devs'",
	    String::Quote (Installation::destdir)
	));

++// Don't do this if called from system update in running system
++if (!Mode:update_in_running_system()) {
	// Mount (bind) the current /dev/ to the /installed_system/dev/
	LocalCommand (sformat (
	    "/bin/rm -rf '%1/dev/' && /bin/mkdir -p '%1/dev/' && /bin/mount -v --bind '/dev/' '%1/dev/'",
	    String::Quote (Installation::destdir)
	));
++}
    }
Comment 14 Lukas Ocilka 2007-02-19 12:02:26 UTC
The part of code that you writing about has been added into yast2-packager-2.15.11. These commands were not called (see my comment #4).
This functionality was not in Alpha1.

-------------------------------------------------------------------
Tue Feb 13 12:51:23 CET 2007 - locilka@suse.cz

- Calling bind mount and removing devs.rpm only in case of upgrade
  (#244937).
- 2.15.11

-------------------------------------------------------------------
Comment 15 Lukas Ocilka 2007-02-19 12:14:49 UTC
grep "inst_kickoff\.ycp" y2log >>

2007-02-16 17:51:45 <1> holler-n(5593) [YCP] clients/inst_kickoff.ycp:141 backup of /etc/sysconfig
2007-02-16 17:51:46 <1> holler-n(5593) [YCP] clients/inst_kickoff.ycp:253 File /etc/mdadm.conf exists, skipping creation...
2007-02-16 17:51:46 <1> holler-n(5593) [Interpreter] clients/inst_kickoff.ycp:439 Called YaST client returned: `next
2007-02-16 17:51:46 <1> holler-n(5593) [YCP] clients/inst_kickoff.ycp:944 Calling `inst_kickoff ($["enable_back":true, "enable_next":true]) returned `next

Function LocalCommand(), mentioned in comment #13, logs what it does. On the other hand, this might happen in Alpha3 and it seems that this feature will not work for 10.3 Alpha4 for "System Update".
Comment 16 Hans-Peter Holler 2007-02-19 12:36:31 UTC
In reply to comment #14:
Sorry, but my iso (see bug description) has yast2-packager-2.15.11-2 from Tue
Feb 13 with the above comment in the changelog.

inst_kickoff.ycp _does_ call "/bin/rm -rf /%1/dev ..." on "System Update" in a
running system with "%1" == "/"!

I hacked this part of the code to
if ("%1" == "/mnt) {
...
}

This did it for me.

In reply to comment #15:
Does this mean that "System Update" in running system won't work with the next Alphas and Factory snapshots ?
Comment 18 Lukas Ocilka 2007-02-19 13:00:54 UTC
devs.rpm has been dropped in openSUSE 10.3, such package should _not_ exist anymore. That's why it was selected to be dropped by the packagemanager during that update process.

So you have reported a bug with against change in code made by yourself :) That's pretty confusing, don't you think so?

Anyway, I've done this change to the yast2-packager-2.15.15:

- Do not call bind mount and do not remove devs.rpm when running
  the System Update (#246389).

--- cut ---
     // Feature #301903, bugzilla #244937
-    if (Mode::update()) {
+    // "/" means updating the running system
+    if (Mode::update() && Installation::destdir != "/") {
        // When upgrading system, remove devs.rpm if installed
        LocalCommand (sformat (
            "/bin/rpm --root '%1' -q 'devs' && /bin/rpm --nodeps --root '%1' -e 'devs'",
--- cut ---

PS: The problem will exist after my change, zypp will drop that package anyway. I've just minimized the use-case to a update-from-CD.
Comment 19 Hans-Peter Holler 2007-02-19 13:15:34 UTC
Ok, i think noone needs devs.rpm if there's equivalent functionality.
But removing /dev/* isn't funny.
I did my hack an hour ago against inst_kickoff.ycp on my harddisk just for testing. This hack is around the /bin/rm -rf ... statement only.
If your solution (2.15.15) doesn't touch /dev in case of system update in running system, feel free to close this bug.
I will be waiting for this version in factory.
THX
Comment 21 Olaf Hering 2007-02-19 13:39:52 UTC
sigh.
guys, 'rpm -e --nodeps --justdeb devs' is all that needs to be done.
no 'rm -rf' required anywhere.
Comment 22 Lukas Ocilka 2007-02-19 13:49:49 UTC
--justdb
  Update only the database, not the filesystem.

This is not how the feature has been defined. The feature wants to remove the package _and_ the content. As I already said, ZYPP *would* remove the package anyway (with content) so --justdb doesn't help here much.

My current fix just doesn't call that rpm command at all in case of System Update.
Comment 23 Lukas Ocilka 2007-02-19 14:13:39 UTC
OK, --justdb will be used for the System Update.
Comment 24 Lukas Ocilka 2007-02-19 14:21:20 UTC
    // Feature #301903, bugzilla #244937
    if (Mode::update()) {
        // "/" means updating the running system, bugzilla #246389
        if (Installation::destdir == "/") {
            // When upgrading system, remove devs.rpm if installed
            LocalCommand (
                "/bin/rpm -q 'devs' && /bin/rpm --nodeps --justdb -e 'devs'"
            );
        // normal upgrade
        } else {
            // When upgrading system, remove devs.rpm if installed
            LocalCommand (sformat (
                "/bin/rpm --root '%1' -q 'devs' && /bin/rpm --nodeps --root '%1' -e 'devs'",
                String::Quote (Installation::destdir)
            ));

            // Mount (bind) the current /dev/ to the /installed_system/dev/
            LocalCommand (sformat (
                "/bin/rm -rf '%1/dev/' && /bin/mkdir -p '%1/dev/' && /bin/mount -v --bind '/dev/' '%1/dev/'",
                String::Quote (Installation::destdir)
            ));
        }
    }

Fixed in yast2-packager-2.15.15 (still not in build)
Comment 25 Hans-Peter Holler 2007-02-19 17:33:04 UTC
Thanks, this change does it. :-)
But: (I know, I'm boring)
How to install 2.15.15 or higher when you have 2.15.11 on your system through "yast2 update" ? The old code will remove especially /dev/loop*, so with any inst-source (e.g. ftp to factory) yast2 won't be able to mount the inst source. :-(
Installing the new version and _then_ doing the system update (in the running system) will resolve that.
Probably worth to be added to the most annoying bugs for factory.
Bye.
Comment 26 Lukas Ocilka 2007-02-20 10:24:04 UTC
Adding it to most annoying bugs? Well, the System Update feature was not planned for such tasks (frankly, it should not be used at all), it's very expert tool with almost no support :) I hope nobody other will use it for this :)))) ;)
Comment 27 Hans-Peter Holler 2007-02-20 17:25:53 UTC
So, what are the tasks the System Update feature is planned for ?
How would you update your system e.g. with current factory ?
Rsyncing the whole stuff and generating a installation dvd to boot from ?
I've updated my system on my current hardware since 9.2 with every gm, alpha, beta, rc and of course since openSUSE with factory this way.
Ok, I know what to do when something's going wrong in most cases, so maybe I'm a expert. Filing this bug did help in this case, so I can feel happy.
Thanks once more.

And I think I'm not the only one doing this.
Comment 28 Lukas Ocilka 2007-02-21 07:37:12 UTC
At least, I'll tell you how to update to the latest factory :)
Run the YaST Packagemanager (Qt), display all (installed) packages, click the right mouse button and select something like "Update when newer version exists". This should be safe because it also solves dependencies.

For updating 10.1 to 10.2 or 10.2 to 10.3, installation media should be used. For instance" booting from mini ISO CD, selecting some new 10.3 installation source, and then selection Update method in the Installation. This is almost what you do but the Update/Installation works in a defined (known) space. It has own installation-system with own kernel and own /dev/ ...

System Update is an expert tool and it should be probably just used to update packages from, e.g., 10.3 Beta2 to 10.3 Beta3, but reporting a bug that it has broken something, let's say wrongly selected languages might be closed as invalid bugreport.

Anyway, this bug seemed to be important to fix, so it it's been fixed :)

Please, use some openSUSE mailing-list for discussions and bugzilla for reporting and fixing bugs only ;) Thanks