LOG Merge --printspec and %rename improvements from OMV

This commit is contained in:
Denis Silakov 2013-07-25 14:38:56 +04:00
parent e1c1811f65
commit f538f75b6e
3 changed files with 137 additions and 1 deletions

View file

@ -0,0 +1,13 @@
--- rpm-5.4.10/macros/mandriva.in.rename~ 2013-02-24 23:17:05.947081929 +0100
+++ rpm-5.4.10/macros/mandriva.in 2013-02-25 00:33:33.342514014 +0100
@@ -47,8 +47,8 @@
%EVRD %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}}%{?distepoch::%{distepoch}}
%rename() \
-Obsoletes: %{1} < %{EVRD} \
-Provides: %{1} = %{EVRD}
+Obsoletes: %{1} < %{?2}%{!?2:%{EVRD}} \
+Provides: %{1} = %{?2}%{!?2:%{EVRD}}
%_default_patch_flags -s -U

114
rpm-5.4.10-printspec.patch Normal file
View file

@ -0,0 +1,114 @@
--- rpm-5.4.10/build/spec.c.printspec~ 2013-01-23 01:04:32.483889763 +0100
+++ rpm-5.4.10/build/spec.c 2013-01-23 01:12:59.970655457 +0100
@@ -27,6 +27,10 @@ int _spec_debug;
/*@-redecl@*/
extern int specedit;
+
+/*@-redecl@*/
+extern int printspec;
+
/*@=redecl@*/
#define SKIPWHITE(_x) {while(*(_x) && (xisspace(*_x) || *(_x) == ',')) (_x)++;}
@@ -489,7 +493,7 @@ static inline /*@only@*/ /*@null@*/ spec
/*@*/
{
speclines sl = NULL;
- if (specedit) {
+ if (specedit || printspec) {
sl = xmalloc(sizeof(*sl));
sl->sl_lines = NULL;
sl->sl_nalloc = 0;
@@ -836,6 +840,34 @@ printNewSpecfile(Spec spec)
}
/**
+ * Print parsed copy of spec file with expanded macros.
+ * @param spec spec file control structure
+ */
+static void
+printParsedSpecfile(Spec spec)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies spec->sl->sl_lines[], spec->packages->header,
+ fileSystem, internalState @*/
+{
+ speclines sl = spec->sl;
+ int i;
+
+ if (sl == NULL)
+ return;
+
+ for (i = 0; i < sl->sl_nlines; i++) {
+ const char * s = sl->sl_lines[i];
+ const char * expandedLine;
+ if (s == NULL)
+ continue;
+ expandedLine = rpmMCExpand(spec->macros, s, NULL);
+ printf("%s", expandedLine);
+ _free(expandedLine);
+ if (strchr(s, '\n') == NULL && s[strlen(s)-1] != '\n')
+ printf("\n");
+ }
+}
+/**
* Add expanded build scriptlet to srpm header.
* @param h srpm header
* @param progTag interpreter tag (0 disables)
@@ -939,6 +971,11 @@ static int _specQuery(rpmts ts, QVA_t qv
goto exit;
}
+ if (printspec) {
+ printParsedSpecfile(spec);
+ goto exit;
+ }
+
switch (qva->qva_source) {
case RPMQV_SPECSRPM:
xx = initSourceHeader(spec, NULL);
--- rpm-5.4.10/lib/librpm.vers.printspec~ 2013-01-23 01:09:47.257299567 +0100
+++ rpm-5.4.10/lib/librpm.vers 2013-01-23 01:10:48.125643410 +0100
@@ -37,6 +37,7 @@ LIBRPM_0
_nosigh;
nplatpat;
platpat;
+ printspec;
_print_pkts;
_psm_debug;
_psm_threads;
--- rpm-5.4.10/lib/poptQV.c.printspec~ 2013-01-23 01:04:46.489658974 +0100
+++ rpm-5.4.10/lib/poptQV.c 2013-01-23 01:07:29.416493474 +0100
@@ -21,6 +21,9 @@ struct rpmQVKArguments_s rpmQVKArgs;
/*@unchecked@*/
int specedit = 0;
+/*@unchecked@*/
+int printspec = 0;
+
#define POPT_QUERYFORMAT -1000
#define POPT_WHATREQUIRES -1001
#define POPT_WHATPROVIDES -1002
@@ -363,6 +366,8 @@ struct poptOption rpmQueryPoptTable[] =
N_("skip %%readme files"), NULL },
#endif
+ { "printspec", '\0', POPT_ARG_VAL, &printspec, -1,
+ N_("print parsed spec file"), NULL },
{ "qf", '\0', POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN, 0,
POPT_QUERYFORMAT, NULL, NULL },
{ "queryformat", '\0', POPT_ARG_STRING, 0, POPT_QUERYFORMAT,
--- rpm-5.4.10/lib/rpmcli.h.printspec~ 2013-01-23 01:04:53.165920321 +0100
+++ rpm-5.4.10/lib/rpmcli.h 2013-01-23 01:05:20.375518501 +0100
@@ -293,6 +293,11 @@ extern int specedit;
/** \ingroup rpmcli
*/
/*@unchecked@*/
+extern int printspec;
+
+/** \ingroup rpmcli
+ */
+/*@unchecked@*/
extern struct poptOption rpmQueryPoptTable[];
/** \ingroup rpmcli

View file

@ -59,7 +59,7 @@ Summary: The RPM package management system
Name: rpm Name: rpm
Epoch: 1 Epoch: 1
Version: %{libver}.%{minorver} Version: %{libver}.%{minorver}
Release: %{?prereldate:0.%{prereldate}.}12 Release: %{?prereldate:0.%{prereldate}.}13
License: LGPLv2.1+ License: LGPLv2.1+
Group: System/Configuration/Packaging Group: System/Configuration/Packaging
URL: http://rpm5.org/ URL: http://rpm5.org/
@ -364,6 +364,12 @@ Patch170: rpm-5.4.10-dbconvert-5.2.patch
# Do not generate pythonegg provides for python3 until we find a better solution # Do not generate pythonegg provides for python3 until we find a better solution
Patch171: rpm-5.4.10-python3-egg-reqs.patch Patch171: rpm-5.4.10-python3-egg-reqs.patch
# adds ability for printing parsed version of spec file with 'rpm -q --specfile --printspec'
# status: very simple, non-intrusive, while quite convenient, should be okay to merge
Patch181: rpm-5.4.10-printspec.patch
Patch191: rpm-5.4.10-enhance-rename-macro-to-accept-optional-second-version-arg.patch
# ROSA stuff # ROSA stuff
Patch501: rpm-5.3.12.vendor.ROSA.patch Patch501: rpm-5.3.12.vendor.ROSA.patch
# Restore RPM_PACKAGE_NAME export as it's still used by aot-compile-rpm # Restore RPM_PACKAGE_NAME export as it's still used by aot-compile-rpm
@ -738,6 +744,9 @@ This package contains the RPM API documentation generated in HTML format.
%patch170 -p1 -b .dbconvert52~ %patch170 -p1 -b .dbconvert52~
%patch171 -p1 -b .python3~ %patch171 -p1 -b .python3~
%patch181 -p1 -b .printspec~
%patch191 -p1 -b .rename~
%patch501 -p1 -b .rosa_vendor~ %patch501 -p1 -b .rosa_vendor~
%patch502 -p1 -b .package_name~ %patch502 -p1 -b .package_name~
%patch503 -p1 -b .specspo~ %patch503 -p1 -b .specspo~