createrepo_c library 1.2.1 C library for metadata manipulation

koji.h
1 /*
2 * Copyright (C) 2018 Red Hat, Inc.
3 *
4 * Licensed under the GNU Lesser General Public License Version 2.1
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef __C_CREATEREPOLIB_KOJI_H__
22 #define __C_CREATEREPOLIB_KOJI_H__
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #include "package.h"
29 #include "mergerepo_c.h"
30
31 // struct KojiMergedReposStuff
32 // contains information needed to simulate sort_and_filter() method from
33 // mergerepos script from Koji.
34 //
35 // sort_and_filter() method description:
36 // ------------------------------------
37 // For each package object, check if the srpm name has ever been seen before.
38 // If is has not, keep the package. If it has, check if the srpm name was first
39 // seen in the same repo as the current package. If so, keep the package from
40 // the srpm with the highest NVR. If not, keep the packages from the first
41 // srpm we found, and delete packages from all other srpms.
42 //
43 // Packages with matching NVRs in multiple repos will be taken from the first
44 // repo.
45 //
46 // If the srpm name appears in the blocked package list, any packages generated
47 // from the srpm will be deleted from the package sack as well.
48 //
49 // This method will also generate a file called "pkgorigins" and add it to the
50 // repo metadata. This is a tab-separated map of package E:N-V-R.A to repo URL
51 // (as specified on the command-line). This allows a package to be tracked back
52 // to its origin, even if the location field in the repodata does not match the
53 // original repo location.
54
55 struct srpm_val {
56 int repo_id; // id of repository
57 char *sourcerpm; // pkg->rpm_sourcerpm
58 };
59
60 struct KojiMergedReposStuff {
61 GHashTable *blocked_srpms;
62 // blocked_srpms:
63 // Names of sprms which will be skipped
64 // Key: srpm name
65 // Value: NULL (not important)
66 GHashTable *include_srpms;
67 // include_srpms:
68 // Only packages from srpms included in this table will be included
69 // in output merged metadata.
70 // Key: srpm name
71 // Value: struct srpm_val
72 GHashTable *seen_rpms;
73 // seen_rpms:
74 // List of packages already included into the output metadata.
75 // Purpose of this list is to avoid a duplicit packages in output.
76 // Key: string with package n-v-r.a
77 // Value: NULL (not important)
78 CR_FILE *pkgorigins;
79 // Every element has format: pkg_nvra\trepourl
80 gboolean simple;
81 };
82
83 /* Limited version of koji_stuff_prepare() that sets up only pkgorigins */
84 int
85 pkgorigins_prepare(struct KojiMergedReposStuff **koji_stuff_ptr,
86 const gchar *tmpdir);
87
88 int
89 koji_stuff_prepare(struct KojiMergedReposStuff **koji_stuff_ptr,
90 struct CmdOptions *cmd_options,
91 GSList *repos);
92
93 void
94 koji_stuff_destroy(struct KojiMergedReposStuff **koji_stuff_ptr);
95
96 void
97 cr_srpm_val_destroy(gpointer data);
98
99 gboolean
100 koji_allowed(cr_Package *pkg, struct KojiMergedReposStuff *koji_stuff);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* __C_CREATEREPOLIB_KOJI_H__ */
CR_FILE
Definition: compression_wrapper.h:84
CmdOptions
Definition: mergerepo_c.h:43
srpm_val
Definition: koji.h:55
KojiMergedReposStuff
Definition: koji.h:60
cr_Package
Definition: package.h:84