~ubuntu-branches/debian/sid/rpm/sid

« back to all changes in this revision

Viewing changes to debian/patches/rpm-4.10.90-rpmlib-filesystem-check.patch

  • Committer: Package Import Robot
  • Author(s): Michal Čihař
  • Date: 2013-06-06 11:39:34 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20130606113934-ela3du14fyba0t6u
Tags: 4.11.0.1-1
* New upstream release.
* Bump standards to 3.9.4.
* Refresh patches, update patch from Fedora.
* Build with Lua 5.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Add Fedora compatible rpm builtin provides
 
2
Origin: vendor, http://pkgs.fedoraproject.org/cgit/rpm.git/plain/rpm-4.10.90-rpmlib-filesystem-check.patch
 
3
Forwarded: not-needed
 
4
--- a/lib/depends.c
 
5
+++ b/lib/depends.c
 
6
@@ -529,6 +529,109 @@
 
7
     return rc;
 
8
 }
 
9
 
 
10
+/*
 
11
+ * Temporary support for live-conversion of the filesystem hierarchy
 
12
+ *   mailto: kay@redhat.com, harald@redhat.com
 
13
+ *   https://fedoraproject.org/wiki/Features/UsrMove
 
14
+ *
 
15
+ *   X-CheckUnifiedSystemdir:
 
16
+ *     /bin, /sbin, /lib, /lib64 --> /usr
 
17
+ *
 
18
+ *   X-CheckUnifiedBindir:
 
19
+ *     /usr/sbin -> /usr/bin
 
20
+ *
 
21
+ *   X-CheckMultiArchLibdir:
 
22
+ *     /usr/lib64 /usr/lib/<platform tuple> (e.g. x86_64-linux-gnu)
 
23
+ *
 
24
+ * This code is not needed for new installations, it can be removed after
 
25
+ * updates from older systems are no longer supported: Fedora 19 / RHEL 8.
 
26
+ */
 
27
+
 
28
+static int CheckLink(const char *dir, const char *root)
 
29
+{
 
30
+    char *d = NULL;
 
31
+    struct stat sbuf;
 
32
+    int rc = 0;
 
33
+
 
34
+    if (!root)
 
35
+       root = "/";
 
36
+
 
37
+    rasprintf(&d, "%s%s", root, dir);
 
38
+    if (!d) {
 
39
+       rc = -1;
 
40
+       goto exit;
 
41
+    }
 
42
+
 
43
+    /* directory or symlink does not exist, all is fine */
 
44
+    if (lstat(d, &sbuf) < 0) {
 
45
+       rc = 1;
 
46
+       goto exit;
 
47
+    }
 
48
+
 
49
+    /* if it is a symlink, all is fine */
 
50
+    if (S_ISLNK(sbuf.st_mode))
 
51
+       rc = 1;
 
52
+
 
53
+exit:
 
54
+    free(d);
 
55
+    return rc;
 
56
+}
 
57
+
 
58
+static int CheckFilesystemHierarchy(rpmds * dsp, const char *root)
 
59
+{
 
60
+    static const char *dirs[] = { "bin", "sbin", "lib", "lib64" };
 
61
+    int check;
 
62
+    int i;
 
63
+    rpmds ds;
 
64
+    rpmstrPool pool = rpmdsPool(*dsp);
 
65
+    int rc = 0;
 
66
+
 
67
+    for (i = 0; i < sizeof(dirs) / sizeof(dirs[0]); i++) {
 
68
+       check = CheckLink(dirs[i], root);
 
69
+       if (check < 0) {
 
70
+           rc = -1;
 
71
+           goto exit;
 
72
+       }
 
73
+
 
74
+       if (check == 0)
 
75
+           goto exit;
 
76
+    }
 
77
+    ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME,
 
78
+                        "rpmlib(X-CheckUnifiedSystemdir)", "1",
 
79
+                        RPMSENSE_EQUAL);
 
80
+    rpmdsMerge(dsp, ds);
 
81
+    rpmdsFree(ds);
 
82
+
 
83
+    check = CheckLink("usr/lib64", root);
 
84
+    if (check < 0) {
 
85
+        rc = -1;
 
86
+        goto exit;
 
87
+    }
 
88
+    if (check > 0) {
 
89
+       ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME,
 
90
+                            "rpmlib(X-CheckMultiArchLibdir)", "1",
 
91
+                            RPMSENSE_EQUAL);
 
92
+       rpmdsMerge(dsp, ds);
 
93
+       rpmdsFree(ds);
 
94
+    }
 
95
+
 
96
+    check = CheckLink("usr/sbin", root);
 
97
+    if (check < 0) {
 
98
+       rc = -1;
 
99
+       goto exit;
 
100
+    }
 
101
+    if (check > 0) {
 
102
+       ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME,
 
103
+                            "rpmlib(X-CheckUnifiedBindir)", "1",
 
104
+                            RPMSENSE_EQUAL);
 
105
+       rpmdsMerge(dsp, ds);
 
106
+       rpmdsFree(ds);
 
107
+    }
 
108
+
 
109
+exit:
 
110
+    return rc;
 
111
+}
 
112
+
 
113
 /**
 
114
  * Check dep for an unsatisfied dependency.
 
115
  * @param ts           transaction set
 
116
@@ -552,8 +655,10 @@
 
117
      * Check those dependencies now.
 
118
      */
 
119
     if (dsflags & RPMSENSE_RPMLIB) {
 
120
-       if (tsmem->rpmlib == NULL)
 
121
+       if (tsmem->rpmlib == NULL) {
 
122
            rpmdsRpmlibPool(rpmtsPool(ts), &(tsmem->rpmlib), NULL);
 
123
+           CheckFilesystemHierarchy(&(tsmem->rpmlib), rpmtsRootDir(ts));
 
124
+       }
 
125
        
 
126
        if (tsmem->rpmlib != NULL && rpmdsSearch(tsmem->rpmlib, dep) >= 0) {
 
127
            rpmdsNotify(dep, "(rpmlib provides)", rc);