On 16.12.2015 03:32, Colin Walters wrote:
> On Tue, Dec 15, 2015, at 06:43 PM, Japheth Cleaver wrote:
>>
>> Perhaps RPM (or yum/dnf, via plugin) could write a duplicate copy of all
>> config files into a tree somewhere? (E.g., /usr/lib/config/ or
>> /usr/share/config/?)
>
> I mentioned this above, but might as well repeat since it was missed; OSTree
> (as used by the existing Fedora Atomic Host) does this by default today in
> /usr/etc, so if one was adapting this change to the client-side system
> assembly
> tools like yum/dnf, I'd say it would make sense to follow the precedent.
>
>
I already experimented with /usr/share/factory/{etc,var} , but /usr/etc sounds
fine to me, too.
Additionally I would like to have that in the rpm package itsself, not with
some plugin on installation, because "rpm -qf" should output to which package
the file in /usr/etc belongs. Also the %config(noreplace) attribute has to be
removed from the pristine config files.
Attached is a quick hack to rpm I have done for experimenting with that feature.
From 1eb125dd814a08b0a8bfd5e4ab95d38525caf5d3 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <[email protected]>
Date: Thu, 12 Jun 2014 18:31:16 +0200
Subject: [PATCH] Quick hack to place all /etc files also in
/usr/share/factory/etc
---
build/Makefile.am | 2 +-
build/files.c | 112 +++++++++++++++++++++++++++++++++++-------------------
build/rpmfc.c | 6 ++-
3 files changed, 77 insertions(+), 43 deletions(-)
diff --git a/build/Makefile.am b/build/Makefile.am
index 1a540bc..5d75ef2 100644
--- a/build/Makefile.am
+++ b/build/Makefile.am
@@ -16,7 +16,7 @@ librpmbuild_la_SOURCES = \
parsePolicies.c policies.c \
rpmbuild_internal.h rpmbuild_misc.h
-librpmbuild_la_LDFLAGS = -version-info 4:0:1
+librpmbuild_la_LDFLAGS = -version-info 6:0:3
librpmbuild_la_LIBADD = \
$(top_builddir)/lib/librpm.la \
$(top_builddir)/rpmio/librpmio.la \
diff --git a/build/files.c b/build/files.c
index 07a6847..f823f79 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1188,6 +1188,69 @@ static struct stat * fakeStat(FileEntry cur, struct stat * statp)
return statp;
}
+static rpmRC add_to_file_list(FileList fl,
+ const char* diskPath,
+ const char *cpioPath,
+ mode_t fileMode,
+ const char *fileUname,
+ const char *fileGname,
+ uid_t fileUid,
+ gid_t fileGid,
+ struct stat* statp,
+ int clone
+ )
+{
+ if (fl->files.used == fl->files.alloced) {
+ fl->files.alloced += 128;
+ fl->files.recs = xrealloc(fl->files.recs,
+ fl->files.alloced * sizeof(*(fl->files.recs)));
+ }
+
+ { FileListRec flp = &fl->files.recs[fl->files.used];
+
+ flp->fl_st = *statp; /* structure assignment */
+ flp->fl_mode = fileMode;
+ flp->fl_uid = fileUid;
+ flp->fl_gid = fileGid;
+
+ flp->cpioPath = xstrdup(cpioPath);
+ flp->diskPath = xstrdup(diskPath);
+ flp->uname = rpmstrPoolId(fl->pool, fileUname, 1);
+ flp->gname = rpmstrPoolId(fl->pool, fileGname, 1);
+
+ if (fl->cur.langs) {
+ flp->langs = argvJoin(fl->cur.langs, "|");
+ } else {
+ flp->langs = xstrdup("");
+ }
+
+ if (fl->cur.caps) {
+ flp->caps = xstrdup(fl->cur.caps);
+ } else {
+ flp->caps = xstrdup("");
+ }
+
+ flp->flags = fl->cur.attrFlags;
+ flp->specdFlags = fl->cur.specdFlags;
+ flp->verifyFlags = fl->cur.verifyFlags;
+
+ if (clone) {
+ flp->flags &= ~(RPMFILE_MISSINGOK|RPMFILE_CONFIG|RPMFILE_NOREPLACE);
+ flp->specdFlags |= SPECD_VERIFY;
+ flp->verifyFlags = RPMVERIFY_ALL;
+ }
+
+ if (!(flp->flags & RPMFILE_EXCLUDE) && S_ISREG(flp->fl_mode)) {
+ if (flp->fl_size >= UINT32_MAX) {
+ fl->largeFiles = 1;
+ }
+ }
+ }
+
+ fl->files.used++;
+ return RPMRC_OK;
+}
+
/**
* Add a file to the package manifest.
* @param fl package file tree walk data
@@ -1333,49 +1396,18 @@ static rpmRC addFile(FileList fl, const char * diskPath,
}
/* Add to the file list */
- if (fl->files.used == fl->files.alloced) {
- fl->files.alloced += 128;
- fl->files.recs = xrealloc(fl->files.recs,
- fl->files.alloced * sizeof(*(fl->files.recs)));
- }
-
- { FileListRec flp = &fl->files.recs[fl->files.used];
-
- flp->fl_st = *statp; /* structure assignment */
- flp->fl_mode = fileMode;
- flp->fl_uid = fileUid;
- flp->fl_gid = fileGid;
+ rc = add_to_file_list(fl, diskPath, cpioPath, fileMode, fileUname, fileGname,
+ fileUid, fileGid, statp, 0);
- flp->cpioPath = xstrdup(cpioPath);
- flp->diskPath = xstrdup(diskPath);
- flp->uname = rpmstrPoolId(fl->pool, fileUname, 1);
- flp->gname = rpmstrPoolId(fl->pool, fileGname, 1);
-
- if (fl->cur.langs) {
- flp->langs = argvJoin(fl->cur.langs, "|");
- } else {
- flp->langs = xstrdup("");
- }
-
- if (fl->cur.caps) {
- flp->caps = xstrdup(fl->cur.caps);
- } else {
- flp->caps = xstrdup("");
- }
-
- flp->flags = fl->cur.attrFlags;
- flp->specdFlags = fl->cur.specdFlags;
- flp->verifyFlags = fl->cur.verifyFlags;
-
- if (!(flp->flags & RPMFILE_EXCLUDE) && S_ISREG(flp->fl_mode)) {
- if (flp->fl_size >= UINT32_MAX) {
- fl->largeFiles = 1;
- }
- }
+ if (strncmp(cpioPath, "/etc", 4) == 0) {
+ char *buf = NULL;
+ if (asprintf(&buf, "/usr/share/factory%s", cpioPath) != -1) {
+ add_to_file_list(fl, diskPath, buf, fileMode, fileUname, fileGname,
+ fileUid, fileGid, statp, 1);
+ free(buf);
+ }
}
- rc = RPMRC_OK;
- fl->files.used++;
exit:
if (rc != RPMRC_OK)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 403af40..0b77de2 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1003,8 +1003,10 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
case S_IFLNK:
case S_IFREG:
default:
- /* XXX all files with extension ".pm" are perl modules for now. */
- if (rpmFileHasSuffix(s, ".pm"))
+ if (slen >= fc->brlen+sizeof("/usr/share/factory/etc/") && rstreqn(s+fc->brlen, "/usr/share/factory/etc/", sizeof("/usr/share/factory/etc/")-1))
+ ftype = "";
+ /* XXX all files with extension ".pm" are perl modules for now. */
+ else if (rpmFileHasSuffix(s, ".pm"))
ftype = "Perl5 module source text";
/* XXX all files with extension ".la" are libtool for now. */
--
2.6.4
--
devel mailing list
[email protected]
http://lists.fedoraproject.org/admin/lists/[email protected]