]> git.pld-linux.org Git - packages/rpm-getdeps.git/commitdiff
- port to rpm 4.16
authorJan Rękorajski <baggins@pld-linux.org>
Sat, 24 Oct 2020 13:45:49 +0000 (15:45 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Sat, 24 Oct 2020 13:45:49 +0000 (15:45 +0200)
- add Makefile
- version 0.0.8

Makefile [new file with mode: 0644]
getdeps.c
rpm-getdeps.spec

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..cb34e24
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,14 @@
+RPM_FORMAT_VERSION := `pkg-config --modversion rpm | cut -d . -f 1`
+RPM_MAJOR_VERSION := `pkg-config --modversion rpm | cut -d . -f 2`
+RPM_MINOR_VERSION := `pkg-config --modversion rpm | cut -d . -f 3`
+
+CC := gcc
+CFLAGS := -Wall -Wno-unused-result -DRPM_FORMAT_VERSION=$(RPM_FORMAT_VERSION) -DRPM_MAJOR_VERSION=$(RPM_MAJOR_VERSION) -DRPM_MINOR_VERSION=$(RPM_MINOR_VERSION) $(RPMCFLAGS)
+LDFLAGS := $(RPMLDFLAGS)
+INCLUDES := `pkg-config --cflags rpm`
+LIBS := `pkg-config --libs rpm`
+rpm-getdeps: rpm-getdeps.o
+       $(CC) $(LDFLAGS) $< -o $@ $(LIBS)
+
+rpm-getdeps.o: getdeps.c
+       $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
index 571df0fbf51139dec81644072a273c1b96f99e76..428d1ee81597174834c8f3c464571ecd6d9a868e 100644 (file)
--- a/getdeps.c
+++ b/getdeps.c
@@ -1,5 +1,3 @@
-// $Id$    --*- c -*--
-
 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
 //  
 // This program is free software; you can redistribute it and/or modify
 // version 0.0.1, 2003-11-19
 //    * initial version
 
-
-#define _GNU_SOURCE
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
+#include <assert.h>
 #include <getopt.h>
+#include <grp.h>
+#include <libgen.h>
 #include <stdbool.h>
 #include <string.h>
-#include <assert.h>
-#include <unistd.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <unistd.h>
 
+#include <header.h>
 #include <rpmbuild.h>
 #include <rpmlib.h>
-#include <header.h>
-
-#ifndef RPM404
-#  include <rpmts.h>
-#endif
+#include <rpmlog.h>
+#include <rpmts.h>
 
 #define ARG_WITH       1024
 #define ARG_WITHOUT    1025
@@ -102,10 +93,10 @@ struct Arguments
 };
 
 struct DepSet {
-    int32_t const *    flags;
-    char const **      name;
-    char const **      version;
-    ssize_t            cnt;
+    rpmtd      flags;
+    rpmtd      name;
+    rpmtd      version;
+    ssize_t    cnt;
 };
 
 inline static void 
@@ -222,42 +213,55 @@ setMacros(char const * const *macros, size_t cnt)
 }
 
 static void
-printDepSet(struct DepSet const *set, char const *prefix)
+printDepSet(struct DepSet set, char const *prefix)
 {
   ssize_t      i;
-  for (i=0; i<set->cnt; ++i)
-    printf("%s%08x %s %s\n", prefix, set->flags[i], set->name[i], set->version[i]);
+  for (i=0; i<set.cnt; ++i) {
+    printf("%s%08x %s %s\n", prefix, (uint32_t)rpmtdGetNumber(set.flags), rpmtdGetString(set.name), rpmtdGetString(set.version));
+    rpmtdNext(set.flags);
+    rpmtdNext(set.name);
+    rpmtdNext(set.version);
+  }
 }
 
 static void
 evaluateHeader(Header h)
 {
-  int32_t              cnt[3];
-  struct DepSet                buildreqs = { 0,0,0,0 };
-  struct DepSet                conflicts = { 0,0,0,0 };
-
-  if (headerGetEntry(h, RPMTAG_REQUIREFLAGS,    0, (void**)&buildreqs.flags,   cnt+0) &&
-      headerGetEntry(h, RPMTAG_REQUIRENAME,     0, (void**)&buildreqs.name,    cnt+1) &&
-      headerGetEntry(h, RPMTAG_REQUIREVERSION,  0, (void**)&buildreqs.version, cnt+2)) {
-    assert(cnt[0]==cnt[1] && cnt[1]==cnt[2]);
-    buildreqs.cnt = cnt[0];
+  struct DepSet                buildreqs;
+  struct DepSet                conflicts;
+
+  buildreqs.flags = rpmtdNew();
+  buildreqs.name = rpmtdNew();
+  buildreqs.version = rpmtdNew();
+  buildreqs.cnt = 0;
+
+  if (headerGet(h, RPMTAG_REQUIREFLAGS,    buildreqs.flags,   0) &&
+      headerGet(h, RPMTAG_REQUIRENAME,     buildreqs.name,    0) &&
+      headerGet(h, RPMTAG_REQUIREVERSION,  buildreqs.version, 0)) {
+    assert(buildreqs.flags->count==buildreqs.name->count && buildreqs.name->count==buildreqs.version->count);
+    buildreqs.cnt = buildreqs.flags->count;
   }
 
-  if (headerGetEntry(h, RPMTAG_CONFLICTFLAGS,   0, (void**)&conflicts.flags,   cnt+0) &&
-      headerGetEntry(h, RPMTAG_CONFLICTNAME,    0, (void**)&conflicts.name,    cnt+1) &&
-      headerGetEntry(h, RPMTAG_CONFLICTVERSION, 0, (void**)&conflicts.version, cnt+2)) {
-    assert(cnt[0]==cnt[1] && cnt[1]==cnt[2]);
-    conflicts.cnt = cnt[0];
+  conflicts.flags = rpmtdNew();
+  conflicts.name = rpmtdNew();
+  conflicts.version = rpmtdNew();
+  conflicts.cnt = 0;
+
+  if (headerGet(h, RPMTAG_CONFLICTFLAGS,   conflicts.flags,   0) &&
+      headerGet(h, RPMTAG_CONFLICTNAME,    conflicts.name,    0) &&
+      headerGet(h, RPMTAG_CONFLICTVERSION, conflicts.version, 0)) {
+    assert(conflicts.flags->count==conflicts.name->count && conflicts.name->count==conflicts.version->count);
+    conflicts.cnt = conflicts.flags->count;
   }
 
-  printDepSet(&buildreqs, "+ ");
-  printDepSet(&conflicts, "- ");
+  printDepSet(buildreqs, "+ ");
+  printDepSet(conflicts, "- ");
 }
 
 int main(int argc, char *argv[])
 {
   struct Arguments     args = { 0,0,0,-1,-1, {0,0,0}, 0 };
-  Spec                 s;
+  rpmSpec              s;
 
   parseArgs(&args, argc, argv);
 
@@ -268,28 +272,12 @@ int main(int argc, char *argv[])
     perror("chroot/setuid/setgid()");
     return EXIT_FAILURE;
   }
-  
-  rpmReadConfigFiles(args.rcfile, args.target);
-  setMacros(args.macros.values, args.macros.cnt);
 
+  rpmSetVerbosity(RPMLOG_ERR);
 
-#ifndef RPM404
-  rpmts                        ts = rpmtsCreate();
-  if (parseSpec(ts, args.specfile, 0,0, 1, 0,0, 1,1)!=0) {
-    return EXIT_FAILURE;
-  }
-  
-  s = rpmtsSpec(ts);
-#else
-  if (parseSpec(&s, args.specfile, 0,0, 1, 0,0, 1,1)!=0) {
-    return EXIT_FAILURE;
-  }
-#endif
+  rpmReadConfigFiles(args.rcfile, args.target);
+  setMacros(args.macros.values, args.macros.cnt);
 
-  evaluateHeader(s->buildRestrictions);
+  s = rpmSpecParse(args.specfile, RPMSPEC_FORCE, NULL);
+  evaluateHeader(rpmSpecSourceHeader(s));
 }
-
-/// Local Variables:
-/// compile-command: "make getdeps LDFLAGS='-lrpm       -lrpmbuild'       CFLAGS='-I/usr/include/rpm       -Wall -W -pedantic --std=c99 -g3 -O0'"
-/// compile-commandX: "make getdeps LDFLAGS='-lrpm-4.0.4 -lrpmbuild-4.0.4 -lrpmio-4.0.4 -lrpmdb-4.0.4 -lpopt' CFLAGS='-I/usr/include/rpm-4.0.4 -Wall -W -pedantic --std=c99 -g3 -O0 -DRPM404'"
-/// End:
index c025b9f0717b1443963f259517b64e2a36a3eb12..d8565cdc1638b93b06f953399516d4da5ee53687 100644 (file)
@@ -1,13 +1,13 @@
 Summary:       Get dependencies out of RPM spec file
 Summary(pl):   Pobieranie zależności z pliku spec pakietu RPM
 Name:          rpm-getdeps
-Version:       0.0.7
-Release:       2
+Version:       0.0.8
+Release:       1
 License:       GPL
 Group:         Applications/System
 Source0:       getdeps.c
-# Source0-md5: c20a7f6a0ef86461514fbf55092ae434
-BuildRequires: rpm-devel
+Source1:       Makefile
+BuildRequires: rpm-devel >= 1:4.16.0
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -18,9 +18,14 @@ Pobieranie zależności z pliku spec pakietu RPM.
 
 %prep
 %setup -q -c -T
+ln -s %{SOURCE0} .
+ln -s %{SOURCE1} .
 
 %build
-%{__cc} %{rpmcflags} %{rpmldflags} -I/usr/include/rpm -Wall -lrpm -lrpmbuild %{SOURCE0} -o rpm-getdeps
+%{__make} \
+       CC="%{__cc}" \
+       RPMLDFLAGS="%{rpmldflags}" \
+       RPMCFLAGS="%{rpmcflags}"
 
 %install
 rm -rf $RPM_BUILD_ROOT
This page took 0.112302 seconds and 4 git commands to generate.