1 From f66af6b6ddfefcbd6ecd6f4d47e0fa4ca231b125 Mon Sep 17 00:00:00 2001
2 From: "Richard W.M. Jones" <rjones@redhat.com>
3 Date: Tue, 23 Mar 2021 14:06:12 +0000
4 Subject: [PATCH 5/7] builder: Get rid of /etc/xdg and XDG_CONFIG_DIRS
7 Put the configuration in /etc/virt-builder as god intended.
9 builder/Makefile.am | 8 ++------
10 builder/libguestfs.conf.in | 4 ++--
11 builder/opensuse.conf.in | 2 +-
12 builder/paths.ml | 4 ++--
13 builder/paths.mli | 4 ++--
14 builder/test-virt-builder-cacheall.sh | 2 +-
15 builder/test-virt-builder-list-simplestreams.sh | 2 +-
16 builder/test-virt-builder-list.sh | 2 +-
17 builder/test-virt-builder-planner.sh | 2 +-
18 builder/test-virt-builder.sh | 2 +-
19 builder/virt-builder.pod | 8 ++++----
21 12 files changed, 21 insertions(+), 25 deletions(-)
23 diff --git a/builder/Makefile.am b/builder/Makefile.am
24 index d67c8e0ded..4d2e07843c 100644
25 --- a/builder/Makefile.am
26 +++ b/builder/Makefile.am
27 @@ -423,12 +423,8 @@ endif
29 # virt-builder's default repository
31 -repoconfdir = $(sysconfdir)/xdg/virt-builder/repos.d
32 -repoconf_DATA = libguestfs.conf libguestfs.gpg \
33 - opensuse.conf opensuse.gpg
36 - $(LN_S) -f xdg/virt-builder $(DESTDIR)$(sysconfdir)/virt-builder
37 +repoconfdir = $(sysconfdir)/virt-builder/repos.d
38 +repoconf_DATA = libguestfs.conf libguestfs.gpg opensuse.conf opensuse.gpg
40 # Build a small C index validator program.
41 bin_PROGRAMS += virt-index-validate
42 diff --git a/builder/libguestfs.conf.in b/builder/libguestfs.conf.in
43 index 412079df64..8d8feab756 100644
44 --- a/builder/libguestfs.conf.in
45 +++ b/builder/libguestfs.conf.in
48 uri=http://builder.libguestfs.org/index.asc
49 -gpgkey=file://@SYSCONFDIR@/xdg/virt-builder/repos.d/libguestfs.gpg
50 +gpgkey=file://@SYSCONFDIR@/virt-builder/repos.d/libguestfs.gpg
52 [archive.libguestfs.org]
53 uri=http://archive.libguestfs.org/builder/index.asc
54 -gpgkey=file://@SYSCONFDIR@/xdg/virt-builder/repos.d/libguestfs.gpg
55 +gpgkey=file://@SYSCONFDIR@/virt-builder/repos.d/libguestfs.gpg
56 diff --git a/builder/opensuse.conf.in b/builder/opensuse.conf.in
57 index 80db267113..19f9796992 100644
58 --- a/builder/opensuse.conf.in
59 +++ b/builder/opensuse.conf.in
62 uri=http://download.opensuse.org/repositories/Virtualization:/virt-builder-images/images/index
63 -gpgkey=file://@SYSCONFDIR@/xdg/virt-builder/repos.d/opensuse.gpg
64 +gpgkey=file://@SYSCONFDIR@/virt-builder/repos.d/opensuse.gpg
65 diff --git a/builder/paths.ml b/builder/paths.ml
66 index b8ce57191e..a7b1f4cc63 100644
67 --- a/builder/paths.ml
68 +++ b/builder/paths.ml
69 @@ -35,8 +35,8 @@ let xdg_config_home () =
71 let xdg_config_dirs () =
73 - try Sys.getenv "XDG_CONFIG_DIRS"
74 - with Not_found -> "/etc/xdg" in
75 + try Sys.getenv "VIRT_BUILDER_DIRS"
76 + with Not_found -> "/etc" in
77 let dirs = String.nsplit ":" dirs in
78 let dirs = List.filter (fun x -> x <> "") dirs in
79 List.map (fun x -> x // prog) dirs
80 diff --git a/builder/paths.mli b/builder/paths.mli
81 index 566c323e57..f4897da952 100644
82 --- a/builder/paths.mli
83 +++ b/builder/paths.mli
84 @@ -23,6 +23,6 @@ val xdg_config_home : unit -> string option
85 (** [$XDG_CONFIG_HOME/prog] or [$HOME/.config/prog] or [None]. *)
87 val xdg_config_dirs : unit -> string list
88 -(** [$XDG_CONFIG_DIRS] (which is a colon-separated path), split. Empty
89 +(** [$VIRT_BUILDER_DIRS] (which is a colon-separated path), split. Empty
90 elements are removed from the list. If the environment variable
91 - is not set [["/etc/xdg"]] is returned instead. *)
92 + is not set [["/etc/virt-builder"]] is returned instead. *)
93 diff --git a/builder/test-virt-builder-cacheall.sh b/builder/test-virt-builder-cacheall.sh
94 index c80d9ecd2a..26298228a0 100755
95 --- a/builder/test-virt-builder-cacheall.sh
96 +++ b/builder/test-virt-builder-cacheall.sh
97 @@ -68,7 +68,7 @@ uri=$indexfile
100 export XDG_CONFIG_HOME=
101 -export XDG_CONFIG_DIRS="$tmpdir"
102 +export VIRT_BUILDER_DIRS="$tmpdir"
103 export XDG_CACHE_HOME="$cachedir"
105 short_list=$($VG virt-builder --no-check-signature --no-cache --list)
106 diff --git a/builder/test-virt-builder-list-simplestreams.sh b/builder/test-virt-builder-list-simplestreams.sh
107 index 3158066b16..4467971a90 100755
108 --- a/builder/test-virt-builder-list-simplestreams.sh
109 +++ b/builder/test-virt-builder-list-simplestreams.sh
110 @@ -22,7 +22,7 @@ $TEST_FUNCTIONS
113 export XDG_CONFIG_HOME=
114 -export XDG_CONFIG_DIRS="$abs_builddir/test-simplestreams"
115 +export VIRT_BUILDER_DIRS="$abs_builddir/test-simplestreams"
117 short_list=$($VG virt-builder --no-check-signature --no-cache --list)
119 diff --git a/builder/test-virt-builder-list.sh b/builder/test-virt-builder-list.sh
120 index 66910fcc3d..a66c1b5d0f 100755
121 --- a/builder/test-virt-builder-list.sh
122 +++ b/builder/test-virt-builder-list.sh
123 @@ -24,7 +24,7 @@ $TEST_FUNCTIONS
126 export XDG_CONFIG_HOME=
127 -export XDG_CONFIG_DIRS="$abs_builddir/test-config"
128 +export VIRT_BUILDER_DIRS="$abs_builddir/test-config"
130 short_list=$($VG virt-builder --no-check-signature --no-cache --list)
132 diff --git a/builder/test-virt-builder-planner.sh b/builder/test-virt-builder-planner.sh
133 index 108b70e95f..135319398c 100755
134 --- a/builder/test-virt-builder-planner.sh
135 +++ b/builder/test-virt-builder-planner.sh
136 @@ -24,7 +24,7 @@ skip_if_skipped
139 export XDG_CONFIG_HOME=
140 -export XDG_CONFIG_DIRS="$abs_builddir/test-config"
141 +export VIRT_BUILDER_DIRS="$abs_builddir/test-config"
143 if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then
144 echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or fedora.qcow2.xz in the build directory"
145 diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh
146 index 18673874a3..fe06071370 100755
147 --- a/builder/test-virt-builder.sh
148 +++ b/builder/test-virt-builder.sh
149 @@ -22,7 +22,7 @@ $TEST_FUNCTIONS
152 export XDG_CONFIG_HOME=
153 -export XDG_CONFIG_DIRS="$abs_builddir/test-config"
154 +export VIRT_BUILDER_DIRS="$abs_builddir/test-config"
156 if [ ! -f fedora.xz ]; then
157 echo "$0: test skipped because there is no fedora.xz in the build directory"
158 diff --git a/builder/virt-builder.pod b/builder/virt-builder.pod
159 index eddadc7962..a56fa89cb1 100644
160 --- a/builder/virt-builder.pod
161 +++ b/builder/virt-builder.pod
162 @@ -1146,9 +1146,9 @@ F<$HOME/.config> if not set).
166 -$XDG_CONFIG_DIRS/virt-builder/repos.d/ (where C<$XDG_CONFIG_DIRS>
167 -means any of the directories in that environment variable, or just F</etc/xdg>
169 +$VIRT_BUILDER_DIRS/virt-builder/repos.d/ (where C<$VIRT_BUILDER_DIRS>
170 +means any of the directories in that environment variable, or just F</etc>
175 @@ -1866,7 +1866,7 @@ Used to determine the location of the template cache. See L</CACHING>.
176 Used to determine the location of the user' sources. See
177 L</SOURCES OF TEMPLATES>.
179 -=item C<XDG_CONFIG_DIRS>
180 +=item C<VIRT_BUILDER_DIRS>
182 Used to determine the location of the system sources. See
183 L</SOURCES OF TEMPLATES>.
184 diff --git a/run.in b/run.in
185 index 5e36aa819b..7b401870d5 100755
188 @@ -95,9 +95,9 @@ export PATH
190 # Make virt-builder use the local website copy to avoid hitting
191 # the network all the time.
192 -if [ -z "$XDG_CONFIG_DIRS" ]; then
193 - prepend XDG_CONFIG_DIRS "$b/builder/test-website"
194 - export XDG_CONFIG_DIRS
195 +if [ -z "$VIRT_BUILDER_DIRS" ]; then
196 + prepend VIRT_BUILDER_DIRS "$b/builder/test-website"
197 + export VIRT_BUILDER_DIRS
200 # This is a cheap way to find some use-after-free and uninitialized