mock build

This commit is contained in:
alexey
2025-03-15 00:01:18 +03:00
parent 9cf2aabc65
commit 998f87cee3
61 changed files with 3581 additions and 37 deletions

View File

@@ -0,0 +1,36 @@
module RPM
module C
typedef :pointer, :header
attach_function 'headerNew', [], :header
attach_function 'headerFree', [:header], :header
attach_function 'headerLink', [:header], :header
# ..
HEADERGET_DEFAULT = [0,
HEADERGET_MINMEM = (1 << 0)].freeze
HEADERGET_EXT = (1 << 1)
HEADERGET_RAW = (1 << 2)
HEADERGET_ALLOC = (1 << 3)
HEADERGET_ARGV = (1 << 4)
# ..
attach_function 'headerGet', %i[header rpmTagVal pointer uint32], :int
attach_function 'headerPut', %i[header pointer uint32], :int
# ...
attach_function 'headerFormat', %i[header string pointer], :pointer
# ...
# http://rpm.org/wiki/Releases/4.14.0 deprecated addMacro/delMacro
unless rpm_version_code >= ((4 << 16) + (14 << 8) + (0 << 0))
attach_function 'headerNVR', [:header, :pointer, :pointer, :pointer], :int
end
# ...
attach_function 'headerGetAsString', %i[header rpmTagVal], :string
# ...
attach_function 'headerPutString', %i[header rpmTagVal string], :int
# ...
attach_function 'headerPutUint32', %i[header rpmTagVal pointer rpm_count_t], :int
# ...
attach_function 'rpmReadPackageFile', %i[header FD_t string pointer], Rc
end
end

View File

@@ -0,0 +1,27 @@
module RPM
module C
CallbackType = enum(:rpmCallbackType, [
:unknown, 0,
:inst_progress, (1 << 0),
:inst_start, (1 << 1),
:inst_open_file, (1 << 2),
:inst_close_file, (1 << 3),
:trans_progress, (1 << 4),
:trans_start, (1 << 5),
:trans_stop, (1 << 6),
:uninst_progress, (1 << 7),
:uninst_start, (1 << 8),
:uninst_stop, (1 << 9),
:repackage_progress, (1 << 10),
:repackage_start, (1 << 11),
:repackage_stop, (1 << 12),
:unpack_error, (1 << 13),
:cpio_error, (1 << 14),
:script_error, (1 << 15)
])
typedef :pointer, :rpmCallbackData
callback :rpmCallbackFunction, %i[pointer rpmCallbackType rpm_loff_t rpm_loff_t fnpyKey rpmCallbackData], :pointer
end
end

View File

@@ -0,0 +1,6 @@
module RPM
module C
attach_function 'rpmShowProgress', %i[pointer rpmCallbackType rpm_loff_t rpm_loff_t fnpyKey pointer], :pointer
end
end

View File

@@ -0,0 +1,20 @@
module RPM
module C
typedef :pointer, :rpmdb
typedef :pointer, :rpmdbMatchIterator
RegexpMode = enum(:rpmMireMode, %i[
default strcmp regex glob
])
attach_function 'rpmdbCountPackages', %i[rpmdb string], :int
attach_function 'rpmdbGetIteratorOffset', [:rpmdbMatchIterator], :uint
attach_function 'rpmdbGetIteratorCount', [:rpmdbMatchIterator], :int
attach_function 'rpmdbSetIteratorRE', %i[rpmdbMatchIterator rpmTagVal rpmMireMode string], :int
attach_function 'rpmdbInitIterator', %i[rpmdb rpmDbiTagVal pointer size_t], :rpmdbMatchIterator
attach_function 'rpmdbNextIterator', [:rpmdb], :header
attach_function 'rpmdbFreeIterator', [:rpmdb], :rpmdbMatchIterator
end
end

View File

@@ -0,0 +1,43 @@
module RPM
module C
typedef :pointer, :rpmds
Sense = enum(:rpmsenseFlags_e, [
:any, 0,
:less, (1 << 1),
:greater, (1 << 2),
:equal, (1 << 3),
# bit 4 unused
:posttrans, (1 << 5),
:prereq, (1 << 6),
#
:pretrans, (1 << 7),
:interp, (1 << 8),
:script_pre, (1 << 9),
:script_post, (1 << 10),
:script_preun, (1 << 11),
:script_postun, (1 << 12),
:script_verify, (1 << 13),
:find_requires, (1 << 14),
:find_provides, (1 << 15),
#
:triggerin, (1 << 16),
:triggerun, (1 << 17),
:triggerpostun, (1 << 18),
:missingok, (1 << 19),
# 20 23 unused
:rpmlib, (1 << 24),
:triggerprein, (1 << 25),
:keyring, (1 << 26),
:strong, (1 << 27),
:config, (1 << 28)
])
typedef :rpmFlags, :rpmsenseFlags
# ...
attach_function 'rpmdsSingle', %i[rpmTagVal string string rpmsenseFlags], :rpmds
# ...
attach_function 'rpmdsCompare', %i[rpmds rpmds], :int
end
end

View File

@@ -0,0 +1,31 @@
module RPM
module C
FileAttrs = enum(:rpmfileAttrs, [
:none, 0,
:config, (1 << 0),
:doc, (1 << 1),
:icon, (1 << 2),
:missingok, (1 << 3),
:noreplace, (1 << 4),
:specfile, (1 << 5),
:ghost, (1 << 6),
:license, (1 << 7),
:readme, (1 << 8),
:exclude, (1 << 9),
:unpatched, (1 << 10),
:pubkey, (1 << 11)
])
typedef :rpmFlags, :rpmfileAttrs
FileState = enum(:rpmfileState,
:missing, -1,
:normal, 0,
:replaced, 1,
:notinstalled, 2,
:netshared, 3,
:wrongcolor, 4)
typedef :pointer, :rpmRelocation
end
end

View File

@@ -0,0 +1,19 @@
module RPM
module C
typedef :pointer, :FD_t
# RPMIO
attach_function 'Fstrerror', [:FD_t], :string
# ...
attach_function 'Fclose', [:FD_t], :int
# ...
attach_function 'Fopen', %i[string string], :FD_t
# ...
attach_function 'Ferror', [:FD_t], :int
attach_function 'fdDup', [:int], :FD_t
attach_function 'Fstrerror', [:FD_t], :string
attach_function 'fdLink', [:pointer], :FD_t
end
end

View File

@@ -0,0 +1,12 @@
module RPM
module C
attach_variable :RPMVERSION, :RPMVERSION, :string
attach_variable :RPMEVR, :rpmEVR, :string
attach_function 'rpmReadConfigFiles', %i[string string], :int
# ...
attach_function 'rpmvercmp', %i[string string], :int
end
end

View File

@@ -0,0 +1,23 @@
module RPM
module C
# rpmlog
RPMLOG_PRIMASK = 0x07
Log = enum(
:emerg, 0,
:alert, 1,
:crit, 2,
:err, 3,
:warning, 4,
:notice, 5,
:info, 6,
:debug, 7
)
attach_function 'rpmlogSetMask', [:int], :int
# TODO: defines to set verbosity
# ...
attach_function 'rpmlogMessage', [], :string
end
end

View File

@@ -0,0 +1,33 @@
module RPM
module C
attach_variable :MACROFILES, :macrofiles, :string
# ...
# Markers for sources of macros added throughout rpm.
RMIL_DEFAULT = -15
RMIL_MACROFILES = -13
RMIL_RPMRC = -11
RMIL_CMDLINE = -7
RMIL_TARBALL = -5
RMIL_SPEC = -3
RMIL_OLDSPEC = -1
RMIL_GLOBAL = 0
# ...
# http://rpm.org/wiki/Releases/4.14.0 deprecated addMacro/delMacro
if rpm_version_code >= ((4 << 16) + (14 << 8) + (0 << 0))
attach_function 'rpmPushMacro', [:pointer, :string, :string, :string, :int], :void
attach_function 'rpmPopMacro', [:pointer, :string], :void
attach_function 'rpmExpandMacros', [:pointer, :pointer, :pointer, :int], :int
else
attach_function 'addMacro', [:pointer, :string, :string, :string, :int], :void
attach_function 'delMacro', [:pointer, :string], :void
attach_function 'expandMacros', [:pointer, :pointer, :pointer, :size_t], :int
end
# ...
# ...
attach_function 'rpmInitMacros', %i[pointer string], :void
# ...
end
end

View File

@@ -0,0 +1,53 @@
module RPM
module C
typedef :pointer, :rpmProblem
ProbFilter = enum(:rpmprobFilterFlags_e, [
:none, 0,
:ignoreos, (1 << 0),
:ignorearch, (1 << 1),
:replacepkg, (1 << 2),
:forcerelocate, (1 << 3),
:replacenewfiles, (1 << 4),
:replaceoldfiles, (1 << 5),
:oldpackage, (1 << 6),
:diskspace, (1 << 7),
:disknodes, (1 << 8)
])
typedef :rpmFlags, :rpmprobFilterFlags
ProblemType = enum(:rpmProblemType, %i[
badarch
bados
pkg_installed
badrelocate
requires
conflict
new_file_conflict
file_conflict
oldpackage
diskspace
disknodes
obsoletes
])
attach_function 'rpmProblemCreate', %i[rpmProblemType string fnpyKey string string uint64], :rpmProblem
attach_function 'rpmProblemFree', [:rpmProblem], :rpmProblem
attach_function 'rpmProblemLink', [:rpmProblem], :rpmProblem
attach_function 'rpmProblemGetType', [:rpmProblem], :rpmProblemType
attach_function 'rpmProblemGetKey', [:rpmProblem], :fnpyKey
attach_function 'rpmProblemGetStr', [:rpmProblem], :string
attach_function 'rpmProblemString', [:rpmProblem], :string
begin
attach_function 'rpmProblemCompare', %i[rpmProblem rpmProblem], :int
rescue ::FFI::NotFoundError
# TODO: Implement this for librpm 4.8.
def self.rpmProblemCompare(_a, _b)
raise NotImplementedError, 'rpmProblemCompare is not present in librpm 4.8 and below'
end
end
end
end

View File

@@ -0,0 +1,11 @@
module RPM
module C
typedef :pointer, :rpmps
typedef :pointer, :rpmpsi
attach_function 'rpmpsInitIterator', [:rpmps], :rpmpsi
attach_function 'rpmpsNextIterator', [:rpmpsi], :int
attach_function 'rpmpsGetProblem', [:rpmpsi], :rpmProblem
attach_function 'rpmpsFree', [:rpmps], :rpmps
end
end

View File

@@ -0,0 +1,304 @@
module RPM
module C
Tag = enum(:rpmTag, [
:not_found, -1,
:headerimage, 61,
:headersignatures, 62,
:headerimmutable, 63,
:headerregions, 64,
:headeri18ntable, 100,
:sig_base, 256,
:sigsize, 256 + 1,
:siglemd5_1, 256 + 2,
:sigpgp, 256 + 3,
:siglemd5_2, 256 + 4,
:sigmd5, 256 + 5,
:siggpg, 256 + 6,
:sigpgp5, 256 + 7,
:badsha1_1, 256 + 8,
:badsha1_2, 256 + 9,
:pubkeys, 256 + 10,
:dsaheader, 256 + 11,
:rsaheader, 256 + 12,
:sha1header, 256 + 13,
:longsigsize, 256 + 14,
:longarchivesize, 256 + 15,
:name, 1000,
:version, 1001,
:release, 1002,
:epoch, 1003,
:summary, 1004,
:description, 1005,
:buildtime, 1006,
:buildhost, 1007,
:installtime, 1008,
:size, 1009,
:distribution, 1010,
:vendor, 1011,
:gif, 1012,
:xpm, 1013,
:license, 1014,
:packager, 1015,
:group, 1016,
:changelog, 1017,
:source, 1018,
:patch, 1019,
:url, 1020,
:os, 1021,
:arch, 1022,
:prein, 1023,
:postin, 1024,
:preun, 1025,
:postun, 1026,
:oldfilenames, 1027,
:filesizes, 1028,
:filestates, 1029,
:filemodes, 1030,
:fileuids, 1031,
:filegids, 1032,
:filerdevs, 1033,
:filemtimes, 1034,
:filedigests, 1035,
:filemd5s, 1035,
:filelinktos, 1036,
:fileflags, 1037,
:root, 1038,
:fileusername, 1039,
:filegroupname, 1040,
:exclude, 1041,
:exclusive, 1042,
:icon, 1043,
:sourcerpm, 1044,
:fileverifyflags, 1045,
:archivesize, 1046,
:providename, 1047,
:requireflags, 1048,
:requirename, 1049,
:requireversion, 1050,
:nosource, 1051,
:nopatch, 1052,
:conflictflags, 1053,
:conflictname, 1054,
:conflictversion, 1055,
:defaultprefix, 1056,
:buildroot, 1057,
:installprefix, 1058,
:excludearch, 1059,
:excludeos, 1060,
:exclusivearch, 1061,
:exclusiveos, 1062,
:autoreqprov, 1063,
:rpmversion, 1064,
:triggerscripts, 1065,
:triggername, 1066,
:triggerversion, 1067,
:triggerflags, 1068,
:triggerindex, 1069,
:verifyscript, 1079,
:changelogtime, 1080,
:changelogname, 1081,
:changelogtext, 1082,
:brokenmd5, 1083,
:prereq, 1084,
:preinprog, 1085,
:postinprog, 1086,
:preunprog, 1087,
:postunprog, 1088,
:buildarchs, 1089,
:obsoletename, 1090,
:verifyscriptprog, 1091,
:triggerscriptprog, 1092,
:docdir, 1093,
:cookie, 1094,
:filedevices, 1095,
:fileinodes, 1096,
:filelangs, 1097,
:prefixes, 1098,
:instprefixes, 1099,
:triggerin, 1100,
:triggerun, 1101,
:triggerpostun, 1102,
:autoreq, 1103,
:autoprov, 1104,
:capability, 1105,
:sourcepackage, 1106,
:oldorigfilenames, 1107,
:buildprereq, 1108,
:buildrequires, 1109,
:buildconflicts, 1110,
:buildmacros, 1111,
:provideflags, 1112,
:provideversion, 1113,
:obsoleteflags, 1114,
:obsoleteversion, 1115,
:dirindexes, 1116,
:basenames, 1117,
:dirnames, 1118,
:origdirindexes, 1119,
:origbasenames, 1120,
:origdirnames, 1121,
:optflags, 1122,
:disturl, 1123,
:payloadformat, 1124,
:payloadcompressor, 1125,
:payloadflags, 1126,
:installcolor, 1127,
:installtid, 1128,
:removetid, 1129,
:sha1rhn, 1130,
:rhnplatform, 1131,
:platform, 1132,
:patchesname, 1133,
:patchesflags, 1134,
:patchesversion, 1135,
:cachectime, 1136,
:cachepkgpath, 1137,
:cachepkgsize, 1138,
:cachepkgmtime, 1139,
:filecolors, 1140,
:fileclass, 1141,
:classdict, 1142,
:filedependsx, 1143,
:filedependsn, 1144,
:dependsdict, 1145,
:sourcepkgid, 1146,
:filecontexts, 1147,
:fscontexts, 1148,
:recontexts, 1149,
:policies, 1150,
:pretrans, 1151,
:posttrans, 1152,
:pretransprog, 1153,
:posttransprog, 1154,
:disttag, 1155,
:suggestsname, 1156,
:suggestsversion, 1157,
:suggestsflags, 1158,
:enhancesname, 1159,
:enhancesversion, 1160,
:enhancesflags, 1161,
:priority, 1162,
:cvsid, 1163,
:blinkpkgid, 1164,
:blinkhdrid, 1165,
:blinknevra, 1166,
:flinkpkgid, 1167,
:flinkhdrid, 1168,
:flinknevra, 1169,
:packageorigin, 1170,
:triggerprein, 1171,
:buildsuggests, 1172,
:buildenhances, 1173,
:scriptstates, 1174,
:scriptmetrics, 1175,
:buildcpuclock, 1176,
:filedigestalgos, 1177,
:variants, 1178,
:xmajor, 1179,
:xminor, 1180,
:repotag, 1181,
:keywords, 1182,
:buildplatforms, 1183,
:packagecolor, 1184,
:packageprefcolor, 1185,
:xattrsdict, 1186,
:filexattrsx, 1187,
:depattrsdict, 1188,
:conflictattrsx, 1189,
:obsoleteattrsx, 1190,
:provideattrsx, 1191,
:requireattrsx, 1192,
:buildprovides, 1193,
:buildobsoletes, 1194,
:dbinstance, 1195,
:nvra, 1196,
:filenames, 5000,
:fileprovide, 5001,
:filerequire, 5002,
:fsnames, 5003,
:fssizes, 5004,
:triggerconds, 5005,
:triggertype, 5006,
:origfilenames, 5007,
:longfilesizes, 5008,
:longsize, 5009,
:filecaps, 5010,
:filedigestalgo, 5011,
:bugurl, 5012,
:evr, 5013,
:nvr, 5014,
:nevr, 5015,
:nevra, 5016,
:headercolor, 5017,
:verbose, 5018,
:epochnum, 5019,
:preinflags, 5020,
:postinflags, 5021,
:preunflags, 5022,
:postunflags, 5023,
:pretransflags, 5024,
:posttransflags, 5025,
:verifyscriptflags, 5026,
:triggerscriptflags, 5027,
:collections, 5029,
:policynames, 5030,
:policytypes, 5031,
:policytypesindexes, 5032,
:policyflags, 5033,
:vcs, 5034,
:ordername, 5035,
:orderversion, 5036,
:orderflags, 5037,
:firstfree_tag
])
Dbi = enum(:rpmDbiTag_e, [
:packages, 0,
:label, 2,
:name, Tag[:name],
:basenames, Tag[:basenames],
:group, Tag[:group],
:requirename, Tag[:requirename],
:providename, Tag[:providename],
:conflictname, Tag[:conflictname],
:obsoletename, Tag[:obsoletename],
:triggername, Tag[:triggername],
:dirnames, Tag[:dirnames],
:installtid, Tag[:installtid],
:sigmd5, Tag[:sigmd5],
:sha1header, Tag[:sha1header]
])
TagType = enum(:rpmTagType, [
:null_type, 0,
:char_type, 1,
:int8_type, 2,
:int16_type, 3,
:int32_type, 4,
:int64_type, 5,
:string_type, 6,
:bin_type, 7,
:string_array_type, 8,
:i18nstring_type, 9
])
TagReturnType = enum(:rpmTagReturnType_e, [
:any_return_type, 0,
:scalar_return_type, 0x00010000,
:array_return_type, 0x00020000,
:mapping_return_type, 0x00040000,
:mask_return_type, 0xffff0000
])
typedef :rpmFlags, :rpmTagReturnType
begin
attach_function 'rpmTagGetReturnType', [:rpmTagVal], :rpmTagReturnType
rescue ::FFI::NotFoundError
attach_function 'rpmTagGetType', [:rpmTagVal], :rpmTagType
def self.rpmTagGetReturnType(tag)
TagReturnType[rpmTagGetType(tag) & TagReturnType[:mask_return_type]]
end
end
end
end

View File

@@ -0,0 +1,34 @@
module RPM
module C
typedef :pointer, :rpmtd
attach_function 'rpmtdNew', [], :pointer
attach_function 'rpmtdFree', [:rpmtd], :pointer
attach_function 'rpmtdReset', [:rpmtd], :void
attach_function 'rpmtdFreeData', [:rpmtd], :void
attach_function 'rpmtdCount', [:rpmtd], :uint32
attach_function 'rpmtdTag', [:rpmtd], :rpmTagVal
attach_function 'rpmtdType', [:rpmtd], TagType
# ...
attach_function 'rpmtdInit', [:rpmtd], :int
attach_function 'rpmtdNext', [:rpmtd], :int
# ...
attach_function 'rpmtdNextUint32', [:rpmtd], :pointer
attach_function 'rpmtdNextUint64', [:rpmtd], :pointer
attach_function 'rpmtdNextString', [:rpmtd], :string
attach_function 'rpmtdGetChar', [:rpmtd], :pointer
attach_function 'rpmtdGetUint16', [:rpmtd], :pointer
attach_function 'rpmtdGetUint32', [:rpmtd], :pointer
attach_function 'rpmtdGetUint64', [:rpmtd], :pointer
attach_function 'rpmtdGetString', [:rpmtd], :string
attach_function 'rpmtdGetNumber', [:rpmtd], :uint64
# ...
attach_function 'rpmtdFromUint8', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
attach_function 'rpmtdFromUint16', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
attach_function 'rpmtdFromUint32', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
attach_function 'rpmtdFromUint64', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
attach_function 'rpmtdFromString', %i[rpmtd rpmTagVal string], :int
attach_function 'rpmtdFromStringArray', %i[rpmtd rpmTagVal pointer rpm_count_t], :int
# ...
end
end

View File

@@ -0,0 +1,71 @@
module RPM
module C
TransFlags = enum(:rpmtransFlags_e, [
:none, 0,
:test, (1 << 0),
:build_probs, (1 << 1),
:noscripts, (1 << 2),
:justdb, (1 << 3),
:notriggers, (1 << 4),
:nodocs, (1 << 5),
:allfiles, (1 << 6),
# bit 7 unused
:nocontexts, (1 << 8),
# bits 9-15 unused
:notriggerprein, (1 << 16),
:nopre, (1 << 17),
:nopost, (1 << 18),
:notriggerin, (1 << 19),
:notriggerun, (1 << 20),
:nopreun, (1 << 21),
:nopostun, (1 << 22),
:notriggerpostun, (11 << 23),
# bits 24-25 unused
:nocollections, (1 << 26),
:nomd5, (1 << 27),
:nofiledigest, (1 << 27),
# bits 28-29 unused
:noconfigs, (1 << 30),
:deploops, (1 << 31)
])
typedef :pointer, :rpmts
typedef :pointer, :rpmps
typedef :rpmFlags, :rpmtransFlags
attach_function 'rpmtsCheck', [:rpmts], :int
attach_function 'rpmtsOrder', [:rpmts], :int
attach_function 'rpmtsRun', %i[rpmts rpmps int], :int
attach_function 'rpmtsLink', [:rpmts], :rpmts
attach_function 'rpmtsCloseDB', [:rpmts], :int
attach_function 'rpmtsOpenDB', %i[rpmts int], :int
attach_function 'rpmtsInitDB', %i[rpmts int], :int
attach_function 'rpmtsGetDBMode', [:rpmts], :int
attach_function 'rpmtsSetDBMode', %i[rpmts int], :int
attach_function 'rpmtsRebuildDB', [:rpmts], :int
attach_function 'rpmtsVerifyDB', [:rpmts], :int
attach_function 'rpmtsInitIterator', %i[rpmts rpmDbiTagVal pointer int], :rpmdbMatchIterator
# ...
attach_function 'rpmtsProblems', [:rpmts], :rpmps
# ...
attach_function 'rpmtsClean', [:rpmts], :void
# more...
attach_function 'rpmtsFree', [:rpmts], :pointer
# ..
attach_function 'rpmtsSetNotifyCallback', %i[rpmts rpmCallbackFunction rpmCallbackData], :int
# ...
attach_function 'rpmtsRootDir', [:rpmts], :string
attach_function 'rpmtsSetRootDir', %i[rpmts string], :int
# ...
attach_function 'rpmtsGetRdb', [:rpmts], :rpmdb
# ..
attach_function 'rpmtsFlags', [:rpmts], :rpmtransFlags
attach_function 'rpmtsSetFlags', %i[rpmts rpmtransFlags], :rpmtransFlags
# ...
attach_function 'rpmtsSetNotifyCallback', %i[rpmts rpmCallbackFunction rpmCallbackData], :int
# ...
attach_function 'rpmtsCreate', [], :rpmts
attach_function 'rpmtsAddInstallElement', %i[rpmts header fnpyKey int rpmRelocation], :int
attach_function 'rpmtsAddEraseElement', %i[rpmts header int], :int
end
end

View File

@@ -0,0 +1,28 @@
module RPM
module C
Rc = enum(
:ok, 0,
:notfound, 1,
:fail, 2,
:nottrusted, 3,
:nokey, 4
)
typedef :int32, :rpm_tag_t
typedef :uint32, :rpm_tagtype_t
typedef :uint32, :rpm_count_t
typedef :rpm_tag_t, :rpmTagVal
typedef :rpm_tag_t, :rpmDbiTagVal
typedef :uint32, :rpmFlags
typedef :uint32, :rpm_off_t
typedef :uint64, :rpm_loff_t
typedef :pointer, :FD_t
typedef :pointer, :fnpyKey
typedef :pointer, :rpmCallbackData
typedef :uint64, :rpm_loff_t
end
end