Version 2.4
[febootstrap.git] / fakechroot-2.8-relchroot.patch
1 This patch must be applied to fakechroot 2.8 or SVN in order to
2 enable correct handling of relative chroots, for rpm and yum.
3
4 Note this patch has been included in upstream fakechroot >= 2.9
5
6 Index: src/libfakechroot.c
7 ===================================================================
8 --- src/libfakechroot.c (revision 311)
9 +++ src/libfakechroot.c (working copy)
10 @@ -1147,7 +1147,7 @@
11  {
12      char *ptr, *ld_library_path, *tmp, *fakechroot_path;
13      int status, len;
14 -    char dir[FAKECHROOT_MAXPATH], cwd[FAKECHROOT_MAXPATH], full_path[FAKECHROOT_MAXPATH];
15 +    char dir[FAKECHROOT_MAXPATH], cwd[FAKECHROOT_MAXPATH];
16  #if !defined(HAVE_SETENV)
17      char *envbuf;
18  #endif
19 @@ -1162,7 +1162,9 @@
20          return -1;
21      }
22      if (*path != '/') {
23 -        if (getcwd(cwd, FAKECHROOT_MAXPATH) == NULL) {
24 +        if (next_getcwd == NULL) fakechroot_init();
25 +
26 +        if (next_getcwd(cwd, FAKECHROOT_MAXPATH) == NULL) {
27              errno = ENAMETOOLONG;
28              return -1;
29          }
30 @@ -1171,24 +1173,22 @@
31              return -1;
32          }
33          if (strcmp(cwd, "/") == 0) {
34 -            snprintf(full_path, FAKECHROOT_MAXPATH, "/%s", path);
35 +            snprintf(dir, FAKECHROOT_MAXPATH, "/%s", path);
36          }
37          else {
38 -            snprintf(full_path, FAKECHROOT_MAXPATH, "%s/%s", cwd, path);
39 +            snprintf(dir, FAKECHROOT_MAXPATH, "%s/%s", cwd, path);
40          }
41      }
42      else {
43 -        snprintf(full_path, FAKECHROOT_MAXPATH, "%s", path);
44 -    }
45 +       fakechroot_path = getenv("FAKECHROOT_BASE");
46  
47 -    fakechroot_path = getenv("FAKECHROOT_BASE");
48 -
49 -    if (fakechroot_path != NULL) {
50 -        snprintf(dir, FAKECHROOT_MAXPATH, "%s%s", fakechroot_path, full_path);
51 +       if (fakechroot_path != NULL) {
52 +           snprintf(dir, FAKECHROOT_MAXPATH, "%s%s", fakechroot_path, path);
53 +       }
54 +       else {
55 +           snprintf(dir, FAKECHROOT_MAXPATH, "%s", path);
56 +       }
57      }
58 -    else {
59 -        snprintf(dir, FAKECHROOT_MAXPATH, "%s", full_path);
60 -    }
61  
62  #if defined(HAVE___XSTAT) && defined(_STAT_VER)
63      if ((status = next___xstat(_STAT_VER, dir, &sb)) != 0) {