1 commit 2f6b86835cbbad530f838bcf5d3e183f92eb3396
2 Author: Marcin Banasiak <marcin.banasiak@gmail.com>
3 Date: Thu Sep 27 17:44:19 2012 +0200
5 Change the way how / is stored in dirindex
7 Previously, / was stored in dirindex with leading slash (i.e. as //)
8 what caused various side effects as:
10 filesystem-4.0-12.x86_64 obsoleted by filesystem-4.0-13.x86_64
11 filesystem-4.0-13.x86_64 marks FHS-2.3-35.x86_64 (cap //)
12 error: FHS-2.3-35.x86_64: equal version installed, give up
14 diff --git a/pkgdir/pkgdir_dirindex.c b/pkgdir/pkgdir_dirindex.c
15 index a6f422f..abfd05c 100644
16 --- a/pkgdir/pkgdir_dirindex.c
17 +++ b/pkgdir/pkgdir_dirindex.c
18 @@ -103,10 +103,14 @@ static int package_key(char *key, int size, const struct pkg *pkg, int prefix)
19 static tn_buf *dirarray_join(tn_buf *nbuf, tn_array *arr, char *sep)
21 int i, size = n_array_size(arr);
23 for (i=0; i < size; i++) {
24 - n_buf_printf(nbuf, "%s%s", (char*)n_array_nth(arr, i),
25 - i < size - 1 ? sep : "");
26 + const char *dirname = n_array_nth(arr, i);
28 + n_buf_printf(nbuf, "%s%s%s", *dirname != '/' ? "/" : "",
29 + dirname, i < size - 1 ? sep : "");
35 @@ -179,7 +183,8 @@ static int store_from_previous(uint32_t package_no, struct pkg *pkg, struct tndb
38 const char *dir = *tl;
39 - dir = dir + 1; /* skip '/' */
41 + dir = dir + 1; /* skip '/' only when strlen(dir) > 1 */
42 add_to_path_index(path_index, dir, package_no);
45 @@ -238,15 +243,13 @@ void store_package(uint32_t package_no, struct pkg *pkg, struct tndb *db,
49 - n_buf_printf(nbuf, "/"); /* prefix all by '/' */
50 - nbuf = dirarray_join(nbuf, required, ":/");
51 + nbuf = dirarray_join(nbuf, required, ":");
52 tndb_put(db, key, klen, n_buf_ptr(nbuf), n_buf_size(nbuf));
57 - n_buf_printf(nbuf, "/"); /* prefix all by '/' */
58 - nbuf = dirarray_join(nbuf, owned, ":/");
59 + nbuf = dirarray_join(nbuf, owned, ":");
61 /* ugly, but what for another package_key() call */
62 key[1] = PREFIX_PKGKEY_OWNDIR;
63 @@ -323,9 +326,13 @@ static int dirindex_create(const struct pkgdir *pkgdir, const char *path,
64 for (i=0; i < n_array_size(directories); i++) {
65 const char *path = n_array_nth(directories, i);
66 tn_array *ids = n_hash_get(path_index, path);
70 - nbuf = dirarray_join(nbuf, ids, ":");
71 + for (j = 0; j < n_array_size(ids); j++) {
72 + n_buf_printf(nbuf, "%s%s", (char *)n_array_nth(ids, j),
73 + j < n_array_size(ids) - 1 ? ":" : "");
76 DBGF(" dir %s %s\n", path, (char*)n_buf_ptr(nbuf));
78 @@ -774,11 +781,11 @@ tn_array *get_package_directories_as_array(const struct pkgdir *pkgdir,
80 dirs = n_array_new(n, free, (tn_fn_cmp)strcmp);
84 n_array_push(dirs, n_strdup(*tl));
89 n_str_tokl_free(tl_save);
92 @@ -809,7 +816,7 @@ static tn_array *do_dirindex_get(const struct pkgdir_dirindex *dirindex,
93 unsigned char val[8192];
94 int n, found, pkgs_passsed = 1;
97 + if (*path == '/' && path[1] != '\0')
100 if (!tndb_get_str(dirindex->db, path, val, sizeof(val)))
101 @@ -877,7 +884,7 @@ int pkgdir_dirindex_pkg_has_path(const struct pkgdir *pkgdir,
103 DBGF("%s %s\n", pkg_id(pkg), path);
106 + if (*path == '/' && path[1] != '\0')
109 if (!tndb_get_str(dirindex->db, path, val, sizeof(val)))
110 commit f575c9bbe3cdd8f2d6ef27eb73dcc270c1a8a3f2
111 Author: Marcin Banasiak <marcin.banasiak@gmail.com>
112 Date: Sun Oct 7 12:41:42 2012 +0200
114 Provide function body for inlined pkg_id
116 diff --git a/pkg.c b/pkg.c
117 index 6e83694..227fe14 100644
120 @@ -1463,11 +1463,6 @@ struct pkg *pkg_link(struct pkg *pkg)
124 -const char *pkg_id(const struct pkg *p)
129 int pkg_id_snprintf(char *str, size_t size, const struct pkg *pkg)
131 return n_snprintf(str, size, "%s", pkg_id(pkg));
132 diff --git a/pkg.h b/pkg.h
133 index f0d71ac..ec6cc6d 100644
136 @@ -231,7 +231,11 @@ EXPORT const char *pkg_pkgdirpath(const struct pkg *pkg);
137 EXPORT unsigned pkg_file_url_type(const struct pkg *pkg);
140 -EXPORT extern__inline const char *pkg_id(const struct pkg *p);
141 +static inline const char *pkg_id(const struct pkg *p)
146 EXPORT int pkg_id_snprintf(char *str, size_t size, const struct pkg *pkg);
147 EXPORT int pkg_idevr_snprintf(char *str, size_t size, const struct pkg *pkg);
149 commit ce00c5a5311fb6d77fcf96b04bca5cf2904d90ae
150 Author: Marcin Banasiak <marcin.banasiak@gmail.com>
151 Date: Sun Oct 7 12:46:36 2012 +0200
153 Kill redundant EXPORT in pm.h
155 diff --git a/pm/pm.h b/pm/pm.h
156 index 9913168..a20c305 100644
159 @@ -204,7 +204,7 @@ EXPORT int pm_get_dbdepdirs(struct pm_ctx *ctx,
161 EXPORT struct pkg *pm_load_package(struct pm_ctx *ctx,
162 tn_alloc *na, const char *path, unsigned ldflags);
163 -EXPORT struct pkgdir;
165 EXPORT struct pkgdir *pkgdb_to_pkgdir(struct pm_ctx *ctx, const char *rootdir,
166 const char *path, unsigned pkgdir_ldflags,
167 const char *key, ...);