ruby-rpm 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 2009-10-20 Duncan Mac-Vicar P. <dmacvicar@suse.de>
2
+
3
+ * port to rpm 4.7. Still should work with older versions
4
+
1
5
  2006-10-13 David Lutterkort <dlutter@redhat.com>
2
6
 
3
7
  * doc/patches: apply patches pulled from SuSe and MDK rpms
data/NEWS CHANGED
@@ -1,3 +1,9 @@
1
+ 1.2.3: 2007-05-07
2
+ - Make RPM::Version hashable (r42)
3
+ - Treat zero epoch the same as no epoch in RPM::Version::<=> (r41)
4
+ - Force GC on close of RPM db to make sure garbage objects don't keep
5
+ db open
6
+
1
7
  1.2.2: 2007-03-21
2
8
  - Fix Dependency.satisfy? and add tests/test_dependency.rb (r25)
3
9
  - Fix segfault when RPM::File.new is called with link_to = nil (r24)
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/testtask'
4
4
  require 'rake/gempackagetask'
5
5
 
6
6
  PKG_NAME='ruby-rpm'
7
- PKG_VERSION='1.2.3'
7
+ PKG_VERSION='1.2.4'
8
8
 
9
9
  EXT_CONF='ext/rpm/extconf.rb'
10
10
  MAKEFILE="ext/rpm/Makefile"
@@ -218,6 +218,7 @@ check_closed(VALUE db)
218
218
  }
219
219
  }
220
220
 
221
+ #ifndef RPMDB_OPAQUE
221
222
  VALUE
222
223
  rpm_db_get_root(VALUE db)
223
224
  {
@@ -231,6 +232,7 @@ rpm_db_get_home(VALUE db)
231
232
  check_closed(db);
232
233
  return rb_str_new2(RPM_DB(db)->db_home);
233
234
  }
235
+ #endif
234
236
 
235
237
  VALUE
236
238
  rpm_db_is_writable(VALUE db)
@@ -284,7 +286,7 @@ static VALUE
284
286
  transaction_commit(VALUE tag, VALUE ts)
285
287
  {
286
288
  rpm_transaction_commit(0, NULL, ts);
287
-
289
+
288
290
  /* not reached because rpm_transaction_commit() always call rb_throw() */
289
291
  return Qnil;
290
292
  }
@@ -430,6 +432,7 @@ rpm_transaction_upgrade(VALUE trans, VALUE pkg, VALUE key)
430
432
  return Qnil;
431
433
  }
432
434
 
435
+ #ifdef RPMTS_AVAILABLE
433
436
  VALUE
434
437
  rpm_transaction_available(VALUE trans, VALUE pkg, VALUE key)
435
438
  {
@@ -454,12 +457,16 @@ rpm_transaction_available(VALUE trans, VALUE pkg, VALUE key)
454
457
  rpmtransAvailablePackage(RPM_TRANSACTION(trans), RPM_HEADER(pkg),
455
458
  RSTRING(key)->ptr);
456
459
  #else
457
- rpmtsAvailablePackage(RPM_TRANSACTION(trans), RPM_HEADER(pkg),
458
- RSTRING(key)->ptr);
460
+ rb_raise(rb_eNotImpError, "need rpmtsAvailablePackage");
461
+ // FIXME: What is the analog for rpmtsAvailablePackage
462
+ // in newer RPM's ?
463
+ //rpmtsAvailablePackage(RPM_TRANSACTION(trans), RPM_HEADER(pkg),
464
+ // RSTRING(key)->ptr);
459
465
  #endif
460
466
 
461
467
  return Qnil;
462
468
  }
469
+ #endif /* RPMTS_AVAILABLE */
463
470
 
464
471
  VALUE
465
472
  rpm_transaction_delete(VALUE trans, VALUE pkg)
@@ -468,7 +475,7 @@ rpm_transaction_delete(VALUE trans, VALUE pkg)
468
475
  VALUE mi;
469
476
 
470
477
  db = rb_ivar_get(trans, id_db);
471
-
478
+
472
479
  if (TYPE(pkg) == T_STRING)
473
480
  mi = rpm_db_init_iterator(db, INT2NUM(RPMDBI_LABEL), pkg);
474
481
  else if (rb_obj_is_kind_of(pkg, rpm_cPackage) != Qfalse) {
@@ -479,9 +486,8 @@ rpm_transaction_delete(VALUE trans, VALUE pkg)
479
486
  VALUE name = rpm_package_aref(pkg,INT2NUM(RPMDBI_LABEL));
480
487
  mi = rpm_db_init_iterator(db, INT2NUM(RPMDBI_LABEL), name);
481
488
  }
482
- } else if ( rb_obj_is_kind_of(pkg, rpm_cDependency) ==Qfalse &&
489
+ } else if ( rb_obj_is_kind_of(pkg, rpm_cDependency) ==Qfalse &&
483
490
  rb_respond_to(pkg,rb_intern("name")) && rb_respond_to(pkg,rb_intern("version"))){
484
- VALUE name = rb_funcall(pkg,rb_intern("name"),0);
485
491
  mi = rpm_db_init_iterator(db, INT2NUM(RPMDBI_LABEL),rb_funcall(pkg,rb_intern("name"),0));
486
492
  rpm_mi_set_iterator_version(mi,rb_funcall(pkg,rb_intern("version"),0));
487
493
  } else
@@ -504,6 +510,7 @@ rpm_transaction_delete(VALUE trans, VALUE pkg)
504
510
 
505
511
  #if RPM_VERSION(4,1,0) <= RPM_VERSION_CODE
506
512
 
513
+ #if 0 /* XXX this shouldn't be needed at all */
507
514
  /* from rpm-4.2.1/lib/rpmps.c */
508
515
  static int
509
516
  sameProblem(const rpmProblem p1, const rpmProblem p2)
@@ -521,9 +528,10 @@ sameProblem(const rpmProblem p1, const rpmProblem p2)
521
528
  return 1;
522
529
  if (p1->ulong1 != p2->ulong1)
523
530
  return 1;
524
-
531
+
525
532
  return 0;
526
533
  }
534
+ #endif
527
535
 
528
536
  static VALUE
529
537
  version_new_from_EVR(const char* evr)
@@ -533,12 +541,12 @@ version_new_from_EVR(const char* evr)
533
541
  char *end = NULL;
534
542
  char *tmp_evr = NULL;
535
543
  VALUE version = Qnil;
536
-
544
+
537
545
  tmp_evr = strdup(evr);
538
546
  if (tmp_evr==NULL) { return Qnil; }
539
547
 
540
548
  e = tmp_evr;
541
- if ( end=strchr(e, ':') ) {
549
+ if ( (end=strchr(e, ':')) ) {
542
550
  /* epoch is found */
543
551
  *end = '\0';
544
552
  vr = end+1;
@@ -639,8 +647,64 @@ rpm_transaction_check(VALUE trans)
639
647
 
640
648
  rc = rpmtsCheck(RPM_TRANSACTION(trans));
641
649
  ps = rpmtsProblems(RPM_TRANSACTION(trans));
650
+ /* get rid of duplicate problems */
651
+ rpmpsTrim(ps, RPMPROB_FILTER_NONE);
642
652
  num = rpmpsNumProblems(ps);
643
653
 
654
+ #ifdef RPMPS_OPAQUE
655
+ rpmpsi psi = rpmpsInitIterator(ps);
656
+ if (num > 0) {
657
+ list = rb_ary_new();
658
+ }
659
+ while (rpmpsNextIterator(psi) >= 0) {
660
+ rpmProblem p = rpmpsGetProblem(psi);
661
+ VALUE dep;
662
+ switch (rpmProblemGetType(p)) {
663
+ case RPMPROB_REQUIRES: {
664
+ char *buf = strdup (rpmProblemGetAltNEVR(p));
665
+ /* TODO: zaki: NULL check*/
666
+ char *end;
667
+
668
+ char *name = buf+2;
669
+ char *relation = NULL;
670
+ char *evr = "";
671
+ rpmsenseFlags sense_flags = 0;
672
+
673
+ end = strchr ( name, ' ');
674
+ if ( end ) {
675
+ *end = '\0';
676
+ relation = end + 1;
677
+ end = strchr ( relation, ' ');
678
+ if ( end ) {
679
+ *end = '\0';
680
+ evr = end + 1;
681
+ }
682
+ for ( ; (*relation) != '\0'; relation++ ) {
683
+ if ( (*relation) == '=' ) {
684
+ sense_flags |= RPMSENSE_EQUAL;
685
+ } else if ( (*relation) == '>' ) {
686
+ sense_flags |= RPMSENSE_GREATER;
687
+ } else if ( (*relation) == '<' ) {
688
+ sense_flags |= RPMSENSE_LESS;
689
+ }
690
+ }
691
+ }
692
+
693
+ dep = rpm_require_new(name,
694
+ rpm_version_new(evr),
695
+ sense_flags,
696
+ package_new_from_NEVR(
697
+ rpmProblemGetPkgNEVR(p)
698
+ ));
699
+ free ( buf );
700
+ rb_ary_push(list, dep);
701
+ break;
702
+ }
703
+ default:
704
+ break;
705
+ }
706
+ }
707
+ #else
644
708
  if (ps != NULL && 0 < num) {
645
709
  rpmProblem p;
646
710
  int i;
@@ -648,7 +712,6 @@ rpm_transaction_check(VALUE trans)
648
712
 
649
713
  for (i = 0; i < num; i++) {
650
714
  const char *altNEVR;
651
- int j;
652
715
  VALUE dep;
653
716
 
654
717
  p = ps->probs + i;
@@ -657,6 +720,7 @@ rpm_transaction_check(VALUE trans)
657
720
  if (p->ignoreProblem)
658
721
  continue;
659
722
 
723
+ #if 0 /* XXX shouldn't be needed at all due to rpmpsTrim() */
660
724
  /* Filter already appended problems. */
661
725
  for (j = 0; j < i; j++) {
662
726
  if (!sameProblem(p, ps->probs + j))
@@ -664,6 +728,7 @@ rpm_transaction_check(VALUE trans)
664
728
  }
665
729
  if (j < i)
666
730
  continue;
731
+ #endif
667
732
 
668
733
  if ( p->type == RPMPROB_REQUIRES ) {
669
734
  char *buf = strdup ( altNEVR );
@@ -689,7 +754,7 @@ rpm_transaction_check(VALUE trans)
689
754
  sense_flags |= RPMSENSE_EQUAL;
690
755
  } else if ( (*relation) == '>' ) {
691
756
  sense_flags |= RPMSENSE_GREATER;
692
- } else if ( (*relation), '<' ) {
757
+ } else if ( (*relation) == '<' ) {
693
758
  sense_flags |= RPMSENSE_LESS;
694
759
  }
695
760
  }
@@ -725,8 +790,9 @@ rpm_transaction_check(VALUE trans)
725
790
  #endif
726
791
  }
727
792
  }
793
+ #endif /* RPMPS_OPAQUE */
728
794
  ps = rpmpsFree(ps);
729
-
795
+
730
796
  return list;
731
797
  #endif
732
798
  }
@@ -892,15 +958,15 @@ rpm_transaction_commit(int argc, VALUE* argv, VALUE trans)
892
958
 
893
959
  if (rb_block_given_p() == Qtrue) {
894
960
  rpmtsSetNotifyCallback(RPM_TRANSACTION(trans),
895
- transaction_callback,(void *)trans);
961
+ (rpmCallbackFunction)transaction_callback,(void *)trans);
896
962
  }else{
897
963
  VALUE keys;
898
-
964
+
899
965
  /* rpmcli.h:extern int rpmcliPackagesTotal; */
900
966
  rpmcliPackagesTotal = 0;
901
-
967
+
902
968
  keys = rpm_transaction_keys(trans);
903
-
969
+
904
970
  if (!NIL_P(keys))
905
971
  rpmcliPackagesTotal = NUM2INT(rb_funcall(keys,rb_intern("length"),0));
906
972
 
@@ -912,6 +978,20 @@ rpm_transaction_commit(int argc, VALUE* argv, VALUE trans)
912
978
 
913
979
  {
914
980
  VALUE list = rb_ary_new();
981
+ #ifdef RPMPS_OPAQUE
982
+ rpmpsi psi = rpmpsInitIterator(ps);
983
+ while (rpmpsNextIterator(psi) >= 0) {
984
+ rpmProblem p = rpmpsGetProblem(psi);
985
+ VALUE prb = rb_struct_new(rpm_sProblem,
986
+ INT2NUM(rpmProblemGetType(p)),
987
+ (VALUE)rpmProblemGetKey(p),
988
+ package_new_from_NEVR(
989
+ rpmProblemGetAltNEVR(p)+2
990
+ ),
991
+ rb_str_new2(rpmProblemString(p)));
992
+ rb_ary_push(list, prb);
993
+ }
994
+ #else
915
995
  if (ps != NULL && rpmpsNumProblems(ps) > 0) {
916
996
  register int i;
917
997
 
@@ -927,10 +1007,11 @@ rpm_transaction_commit(int argc, VALUE* argv, VALUE trans)
927
1007
  rb_ary_push(list, prb);
928
1008
  }
929
1009
  }
1010
+ #endif
930
1011
  rb_ivar_set(trans, id_pl, list);
931
1012
  }
932
1013
  if (ps) ps = rpmpsFree(ps);
933
-
1014
+
934
1015
  #endif
935
1016
 
936
1017
  rb_ivar_set(trans, id_commited, Qtrue);
@@ -967,9 +1048,9 @@ rpm_db_init_iterator(VALUE db, VALUE key, VALUE val)
967
1048
  }
968
1049
 
969
1050
  mi = ALLOC_N(rpm_mi_t,1);
970
- if (mi->mi = rpmdbInitIterator(RPM_DB(db), NUM2INT(rb_Integer(key)),
1051
+ if ((mi->mi = rpmdbInitIterator(RPM_DB(db), NUM2INT(rb_Integer(key)),
971
1052
  NIL_P(val) ? NULL : RSTRING(val)->ptr,
972
- NIL_P(val) ? 0 : RSTRING(val)->len)){
1053
+ NIL_P(val) ? 0 : RSTRING(val)->len))){
973
1054
  mi->db = (rpm_db_t*)DATA_PTR(db);
974
1055
  db_ref(mi->db);
975
1056
  return Data_Wrap_Struct(rpm_cMatchIterator, NULL, mi_free, mi);
@@ -1058,8 +1139,10 @@ Init_rpm_DB(void)
1058
1139
  rb_define_singleton_method(rpm_cDB, "rebuild", db_s_rebuild, -1);
1059
1140
  rb_define_method(rpm_cDB, "close", rpm_db_close, 0);
1060
1141
  rb_define_method(rpm_cDB, "closed?", rpm_db_is_closed, 0);
1142
+ #ifndef RPMDB_OPAQUE
1061
1143
  rb_define_method(rpm_cDB, "root", rpm_db_get_root, 0);
1062
1144
  rb_define_method(rpm_cDB, "home", rpm_db_get_home, 0);
1145
+ #endif
1063
1146
  rb_define_method(rpm_cDB, "writable?", rpm_db_is_writable, 0);
1064
1147
  rb_define_method(rpm_cDB, "each_match", rpm_db_each_match, 2);
1065
1148
  rb_define_method(rpm_cDB, "each", rpm_db_each, 0);
@@ -1095,7 +1178,9 @@ Init_rpm_transaction(void)
1095
1178
  rb_define_method(rpm_cTransaction, "script_file=", rpm_transaction_set_script_file, 1);
1096
1179
  rb_define_method(rpm_cTransaction, "install", rpm_transaction_install, 2);
1097
1180
  rb_define_method(rpm_cTransaction, "upgrade", rpm_transaction_upgrade, 2);
1181
+ #ifdef RPMTS_AVAILABLE
1098
1182
  rb_define_method(rpm_cTransaction, "available", rpm_transaction_available, 2);
1183
+ #endif
1099
1184
  rb_define_method(rpm_cTransaction, "delete", rpm_transaction_delete, 1);
1100
1185
  rb_define_method(rpm_cTransaction, "check", rpm_transaction_check, 0);
1101
1186
  rb_define_method(rpm_cTransaction, "order", rpm_transaction_order, 0);
@@ -0,0 +1,10 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_POPT_H 1
4
+ #define _RPM_4_4_COMPAT 1
5
+ #define RPM_VERSION_CODE 263937
6
+ #define HAVE_RPM_RPMLOG_H 1
7
+ #define HAVE_RPM_RPMPS_H 1
8
+ #define HAVE_RPM_RPMTS_H 1
9
+ #define HAVE_RPM_RPMDS_H 1
10
+ #endif
@@ -5,10 +5,15 @@
5
5
 
6
6
  ### $Id: extconf.rb 19 2004-03-28 10:01:23Z zaki $
7
7
 
8
+ # To build against an rpm installed in a nonstandard location, you need to
9
+ # set PKG_CONFIG_PATH and make sure the corresponding rpm executable is on
10
+ # PATH, e.g. if rpm was configured with --prefix=/dir you want
11
+ # PKG_CONFIG_PATH=/dir/lib/pkgconfig
12
+ # PATH=/dir/bin:$PATH
13
+
8
14
  require 'mkmf'
9
15
 
10
16
  dir_config('popt')
11
- dir_config("rpm", "/usr/include/rpm", "/usr/lib")
12
17
 
13
18
  def check_popt
14
19
  if have_header('popt.h') and have_library('popt') then
@@ -39,9 +44,15 @@ end
39
44
 
40
45
  def check_rpm
41
46
  return false unless check_db
42
- $libs = append_library($libs, 'rpmdb')
47
+ # Set things up manually
48
+ dir_config("rpm")
49
+ $libs = append_library($libs, 'rpmdb') if rpm_version < rpm_version([4,6,0])
43
50
  $libs = append_library($libs, 'rpm')
44
- if have_header('rpmlib.h') and
51
+ if rpm_version >= rpm_version([4,6,0])
52
+ $defs << "-D_RPM_4_4_COMPAT"
53
+ return true
54
+ end
55
+ if have_header('rpm/rpmlib.h') and
45
56
  have_library('rpmio') and
46
57
  have_library('rpmbuild', 'getBuildTime') then
47
58
  true
@@ -51,11 +62,18 @@ def check_rpm
51
62
  end
52
63
  end
53
64
 
65
+ # if no parameters, returns the installed rpm
66
+ # version, or the one specified by the array
67
+ # ie: [4,1,0]
68
+ def rpm_version(ver=[])
69
+ ver = `LANG=C rpm --version| cut -d' ' -f 3`.split(/\./) if ver.empty?
70
+ return (ver[0].to_i<<16) + (ver[1].to_i<<8) + (ver[2].to_i<<0)
71
+ end
72
+
54
73
  def check_rpm_version
55
- version_string=`LANG=C rpm --version| cut -d' ' -f 3`
56
- ver=version_string.split(/\./)
57
74
  # TODO: zaki: strict checking is requires
58
- $CFLAGS="#{$CFLAGS} -DRPM_VERSION_CODE=#{(ver[0].to_i<<16) + (ver[1].to_i<<8) + (ver[2].to_i<<0)}"
75
+ verflag = "-DRPM_VERSION_CODE=#{rpm_version}"
76
+ $defs << verflag
59
77
  end
60
78
 
61
79
  def check_debug
@@ -73,6 +91,12 @@ exit unless check_rpm_version
73
91
 
74
92
  check_debug
75
93
 
94
+ HEADERS = [ "rpmlog", "rpmps", "rpmts", "rpmds" ]
95
+ HEADERS.each { |hdr| have_header("rpm/#{hdr}.h") }
96
+
97
+ $CFLAGS="#{$CFLAGS} -Werror -Wno-deprecated-declarations"
98
+
76
99
  system 'gcc -MM *.c >depend 2>/dev/null'
77
100
 
101
+ create_header
78
102
  create_makefile('rpmmodule')
@@ -104,12 +104,29 @@ package_s_create(VALUE klass, VALUE name, VALUE version)
104
104
  return pkg;
105
105
  }
106
106
 
107
+ static rpmRC read_header_from_file(FD_t fd, const char *filename, Header *hdr)
108
+ {
109
+ rpmRC rc;
110
+ //#if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
111
+ #if 0
112
+ /* filename is ignored */
113
+ Header sigs;
114
+ rc = rpmReadPackageInfo(fd, &sigs, hdr);
115
+ headerFree(sigs);
116
+ #else
117
+ rpmts ts = rpmtsCreate();
118
+ rc = rpmReadPackageFile(ts, fd, filename, hdr);
119
+ rpmtsFree(ts);
120
+ #endif
121
+ return rc;
122
+ }
123
+
107
124
  static VALUE
108
125
  package_s_open(VALUE klass, VALUE filename)
109
126
  {
110
127
  VALUE pkg = Qnil;
111
128
  FD_t fd;
112
- Header hdr, sigs;
129
+ Header hdr;
113
130
  rpmRC rc;
114
131
 
115
132
  if (TYPE(filename) != T_STRING) {
@@ -121,7 +138,8 @@ package_s_open(VALUE klass, VALUE filename)
121
138
  rb_raise(rb_eRuntimeError, "can not open file %s",
122
139
  RSTRING(filename)->ptr);
123
140
  }
124
- rc = rpmReadPackageInfo(fd, &sigs, &hdr);
141
+
142
+ rc = read_header_from_file(fd, RSTRING(filename)->ptr, &hdr);
125
143
  Fclose(fd);
126
144
 
127
145
  switch (rc) {
@@ -133,7 +151,7 @@ package_s_open(VALUE klass, VALUE filename)
133
151
  /* MO_TODO: zaki: should I warn these two status to users? */
134
152
  #endif
135
153
  case RPMRC_OK:
136
- headerFree(sigs);
154
+ //headerFree(sigs);
137
155
  pkg = package_new_from_header(klass, hdr);
138
156
  headerFree(hdr);
139
157
  break;
@@ -175,7 +193,7 @@ package_s_load(VALUE klass, VALUE str)
175
193
  Fseek(fd, 0, SEEK_SET);
176
194
  hdr = headerRead(fd, HEADER_MAGIC_YES);
177
195
  Fclose(fd);
178
- Unlink(RSTRING(temp)->ptr);
196
+ unlink(RSTRING(temp)->ptr);
179
197
 
180
198
  if (!hdr) {
181
199
  rb_raise(rb_eArgError, "unable load RPM::Package");
@@ -190,15 +208,18 @@ package_s_load(VALUE klass, VALUE str)
190
208
  VALUE
191
209
  rpm_package_copy_tags(VALUE from,VALUE to,VALUE tags)
192
210
  {
193
- int_32 *copy_tags;
211
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
212
+ #define rpmTag int_32
213
+ #endif
214
+ rpmTag *copy_tags;
194
215
  int length = NUM2INT(rb_funcall(tags,rb_intern("length"),0));
195
216
  int i;
196
217
 
197
- copy_tags = ALLOCA_N(int_32,length);
218
+ copy_tags = ALLOCA_N(rpmTag,length);
198
219
  for (i=0;i<length;i++)
199
220
  copy_tags[i] = NUM2INT(rb_ary_entry(tags, i));
200
221
  headerCopyTags(RPM_HEADER(from),RPM_HEADER(to),copy_tags);
201
- return Qnil;
222
+ return Qnil;
202
223
  }
203
224
 
204
225
  VALUE
@@ -302,6 +323,7 @@ rpm_package_delete_tag(VALUE pkg, VALUE tag)
302
323
  return val;
303
324
  }
304
325
 
326
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
305
327
  VALUE
306
328
  rpm_package_aref(VALUE pkg, VALUE tag)
307
329
  {
@@ -311,7 +333,6 @@ rpm_package_aref(VALUE pkg, VALUE tag)
311
333
  rpmTagType type;
312
334
  int_32 count;
313
335
  register int i;
314
- register const char* p;
315
336
  int ary_p = 0;
316
337
  int i18n_p = 0;
317
338
 
@@ -440,6 +461,141 @@ rpm_package_aref(VALUE pkg, VALUE tag)
440
461
  leave:
441
462
  return val;
442
463
  }
464
+ #else
465
+ VALUE
466
+ rpm_package_aref(VALUE pkg, VALUE tag)
467
+ {
468
+ rpmTag tagval = NUM2INT(tag);
469
+ VALUE val = Qnil;
470
+ rpmtd tagc = rpmtdNew();
471
+ int ary_p = 0;
472
+ int i18n_p = 0;
473
+
474
+ if (!headerGet(RPM_HEADER(pkg), tagval, tagc, HEADERGET_MINMEM)) {
475
+ rpmtdFree(tagc);
476
+ goto leave;
477
+ }
478
+ switch (tagval) {
479
+ case RPMTAG_DIRINDEXES:
480
+ case RPMTAG_FILESIZES:
481
+ case RPMTAG_FILESTATES:
482
+ case RPMTAG_FILEMODES:
483
+ case RPMTAG_FILERDEVS:
484
+ case RPMTAG_FILEMTIMES:
485
+ case RPMTAG_FILEMD5S:
486
+ case RPMTAG_FILEFLAGS:
487
+ case RPMTAG_FILEUSERNAME:
488
+ case RPMTAG_FILEGROUPNAME:
489
+ case RPMTAG_PROVIDEFLAGS:
490
+ case RPMTAG_REQUIREFLAGS:
491
+ case RPMTAG_CONFLICTFLAGS:
492
+ case RPMTAG_OBSOLETEFLAGS:
493
+ ary_p = 1;
494
+ break;
495
+
496
+ case RPMTAG_GROUP:
497
+ case RPMTAG_SUMMARY:
498
+ case RPMTAG_DISTRIBUTION:
499
+ case RPMTAG_VENDOR:
500
+ case RPMTAG_LICENSE:
501
+ case RPMTAG_PACKAGER:
502
+ case RPMTAG_DESCRIPTION:
503
+ i18n_p = 1;
504
+ break;
505
+ default:
506
+ break;
507
+ }
508
+
509
+ switch (rpmtdType(tagc)) {
510
+ case RPM_BIN_TYPE:
511
+ val = rb_str_new2(rpmtdGetString(tagc));
512
+ break;
513
+
514
+ case RPM_CHAR_TYPE:
515
+ case RPM_INT8_TYPE:
516
+ if (rpmtdCount(tagc) == 1 && !ary_p) {
517
+ val = INT2NUM(*rpmtdGetChar(tagc));
518
+ } else {
519
+ val = rb_ary_new();
520
+ rpmtdInit(tagc);
521
+ while ( rpmtdNext(tagc) != -1 ) {
522
+ rb_ary_push(val, INT2NUM(*rpmtdGetChar(tagc)));
523
+ }
524
+ }
525
+ break;
526
+
527
+ case RPM_INT16_TYPE:
528
+ if (rpmtdCount(tagc) == 1 && !ary_p) {
529
+ val = INT2NUM(*rpmtdGetUint16(tagc));
530
+ } else {
531
+ val = rb_ary_new();
532
+ rpmtdInit(tagc);
533
+ while ( rpmtdNext(tagc) != -1 ) {
534
+ rb_ary_push(val, INT2NUM(*rpmtdGetUint16(tagc)));
535
+ }
536
+ }
537
+ break;
538
+
539
+ case RPM_INT32_TYPE:
540
+ if (rpmtdCount(tagc) == 1 && !ary_p) {
541
+ val = INT2NUM(*rpmtdGetUint32(tagc));
542
+ } else {
543
+ val = rb_ary_new();
544
+ rpmtdInit(tagc);
545
+ while ( rpmtdNext(tagc) != -1) {
546
+ rb_ary_push(val, INT2NUM(*rpmtdGetUint32(tagc)));
547
+ }
548
+ }
549
+ break;
550
+
551
+ case RPM_STRING_TYPE:
552
+ if (rpmtdCount(tagc) == 1 && !ary_p) {
553
+ val = rb_str_new2(rpmtdGetString(tagc));
554
+ } else {
555
+ val = rb_ary_new();
556
+ while ( rpmtdNext(tagc) != -1) {
557
+ rb_ary_push(val, rb_str_new2(rpmtdGetString(tagc)));
558
+ }
559
+ }
560
+ rpmtdFree(tagc);
561
+ break;
562
+
563
+ case RPM_STRING_ARRAY_TYPE:
564
+ {
565
+ if (i18n_p) {
566
+ rpmtd i18ntd = rpmtdNew();
567
+
568
+ if (!headerGet(RPM_HEADER(pkg), HEADER_I18NTABLE, i18ntd, HEADERGET_MINMEM)) {
569
+ goto strary;
570
+ }
571
+
572
+ val = rb_hash_new();
573
+ rpmtdInit(tagc);
574
+ while ( rpmtdNext(tagc) != -1) {
575
+ VALUE lang = rb_str_new2(rpmtdNextString(i18ntd));
576
+ VALUE str = rb_str_new2(rpmtdGetString(tagc));
577
+ rb_hash_aset(val, lang, str);
578
+ }
579
+ rpmtdFree(i18ntd);
580
+ } else {
581
+ strary:
582
+ val = rb_ary_new();
583
+ rpmtdInit(tagc);
584
+ while ( rpmtdNext(tagc) != -1) {
585
+ rb_ary_push(val, rb_str_new2(rpmtdGetString(tagc)));
586
+ }
587
+ }
588
+ rpmtdFree(tagc);
589
+ }
590
+ break;
591
+
592
+ default:
593
+ goto leave;
594
+ }
595
+ leave:
596
+ return val;
597
+ }
598
+ #endif
443
599
 
444
600
  VALUE
445
601
  rpm_package_sprintf(VALUE pkg, VALUE fmt)
@@ -579,6 +735,7 @@ rpm_package_get_files(VALUE pkg)
579
735
  return files;
580
736
  }
581
737
 
738
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
582
739
  VALUE
583
740
  rpm_package_get_dependency(VALUE pkg,int nametag,int versiontag,int flagtag,VALUE (*dependency_new)(const char*,VALUE,int,VALUE))
584
741
  {
@@ -617,6 +774,42 @@ rpm_package_get_dependency(VALUE pkg,int nametag,int versiontag,int flagtag,VALU
617
774
  release_entry(flagtype, (void*)flags);
618
775
  return deps;
619
776
  }
777
+ #else
778
+ VALUE
779
+ rpm_package_get_dependency(VALUE pkg,int nametag,int versiontag,int flagtag,VALUE (*dependency_new)(const char*,VALUE,int,VALUE))
780
+ {
781
+ VALUE deps;
782
+
783
+ rpmtd nametd = rpmtdNew();
784
+ rpmtd versiontd = rpmtdNew();
785
+ rpmtd flagtd = rpmtdNew();
786
+
787
+ deps = rb_ary_new();
788
+
789
+ if (!headerGet(RPM_HEADER(pkg), nametag, nametd, HEADERGET_MINMEM)) {
790
+ goto leave;
791
+ }
792
+ if (!headerGet(RPM_HEADER(pkg), versiontag, versiontd, HEADERGET_MINMEM)) {
793
+ goto leave;
794
+ return deps;
795
+ }
796
+ if (!headerGet(RPM_HEADER(pkg), flagtag, flagtd, HEADERGET_MINMEM)) {
797
+ goto leave;
798
+ return deps;
799
+ }
800
+
801
+ rpmtdInit(nametd);
802
+ while ( rpmtdNext(nametd) != -1 ) {
803
+ rb_ary_push(deps,dependency_new(rpmtdGetString(nametd),rpm_version_new(rpmtdNextString(versiontd)),*rpmtdNextUint32(flagtd),pkg));
804
+ }
805
+
806
+ leave:
807
+ rpmtdFree(nametd);
808
+ rpmtdFree(versiontd);
809
+ rpmtdFree(flagtd);
810
+ return deps;
811
+ }
812
+ #endif
620
813
 
621
814
  VALUE
622
815
  rpm_package_get_provides(VALUE pkg)
@@ -642,6 +835,7 @@ rpm_package_get_obsoletes(VALUE pkg)
642
835
  return rpm_package_get_dependency(pkg,RPMTAG_OBSOLETENAME,RPMTAG_OBSOLETEVERSION,RPMTAG_OBSOLETEFLAGS,rpm_obsolete_new);
643
836
  }
644
837
 
838
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
645
839
  VALUE
646
840
  rpm_package_get_changelog(VALUE pkg)
647
841
  {
@@ -680,6 +874,47 @@ rpm_package_get_changelog(VALUE pkg)
680
874
  }
681
875
  return cl;
682
876
  }
877
+ #else
878
+ VALUE
879
+ rpm_package_get_changelog(VALUE pkg)
880
+ {
881
+ VALUE cl;
882
+ rpmtd timetd = rpmtdNew();
883
+ rpmtd nametd = rpmtdNew();
884
+ rpmtd texttd = rpmtdNew();
885
+
886
+ cl = rb_ary_new();
887
+
888
+ if (!headerGet(RPM_HEADER(pkg), RPMTAG_CHANGELOGTIME, timetd, HEADERGET_MINMEM)) {
889
+ goto leave;
890
+ }
891
+ if (!headerGet(RPM_HEADER(pkg), RPMTAG_CHANGELOGNAME, nametd, HEADERGET_MINMEM)) {
892
+ goto leave;
893
+ }
894
+ if (!headerGet(RPM_HEADER(pkg), RPMTAG_CHANGELOGTEXT, texttd, HEADERGET_MINMEM)) {
895
+ goto leave;
896
+ }
897
+
898
+ rpmtdInit(timetd);
899
+ rpmtdInit(nametd);
900
+ rpmtdInit(texttd);
901
+
902
+ while ( rpmtdNext(timetd) != -1 ) {
903
+ VALUE chglog = rb_struct_new(
904
+ rpm_sChangeLog,
905
+ rb_time_new((time_t) rpmtdGetUint32(timetd), (time_t)0),
906
+ rb_str_new2(rpmtdNextString(nametd)),
907
+ rb_str_new2(rpmtdNextString(texttd)));
908
+ rb_ary_push(cl, chglog);
909
+ }
910
+
911
+ leave:
912
+ rpmtdFree(timetd);
913
+ rpmtdFree(nametd);
914
+ rpmtdFree(texttd);
915
+ return cl;
916
+ }
917
+ #endif
683
918
 
684
919
  VALUE
685
920
  rpm_package_dump(VALUE pkg)
@@ -699,7 +934,7 @@ rpm_package_dump(VALUE pkg)
699
934
  munmap(buf, size);
700
935
 
701
936
  Fclose(fd);
702
- Unlink(RSTRING(temp)->ptr);
937
+ unlink(RSTRING(temp)->ptr);
703
938
 
704
939
  return dump;
705
940
  }
@@ -6,6 +6,8 @@
6
6
 
7
7
  /* $Id: private.h 17 2004-03-19 05:12:19Z zaki $ */
8
8
 
9
+ #include <extconf.h>
10
+
9
11
  #define RPM_VERSION(maj,min,pl) (((maj) << 16) + ((min) << 8) + (pl))
10
12
 
11
13
  #include <ctype.h>
@@ -20,16 +22,23 @@
20
22
  #include <unistd.h>
21
23
  #include <st.h>
22
24
 
23
- #include <rpmcli.h>
24
- #include <rpmlib.h>
25
- #include <rpmdb.h>
26
- #include <rpmbuild.h>
27
- #include <rpmmessages.h>
28
- #if RPM_VERSION(4,1,0) <= RPM_VERSION_CODE
29
- #include <rpmts.h>
30
- #include <rpmps.h>
31
- #include <rpmds.h>
32
- #include "rpm40_compat.h"
25
+ #include <rpm/rpmcli.h>
26
+ #include <rpm/rpmlib.h>
27
+ #include <rpm/rpmdb.h>
28
+ #include <rpm/rpmbuild.h>
29
+ #if HAVE_RPM_RPMLOG_H
30
+ # include <rpm/rpmlog.h>
31
+ #else
32
+ # include <rpm/rpmmessages.h>
33
+ #endif
34
+ #if HAVE_RPM_RPMTS_H
35
+ # include <rpm/rpmts.h>
36
+ #endif
37
+ #if HAVE_RPM_RPMPS_H
38
+ # include <rpm/rpmps.h>
39
+ #endif
40
+ #if HAVE_RPM_RPMDS_H
41
+ # include <rpm/rpmds.h>
33
42
  #endif
34
43
 
35
44
  #include "ruby-rpm.h"
@@ -49,6 +58,13 @@
49
58
  #define RPM_TRANSACTION(v) (((rpm_trans_t*)DATA_PTR((v)))->ts)
50
59
  #define RPM_SCRIPT_FD(v) (((rpm_trans_t*)DATA_PTR((v)))->script_fd)
51
60
 
61
+ #if RPM_VERSION_CODE >= RPM_VERSION(4,5,90)
62
+ #define RPMDB_OPAQUE 1
63
+ #define RPMPS_OPAQUE 1
64
+ #else
65
+ #define RPMTS_AVAILABLE 1
66
+ #endif
67
+
52
68
  typedef struct {
53
69
  rpmdb db;
54
70
  int ref_count;
@@ -98,6 +114,7 @@ void Init_rpm_spec(void);
98
114
  /* version.c */
99
115
  void Init_rpm_version(void);
100
116
 
117
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
101
118
  static void inline
102
119
  get_entry(Header hdr, rpmTag tag, rpmTagType* type, void** ptr)
103
120
  {
@@ -106,6 +123,13 @@ get_entry(Header hdr, rpmTag tag, rpmTagType* type, void** ptr)
106
123
  *ptr = NULL;
107
124
  }
108
125
  }
126
+ #else
127
+ static void inline
128
+ get_entry(Header hdr, rpmTag tag, rpmtd tc)
129
+ {
130
+ headerGet(hdr, tag, tc, HEADERGET_MINMEM);
131
+ }
132
+ #endif
109
133
 
110
134
  static void inline
111
135
  release_entry(rpmTagType type, void* ptr)
@@ -204,6 +204,7 @@ Init_rpmmodule(void)
204
204
  DEF_LOG(DEBUG);
205
205
  #undef DEF_LOG
206
206
 
207
+ #if RPM_VERSION_CODE < RPM_VERSION(4,5,90)
207
208
  #define DEF_MESS(name) \
208
209
  rb_define_const(rpm_mRPM, "MESS_"#name, INT2NUM(RPMMESS_##name))
209
210
  DEF_MESS(DEBUG);
@@ -214,6 +215,7 @@ Init_rpmmodule(void)
214
215
  DEF_MESS(FATALERROR);
215
216
  DEF_MESS(QUIET);
216
217
  #undef DEF_MESS
218
+ #endif
217
219
 
218
220
  #define DEFINE_DBI(name) \
219
221
  rb_define_const(rpm_mRPM, "DBI_"#name, INT2NUM(RPMDBI_##name))
@@ -400,7 +402,9 @@ Init_rpmmodule(void)
400
402
  #define DEFINE_SENSE(name) \
401
403
  rb_define_const(rpm_mRPM, "SENSE_"#name, INT2NUM(RPMSENSE_##name))
402
404
  DEFINE_SENSE(ANY);
405
+ #if RPM_VERSION_CODE < RPM_VERSION(4,5,90)
403
406
  DEFINE_SENSE(SERIAL);
407
+ #endif
404
408
  DEFINE_SENSE(LESS);
405
409
  DEFINE_SENSE(GREATER);
406
410
  DEFINE_SENSE(EQUAL);
@@ -453,7 +457,9 @@ Init_rpmmodule(void)
453
457
  DEF_PROB(OLDPACKAGE);
454
458
  DEF_PROB(DISKSPACE);
455
459
  DEF_PROB(DISKNODES);
460
+ #if RPM_VERSION_CODE < RPM_VERSION(4,5,90)
456
461
  DEF_PROB(BADPRETRANS);
462
+ #endif
457
463
  #undef DEF_PROB
458
464
 
459
465
  #define DEF_CALLBACK(name) \
@@ -513,7 +519,7 @@ Init_rpmmodule(void)
513
519
  DEF_TRANS_FLAG(APPLYONLY);
514
520
  #if RPM_VERSION_CODE < RPM_VERSION(4,1,0)
515
521
  DEF_TRANS_FLAG(CHAINSAW);
516
- #else
522
+ #elif RPM_VERSION_CODE < RPM_VERSION(4,5,90)
517
523
  DEF_TRANS_FLAG(ANACONDA);
518
524
  #endif
519
525
  /* NOMD5 is not in jbj's 4.4.6 any more - Mandriva uses that */
@@ -11,7 +11,7 @@
11
11
 
12
12
  #include <ruby.h>
13
13
 
14
- #define RUBY_RPM_VERSION "1.1.10"
14
+ #define RUBY_RPM_VERSION "1.2.4"
15
15
 
16
16
  extern VALUE rpm_mRPM;
17
17
  extern VALUE rpm_cConflict;
@@ -53,7 +53,6 @@ spec_s_open(VALUE klass, VALUE filename)
53
53
  break;
54
54
  }
55
55
 
56
- case RPMERR_BADSPEC:
57
56
  default:
58
57
  rb_raise(rb_eRuntimeError, "specfile `%s' parsing failed", RSTRING(filename)->ptr);
59
58
  }
@@ -66,7 +65,6 @@ spec_s_open(VALUE klass, VALUE filename)
66
65
  break;
67
66
  }
68
67
 
69
- case RPMERR_BADSPEC:
70
68
  default:
71
69
  rb_raise(rb_eRuntimeError, "specfile `%s' parsing failed", RSTRING(filename)->ptr);
72
70
  }
@@ -83,9 +81,15 @@ rpm_spec_open(const char* filename)
83
81
  VALUE
84
82
  rpm_spec_get_buildroot(VALUE spec)
85
83
  {
84
+ #if RPM_VERSION_CODE >= RPM_VERSION(4,5,90)
85
+ if (RPM_SPEC(spec)->buildRoot) {
86
+ return rb_str_new2(RPM_SPEC(spec)->buildRoot);
87
+ }
88
+ #else
86
89
  if (RPM_SPEC(spec)->buildRootURL) {
87
90
  return rb_str_new2(RPM_SPEC(spec)->buildRootURL);
88
91
  }
92
+ #endif
89
93
  return Qnil;
90
94
  }
91
95
 
@@ -120,6 +124,7 @@ rpm_spec_get_buildrequires(VALUE spec)
120
124
  {
121
125
  VALUE br = rb_ivar_get(spec, id_br);
122
126
 
127
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
123
128
  if (NIL_P(br)) {
124
129
  const char** names;
125
130
  const char** vers;
@@ -153,13 +158,44 @@ rpm_spec_get_buildrequires(VALUE spec)
153
158
 
154
159
  leave:
155
160
  return br;
161
+ #else
162
+ rpmtd nametd = rpmtdNew();
163
+ rpmtd versiontd = rpmtdNew();
164
+ rpmtd flagtd = rpmtdNew();
165
+
166
+ if (NIL_P(br)) {
167
+ br = rb_ary_new();
168
+ if (!headerGet(RPM_SPEC(spec)->buildRestrictions,
169
+ RPMTAG_REQUIRENAME, nametd, HEADERGET_MINMEM)) {
170
+ goto leave;
171
+ }
172
+
173
+ get_entry(RPM_SPEC(spec)->buildRestrictions, RPMTAG_REQUIREVERSION,
174
+ versiontd);
175
+ get_entry(RPM_SPEC(spec)->buildRestrictions, RPMTAG_REQUIREFLAGS,
176
+ flagtd);
177
+
178
+ rpmtdInit(nametd);
179
+ while ( rpmtdNext(nametd) != -1 ) {
180
+ rb_ary_push(br, rpm_require_new(rpmtdGetString(nametd), rpm_version_new(rpmtdNextString(versiontd)), *rpmtdNextUint32(flagtd), spec));
181
+ }
182
+ rb_ivar_set(spec, id_br, br);
183
+ }
184
+
185
+ leave:
186
+ rpmtdFree(nametd);
187
+ rpmtdFree(versiontd);
188
+ rpmtdFree(flagtd);
189
+
190
+ return br;
191
+ #endif
156
192
  }
157
193
 
158
194
  VALUE
159
195
  rpm_spec_get_buildconflicts(VALUE spec)
160
196
  {
161
197
  VALUE bc = rb_ivar_get(spec, id_bc);
162
-
198
+ #if RPM_VERSION_CODE < RPM_VERSION(4,6,0)
163
199
  if (NIL_P(bc)) {
164
200
  const char** names;
165
201
  const char** vers;
@@ -192,6 +228,38 @@ rpm_spec_get_buildconflicts(VALUE spec)
192
228
  }
193
229
  leave:
194
230
  return bc;
231
+ #else
232
+ rpmtd nametd = rpmtdNew();
233
+ rpmtd versiontd = rpmtdNew();
234
+ rpmtd flagtd = rpmtdNew();
235
+
236
+ if (NIL_P(bc)) {
237
+ bc = rb_ary_new();
238
+ if (!headerGet(RPM_SPEC(spec)->buildRestrictions,
239
+ RPMTAG_CONFLICTNAME, nametd, HEADERGET_MINMEM)) {
240
+
241
+ goto leave;
242
+ }
243
+
244
+ get_entry(RPM_SPEC(spec)->buildRestrictions, RPMTAG_CONFLICTVERSION,
245
+ versiontd);
246
+ get_entry(RPM_SPEC(spec)->buildRestrictions, RPMTAG_CONFLICTFLAGS,
247
+ flagtd);
248
+
249
+ rpmtdInit(nametd);
250
+ while ( rpmtdNext(nametd) != -1) {
251
+ rb_ary_push(bc, rpm_conflict_new(rpmtdGetString(nametd), rpm_version_new(rpmtdNextString(versiontd)), *rpmtdNextUint32(flagtd), spec));
252
+ }
253
+
254
+ rb_ivar_set(spec, id_bc, bc);
255
+ }
256
+ leave:
257
+ rpmtdFree(nametd);
258
+ rpmtdFree(versiontd);
259
+ rpmtdFree(flagtd);
260
+
261
+ return bc;
262
+ #endif
195
263
  }
196
264
 
197
265
  VALUE
@@ -214,10 +282,10 @@ rpm_spec_get_sources(VALUE spec)
214
282
 
215
283
  if (NIL_P(src)) {
216
284
  struct Source* s = RPM_SPEC(spec)->sources;
217
-
285
+
218
286
  src = rb_ary_new();
219
287
  while (s != NULL) {
220
- VALUE obj;
288
+ VALUE obj = Qnil;
221
289
 
222
290
  if (s->flags & RPMBUILD_ISSOURCE) {
223
291
  obj = rpm_source_new(s->fullSource, s->num, s->flags & RPMBUILD_ISNO);
@@ -191,7 +191,7 @@ rpm_version_cmp(VALUE ver, VALUE other)
191
191
  VALUE vr,or;
192
192
  VALUE vv,ov;
193
193
  int sense = 0;
194
-
194
+
195
195
  if (rb_obj_is_kind_of(other, rpm_cVersion) != Qtrue) {
196
196
  rb_raise(rb_eTypeError, "illegal argument type");
197
197
  }
@@ -289,7 +289,7 @@ rpm_version_to_vre(VALUE ver)
289
289
  r = rb_ivar_get(ver, id_r);
290
290
  e = rb_ivar_get(ver, id_e);
291
291
  if (!NIL_P(e)) {
292
- snprintf(buf,BUFSIZ,"%d:",NUM2INT(e));
292
+ snprintf(buf,BUFSIZ,"%ld:", (long) NUM2INT(e));
293
293
  p += strlen(buf);
294
294
  }
295
295
  strcpy(p, RSTRING(v)->ptr);
@@ -304,14 +304,13 @@ VALUE
304
304
  rpm_version_inspect(VALUE ver)
305
305
  {
306
306
  char buf[BUFSIZ];
307
- char *p = buf;
308
307
  VALUE v, r, e;
309
308
  v = rb_ivar_get(ver, id_v);
310
309
  r = rb_ivar_get(ver, id_r);
311
310
  e = rb_ivar_get(ver, id_e);
312
311
 
313
312
  if (!NIL_P(e)) {
314
- snprintf(buf, BUFSIZ, "#<RPM::Version v=%s, r=%s, e=%d>", RSTRING(rb_inspect(v))->ptr, RSTRING(rb_inspect(r))->ptr, NUM2INT(e));
313
+ snprintf(buf, BUFSIZ, "#<RPM::Version v=%s, r=%s, e=%ld>", RSTRING(rb_inspect(v))->ptr, RSTRING(rb_inspect(r))->ptr, (long) NUM2INT(e));
315
314
  } else {
316
315
  snprintf(buf, BUFSIZ, "#<RPM::Version v=%s, r=%s>", RSTRING(rb_inspect(v))->ptr, RSTRING(rb_inspect(r))->ptr);
317
316
  }
@@ -327,7 +326,7 @@ rpm_version_hash(VALUE ver)
327
326
  v = rb_ivar_get(ver, id_v);
328
327
  r = rb_ivar_get(ver, id_r);
329
328
  e = rb_ivar_get(ver, id_e);
330
-
329
+
331
330
  h = NIL_P(e) ? 0 : NUM2INT(e);
332
331
  h = (h << 1) ^ NUM2LONG(rb_hash(r));
333
332
  h = (h << 1) ^ NUM2LONG(rb_hash(v));
@@ -1,21 +1,30 @@
1
1
  %{!?ruby_sitelib: %define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")}
2
2
  %{!?ruby_sitearch: %define ruby_sitearch %(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")}
3
3
 
4
+ %define has_ruby_abi 0%{?fedora:%fedora} >= 5 || 0%{?rhel:%rhel} >= 5
5
+
4
6
  Summary: Ruby bindings for RPM
5
7
  Name: ruby-rpm
6
8
 
7
- Version: 1.2.3
8
- Release: 1%{?dist}
9
+ Version: 1.2.4
10
+ Release: 3%{?dist}
9
11
  Group: Development/Languages
10
- License: GPL
12
+ License: GPLv2+
11
13
  URL: http://rubyforge.org/projects/ruby-rpm/
12
- Source0: %{name}-%{version}.tgz
13
- BuildRoot: %{_tmppath}/%{name}-%{version}-root
14
- Requires: ruby >= 1.8.1
15
- BuildRequires: ruby >= 1.8.1
16
- BuildRequires: ruby-devel >= 1.8.1
14
+ Source0: http://rubyforge.org/frs/download.php/26403/%{name}-1.2.3.tgz
15
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
16
+ %if %has_ruby_abi
17
+ Requires: ruby(abi) = 1.8
18
+ BuildRequires: ruby(abi) = 1.8
19
+ %endif
20
+ Provides: ruby(rpm) = %version
21
+ BuildRequires: ruby ruby-devel
17
22
  BuildRequires: rpm-devel >= 4.2.1
18
23
  BuildRequires: db4-devel
24
+ # In popt before F8, in popt-devel for F8 and later
25
+ %if 0%{?fedora:%fedora} >= 8
26
+ BuildRequires: popt-devel
27
+ %endif
19
28
 
20
29
  %description
21
30
  Provides bindings for accessing RPM packages and databases from Ruby. It
@@ -36,7 +45,7 @@ ruby install.rb config \
36
45
  ruby install.rb setup
37
46
 
38
47
  %install
39
- [ "%{buildroot}" != "/" ] && %__rm -rf %{buildroot}
48
+ rm -rf %{buildroot}
40
49
  ruby install.rb config \
41
50
  --bin-dir=%{buildroot}%{_bindir} \
42
51
  --rb-dir=%{buildroot}%{ruby_sitelib} \
@@ -46,15 +55,21 @@ ruby install.rb install
46
55
  chmod 0755 %{buildroot}%{ruby_sitearch}/rpmmodule.so
47
56
 
48
57
  %clean
49
- [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
58
+ rm -rf %{buildroot}
50
59
 
51
60
  %files
52
- %defattr(-, root, root)
61
+ %defattr(-, root, root,-)
53
62
  %doc NEWS README COPYING ChangeLog doc
54
63
  %{ruby_sitelib}/rpm.rb
55
64
  %{ruby_sitearch}/rpmmodule.so
56
65
 
57
66
  %changelog
67
+ * Fri Oct 19 2007 David Lutterkort <dlutter@redhat.com> - 1.2.3-3
68
+ - Fix BR on popt-devel
69
+
70
+ * Mon Oct 8 2007 David Lutterkort <dlutter@redhat.com> - 1.2.3-2
71
+ - Bring in agreement with Fedora guidelines
72
+
58
73
  * Tue Nov 14 2006 David Lutterkort <dlutter@redhat.com> - 1.2.1-1
59
74
  - Adapted for Fedora
60
75
 
File without changes
@@ -3,8 +3,14 @@ require 'fileutils'
3
3
  require 'tmpdir'
4
4
  require 'rpm'
5
5
 
6
+ def rpm_version(ver=[])
7
+ ver = `LANG=C rpm --version| cut -d' ' -f 3`.split(/\./) if ver.empty?
8
+ return (ver[0].to_i<<16) + (ver[1].to_i<<8) + (ver[2].to_i<<0)
9
+ end
10
+
6
11
  class RPM_DB_Tests < Test::Unit::TestCase
7
12
  def setup
13
+ @version = rpm_version
8
14
  @work_dir = "#{Dir.tmpdir}/.ruby-rpm-test"
9
15
  unless File.directory?(@work_dir) then
10
16
  Dir.mkdir(@work_dir, 0777)
@@ -25,7 +31,9 @@ class RPM_DB_Tests < Test::Unit::TestCase
25
31
  end # def test_initdb
26
32
 
27
33
  def test_rebuild
28
- RPM::DB.rebuild( @work_dir )
34
+ # We add the "/" to work around an obscure bug in older
35
+ # RPM versions
36
+ RPM::DB.rebuild( @work_dir + "/")
29
37
  assert( File.exist?( "#{@tmppath}/#{RPM['_dbpath']}/Packages" ) )
30
38
  end
31
39
 
@@ -33,12 +41,18 @@ class RPM_DB_Tests < Test::Unit::TestCase
33
41
  assert( @a )
34
42
  end
35
43
 
36
- def test_root
37
- assert_equal( @a.root, @work_dir )
44
+ def test_root
45
+ assert_equal( @a.root, @work_dir ) if @version < rpm_version([4,6,0])
46
+ if @version >= rpm_version([4,6,0])
47
+ assert_raise(NoMethodError) { @a.root }
48
+ end
38
49
  end
39
50
 
40
51
  def test_home
41
- assert_equal( @a.home, RPM['_dbpath'] )
52
+ assert_equal( @a.home, RPM['_dbpath'] ) if @version < rpm_version([4,6,0])
53
+ if @version >= rpm_version([4,6,0])
54
+ assert_raise(NoMethodError) { @a.home }
55
+ end
42
56
  end
43
-
57
+
44
58
  end # class RPM_DB_Tests < Test::Unit::TestCase
metadata CHANGED
@@ -1,33 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: ruby-rpm
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.2.3
7
- date: 2007-05-07 00:00:00 -07:00
8
- summary: Ruby bindings for RPM
9
- require_paths:
10
- - lib
11
- email: ruby-rpm-devel@rubyforge.org
12
- homepage: http://rubyforge.org/projects/ruby-rpm/
13
- rubyforge_project:
14
- description: Provides bindings for accessing RPM packages and databases from Ruby. It includes the low-level C API to talk to rpm as well as Ruby classes to model the various objects that RPM deals with (such as packages, dependencies, and files).
15
- autorequire: rpm
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: false
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.1
24
- version:
4
+ version: 1.2.4
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors: []
30
7
 
8
+ autorequire: rpm
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-10 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: |
17
+ Provides bindings for accessing RPM packages and databases from Ruby. It
18
+ includes the low-level C API to talk to rpm as well as Ruby classes to
19
+ model the various objects that RPM deals with (such as packages,
20
+ dependencies, and files).
21
+
22
+ email: ruby-rpm-devel@rubyforge.org
23
+ executables: []
24
+
25
+ extensions:
26
+ - ext/rpm/extconf.rb
27
+ extra_rdoc_files: []
28
+
31
29
  files:
32
30
  - Rakefile
33
31
  - ChangeLog
@@ -37,41 +35,57 @@ files:
37
35
  - install.rb
38
36
  - doc/refm.rd.ja
39
37
  - lib/rpm.rb
40
- - ext/rpm/version.c
41
- - ext/rpm/file.c
42
- - ext/rpm/private.h
38
+ - ext/rpm/rpm.c
43
39
  - ext/rpm/ruby-rpm.h
40
+ - ext/rpm/source.c
44
41
  - ext/rpm/rpm40_compat.c
42
+ - ext/rpm/private.h
43
+ - ext/rpm/rpm40_compat.h
44
+ - ext/rpm/db.c
45
45
  - ext/rpm/dependency.c
46
46
  - ext/rpm/package.c
47
- - ext/rpm/db.c
48
- - ext/rpm/rpm40_compat.h
49
- - ext/rpm/rpm.c
47
+ - ext/rpm/extconf.h
48
+ - ext/rpm/version.c
50
49
  - ext/rpm/spec.c
51
- - ext/rpm/source.c
50
+ - ext/rpm/file.c
52
51
  - ext/rpm/MANIFEST
53
52
  - ext/rpm/extconf.rb
54
- - tests/test_file.rb
55
53
  - tests/test_db.rb
56
- - tests/test_version.rb
57
- - tests/test_rpm.rb
58
- - tests/test_dependency.rb
59
- - tests/test_source.rb
60
54
  - tests/test_ts.rb
55
+ - tests/test_dependency.rb
61
56
  - tests/runner.rb
62
- - spec/fedora
57
+ - tests/test_version.rb
58
+ - tests/test_file.rb
59
+ - tests/test_source.rb
60
+ - tests/test_rpm.rb
63
61
  - spec/fedora/ruby-rpm.spec
64
- test_files:
65
- - tests/runner.rb
66
- rdoc_options: []
67
-
68
- extra_rdoc_files: []
62
+ has_rdoc: true
63
+ homepage: http://rubyforge.org/projects/ruby-rpm/
64
+ licenses: []
69
65
 
70
- executables: []
66
+ post_install_message:
67
+ rdoc_options: []
71
68
 
72
- extensions:
73
- - ext/rpm/extconf.rb
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.1
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
74
83
  requirements: []
75
84
 
76
- dependencies: []
77
-
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.5
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Ruby bindings for RPM
90
+ test_files:
91
+ - tests/runner.rb