aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/guile-3.0-relocatable.patch
blob: 3d101636dc3978ffc6e7fbc2321e7ea1ec5cda40 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
This patch changes Guile to use a default search path relative to the
location of the `guile' binary, allowing it to be relocated.

diff --git a/libguile/load.c b/libguile/load.c
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -27,6 +27,7 @@
 #include <stat-time.h>
 #include <string.h>
 #include <stdio.h>
+#include <libgen.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -334,6 +335,32 @@ scm_init_load_path ()
   SCM cpath = SCM_EOL;
 
 #ifdef SCM_LIBRARY_DIR
+  char *program, *bin_dir, *prefix, *module_dir, *ccache_dir;
+
+  /* Determine the source and compiled module directories at run-time,
+     relative to the executable's location.
+
+     Note: Use /proc/self/exe instead of argv[0] because the latter is
+     not necessarily an absolute, nor a valid file name.  */
+
+  program = scm_gc_malloc_pointerless (256, "string");
+  readlink ("/proc/self/exe", program, 256);
+
+  bin_dir = dirname (strdupa (program));
+
+  prefix = scm_gc_malloc_pointerless (strlen (bin_dir) + 4, "string");
+  strcpy (prefix, bin_dir);
+  strcat (prefix, "/..");
+  prefix = canonicalize_file_name (prefix);
+
+  module_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
+  strcpy (module_dir, prefix);
+  strcat (module_dir, "/share/guile/" SCM_EFFECTIVE_VERSION);
+
+  ccache_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
+  strcpy (ccache_dir, prefix);
+  strcat (ccache_dir, "/lib/guile/" SCM_EFFECTIVE_VERSION "/ccache");
+
   env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_PATH"));
   if (env && strcmp (env, "") == 0)
     /* special-case interpret system-path=="" as meaning no system path instead
@@ -342,10 +369,7 @@ scm_init_load_path ()
   else if (env)
     path = scm_parse_path (scm_from_locale_string (env), path);
   else
-    path = scm_list_4 (scm_from_utf8_string (SCM_LIBRARY_DIR),
-                       scm_from_utf8_string (SCM_SITE_DIR),
-                       scm_from_utf8_string (SCM_GLOBAL_SITE_DIR),
-                       scm_from_utf8_string (SCM_PKGDATA_DIR));
+    path = scm_list_1 (scm_from_locale_string (module_dir));
 
   env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH"));
   if (env && strcmp (env, "") == 0)
@@ -355,8 +379,7 @@ scm_init_load_path ()
     cpath = scm_parse_path (scm_from_locale_string (env), cpath);
   else
     {
-      cpath = scm_list_2 (scm_from_utf8_string (SCM_CCACHE_DIR),
-                          scm_from_utf8_string (SCM_SITE_CCACHE_DIR));
+      cpath = scm_list_1 (scm_from_locale_string (ccache_dir));
     }
 
 #endif /* SCM_LIBRARY_DIR */
td>logplainabout -rw-r--r--cpan.scm3659logplainabout -rw-r--r--cpio.scm3154logplainabout -rw-r--r--cran.scm4994logplainabout -rw-r--r--crate.scm15560logplainabout -rw-r--r--cve-sample.json46446logplainabout -rw-r--r--cve.scm3672logplainabout -rw-r--r--debug-link.scm6709logplainabout -rw-r--r--derivations.scm62328logplainabout -rw-r--r--discovery.scm2540logplainabout -rw-r--r--elpa.scm2850logplainabout -rw-r--r--file-systems.scm2686logplainabout -rw-r--r--gem.scm6473logplainabout -rw-r--r--gexp.scm61752logplainabout -rw-r--r--git.scm5068logplainabout -rw-r--r--glob.scm2331logplainabout -rw-r--r--gnu-maintenance.scm1688logplainabout -rw-r--r--grafts.scm22364logplainabout -rw-r--r--graph.scm17011logplainabout -rw-r--r--gremlin.scm3478logplainabout -rw-r--r--guix-archive.sh2855logplainabout -rw-r--r--guix-authenticate.sh2963logplainabout -rw-r--r--guix-build-branch.sh2222logplainabout -rw-r--r--guix-build.sh9999logplainabout -rw-r--r--guix-daemon.sh8336logplainabout -rw-r--r--guix-describe.sh1405logplainabout -rw-r--r--guix-download.sh1593logplainabout -rw-r--r--guix-environment-container.sh5741logplainabout -rw-r--r--guix-environment.sh8861logplainabout -rw-r--r--guix-gc.sh2819logplainabout -rw-r--r--guix-graph.sh2627logplainabout -rw-r--r--guix-hash.sh2266logplainabout -rw-r--r--guix-lint.sh2579logplainabout -rw-r--r--guix-pack-localstatedir.sh2565logplainabout -rw-r--r--guix-pack-relocatable.sh3289logplainabout -rw-r--r--guix-pack.sh4629logplainabout -rw-r--r--guix-package-aliases.sh1927logplainabout -rw-r--r--guix-package-net.sh7277logplainabout -rw-r--r--guix-package.sh15437logplainabout -rw-r--r--guix-system.sh9523logplainabout -rw-r--r--hackage.scm10660logplainabout -rw-r--r--import-utils.scm6173logplainabout -rw-r--r--inferior.scm10268logplainabout -rw-r--r--lint.scm37909logplainabout -rw-r--r--lzlib.scm4749logplainabout -rw-r--r--modules.scm2582logplainabout -rw-r--r--monads.scm9099logplainabout -rw-r--r--nar.scm21502logplainabout -rw-r--r--networking.scm4056logplainabout -rw-r--r--opam.scm7629logplainabout -rw-r--r--pack.scm10180logplainabout -rw-r--r--packages.scm58680logplainabout -rw-r--r--pki.scm5220logplainabout -rw-r--r--print.scm2561logplainabout -rw-r--r--processes.scm4691logplainabout -rw-r--r--profiles.scm28633logplainabout -rw-r--r--publish.scm25948logplainabout -rw-r--r--pypi.scm13645logplainabout -rw-r--r--records.scm15123logplainabout -rw-r--r--scripts-build.scm12015logplainabout -rw-r--r--scripts.scm2034logplainabout -rw-r--r--search-paths.scm1768logplainabout -rw-r--r--services.scm11536logplainabout -rw-r--r--sets.scm1507logplainabout -rw-r--r--signing-key.pub302logplainabout -rw-r--r--signing-key.sec983logplainabout -rw-r--r--size.scm4576logplainabout -rw-r--r--snix.scm2504logplainabout -rw-r--r--status.scm12235logplainabout -rw-r--r--store-database.scm3718logplainabout -rw-r--r--store-deduplication.scm4533logplainabout -rw-r--r--store-roots.scm1899logplainabout -rw-r--r--store.scm50694logplainabout -rw-r--r--substitute.scm21770logplainabout -rw-r--r--swh.scm3834logplainabout -rw-r--r--syscalls.scm19724logplainabout -rw-r--r--system.scm5143logplainabout -rw-r--r--test.drv5922logplainabout -rw-r--r--texlive.scm4493logplainabout -rw-r--r--ui.scm8859logplainabout -rw-r--r--union.scm9714logplainabout -rw-r--r--upstream.scm1963logplainabout -rw-r--r--utils.scm9783logplainabout -rw-r--r--uuid.scm2755logplainabout -rw-r--r--workers.scm2172logplainabout -rw-r--r--zlib.scm2237logplainabout