Skip to content

Commit e5b77bd

Browse files
authored
Merge pull request #4233 from masatake/rpmspec--minor
RpmSpec: don't make a FQ tag for sub-packages if -n option is specified on %package line
2 parents 45426f5 + fa383bc commit e5b77bd

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

Units/parser-rpmspec.r/simple-rpmspec.d/expected.tags

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ install_post input.spec /^%define install_post \\$/;" kind:macro line:31 roles:d
2020
docs input.spec /^%package docs$/;" kind:package line:40 package:ctags roles:def
2121
ctags-docs input.spec /^%package docs$/;" kind:package line:40 package:ctags roles:def
2222
universal-ctags-devel input.spec /^%package -n universal-ctags-devel$/;" kind:package line:44 package:ctags roles:def
23-
ctags-universal-ctags-devel input.spec /^%package -n universal-ctags-devel$/;" kind:package line:44 package:ctags roles:def
2423
libxml input.spec /^%configure --with-libxml=%{YES} --with-libyml=%{YES}\\$/;" kind:optwith line:52 roles:cmdline
2524
libyml input.spec /^%configure --with-libxml=%{YES} --with-libyml=%{YES}\\$/;" kind:optwith line:52 roles:cmdline
2625
foo input.spec /^ --without-foo --enable-bar \\$/;" kind:optwith line:53 roles:cmdline

parsers/rpmspec.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* References:
1111
* - https://rpm-software-management.github.io/rpm/manual/macros.html
1212
* - https://rpm-software-management.github.io/rpm/manual/spec.html
13+
* - http://ftp.rpm.org/api/4.4.2.2/dependencies.html
1314
*/
1415

1516
/*
1617
* TODO
1718
*
1819
* 1. Capturing required and provide packages as reference tags
1920
* 2. Capturing bz numbers and package versions in %changelog section
20-
* 3. Capturing %configure --enable-FOO --with-BAR
2121
*/
2222
#include "general.h" /* must always come first */
2323

@@ -311,17 +311,40 @@ static bool found_package_cb (const char *line,
311311
unsigned int count,
312312
void *userData)
313313
{
314-
if (count > 0)
315-
{
316-
vString *name = vStringNew ();
317-
tagEntryInfo tag;
314+
if (count == 0)
315+
return true;
316+
317+
/* ---
318+
* NAME: foo
319+
* %package bar
320+
* ---
321+
* In this case, emit foo-bar as a FQ tag.
322+
*
323+
* ---
324+
* NAME: foo
325+
* %package -n baz
326+
* ---
327+
* In this case, don't emit FQ tag.
328+
*/
329+
bool fq = true;
330+
331+
/* strlen("-n") => 2 */
332+
if (matches[1].length > 2)
333+
fq = false;
334+
335+
vString *name = vStringNew ();
336+
tagEntryInfo tag;
337+
338+
vStringNCopyS (name, line + matches[2].start, matches[2].length);
339+
initTagEntry (&tag, vStringValue (name), K_PACKAGE);
340+
tag.extensionFields.scopeIndex = ((struct rpmSpecCtx *)userData)->package_index;
341+
342+
if (!fq)
343+
tag.skipAutoFQEmission = 1;
344+
345+
makeTagEntry (&tag);
346+
vStringDelete (name);
318347

319-
vStringNCopyS (name, line + matches[2].start, matches[2].length);
320-
initTagEntry (&tag, vStringValue (name), K_PACKAGE);
321-
tag.extensionFields.scopeIndex = ((struct rpmSpecCtx *)userData)->package_index;
322-
makeTagEntry (&tag);
323-
vStringDelete (name);
324-
}
325348
return true;
326349
}
327350

0 commit comments

Comments
 (0)