[gnome-ostree] build: Write out stub passwd/group files so that getpwuid() works
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree] build: Write out stub passwd/group files so that getpwuid() works
- Date: Wed, 5 Dec 2012 14:38:29 +0000 (UTC)
commit da7020bdba17d77686cf1cdb616dc46160696bc3
Author: Colin Walters <walters verbum org>
Date: Wed Dec 5 08:52:19 2012 -0500
build: Write out stub passwd/group files so that getpwuid() works
Some bits of (broken) software attempt to look up the build user. For
example, ibus presently runs dbus-launch to then invoke gsettings so
it can generate a text file. dbus errors out when it's not able to
find its uid, of course.
We can help these bits of software along by generating an /etc/passwd
in the build environment that "works".
src/ostbuild/pyostbuild/builtin_build.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
index ae62924..e86f40c 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -115,6 +115,11 @@ class OstbuildBuild(builtins.Builtin):
sha = hashlib.sha256()
+ uid = os.getuid()
+ gid = os.getgid()
+ etc_passwd = 'root:x:0:0:root:/root:/bin/bash\nbuilduser:x:%u:%u:builduser:/:/bin/bash\n' % (uid, gid)
+ etc_group = 'root:x:0:root\nbuilduser:x:%u:builduser\n' % (gid, )
+
(fd, tmppath) = tempfile.mkstemp(suffix='.txt', prefix='ostbuild-buildroot-')
f = os.fdopen(fd, 'w')
for (branch, subpath) in checkout_trees:
@@ -131,6 +136,9 @@ class OstbuildBuild(builtins.Builtin):
buf = f.read(8192)
f.close()
+ sha.update(etc_passwd)
+ sha.update(etc_group)
+
new_root_cacheid = sha.hexdigest()
cached_root = os.path.join(buildroot_cachedir, new_root_cacheid)
@@ -156,6 +164,12 @@ class OstbuildBuild(builtins.Builtin):
builddir_tmp = os.path.join(cached_root_tmp, 'ostbuild')
fileutil.ensure_dir(os.path.join(builddir_tmp, 'source', component_name))
fileutil.ensure_dir(os.path.join(builddir_tmp, 'results'))
+ f = open(os.path.join(cached_root_tmp, 'etc', 'passwd'), 'w')
+ f.write(etc_passwd)
+ f.close()
+ f = open(os.path.join(cached_root_tmp, 'etc', 'group'), 'w')
+ f.write(etc_group)
+ f.close()
os.rename(cached_root_tmp, cached_root)
self._clean_stale_buildroots(buildroot_cachedir, os.path.basename(cached_root))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]