rpm2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/workflows/ci.yaml +25 -0
  4. data/.gitignore +8 -0
  5. data/.rubocop.yml +1 -0
  6. data/.rubocop_todo.yml +111 -0
  7. data/.whitesource +3 -0
  8. data/CHANGELOG.md +66 -0
  9. data/Gemfile +9 -0
  10. data/MIT-LICENSE +23 -0
  11. data/README.md +374 -0
  12. data/Rakefile +58 -0
  13. data/_docker/Dockerfile.ubi8 +8 -0
  14. data/_docker/Dockerfile.ubi9 +8 -0
  15. data/lib/rpm/c/header.rb +36 -0
  16. data/lib/rpm/c/rpmcallback.rb +27 -0
  17. data/lib/rpm/c/rpmcli.rb +6 -0
  18. data/lib/rpm/c/rpmdb.rb +20 -0
  19. data/lib/rpm/c/rpmds.rb +43 -0
  20. data/lib/rpm/c/rpmfi.rb +31 -0
  21. data/lib/rpm/c/rpmio.rb +17 -0
  22. data/lib/rpm/c/rpmlib.rb +12 -0
  23. data/lib/rpm/c/rpmlog.rb +23 -0
  24. data/lib/rpm/c/rpmmacro.rb +33 -0
  25. data/lib/rpm/c/rpmprob.rb +53 -0
  26. data/lib/rpm/c/rpmps.rb +11 -0
  27. data/lib/rpm/c/rpmtag.rb +304 -0
  28. data/lib/rpm/c/rpmtd.rb +34 -0
  29. data/lib/rpm/c/rpmts.rb +69 -0
  30. data/lib/rpm/c/rpmtypes.rb +28 -0
  31. data/lib/rpm/c.rb +49 -0
  32. data/lib/rpm/compat.rb +40 -0
  33. data/lib/rpm/db.rb +117 -0
  34. data/lib/rpm/dependency.rb +120 -0
  35. data/lib/rpm/file.rb +134 -0
  36. data/lib/rpm/gem_version.rb +7 -0
  37. data/lib/rpm/match_iterator.rb +66 -0
  38. data/lib/rpm/package.rb +332 -0
  39. data/lib/rpm/problem.rb +65 -0
  40. data/lib/rpm/transaction.rb +268 -0
  41. data/lib/rpm/utils.rb +7 -0
  42. data/lib/rpm/version.rb +146 -0
  43. data/lib/rpm.rb +88 -0
  44. data/lib/rpm2.rb +1 -0
  45. data/rpm2.gemspec +29 -0
  46. data/test/data/a.spec +49 -0
  47. data/test/data/simple-1.0-0.i586.rpm +0 -0
  48. data/test/data/simple.spec +38 -0
  49. data/test/data/simple_with_deps-1.0-0.i586.rpm +0 -0
  50. data/test/data/simple_with_deps.spec +41 -0
  51. data/test/helper.rb +7 -0
  52. data/test/test_dependency.rb +28 -0
  53. data/test/test_file.rb +36 -0
  54. data/test/test_lib.rb +33 -0
  55. data/test/test_package.rb +76 -0
  56. data/test/test_problem.rb +18 -0
  57. data/test/test_rpm.rb +33 -0
  58. data/test/test_transaction.rb +156 -0
  59. data/test/test_version.rb +64 -0
  60. metadata +133 -0
@@ -0,0 +1,8 @@
1
+ FROM registry.access.redhat.com/ubi9/ubi
2
+ RUN dnf module -y enable ruby:3.3
3
+ RUN dnf install -y ruby git
4
+ RUN gem install bundler
5
+ WORKDIR /src
6
+ RUN ls -lR
7
+ COPY ../ /src
8
+ RUN bundle install
@@ -0,0 +1,36 @@
1
+
2
+ module RPM
3
+ module C
4
+ typedef :pointer, :header
5
+
6
+ attach_function 'headerNew', [], :header
7
+ attach_function 'headerFree', [:header], :header
8
+ attach_function 'headerLink', [:header], :header
9
+ # ..
10
+ HEADERGET_DEFAULT = [0,
11
+ HEADERGET_MINMEM = (1 << 0)].freeze
12
+ HEADERGET_EXT = (1 << 1)
13
+ HEADERGET_RAW = (1 << 2)
14
+ HEADERGET_ALLOC = (1 << 3)
15
+ HEADERGET_ARGV = (1 << 4)
16
+
17
+ # ..
18
+ attach_function 'headerGet', %i[header rpmTagVal pointer uint32], :int
19
+ attach_function 'headerPut', %i[header pointer uint32], :int
20
+ # ...
21
+ attach_function 'headerFormat', %i[header string pointer], :pointer
22
+ # ...
23
+ # http://rpm.org/wiki/Releases/4.14.0 deprecated addMacro/delMacro
24
+ unless rpm_version_code >= ((4 << 16) + (14 << 8) + (0 << 0))
25
+ attach_function 'headerNVR', [:header, :pointer, :pointer, :pointer], :int
26
+ end
27
+ # ...
28
+ attach_function 'headerGetAsString', %i[header rpmTagVal], :string
29
+ # ...
30
+ attach_function 'headerPutString', %i[header rpmTagVal string], :int
31
+ # ...
32
+ attach_function 'headerPutUint32', %i[header rpmTagVal pointer rpm_count_t], :int
33
+ # ...
34
+ attach_function 'rpmReadPackageFile', %i[header FD_t string pointer], Rc
35
+ end
36
+ end
@@ -0,0 +1,27 @@
1
+
2
+ module RPM
3
+ module C
4
+ CallbackType = enum(:rpmCallbackType, [
5
+ :unknown, 0,
6
+ :inst_progress, (1 << 0),
7
+ :inst_start, (1 << 1),
8
+ :inst_open_file, (1 << 2),
9
+ :inst_close_file, (1 << 3),
10
+ :trans_progress, (1 << 4),
11
+ :trans_start, (1 << 5),
12
+ :trans_stop, (1 << 6),
13
+ :uninst_progress, (1 << 7),
14
+ :uninst_start, (1 << 8),
15
+ :uninst_stop, (1 << 9),
16
+ :repackage_progress, (1 << 10),
17
+ :repackage_start, (1 << 11),
18
+ :repackage_stop, (1 << 12),
19
+ :unpack_error, (1 << 13),
20
+ :cpio_error, (1 << 14),
21
+ :script_error, (1 << 15)
22
+ ])
23
+
24
+ typedef :pointer, :rpmCallbackData
25
+ callback :rpmCallbackFunction, %i[pointer rpmCallbackType rpm_loff_t rpm_loff_t fnpyKey rpmCallbackData], :pointer
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module RPM
3
+ module C
4
+ attach_function 'rpmShowProgress', %i[pointer rpmCallbackType rpm_loff_t rpm_loff_t fnpyKey pointer], :pointer
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ module RPM
2
+ module C
3
+ typedef :pointer, :rpmdb
4
+ typedef :pointer, :rpmdbMatchIterator
5
+
6
+ RegexpMode = enum(:rpmMireMode, %i[
7
+ default strcmp regex glob
8
+ ])
9
+
10
+ attach_function 'rpmdbCountPackages', %i[rpmdb string], :int
11
+ attach_function 'rpmdbGetIteratorOffset', [:rpmdbMatchIterator], :uint
12
+ attach_function 'rpmdbGetIteratorCount', [:rpmdbMatchIterator], :int
13
+ attach_function 'rpmdbSetIteratorRE', %i[rpmdbMatchIterator rpmTagVal rpmMireMode string], :int
14
+
15
+ attach_function 'rpmdbInitIterator', %i[rpmdb rpmDbiTagVal pointer size_t], :rpmdbMatchIterator
16
+
17
+ attach_function 'rpmdbNextIterator', [:rpmdb], :header
18
+ attach_function 'rpmdbFreeIterator', [:rpmdb], :rpmdbMatchIterator
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+
2
+ module RPM
3
+ module C
4
+ typedef :pointer, :rpmds
5
+
6
+ Sense = enum(:rpmsenseFlags_e, [
7
+ :any, 0,
8
+ :less, (1 << 1),
9
+ :greater, (1 << 2),
10
+ :equal, (1 << 3),
11
+ # bit 4 unused
12
+ :posttrans, (1 << 5),
13
+ :prereq, (1 << 6),
14
+ #
15
+ :pretrans, (1 << 7),
16
+ :interp, (1 << 8),
17
+ :script_pre, (1 << 9),
18
+ :script_post, (1 << 10),
19
+ :script_preun, (1 << 11),
20
+ :script_postun, (1 << 12),
21
+ :script_verify, (1 << 13),
22
+ :find_requires, (1 << 14),
23
+ :find_provides, (1 << 15),
24
+ #
25
+ :triggerin, (1 << 16),
26
+ :triggerun, (1 << 17),
27
+ :triggerpostun, (1 << 18),
28
+ :missingok, (1 << 19),
29
+ # 20 23 unused
30
+ :rpmlib, (1 << 24),
31
+ :triggerprein, (1 << 25),
32
+ :keyring, (1 << 26),
33
+ :strong, (1 << 27),
34
+ :config, (1 << 28)
35
+ ])
36
+ typedef :rpmFlags, :rpmsenseFlags
37
+
38
+ # ...
39
+ attach_function 'rpmdsSingle', %i[rpmTagVal string string rpmsenseFlags], :rpmds
40
+ # ...
41
+ attach_function 'rpmdsCompare', %i[rpmds rpmds], :int
42
+ end
43
+ end
@@ -0,0 +1,31 @@
1
+
2
+ module RPM
3
+ module C
4
+ FileAttrs = enum(:rpmfileAttrs, [
5
+ :none, 0,
6
+ :config, (1 << 0),
7
+ :doc, (1 << 1),
8
+ :icon, (1 << 2),
9
+ :missingok, (1 << 3),
10
+ :noreplace, (1 << 4),
11
+ :specfile, (1 << 5),
12
+ :ghost, (1 << 6),
13
+ :license, (1 << 7),
14
+ :readme, (1 << 8),
15
+ :exclude, (1 << 9),
16
+ :unpatched, (1 << 10),
17
+ :pubkey, (1 << 11)
18
+ ])
19
+ typedef :rpmFlags, :rpmfileAttrs
20
+
21
+ FileState = enum(:rpmfileState,
22
+ :missing, -1,
23
+ :normal, 0,
24
+ :replaced, 1,
25
+ :notinstalled, 2,
26
+ :netshared, 3,
27
+ :wrongcolor, 4)
28
+
29
+ typedef :pointer, :rpmRelocation
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ module RPM
2
+ module C
3
+ typedef :pointer, :FD_t
4
+ # RPMIO
5
+ attach_function 'Fstrerror', [:FD_t], :string
6
+ # ...
7
+ attach_function 'Fclose', [:FD_t], :int
8
+ # ...
9
+ attach_function 'Fopen', %i[string string], :FD_t
10
+ # ...
11
+ attach_function 'Ferror', [:FD_t], :int
12
+
13
+ attach_function 'fdDup', [:int], :FD_t
14
+
15
+ attach_function 'fdLink', [:pointer], :FD_t
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+
2
+ module RPM
3
+ module C
4
+ attach_variable :RPMVERSION, :RPMVERSION, :string
5
+ attach_variable :RPMEVR, :rpmEVR, :string
6
+
7
+ attach_function 'rpmReadConfigFiles', %i[string string], :int
8
+
9
+ # ...
10
+ attach_function 'rpmvercmp', %i[string string], :int
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module RPM
3
+ module C
4
+ # rpmlog
5
+ RPMLOG_PRIMASK = 0x07
6
+
7
+ Log = enum(
8
+ :emerg, 0,
9
+ :alert, 1,
10
+ :crit, 2,
11
+ :err, 3,
12
+ :warning, 4,
13
+ :notice, 5,
14
+ :info, 6,
15
+ :debug, 7
16
+ )
17
+
18
+ attach_function 'rpmlogSetMask', [:int], :int
19
+ # TODO: defines to set verbosity
20
+ # ...
21
+ attach_function 'rpmlogMessage', [], :string
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+
2
+ module RPM
3
+ module C
4
+ attach_variable :MACROFILES, :macrofiles, :string
5
+ # ...
6
+
7
+ # Markers for sources of macros added throughout rpm.
8
+ RMIL_DEFAULT = -15
9
+ RMIL_MACROFILES = -13
10
+ RMIL_RPMRC = -11
11
+ RMIL_CMDLINE = -7
12
+ RMIL_TARBALL = -5
13
+ RMIL_SPEC = -3
14
+ RMIL_OLDSPEC = -1
15
+ RMIL_GLOBAL = 0
16
+
17
+ # ...
18
+ # http://rpm.org/wiki/Releases/4.14.0 deprecated addMacro/delMacro
19
+ if rpm_version_code >= ((4 << 16) + (14 << 8) + (0 << 0))
20
+ attach_function 'rpmPushMacro', [:pointer, :string, :string, :string, :int], :void
21
+ attach_function 'rpmPopMacro', [:pointer, :string], :void
22
+ attach_function 'rpmExpandMacros', [:pointer, :pointer, :pointer, :int], :int
23
+ else
24
+ attach_function 'addMacro', [:pointer, :string, :string, :string, :int], :void
25
+ attach_function 'delMacro', [:pointer, :string], :void
26
+ attach_function 'expandMacros', [:pointer, :pointer, :pointer, :size_t], :int
27
+ end
28
+ # ...
29
+ # ...
30
+ attach_function 'rpmInitMacros', %i[pointer string], :void
31
+ # ...
32
+ end
33
+ end
@@ -0,0 +1,53 @@
1
+
2
+ module RPM
3
+ module C
4
+ typedef :pointer, :rpmProblem
5
+
6
+ ProbFilter = enum(:rpmprobFilterFlags_e, [
7
+ :none, 0,
8
+ :ignoreos, (1 << 0),
9
+ :ignorearch, (1 << 1),
10
+ :replacepkg, (1 << 2),
11
+ :forcerelocate, (1 << 3),
12
+ :replacenewfiles, (1 << 4),
13
+ :replaceoldfiles, (1 << 5),
14
+ :oldpackage, (1 << 6),
15
+ :diskspace, (1 << 7),
16
+ :disknodes, (1 << 8)
17
+ ])
18
+
19
+ typedef :rpmFlags, :rpmprobFilterFlags
20
+
21
+ ProblemType = enum(:rpmProblemType, %i[
22
+ badarch
23
+ bados
24
+ pkg_installed
25
+ badrelocate
26
+ requires
27
+ conflict
28
+ new_file_conflict
29
+ file_conflict
30
+ oldpackage
31
+ diskspace
32
+ disknodes
33
+ obsoletes
34
+ ])
35
+
36
+ attach_function 'rpmProblemCreate', %i[rpmProblemType string fnpyKey string string uint64], :rpmProblem
37
+ attach_function 'rpmProblemFree', [:rpmProblem], :rpmProblem
38
+ attach_function 'rpmProblemLink', [:rpmProblem], :rpmProblem
39
+ attach_function 'rpmProblemGetType', [:rpmProblem], :rpmProblemType
40
+ attach_function 'rpmProblemGetKey', [:rpmProblem], :fnpyKey
41
+ attach_function 'rpmProblemGetStr', [:rpmProblem], :string
42
+ attach_function 'rpmProblemString', [:rpmProblem], :string
43
+
44
+ begin
45
+ attach_function 'rpmProblemCompare', %i[rpmProblem rpmProblem], :int
46
+ rescue ::FFI::NotFoundError
47
+ # TODO: Implement this for librpm 4.8.
48
+ def self.rpmProblemCompare(_a, _b)
49
+ raise NotImplementedError, 'rpmProblemCompare is not present in librpm 4.8 and below'
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ module RPM
2
+ module C
3
+ typedef :pointer, :rpmps
4
+ typedef :pointer, :rpmpsi
5
+
6
+ attach_function 'rpmpsInitIterator', [:rpmps], :rpmpsi
7
+ attach_function 'rpmpsNextIterator', [:rpmpsi], :int
8
+ attach_function 'rpmpsGetProblem', [:rpmpsi], :rpmProblem
9
+ attach_function 'rpmpsFree', [:rpmps], :rpmps
10
+ end
11
+ end
@@ -0,0 +1,304 @@
1
+ module RPM
2
+ module C
3
+ Tag = enum(:rpmTag, [
4
+ :not_found, -1,
5
+ :headerimage, 61,
6
+ :headersignatures, 62,
7
+ :headerimmutable, 63,
8
+ :headerregions, 64,
9
+ :headeri18ntable, 100,
10
+ :sig_base, 256,
11
+ :sigsize, 256 + 1,
12
+ :siglemd5_1, 256 + 2,
13
+ :sigpgp, 256 + 3,
14
+ :siglemd5_2, 256 + 4,
15
+ :sigmd5, 256 + 5,
16
+ :siggpg, 256 + 6,
17
+ :sigpgp5, 256 + 7,
18
+ :badsha1_1, 256 + 8,
19
+ :badsha1_2, 256 + 9,
20
+ :pubkeys, 256 + 10,
21
+ :dsaheader, 256 + 11,
22
+ :rsaheader, 256 + 12,
23
+ :sha1header, 256 + 13,
24
+ :longsigsize, 256 + 14,
25
+ :longarchivesize, 256 + 15,
26
+ :name, 1000,
27
+ :version, 1001,
28
+ :release, 1002,
29
+ :epoch, 1003,
30
+ :summary, 1004,
31
+ :description, 1005,
32
+ :buildtime, 1006,
33
+ :buildhost, 1007,
34
+ :installtime, 1008,
35
+ :size, 1009,
36
+ :distribution, 1010,
37
+ :vendor, 1011,
38
+ :gif, 1012,
39
+ :xpm, 1013,
40
+ :license, 1014,
41
+ :packager, 1015,
42
+ :group, 1016,
43
+ :changelog, 1017,
44
+ :source, 1018,
45
+ :patch, 1019,
46
+ :url, 1020,
47
+ :os, 1021,
48
+ :arch, 1022,
49
+ :prein, 1023,
50
+ :postin, 1024,
51
+ :preun, 1025,
52
+ :postun, 1026,
53
+ :oldfilenames, 1027,
54
+ :filesizes, 1028,
55
+ :filestates, 1029,
56
+ :filemodes, 1030,
57
+ :fileuids, 1031,
58
+ :filegids, 1032,
59
+ :filerdevs, 1033,
60
+ :filemtimes, 1034,
61
+ :filedigests, 1035,
62
+ :filemd5s, 1035,
63
+ :filelinktos, 1036,
64
+ :fileflags, 1037,
65
+ :root, 1038,
66
+ :fileusername, 1039,
67
+ :filegroupname, 1040,
68
+ :exclude, 1041,
69
+ :exclusive, 1042,
70
+ :icon, 1043,
71
+ :sourcerpm, 1044,
72
+ :fileverifyflags, 1045,
73
+ :archivesize, 1046,
74
+ :providename, 1047,
75
+ :requireflags, 1048,
76
+ :requirename, 1049,
77
+ :requireversion, 1050,
78
+ :nosource, 1051,
79
+ :nopatch, 1052,
80
+ :conflictflags, 1053,
81
+ :conflictname, 1054,
82
+ :conflictversion, 1055,
83
+ :defaultprefix, 1056,
84
+ :buildroot, 1057,
85
+ :installprefix, 1058,
86
+ :excludearch, 1059,
87
+ :excludeos, 1060,
88
+ :exclusivearch, 1061,
89
+ :exclusiveos, 1062,
90
+ :autoreqprov, 1063,
91
+ :rpmversion, 1064,
92
+ :triggerscripts, 1065,
93
+ :triggername, 1066,
94
+ :triggerversion, 1067,
95
+ :triggerflags, 1068,
96
+ :triggerindex, 1069,
97
+ :verifyscript, 1079,
98
+ :changelogtime, 1080,
99
+ :changelogname, 1081,
100
+ :changelogtext, 1082,
101
+ :brokenmd5, 1083,
102
+ :prereq, 1084,
103
+ :preinprog, 1085,
104
+ :postinprog, 1086,
105
+ :preunprog, 1087,
106
+ :postunprog, 1088,
107
+ :buildarchs, 1089,
108
+ :obsoletename, 1090,
109
+ :verifyscriptprog, 1091,
110
+ :triggerscriptprog, 1092,
111
+ :docdir, 1093,
112
+ :cookie, 1094,
113
+ :filedevices, 1095,
114
+ :fileinodes, 1096,
115
+ :filelangs, 1097,
116
+ :prefixes, 1098,
117
+ :instprefixes, 1099,
118
+ :triggerin, 1100,
119
+ :triggerun, 1101,
120
+ :triggerpostun, 1102,
121
+ :autoreq, 1103,
122
+ :autoprov, 1104,
123
+ :capability, 1105,
124
+ :sourcepackage, 1106,
125
+ :oldorigfilenames, 1107,
126
+ :buildprereq, 1108,
127
+ :buildrequires, 1109,
128
+ :buildconflicts, 1110,
129
+ :buildmacros, 1111,
130
+ :provideflags, 1112,
131
+ :provideversion, 1113,
132
+ :obsoleteflags, 1114,
133
+ :obsoleteversion, 1115,
134
+ :dirindexes, 1116,
135
+ :basenames, 1117,
136
+ :dirnames, 1118,
137
+ :origdirindexes, 1119,
138
+ :origbasenames, 1120,
139
+ :origdirnames, 1121,
140
+ :optflags, 1122,
141
+ :disturl, 1123,
142
+ :payloadformat, 1124,
143
+ :payloadcompressor, 1125,
144
+ :payloadflags, 1126,
145
+ :installcolor, 1127,
146
+ :installtid, 1128,
147
+ :removetid, 1129,
148
+ :sha1rhn, 1130,
149
+ :rhnplatform, 1131,
150
+ :platform, 1132,
151
+ :patchesname, 1133,
152
+ :patchesflags, 1134,
153
+ :patchesversion, 1135,
154
+ :cachectime, 1136,
155
+ :cachepkgpath, 1137,
156
+ :cachepkgsize, 1138,
157
+ :cachepkgmtime, 1139,
158
+ :filecolors, 1140,
159
+ :fileclass, 1141,
160
+ :classdict, 1142,
161
+ :filedependsx, 1143,
162
+ :filedependsn, 1144,
163
+ :dependsdict, 1145,
164
+ :sourcepkgid, 1146,
165
+ :filecontexts, 1147,
166
+ :fscontexts, 1148,
167
+ :recontexts, 1149,
168
+ :policies, 1150,
169
+ :pretrans, 1151,
170
+ :posttrans, 1152,
171
+ :pretransprog, 1153,
172
+ :posttransprog, 1154,
173
+ :disttag, 1155,
174
+ :suggestsname, 1156,
175
+ :suggestsversion, 1157,
176
+ :suggestsflags, 1158,
177
+ :enhancesname, 1159,
178
+ :enhancesversion, 1160,
179
+ :enhancesflags, 1161,
180
+ :priority, 1162,
181
+ :cvsid, 1163,
182
+ :blinkpkgid, 1164,
183
+ :blinkhdrid, 1165,
184
+ :blinknevra, 1166,
185
+ :flinkpkgid, 1167,
186
+ :flinkhdrid, 1168,
187
+ :flinknevra, 1169,
188
+ :packageorigin, 1170,
189
+ :triggerprein, 1171,
190
+ :buildsuggests, 1172,
191
+ :buildenhances, 1173,
192
+ :scriptstates, 1174,
193
+ :scriptmetrics, 1175,
194
+ :buildcpuclock, 1176,
195
+ :filedigestalgos, 1177,
196
+ :variants, 1178,
197
+ :xmajor, 1179,
198
+ :xminor, 1180,
199
+ :repotag, 1181,
200
+ :keywords, 1182,
201
+ :buildplatforms, 1183,
202
+ :packagecolor, 1184,
203
+ :packageprefcolor, 1185,
204
+ :xattrsdict, 1186,
205
+ :filexattrsx, 1187,
206
+ :depattrsdict, 1188,
207
+ :conflictattrsx, 1189,
208
+ :obsoleteattrsx, 1190,
209
+ :provideattrsx, 1191,
210
+ :requireattrsx, 1192,
211
+ :buildprovides, 1193,
212
+ :buildobsoletes, 1194,
213
+ :dbinstance, 1195,
214
+ :nvra, 1196,
215
+ :filenames, 5000,
216
+ :fileprovide, 5001,
217
+ :filerequire, 5002,
218
+ :fsnames, 5003,
219
+ :fssizes, 5004,
220
+ :triggerconds, 5005,
221
+ :triggertype, 5006,
222
+ :origfilenames, 5007,
223
+ :longfilesizes, 5008,
224
+ :longsize, 5009,
225
+ :filecaps, 5010,
226
+ :filedigestalgo, 5011,
227
+ :bugurl, 5012,
228
+ :evr, 5013,
229
+ :nvr, 5014,
230
+ :nevr, 5015,
231
+ :nevra, 5016,
232
+ :headercolor, 5017,
233
+ :verbose, 5018,
234
+ :epochnum, 5019,
235
+ :preinflags, 5020,
236
+ :postinflags, 5021,
237
+ :preunflags, 5022,
238
+ :postunflags, 5023,
239
+ :pretransflags, 5024,
240
+ :posttransflags, 5025,
241
+ :verifyscriptflags, 5026,
242
+ :triggerscriptflags, 5027,
243
+ :collections, 5029,
244
+ :policynames, 5030,
245
+ :policytypes, 5031,
246
+ :policytypesindexes, 5032,
247
+ :policyflags, 5033,
248
+ :vcs, 5034,
249
+ :ordername, 5035,
250
+ :orderversion, 5036,
251
+ :orderflags, 5037,
252
+ :firstfree_tag
253
+ ])
254
+
255
+ Dbi = enum(:rpmDbiTag_e, [
256
+ :packages, 0,
257
+ :label, 2,
258
+ :name, Tag[:name],
259
+ :basenames, Tag[:basenames],
260
+ :group, Tag[:group],
261
+ :requirename, Tag[:requirename],
262
+ :providename, Tag[:providename],
263
+ :conflictname, Tag[:conflictname],
264
+ :obsoletename, Tag[:obsoletename],
265
+ :triggername, Tag[:triggername],
266
+ :dirnames, Tag[:dirnames],
267
+ :installtid, Tag[:installtid],
268
+ :sigmd5, Tag[:sigmd5],
269
+ :sha1header, Tag[:sha1header]
270
+ ])
271
+
272
+ TagType = enum(:rpmTagType, [
273
+ :null_type, 0,
274
+ :char_type, 1,
275
+ :int8_type, 2,
276
+ :int16_type, 3,
277
+ :int32_type, 4,
278
+ :int64_type, 5,
279
+ :string_type, 6,
280
+ :bin_type, 7,
281
+ :string_array_type, 8,
282
+ :i18nstring_type, 9
283
+ ])
284
+
285
+ TagReturnType = enum(:rpmTagReturnType_e, [
286
+ :any_return_type, 0,
287
+ :scalar_return_type, 0x00010000,
288
+ :array_return_type, 0x00020000,
289
+ :mapping_return_type, 0x00040000,
290
+ :mask_return_type, 0xffff0000
291
+ ])
292
+ typedef :rpmFlags, :rpmTagReturnType
293
+
294
+ begin
295
+ attach_function 'rpmTagGetReturnType', [:rpmTagVal], :rpmTagReturnType
296
+ rescue ::FFI::NotFoundError
297
+ attach_function 'rpmTagGetType', [:rpmTagVal], :rpmTagType
298
+
299
+ def self.rpmTagGetReturnType(tag)
300
+ TagReturnType[rpmTagGetType(tag) & TagReturnType[:mask_return_type]]
301
+ end
302
+ end
303
+ end
304
+ end
@@ -0,0 +1,34 @@
1
+ module RPM
2
+ module C
3
+ typedef :pointer, :rpmtd
4
+
5
+ attach_function 'rpmtdNew', [], :pointer
6
+ attach_function 'rpmtdFree', [:rpmtd], :pointer
7
+ attach_function 'rpmtdReset', [:rpmtd], :void
8
+ attach_function 'rpmtdFreeData', [:rpmtd], :void
9
+ attach_function 'rpmtdCount', [:rpmtd], :uint32
10
+ attach_function 'rpmtdTag', [:rpmtd], :rpmTagVal
11
+ attach_function 'rpmtdType', [:rpmtd], TagType
12
+ # ...
13
+ attach_function 'rpmtdInit', [:rpmtd], :int
14
+ attach_function 'rpmtdNext', [:rpmtd], :int
15
+ # ...
16
+ attach_function 'rpmtdNextUint32', [:rpmtd], :pointer
17
+ attach_function 'rpmtdNextUint64', [:rpmtd], :pointer
18
+ attach_function 'rpmtdNextString', [:rpmtd], :string
19
+ attach_function 'rpmtdGetChar', [:rpmtd], :pointer
20
+ attach_function 'rpmtdGetUint16', [:rpmtd], :pointer
21
+ attach_function 'rpmtdGetUint32', [:rpmtd], :pointer
22
+ attach_function 'rpmtdGetUint64', [:rpmtd], :pointer
23
+ attach_function 'rpmtdGetString', [:rpmtd], :string
24
+ attach_function 'rpmtdGetNumber', [:rpmtd], :uint64
25
+ # ...
26
+ attach_function 'rpmtdFromUint8', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
27
+ attach_function 'rpmtdFromUint16', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
28
+ attach_function 'rpmtdFromUint32', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
29
+ attach_function 'rpmtdFromUint64', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
30
+ attach_function 'rpmtdFromString', %i[rpmtd rpmTagVal string], :int
31
+ attach_function 'rpmtdFromStringArray', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
32
+ # ...
33
+ end
34
+ end