RPM package file: Go parsing library

An RPM package consists of the lead, the signature (contains digests and signatures), the header (contains the package metadata) and the payload (a compressed archive of the package files).

This structure is shared by all package format versions supported by this Kaitai Struct implementation:

The versions differ mainly in the tags they use: v6 packages store all sizes as 64-bit integers, carry only cryptographic data in the signature and always use the stripped-down cpio archive format (see the payload instance).

The formats before v3, as well as the abandoned rpm5 fork, are not covered by this implementation.

Application

RPM Package Manager

File extension

["rpm", "srpm", "src.rpm", "drpm"]

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.11

References

This page hosts a formal specification of RPM package file using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

Go source code to parse RPM package file

rpm.go

// Code generated by kaitai-struct-compiler from a .ksy source file. DO NOT EDIT.

import (
	"github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
	"io"
	"bytes"
)


/**
 * An RPM package consists of the lead, the signature (contains digests and
 * signatures), the header (contains the package metadata) and the payload (a
 * compressed archive of the package files).
 * 
 * This structure is shared by all package format versions supported by this
 * Kaitai Struct implementation:
 * 
 * * v3, written by RPM 2.1 to 3.x.
 * * v4, written by RPM 4.x, and by RPM 6.x when the `%_rpmformat` macro is set
 *   to 4 - see
 *   <https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/man/rpmbuild-config.5.scd?plain=1#L189-L192>.
 *   For example, Fedora 43 and 44 patch RPM 6.0 to keep producing v4 packages by
 *   default - see
 *   <https://src.fedoraproject.org/rpms/rpm/blob/7099d81c3b5ecf1777a43095be429cb198bcc566/f/rpm-6.0-rpmformat.patch>.
 * * v6, written by upstream RPM 6.0 by default - see
 *   <https://github.com/rpm-software-management/rpm/commit/99d80a22d3d299bdc4418f7e61cd491731626d37>.
 * 
 * The versions differ mainly in the tags they use: v6 packages store all sizes
 * as 64-bit integers, carry only cryptographic data in the signature and always
 * use the stripped-down cpio archive format (see the `payload` instance).
 * 
 * The formats before v3, as well as the abandoned rpm5 fork, are not covered by
 * this implementation.
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_v6.md">Source</a>
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_v4.md">Source</a>
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_v3.md">Source</a>
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/signatures_digests.md">Source</a>
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/large_files.md">Source</a>
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/tags.md">Source</a>
 * @see <a href="https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/pkgformat.html">Source</a>
 * @see <a href="https://ftp.osuosl.org/pub/rpm/max-rpm/">Source</a>
 */

type Rpm_Architectures int
const (
	Rpm_Architectures__NotSet Rpm_Architectures = 0
	Rpm_Architectures__X86 Rpm_Architectures = 1
	Rpm_Architectures__Alpha Rpm_Architectures = 2
	Rpm_Architectures__Sparc Rpm_Architectures = 3
	Rpm_Architectures__Mips Rpm_Architectures = 4
	Rpm_Architectures__Ppc Rpm_Architectures = 5
	Rpm_Architectures__M68k Rpm_Architectures = 6
	Rpm_Architectures__Sgi Rpm_Architectures = 7
	Rpm_Architectures__Rs6000 Rpm_Architectures = 8
	Rpm_Architectures__Ia64 Rpm_Architectures = 9
	Rpm_Architectures__Sparc64 Rpm_Architectures = 10
	Rpm_Architectures__Mips64 Rpm_Architectures = 11
	Rpm_Architectures__Arm Rpm_Architectures = 12
	Rpm_Architectures__M68kMint Rpm_Architectures = 13
	Rpm_Architectures__S390 Rpm_Architectures = 14
	Rpm_Architectures__S390x Rpm_Architectures = 15
	Rpm_Architectures__Ppc64 Rpm_Architectures = 16
	Rpm_Architectures__Sh Rpm_Architectures = 17
	Rpm_Architectures__Xtensa Rpm_Architectures = 18
	Rpm_Architectures__Aarch64 Rpm_Architectures = 19
	Rpm_Architectures__MipsR6 Rpm_Architectures = 20
	Rpm_Architectures__Mips64R6 Rpm_Architectures = 21
	Rpm_Architectures__Riscv Rpm_Architectures = 22
	Rpm_Architectures__Loongarch64 Rpm_Architectures = 23
	Rpm_Architectures__E2k Rpm_Architectures = 24
	Rpm_Architectures__NoArch Rpm_Architectures = 255
)
var values_Rpm_Architectures = map[Rpm_Architectures]struct{}{0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, 8: {}, 9: {}, 10: {}, 11: {}, 12: {}, 13: {}, 14: {}, 15: {}, 16: {}, 17: {}, 18: {}, 19: {}, 20: {}, 21: {}, 22: {}, 23: {}, 24: {}, 255: {}}
func (v Rpm_Architectures) isDefined() bool {
	_, ok := values_Rpm_Architectures[v]
	return ok
}

type Rpm_HeaderTags int
const (
	Rpm_HeaderTags__Signatures Rpm_HeaderTags = 62
	Rpm_HeaderTags__HeaderImmutable Rpm_HeaderTags = 63
	Rpm_HeaderTags__I18nTable Rpm_HeaderTags = 100
	Rpm_HeaderTags__Name Rpm_HeaderTags = 1000
	Rpm_HeaderTags__Version Rpm_HeaderTags = 1001
	Rpm_HeaderTags__Release Rpm_HeaderTags = 1002
	Rpm_HeaderTags__Epoch Rpm_HeaderTags = 1003
	Rpm_HeaderTags__Summary Rpm_HeaderTags = 1004
	Rpm_HeaderTags__Description Rpm_HeaderTags = 1005
	Rpm_HeaderTags__BuildTime Rpm_HeaderTags = 1006
	Rpm_HeaderTags__BuildHost Rpm_HeaderTags = 1007
	Rpm_HeaderTags__InstallTime Rpm_HeaderTags = 1008
	Rpm_HeaderTags__Size Rpm_HeaderTags = 1009
	Rpm_HeaderTags__Distribution Rpm_HeaderTags = 1010
	Rpm_HeaderTags__Vendor Rpm_HeaderTags = 1011
	Rpm_HeaderTags__GifObsolete Rpm_HeaderTags = 1012
	Rpm_HeaderTags__XpmObsolete Rpm_HeaderTags = 1013
	Rpm_HeaderTags__License Rpm_HeaderTags = 1014
	Rpm_HeaderTags__Packager Rpm_HeaderTags = 1015
	Rpm_HeaderTags__Group Rpm_HeaderTags = 1016
	Rpm_HeaderTags__ChangelogInternal Rpm_HeaderTags = 1017
	Rpm_HeaderTags__Source Rpm_HeaderTags = 1018
	Rpm_HeaderTags__Patch Rpm_HeaderTags = 1019
	Rpm_HeaderTags__Url Rpm_HeaderTags = 1020
	Rpm_HeaderTags__Os Rpm_HeaderTags = 1021
	Rpm_HeaderTags__Arch Rpm_HeaderTags = 1022
	Rpm_HeaderTags__PreInstallScriptlet Rpm_HeaderTags = 1023
	Rpm_HeaderTags__PostInstallScriptlet Rpm_HeaderTags = 1024
	Rpm_HeaderTags__PreUninstallScriptlet Rpm_HeaderTags = 1025
	Rpm_HeaderTags__PostUninstallScriptlet Rpm_HeaderTags = 1026
	Rpm_HeaderTags__OldFileNamesObsolete Rpm_HeaderTags = 1027
	Rpm_HeaderTags__FileSizes Rpm_HeaderTags = 1028
	Rpm_HeaderTags__FileStates Rpm_HeaderTags = 1029
	Rpm_HeaderTags__FileModes Rpm_HeaderTags = 1030
	Rpm_HeaderTags__FileUidsInternal Rpm_HeaderTags = 1031
	Rpm_HeaderTags__FileGidsInternal Rpm_HeaderTags = 1032
	Rpm_HeaderTags__DeviceNumber Rpm_HeaderTags = 1033
	Rpm_HeaderTags__Mtimes Rpm_HeaderTags = 1034
	Rpm_HeaderTags__FileDigests Rpm_HeaderTags = 1035
	Rpm_HeaderTags__LinkTos Rpm_HeaderTags = 1036
	Rpm_HeaderTags__FileFlags Rpm_HeaderTags = 1037
	Rpm_HeaderTags__RootInternal Rpm_HeaderTags = 1038
	Rpm_HeaderTags__FileOwner Rpm_HeaderTags = 1039
	Rpm_HeaderTags__FileGroup Rpm_HeaderTags = 1040
	Rpm_HeaderTags__ExcludeInternal Rpm_HeaderTags = 1041
	Rpm_HeaderTags__ExclusiveInternal Rpm_HeaderTags = 1042
	Rpm_HeaderTags__IconObsolete Rpm_HeaderTags = 1043
	Rpm_HeaderTags__SourceRpm Rpm_HeaderTags = 1044
	Rpm_HeaderTags__FileVerifyFlags Rpm_HeaderTags = 1045
	Rpm_HeaderTags__ArchiveSize Rpm_HeaderTags = 1046
	Rpm_HeaderTags__ProvideName Rpm_HeaderTags = 1047
	Rpm_HeaderTags__RequireFlags Rpm_HeaderTags = 1048
	Rpm_HeaderTags__RequireName Rpm_HeaderTags = 1049
	Rpm_HeaderTags__RequireVersion Rpm_HeaderTags = 1050
	Rpm_HeaderTags__NoSource Rpm_HeaderTags = 1051
	Rpm_HeaderTags__NoPatch Rpm_HeaderTags = 1052
	Rpm_HeaderTags__ConflictFlags Rpm_HeaderTags = 1053
	Rpm_HeaderTags__ConflictName Rpm_HeaderTags = 1054
	Rpm_HeaderTags__ConflictVersion Rpm_HeaderTags = 1055
	Rpm_HeaderTags__DefaultPrefixInternal Rpm_HeaderTags = 1056
	Rpm_HeaderTags__BuildRootInternal Rpm_HeaderTags = 1057
	Rpm_HeaderTags__InstallPrefixInternal Rpm_HeaderTags = 1058
	Rpm_HeaderTags__ExcludeArch Rpm_HeaderTags = 1059
	Rpm_HeaderTags__ExcludeOs Rpm_HeaderTags = 1060
	Rpm_HeaderTags__ExclusiveArch Rpm_HeaderTags = 1061
	Rpm_HeaderTags__ExclusiveOs Rpm_HeaderTags = 1062
	Rpm_HeaderTags__AutoreqprovInternal Rpm_HeaderTags = 1063
	Rpm_HeaderTags__RpmVersion Rpm_HeaderTags = 1064
	Rpm_HeaderTags__TriggerScripts Rpm_HeaderTags = 1065
	Rpm_HeaderTags__TriggerName Rpm_HeaderTags = 1066
	Rpm_HeaderTags__TriggerVersion Rpm_HeaderTags = 1067
	Rpm_HeaderTags__TriggerFlags Rpm_HeaderTags = 1068
	Rpm_HeaderTags__TriggerIndex Rpm_HeaderTags = 1069
	Rpm_HeaderTags__VerifyScript Rpm_HeaderTags = 1079
	Rpm_HeaderTags__ChangelogTime Rpm_HeaderTags = 1080
	Rpm_HeaderTags__ChangelogName Rpm_HeaderTags = 1081
	Rpm_HeaderTags__ChangelogText Rpm_HeaderTags = 1082
	Rpm_HeaderTags__BrokenMd5Internal Rpm_HeaderTags = 1083
	Rpm_HeaderTags__PrereqInternal Rpm_HeaderTags = 1084
	Rpm_HeaderTags__PreInstallInterpreter Rpm_HeaderTags = 1085
	Rpm_HeaderTags__PostInstallInterpreter Rpm_HeaderTags = 1086
	Rpm_HeaderTags__PreUninstallInterpreter Rpm_HeaderTags = 1087
	Rpm_HeaderTags__PostUninstallInterpreter Rpm_HeaderTags = 1088
	Rpm_HeaderTags__BuildArchs Rpm_HeaderTags = 1089
	Rpm_HeaderTags__ObsoleteName Rpm_HeaderTags = 1090
	Rpm_HeaderTags__VerifyScriptProg Rpm_HeaderTags = 1091
	Rpm_HeaderTags__TriggerScriptProg Rpm_HeaderTags = 1092
	Rpm_HeaderTags__DocDirInternal Rpm_HeaderTags = 1093
	Rpm_HeaderTags__Cookie Rpm_HeaderTags = 1094
	Rpm_HeaderTags__FileDevices Rpm_HeaderTags = 1095
	Rpm_HeaderTags__FileInodes Rpm_HeaderTags = 1096
	Rpm_HeaderTags__FileLangs Rpm_HeaderTags = 1097
	Rpm_HeaderTags__Prefixes Rpm_HeaderTags = 1098
	Rpm_HeaderTags__InstallPrefixes Rpm_HeaderTags = 1099
	Rpm_HeaderTags__TriggerInstallInternal Rpm_HeaderTags = 1100
	Rpm_HeaderTags__TriggerUninstallInternal Rpm_HeaderTags = 1101
	Rpm_HeaderTags__TriggerPostUninstallInternal Rpm_HeaderTags = 1102
	Rpm_HeaderTags__AutoreqInternal Rpm_HeaderTags = 1103
	Rpm_HeaderTags__AutoprovInternal Rpm_HeaderTags = 1104
	Rpm_HeaderTags__CapabilityInternal Rpm_HeaderTags = 1105
	Rpm_HeaderTags__SourcePackage Rpm_HeaderTags = 1106
	Rpm_HeaderTags__OldOrigFilenamesInternal Rpm_HeaderTags = 1107
	Rpm_HeaderTags__BuildPrereqInternal Rpm_HeaderTags = 1108
	Rpm_HeaderTags__BuildRequiresInternal Rpm_HeaderTags = 1109
	Rpm_HeaderTags__BuildConflictsInternal Rpm_HeaderTags = 1110
	Rpm_HeaderTags__BuildMacrosInternal Rpm_HeaderTags = 1111
	Rpm_HeaderTags__ProvideFlags Rpm_HeaderTags = 1112
	Rpm_HeaderTags__ProvideVersion Rpm_HeaderTags = 1113
	Rpm_HeaderTags__ObsoleteFlags Rpm_HeaderTags = 1114
	Rpm_HeaderTags__ObsoleteVersion Rpm_HeaderTags = 1115
	Rpm_HeaderTags__DirIndexes Rpm_HeaderTags = 1116
	Rpm_HeaderTags__BaseNames Rpm_HeaderTags = 1117
	Rpm_HeaderTags__DirNames Rpm_HeaderTags = 1118
	Rpm_HeaderTags__OrigDirIndexes Rpm_HeaderTags = 1119
	Rpm_HeaderTags__OrigBaseNames Rpm_HeaderTags = 1120
	Rpm_HeaderTags__OrigDirNames Rpm_HeaderTags = 1121
	Rpm_HeaderTags__OptFlags Rpm_HeaderTags = 1122
	Rpm_HeaderTags__DistUrl Rpm_HeaderTags = 1123
	Rpm_HeaderTags__PayloadFormat Rpm_HeaderTags = 1124
	Rpm_HeaderTags__PayloadCompressor Rpm_HeaderTags = 1125
	Rpm_HeaderTags__PayloadFlags Rpm_HeaderTags = 1126
	Rpm_HeaderTags__InstallColor Rpm_HeaderTags = 1127
	Rpm_HeaderTags__InstallTid Rpm_HeaderTags = 1128
	Rpm_HeaderTags__RemoveTidObsolete Rpm_HeaderTags = 1129
	Rpm_HeaderTags__Sha1RhnInternal Rpm_HeaderTags = 1130
	Rpm_HeaderTags__RhnPlatformInternal Rpm_HeaderTags = 1131
	Rpm_HeaderTags__Platform Rpm_HeaderTags = 1132
	Rpm_HeaderTags__PatchesNameObsolete Rpm_HeaderTags = 1133
	Rpm_HeaderTags__PatchesFlagsObsolete Rpm_HeaderTags = 1134
	Rpm_HeaderTags__PatchesVersionObsolete Rpm_HeaderTags = 1135
	Rpm_HeaderTags__CacheCtimeInternal Rpm_HeaderTags = 1136
	Rpm_HeaderTags__CachePkgPathInternal Rpm_HeaderTags = 1137
	Rpm_HeaderTags__CachePkgSizeInternal Rpm_HeaderTags = 1138
	Rpm_HeaderTags__CachePkgMtimeInternal Rpm_HeaderTags = 1139
	Rpm_HeaderTags__FileColors Rpm_HeaderTags = 1140
	Rpm_HeaderTags__FileClass Rpm_HeaderTags = 1141
	Rpm_HeaderTags__ClassDict Rpm_HeaderTags = 1142
	Rpm_HeaderTags__FileDependsIdx Rpm_HeaderTags = 1143
	Rpm_HeaderTags__FileDependsNum Rpm_HeaderTags = 1144
	Rpm_HeaderTags__DependsDict Rpm_HeaderTags = 1145
	Rpm_HeaderTags__SourceSigMd5 Rpm_HeaderTags = 1146
	Rpm_HeaderTags__FileContextsObsolete Rpm_HeaderTags = 1147
	Rpm_HeaderTags__FsContextsObsolete Rpm_HeaderTags = 1148
	Rpm_HeaderTags__ReContextsObsolete Rpm_HeaderTags = 1149
	Rpm_HeaderTags__Policies Rpm_HeaderTags = 1150
	Rpm_HeaderTags__PreTrans Rpm_HeaderTags = 1151
	Rpm_HeaderTags__PostTrans Rpm_HeaderTags = 1152
	Rpm_HeaderTags__PreTransProg Rpm_HeaderTags = 1153
	Rpm_HeaderTags__PostTransProg Rpm_HeaderTags = 1154
	Rpm_HeaderTags__DistTag Rpm_HeaderTags = 1155
	Rpm_HeaderTags__OldSuggestsNameObsolete Rpm_HeaderTags = 1156
	Rpm_HeaderTags__OldSuggestsVersionObsolete Rpm_HeaderTags = 1157
	Rpm_HeaderTags__OldSuggestsFlagsObsolete Rpm_HeaderTags = 1158
	Rpm_HeaderTags__OldEnhancesNameObsolete Rpm_HeaderTags = 1159
	Rpm_HeaderTags__OldEnhancesVersionObsolete Rpm_HeaderTags = 1160
	Rpm_HeaderTags__OldEnhancesFlagsObsolete Rpm_HeaderTags = 1161
	Rpm_HeaderTags__PriorityUnimplemented Rpm_HeaderTags = 1162
	Rpm_HeaderTags__CvsidUnimplemented Rpm_HeaderTags = 1163
	Rpm_HeaderTags__BlinkPkgidUnimplemented Rpm_HeaderTags = 1164
	Rpm_HeaderTags__BlinkHdridUnimplemented Rpm_HeaderTags = 1165
	Rpm_HeaderTags__BlinkNevraUnimplemented Rpm_HeaderTags = 1166
	Rpm_HeaderTags__FlinkPkgidUnimplemented Rpm_HeaderTags = 1167
	Rpm_HeaderTags__FlinkHdridUnimplemented Rpm_HeaderTags = 1168
	Rpm_HeaderTags__FlinkNevraUnimplemented Rpm_HeaderTags = 1169
	Rpm_HeaderTags__PackageOriginUnimplemented Rpm_HeaderTags = 1170
	Rpm_HeaderTags__TriggerPreInstallInternal Rpm_HeaderTags = 1171
	Rpm_HeaderTags__BuildSuggestsUnimplemented Rpm_HeaderTags = 1172
	Rpm_HeaderTags__BuildEnhancesUnimplemented Rpm_HeaderTags = 1173
	Rpm_HeaderTags__ScriptStatesUnimplemented Rpm_HeaderTags = 1174
	Rpm_HeaderTags__ScriptMetricsUnimplemented Rpm_HeaderTags = 1175
	Rpm_HeaderTags__BuildCpuClockUnimplemented Rpm_HeaderTags = 1176
	Rpm_HeaderTags__FileDigestAlgosUnimplemented Rpm_HeaderTags = 1177
	Rpm_HeaderTags__VariantsUnimplemented Rpm_HeaderTags = 1178
	Rpm_HeaderTags__XmajorUnimplemented Rpm_HeaderTags = 1179
	Rpm_HeaderTags__XminorUnimplemented Rpm_HeaderTags = 1180
	Rpm_HeaderTags__RepoTagUnimplemented Rpm_HeaderTags = 1181
	Rpm_HeaderTags__KeywordsUnimplemented Rpm_HeaderTags = 1182
	Rpm_HeaderTags__BuildPlatformsUnimplemented Rpm_HeaderTags = 1183
	Rpm_HeaderTags__PackageColorUnimplemented Rpm_HeaderTags = 1184
	Rpm_HeaderTags__PackagePrefColorUnimplemented Rpm_HeaderTags = 1185
	Rpm_HeaderTags__XattrsDictUnimplemented Rpm_HeaderTags = 1186
	Rpm_HeaderTags__FilexAttrsxUnimplemented Rpm_HeaderTags = 1187
	Rpm_HeaderTags__DepAttrsDictUnimplemented Rpm_HeaderTags = 1188
	Rpm_HeaderTags__ConflictAttrsxUnimplemented Rpm_HeaderTags = 1189
	Rpm_HeaderTags__ObsoleteAttrsxUnimplemented Rpm_HeaderTags = 1190
	Rpm_HeaderTags__ProvideAttrsxUnimplemented Rpm_HeaderTags = 1191
	Rpm_HeaderTags__RequireAttrsxUnimplemented Rpm_HeaderTags = 1192
	Rpm_HeaderTags__BuildProvidesUnimplemented Rpm_HeaderTags = 1193
	Rpm_HeaderTags__BuildObsoletesUnimplemented Rpm_HeaderTags = 1194
	Rpm_HeaderTags__DbInstance Rpm_HeaderTags = 1195
	Rpm_HeaderTags__Nvra Rpm_HeaderTags = 1196
	Rpm_HeaderTags__FileNames Rpm_HeaderTags = 5000
	Rpm_HeaderTags__FileProvide Rpm_HeaderTags = 5001
	Rpm_HeaderTags__FileRequire Rpm_HeaderTags = 5002
	Rpm_HeaderTags__FsNamesUnimplemented Rpm_HeaderTags = 5003
	Rpm_HeaderTags__FsSizesUnimplemented Rpm_HeaderTags = 5004
	Rpm_HeaderTags__TriggerConds Rpm_HeaderTags = 5005
	Rpm_HeaderTags__TriggerType Rpm_HeaderTags = 5006
	Rpm_HeaderTags__OrigFileNames Rpm_HeaderTags = 5007
	Rpm_HeaderTags__LongFileSizes Rpm_HeaderTags = 5008
	Rpm_HeaderTags__LongSize Rpm_HeaderTags = 5009
	Rpm_HeaderTags__FileCaps Rpm_HeaderTags = 5010
	Rpm_HeaderTags__FileDigestAlgo Rpm_HeaderTags = 5011
	Rpm_HeaderTags__BugUrl Rpm_HeaderTags = 5012
	Rpm_HeaderTags__Evr Rpm_HeaderTags = 5013
	Rpm_HeaderTags__Nvr Rpm_HeaderTags = 5014
	Rpm_HeaderTags__Nevr Rpm_HeaderTags = 5015
	Rpm_HeaderTags__Nevra Rpm_HeaderTags = 5016
	Rpm_HeaderTags__HeaderColor Rpm_HeaderTags = 5017
	Rpm_HeaderTags__Verbose Rpm_HeaderTags = 5018
	Rpm_HeaderTags__EpochNum Rpm_HeaderTags = 5019
	Rpm_HeaderTags__PreInstallFlags Rpm_HeaderTags = 5020
	Rpm_HeaderTags__PostInstallFlags Rpm_HeaderTags = 5021
	Rpm_HeaderTags__PreUninstallFlags Rpm_HeaderTags = 5022
	Rpm_HeaderTags__PostUninstallFlags Rpm_HeaderTags = 5023
	Rpm_HeaderTags__PreTransFlags Rpm_HeaderTags = 5024
	Rpm_HeaderTags__PostTransFlags Rpm_HeaderTags = 5025
	Rpm_HeaderTags__VerifyScriptFlags Rpm_HeaderTags = 5026
	Rpm_HeaderTags__TriggerScriptFlags Rpm_HeaderTags = 5027
	Rpm_HeaderTags__CollectionsUnimplemented Rpm_HeaderTags = 5029
	Rpm_HeaderTags__PolicyNames Rpm_HeaderTags = 5030
	Rpm_HeaderTags__PolicyTypes Rpm_HeaderTags = 5031
	Rpm_HeaderTags__PolicyTypesIndexes Rpm_HeaderTags = 5032
	Rpm_HeaderTags__PolicyFlags Rpm_HeaderTags = 5033
	Rpm_HeaderTags__Vcs Rpm_HeaderTags = 5034
	Rpm_HeaderTags__OrderName Rpm_HeaderTags = 5035
	Rpm_HeaderTags__OrderVersion Rpm_HeaderTags = 5036
	Rpm_HeaderTags__OrderFlags Rpm_HeaderTags = 5037
	Rpm_HeaderTags__MssfManifestUnimplemented Rpm_HeaderTags = 5038
	Rpm_HeaderTags__MssfDomainUnimplemented Rpm_HeaderTags = 5039
	Rpm_HeaderTags__InstFileNames Rpm_HeaderTags = 5040
	Rpm_HeaderTags__RequireNevrs Rpm_HeaderTags = 5041
	Rpm_HeaderTags__ProvideNevrs Rpm_HeaderTags = 5042
	Rpm_HeaderTags__ObsoleteNevrs Rpm_HeaderTags = 5043
	Rpm_HeaderTags__ConflictNevrs Rpm_HeaderTags = 5044
	Rpm_HeaderTags__FileNlinks Rpm_HeaderTags = 5045
	Rpm_HeaderTags__RecommendName Rpm_HeaderTags = 5046
	Rpm_HeaderTags__RecommendVersion Rpm_HeaderTags = 5047
	Rpm_HeaderTags__RecommendFlags Rpm_HeaderTags = 5048
	Rpm_HeaderTags__SuggestName Rpm_HeaderTags = 5049
	Rpm_HeaderTags__SuggestVersion Rpm_HeaderTags = 5050
	Rpm_HeaderTags__SuggestFlags Rpm_HeaderTags = 5051
	Rpm_HeaderTags__SupplementName Rpm_HeaderTags = 5052
	Rpm_HeaderTags__SupplementVersion Rpm_HeaderTags = 5053
	Rpm_HeaderTags__SupplementFlags Rpm_HeaderTags = 5054
	Rpm_HeaderTags__EnhanceName Rpm_HeaderTags = 5055
	Rpm_HeaderTags__EnhanceVersion Rpm_HeaderTags = 5056
	Rpm_HeaderTags__EnhanceFlags Rpm_HeaderTags = 5057
	Rpm_HeaderTags__RecommendNevrs Rpm_HeaderTags = 5058
	Rpm_HeaderTags__SuggestNevrs Rpm_HeaderTags = 5059
	Rpm_HeaderTags__SupplementNevrs Rpm_HeaderTags = 5060
	Rpm_HeaderTags__EnhanceNevrs Rpm_HeaderTags = 5061
	Rpm_HeaderTags__Encoding Rpm_HeaderTags = 5062
	Rpm_HeaderTags__FileTriggerInstallInternal Rpm_HeaderTags = 5063
	Rpm_HeaderTags__FileTriggerUninstallInternal Rpm_HeaderTags = 5064
	Rpm_HeaderTags__FileTriggerPostUninstallInternal Rpm_HeaderTags = 5065
	Rpm_HeaderTags__FileTriggerScripts Rpm_HeaderTags = 5066
	Rpm_HeaderTags__FileTriggerScriptProg Rpm_HeaderTags = 5067
	Rpm_HeaderTags__FileTriggerScriptFlags Rpm_HeaderTags = 5068
	Rpm_HeaderTags__FileTriggerName Rpm_HeaderTags = 5069
	Rpm_HeaderTags__FileTriggerIndex Rpm_HeaderTags = 5070
	Rpm_HeaderTags__FileTriggerVersion Rpm_HeaderTags = 5071
	Rpm_HeaderTags__FileTriggerFlags Rpm_HeaderTags = 5072
	Rpm_HeaderTags__TransFileTriggerInstallInternal Rpm_HeaderTags = 5073
	Rpm_HeaderTags__TransFileTriggerUninstallInternal Rpm_HeaderTags = 5074
	Rpm_HeaderTags__TransFileTriggerPostUninstallInternal Rpm_HeaderTags = 5075
	Rpm_HeaderTags__TransFileTriggerScripts Rpm_HeaderTags = 5076
	Rpm_HeaderTags__TransFileTriggerScriptProg Rpm_HeaderTags = 5077
	Rpm_HeaderTags__TransFileTriggerScriptFlags Rpm_HeaderTags = 5078
	Rpm_HeaderTags__TransFileTriggerName Rpm_HeaderTags = 5079
	Rpm_HeaderTags__TransFileTriggerIndex Rpm_HeaderTags = 5080
	Rpm_HeaderTags__TransFileTriggerVersion Rpm_HeaderTags = 5081
	Rpm_HeaderTags__TransFileTriggerFlags Rpm_HeaderTags = 5082
	Rpm_HeaderTags__RemovePathPostfixesInternal Rpm_HeaderTags = 5083
	Rpm_HeaderTags__FileTriggerPriorities Rpm_HeaderTags = 5084
	Rpm_HeaderTags__TransFileTriggerPriorities Rpm_HeaderTags = 5085
	Rpm_HeaderTags__FileTriggerConds Rpm_HeaderTags = 5086
	Rpm_HeaderTags__FileTriggerType Rpm_HeaderTags = 5087
	Rpm_HeaderTags__TransFileTriggerConds Rpm_HeaderTags = 5088
	Rpm_HeaderTags__TransFileTriggerType Rpm_HeaderTags = 5089
	Rpm_HeaderTags__FileSignatures Rpm_HeaderTags = 5090
	Rpm_HeaderTags__FileSignatureLength Rpm_HeaderTags = 5091
	Rpm_HeaderTags__PayloadSha256 Rpm_HeaderTags = 5092
	Rpm_HeaderTags__PayloadSha256AlgoObsolete Rpm_HeaderTags = 5093
	Rpm_HeaderTags__AutoInstalledUnimplemented Rpm_HeaderTags = 5094
	Rpm_HeaderTags__IdentityUnimplemented Rpm_HeaderTags = 5095
	Rpm_HeaderTags__ModularityLabel Rpm_HeaderTags = 5096
	Rpm_HeaderTags__PayloadSha256Alt Rpm_HeaderTags = 5097
	Rpm_HeaderTags__ArchSuffix Rpm_HeaderTags = 5098
	Rpm_HeaderTags__Spec Rpm_HeaderTags = 5099
	Rpm_HeaderTags__TranslationUrl Rpm_HeaderTags = 5100
	Rpm_HeaderTags__UpstreamReleases Rpm_HeaderTags = 5101
	Rpm_HeaderTags__SourceLicenseInternal Rpm_HeaderTags = 5102
	Rpm_HeaderTags__PreUntrans Rpm_HeaderTags = 5103
	Rpm_HeaderTags__PostUntrans Rpm_HeaderTags = 5104
	Rpm_HeaderTags__PreUntransProg Rpm_HeaderTags = 5105
	Rpm_HeaderTags__PostUntransProg Rpm_HeaderTags = 5106
	Rpm_HeaderTags__PreUntransFlags Rpm_HeaderTags = 5107
	Rpm_HeaderTags__PostUntransFlags Rpm_HeaderTags = 5108
	Rpm_HeaderTags__SysUsers Rpm_HeaderTags = 5109
	Rpm_HeaderTags__BuildSystemInternal Rpm_HeaderTags = 5110
	Rpm_HeaderTags__BuildOptionInternal Rpm_HeaderTags = 5111
	Rpm_HeaderTags__PayloadSize Rpm_HeaderTags = 5112
	Rpm_HeaderTags__PayloadSizeAlt Rpm_HeaderTags = 5113
	Rpm_HeaderTags__RpmFormat Rpm_HeaderTags = 5114
	Rpm_HeaderTags__FileMimeIndex Rpm_HeaderTags = 5115
	Rpm_HeaderTags__MimeDict Rpm_HeaderTags = 5116
	Rpm_HeaderTags__FileMimes Rpm_HeaderTags = 5117
	Rpm_HeaderTags__PackageDigests Rpm_HeaderTags = 5118
	Rpm_HeaderTags__PackageDigestAlgos Rpm_HeaderTags = 5119
	Rpm_HeaderTags__SourceNevr Rpm_HeaderTags = 5120
	Rpm_HeaderTags__PayloadSha512 Rpm_HeaderTags = 5121
	Rpm_HeaderTags__PayloadSha512Alt Rpm_HeaderTags = 5122
	Rpm_HeaderTags__PayloadSha3256 Rpm_HeaderTags = 5123
	Rpm_HeaderTags__PayloadSha3256Alt Rpm_HeaderTags = 5124
)
var values_Rpm_HeaderTags = map[Rpm_HeaderTags]struct{}{62: {}, 63: {}, 100: {}, 1000: {}, 1001: {}, 1002: {}, 1003: {}, 1004: {}, 1005: {}, 1006: {}, 1007: {}, 1008: {}, 1009: {}, 1010: {}, 1011: {}, 1012: {}, 1013: {}, 1014: {}, 1015: {}, 1016: {}, 1017: {}, 1018: {}, 1019: {}, 1020: {}, 1021: {}, 1022: {}, 1023: {}, 1024: {}, 1025: {}, 1026: {}, 1027: {}, 1028: {}, 1029: {}, 1030: {}, 1031: {}, 1032: {}, 1033: {}, 1034: {}, 1035: {}, 1036: {}, 1037: {}, 1038: {}, 1039: {}, 1040: {}, 1041: {}, 1042: {}, 1043: {}, 1044: {}, 1045: {}, 1046: {}, 1047: {}, 1048: {}, 1049: {}, 1050: {}, 1051: {}, 1052: {}, 1053: {}, 1054: {}, 1055: {}, 1056: {}, 1057: {}, 1058: {}, 1059: {}, 1060: {}, 1061: {}, 1062: {}, 1063: {}, 1064: {}, 1065: {}, 1066: {}, 1067: {}, 1068: {}, 1069: {}, 1079: {}, 1080: {}, 1081: {}, 1082: {}, 1083: {}, 1084: {}, 1085: {}, 1086: {}, 1087: {}, 1088: {}, 1089: {}, 1090: {}, 1091: {}, 1092: {}, 1093: {}, 1094: {}, 1095: {}, 1096: {}, 1097: {}, 1098: {}, 1099: {}, 1100: {}, 1101: {}, 1102: {}, 1103: {}, 1104: {}, 1105: {}, 1106: {}, 1107: {}, 1108: {}, 1109: {}, 1110: {}, 1111: {}, 1112: {}, 1113: {}, 1114: {}, 1115: {}, 1116: {}, 1117: {}, 1118: {}, 1119: {}, 1120: {}, 1121: {}, 1122: {}, 1123: {}, 1124: {}, 1125: {}, 1126: {}, 1127: {}, 1128: {}, 1129: {}, 1130: {}, 1131: {}, 1132: {}, 1133: {}, 1134: {}, 1135: {}, 1136: {}, 1137: {}, 1138: {}, 1139: {}, 1140: {}, 1141: {}, 1142: {}, 1143: {}, 1144: {}, 1145: {}, 1146: {}, 1147: {}, 1148: {}, 1149: {}, 1150: {}, 1151: {}, 1152: {}, 1153: {}, 1154: {}, 1155: {}, 1156: {}, 1157: {}, 1158: {}, 1159: {}, 1160: {}, 1161: {}, 1162: {}, 1163: {}, 1164: {}, 1165: {}, 1166: {}, 1167: {}, 1168: {}, 1169: {}, 1170: {}, 1171: {}, 1172: {}, 1173: {}, 1174: {}, 1175: {}, 1176: {}, 1177: {}, 1178: {}, 1179: {}, 1180: {}, 1181: {}, 1182: {}, 1183: {}, 1184: {}, 1185: {}, 1186: {}, 1187: {}, 1188: {}, 1189: {}, 1190: {}, 1191: {}, 1192: {}, 1193: {}, 1194: {}, 1195: {}, 1196: {}, 5000: {}, 5001: {}, 5002: {}, 5003: {}, 5004: {}, 5005: {}, 5006: {}, 5007: {}, 5008: {}, 5009: {}, 5010: {}, 5011: {}, 5012: {}, 5013: {}, 5014: {}, 5015: {}, 5016: {}, 5017: {}, 5018: {}, 5019: {}, 5020: {}, 5021: {}, 5022: {}, 5023: {}, 5024: {}, 5025: {}, 5026: {}, 5027: {}, 5029: {}, 5030: {}, 5031: {}, 5032: {}, 5033: {}, 5034: {}, 5035: {}, 5036: {}, 5037: {}, 5038: {}, 5039: {}, 5040: {}, 5041: {}, 5042: {}, 5043: {}, 5044: {}, 5045: {}, 5046: {}, 5047: {}, 5048: {}, 5049: {}, 5050: {}, 5051: {}, 5052: {}, 5053: {}, 5054: {}, 5055: {}, 5056: {}, 5057: {}, 5058: {}, 5059: {}, 5060: {}, 5061: {}, 5062: {}, 5063: {}, 5064: {}, 5065: {}, 5066: {}, 5067: {}, 5068: {}, 5069: {}, 5070: {}, 5071: {}, 5072: {}, 5073: {}, 5074: {}, 5075: {}, 5076: {}, 5077: {}, 5078: {}, 5079: {}, 5080: {}, 5081: {}, 5082: {}, 5083: {}, 5084: {}, 5085: {}, 5086: {}, 5087: {}, 5088: {}, 5089: {}, 5090: {}, 5091: {}, 5092: {}, 5093: {}, 5094: {}, 5095: {}, 5096: {}, 5097: {}, 5098: {}, 5099: {}, 5100: {}, 5101: {}, 5102: {}, 5103: {}, 5104: {}, 5105: {}, 5106: {}, 5107: {}, 5108: {}, 5109: {}, 5110: {}, 5111: {}, 5112: {}, 5113: {}, 5114: {}, 5115: {}, 5116: {}, 5117: {}, 5118: {}, 5119: {}, 5120: {}, 5121: {}, 5122: {}, 5123: {}, 5124: {}}
func (v Rpm_HeaderTags) isDefined() bool {
	_, ok := values_Rpm_HeaderTags[v]
	return ok
}

type Rpm_OperatingSystems int
const (
	Rpm_OperatingSystems__NotSet Rpm_OperatingSystems = 0
	Rpm_OperatingSystems__Linux Rpm_OperatingSystems = 1
	Rpm_OperatingSystems__Irix Rpm_OperatingSystems = 2
	Rpm_OperatingSystems__NoOs Rpm_OperatingSystems = 255
)
var values_Rpm_OperatingSystems = map[Rpm_OperatingSystems]struct{}{0: {}, 1: {}, 2: {}, 255: {}}
func (v Rpm_OperatingSystems) isDefined() bool {
	_, ok := values_Rpm_OperatingSystems[v]
	return ok
}

type Rpm_RecordTypes int
const (
	Rpm_RecordTypes__Char Rpm_RecordTypes = 1
	Rpm_RecordTypes__Uint8 Rpm_RecordTypes = 2
	Rpm_RecordTypes__Uint16 Rpm_RecordTypes = 3
	Rpm_RecordTypes__Uint32 Rpm_RecordTypes = 4
	Rpm_RecordTypes__Uint64 Rpm_RecordTypes = 5
	Rpm_RecordTypes__String Rpm_RecordTypes = 6
	Rpm_RecordTypes__Bin Rpm_RecordTypes = 7
	Rpm_RecordTypes__StringArray Rpm_RecordTypes = 8
	Rpm_RecordTypes__I18nString Rpm_RecordTypes = 9
)
var values_Rpm_RecordTypes = map[Rpm_RecordTypes]struct{}{1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, 8: {}, 9: {}}
func (v Rpm_RecordTypes) isDefined() bool {
	_, ok := values_Rpm_RecordTypes[v]
	return ok
}

type Rpm_RpmTypes int
const (
	Rpm_RpmTypes__Binary Rpm_RpmTypes = 0
	Rpm_RpmTypes__Source Rpm_RpmTypes = 1
)
var values_Rpm_RpmTypes = map[Rpm_RpmTypes]struct{}{0: {}, 1: {}}
func (v Rpm_RpmTypes) isDefined() bool {
	_, ok := values_Rpm_RpmTypes[v]
	return ok
}

type Rpm_SignatureTags int
const (
	Rpm_SignatureTags__Signatures Rpm_SignatureTags = 62
	Rpm_SignatureTags__HeaderImmutable Rpm_SignatureTags = 63
	Rpm_SignatureTags__I18nTable Rpm_SignatureTags = 100
	Rpm_SignatureTags__BadSha11Obsolete Rpm_SignatureTags = 264
	Rpm_SignatureTags__BadSha12Obsolete Rpm_SignatureTags = 265
	Rpm_SignatureTags__Dsa Rpm_SignatureTags = 267
	Rpm_SignatureTags__Rsa Rpm_SignatureTags = 268
	Rpm_SignatureTags__Sha1 Rpm_SignatureTags = 269
	Rpm_SignatureTags__LongSize Rpm_SignatureTags = 270
	Rpm_SignatureTags__LongArchiveSize Rpm_SignatureTags = 271
	Rpm_SignatureTags__Sha256 Rpm_SignatureTags = 273
	Rpm_SignatureTags__FileSignatures Rpm_SignatureTags = 274
	Rpm_SignatureTags__FileSignatureLength Rpm_SignatureTags = 275
	Rpm_SignatureTags__VeritySignatures Rpm_SignatureTags = 276
	Rpm_SignatureTags__VeritySignatureAlgo Rpm_SignatureTags = 277
	Rpm_SignatureTags__Openpgp Rpm_SignatureTags = 278
	Rpm_SignatureTags__Sha3256 Rpm_SignatureTags = 279
	Rpm_SignatureTags__Reserved Rpm_SignatureTags = 999
	Rpm_SignatureTags__Size Rpm_SignatureTags = 1000
	Rpm_SignatureTags__LeMd51Obsolete Rpm_SignatureTags = 1001
	Rpm_SignatureTags__Pgp Rpm_SignatureTags = 1002
	Rpm_SignatureTags__LeMd52Obsolete Rpm_SignatureTags = 1003
	Rpm_SignatureTags__Md5 Rpm_SignatureTags = 1004
	Rpm_SignatureTags__Gpg Rpm_SignatureTags = 1005
	Rpm_SignatureTags__Pgp5Obsolete Rpm_SignatureTags = 1006
	Rpm_SignatureTags__PayloadSize Rpm_SignatureTags = 1007
	Rpm_SignatureTags__ReservedSpace Rpm_SignatureTags = 1008
)
var values_Rpm_SignatureTags = map[Rpm_SignatureTags]struct{}{62: {}, 63: {}, 100: {}, 264: {}, 265: {}, 267: {}, 268: {}, 269: {}, 270: {}, 271: {}, 273: {}, 274: {}, 275: {}, 276: {}, 277: {}, 278: {}, 279: {}, 999: {}, 1000: {}, 1001: {}, 1002: {}, 1003: {}, 1004: {}, 1005: {}, 1006: {}, 1007: {}, 1008: {}}
func (v Rpm_SignatureTags) isDefined() bool {
	_, ok := values_Rpm_SignatureTags[v]
	return ok
}
type Rpm struct {
	Lead *Rpm_Lead
	Signature *Rpm_Header
	SignaturePadding []byte
	_unnamed3 []byte
	Header *Rpm_Header
	_unnamed5 []byte
	SignatureTagsSteps []*Rpm_SignatureTagsStep
	HeaderTagsSteps []*Rpm_HeaderTagsStep
	_io *kaitai.Stream
	_root *Rpm
	_parent kaitai.Struct
	_f_hasHeaderPayloadSizeTag bool
	hasHeaderPayloadSizeTag bool
	_f_hasPayload bool
	hasPayload bool
	_f_hasSignatureLongSizeTag bool
	hasSignatureLongSizeTag bool
	_f_hasSignatureSizeTag bool
	hasSignatureSizeTag bool
	_f_headerPayloadSizeTag bool
	headerPayloadSizeTag *Rpm_HeaderIndexRecord
	_f_lenHeader bool
	lenHeader int
	_f_lenPayload bool
	lenPayload int
	_f_ofsHeader bool
	ofsHeader int
	_f_ofsPayload bool
	ofsPayload int
	_f_payload bool
	payload []byte
	_f_signatureLongSizeTag bool
	signatureLongSizeTag *Rpm_HeaderIndexRecord
	_f_signatureSizeTag bool
	signatureSizeTag *Rpm_HeaderIndexRecord
}
func NewRpm() *Rpm {
	return &Rpm{
	}
}

func (this Rpm) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm) Read(io *kaitai.Stream, parent kaitai.Struct, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp1 := NewRpm_Lead()
	err = tmp1.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.Lead = tmp1
	tmp2 := NewRpm_Header(true)
	err = tmp2.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.Signature = tmp2
	tmp4, err := this._io.Pos()
	if err != nil {
		return err
	}
	tmp3 := -(tmp4) % 8
	if tmp3 < 0 {
		tmp3 += 8
	}
	tmp5, err := this._io.ReadBytes(int(tmp3))
	if err != nil {
		return err
	}
	tmp5 = tmp5
	this.SignaturePadding = tmp5
	tmp6, err := this.OfsHeader()
	if err != nil {
		return err
	}
	if (tmp6 < 0) {
		tmp7, err := this._io.ReadBytes(int(0))
		if err != nil {
			return err
		}
		tmp7 = tmp7
		this._unnamed3 = tmp7
	}
	tmp8 := NewRpm_Header(false)
	err = tmp8.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.Header = tmp8
	tmp9, err := this.OfsPayload()
	if err != nil {
		return err
	}
	if (tmp9 < 0) {
		tmp10, err := this._io.ReadBytes(int(0))
		if err != nil {
			return err
		}
		tmp10 = tmp10
		this._unnamed5 = tmp10
	}
	for i := 0; i < int(this.Signature.HeaderRecord.NumIndexRecords); i++ {
		_ = i
		var tmp11 int;
		if (i != 0) {
			tmp12, err := this.SignatureTagsSteps[i - 1].SizeTagIdx()
			if err != nil {
				return err
			}
			tmp11 = tmp12
		} else {
			tmp11 = -1
		}
		var tmp13 int;
		if (i != 0) {
			tmp14, err := this.SignatureTagsSteps[i - 1].LongSizeTagIdx()
			if err != nil {
				return err
			}
			tmp13 = tmp14
		} else {
			tmp13 = -1
		}
		tmp15 := NewRpm_SignatureTagsStep(i, tmp11, tmp13)
		err = tmp15.Read(this._io, this, this._root)
		if err != nil {
			return err
		}
		this.SignatureTagsSteps = append(this.SignatureTagsSteps, tmp15)
	}
	for i := 0; i < int(this.Header.HeaderRecord.NumIndexRecords); i++ {
		_ = i
		var tmp16 int;
		if (i != 0) {
			tmp17, err := this.HeaderTagsSteps[i - 1].PayloadSizeTagIdx()
			if err != nil {
				return err
			}
			tmp16 = tmp17
		} else {
			tmp16 = -1
		}
		tmp18 := NewRpm_HeaderTagsStep(i, tmp16)
		err = tmp18.Read(this._io, this, this._root)
		if err != nil {
			return err
		}
		this.HeaderTagsSteps = append(this.HeaderTagsSteps, tmp18)
	}
	return err
}
func (this *Rpm) HasHeaderPayloadSizeTag() (v bool, err error) {
	if (this._f_hasHeaderPayloadSizeTag) {
		return this.hasHeaderPayloadSizeTag, nil
	}
	this._f_hasHeaderPayloadSizeTag = true
	tmp19 := this.HeaderTagsSteps
	tmp20, err := tmp19[len(tmp19) - 1].PayloadSizeTagIdx()
	if err != nil {
		return false, err
	}
	this.hasHeaderPayloadSizeTag = bool(tmp20 != -1)
	return this.hasHeaderPayloadSizeTag, nil
}
func (this *Rpm) HasPayload() (v bool, err error) {
	if (this._f_hasPayload) {
		return this.hasPayload, nil
	}
	this._f_hasPayload = true
	tmp21, err := this.HasHeaderPayloadSizeTag()
	if err != nil {
		return false, err
	}
	tmp22, err := this.HasSignatureLongSizeTag()
	if err != nil {
		return false, err
	}
	tmp23, err := this.HasSignatureSizeTag()
	if err != nil {
		return false, err
	}
	this.hasPayload = bool( ((tmp21) || (tmp22) || (tmp23)) )
	return this.hasPayload, nil
}
func (this *Rpm) HasSignatureLongSizeTag() (v bool, err error) {
	if (this._f_hasSignatureLongSizeTag) {
		return this.hasSignatureLongSizeTag, nil
	}
	this._f_hasSignatureLongSizeTag = true
	tmp24 := this.SignatureTagsSteps
	tmp25, err := tmp24[len(tmp24) - 1].LongSizeTagIdx()
	if err != nil {
		return false, err
	}
	this.hasSignatureLongSizeTag = bool(tmp25 != -1)
	return this.hasSignatureLongSizeTag, nil
}
func (this *Rpm) HasSignatureSizeTag() (v bool, err error) {
	if (this._f_hasSignatureSizeTag) {
		return this.hasSignatureSizeTag, nil
	}
	this._f_hasSignatureSizeTag = true
	tmp26 := this.SignatureTagsSteps
	tmp27, err := tmp26[len(tmp26) - 1].SizeTagIdx()
	if err != nil {
		return false, err
	}
	this.hasSignatureSizeTag = bool(tmp27 != -1)
	return this.hasSignatureSizeTag, nil
}
func (this *Rpm) HeaderPayloadSizeTag() (v *Rpm_HeaderIndexRecord, err error) {
	if (this._f_headerPayloadSizeTag) {
		return this.headerPayloadSizeTag, nil
	}
	this._f_headerPayloadSizeTag = true
	tmp28, err := this.HasHeaderPayloadSizeTag()
	if err != nil {
		return nil, err
	}
	if (tmp28) {
		tmp29 := this.HeaderTagsSteps
		tmp30, err := tmp29[len(tmp29) - 1].PayloadSizeTagIdx()
		if err != nil {
			return nil, err
		}
		this.headerPayloadSizeTag = this.Header.IndexRecords[tmp30]
	}
	return this.headerPayloadSizeTag, nil
}
func (this *Rpm) LenHeader() (v int, err error) {
	if (this._f_lenHeader) {
		return this.lenHeader, nil
	}
	this._f_lenHeader = true
	tmp31, err := this.OfsPayload()
	if err != nil {
		return 0, err
	}
	tmp32, err := this.OfsHeader()
	if err != nil {
		return 0, err
	}
	this.lenHeader = int(tmp31 - tmp32)
	return this.lenHeader, nil
}

/**
 * Size of the (compressed) payload in bytes. v6 packages store it in
 * `header_tags::payload_size`, v4/v3 packages in `signature_tags::size`
 * (which also includes the size of the header).
 * 
 * If the header and payload together or the uncompressed payload reach
 * 4 GiB, v4 packages use `signature_tags::long_size` instead - see
 * <https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/lib/signature.cc#L182-L212>.
 * 
 * RPM never writes both (so this is just a hypothetical scenario), but if
 * both are present, `signature_tags::long_size` takes precedence over
 * `signature_tags::size`, just like in RPM's `printSize()` function:
 * <https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/lib/signature.cc#L36-L43>
 */
func (this *Rpm) LenPayload() (v int, err error) {
	if (this._f_lenPayload) {
		return this.lenPayload, nil
	}
	this._f_lenPayload = true
	tmp33, err := this.HasPayload()
	if err != nil {
		return 0, err
	}
	if (tmp33) {
		var tmp34 uint64;
		tmp35, err := this.HasHeaderPayloadSizeTag()
		if err != nil {
			return 0, err
		}
		if (tmp35) {
			tmp36, err := this.HeaderPayloadSizeTag()
			if err != nil {
				return 0, err
			}
			tmp37, err := tmp36.Body()
			if err != nil {
				return 0, err
			}
			tmp34 = tmp37.(*Rpm_RecordTypeUint64).Values[0]
		} else {
			var tmp38 int;
			tmp39, err := this.HasSignatureLongSizeTag()
			if err != nil {
				return 0, err
			}
			if (tmp39) {
				tmp40, err := this.SignatureLongSizeTag()
				if err != nil {
					return 0, err
				}
				tmp41, err := tmp40.Body()
				if err != nil {
					return 0, err
				}
				tmp42, err := this.LenHeader()
				if err != nil {
					return 0, err
				}
				tmp38 = tmp41.(*Rpm_RecordTypeUint64).Values[0] - tmp42
			} else {
				tmp43, err := this.SignatureSizeTag()
				if err != nil {
					return 0, err
				}
				tmp44, err := tmp43.Body()
				if err != nil {
					return 0, err
				}
				tmp45, err := this.LenHeader()
				if err != nil {
					return 0, err
				}
				tmp38 = tmp44.(*Rpm_RecordTypeUint32).Values[0] - tmp45
			}
			tmp34 = tmp38
		}
		this.lenPayload = int(tmp34)
	}
	return this.lenPayload, nil
}
func (this *Rpm) OfsHeader() (v int, err error) {
	if (this._f_ofsHeader) {
		return this.ofsHeader, nil
	}
	this._f_ofsHeader = true
	tmp46, err := this._io.Pos()
	if err != nil {
		return 0, err
	}
	this.ofsHeader = int(tmp46)
	return this.ofsHeader, nil
}
func (this *Rpm) OfsPayload() (v int, err error) {
	if (this._f_ofsPayload) {
		return this.ofsPayload, nil
	}
	this._f_ofsPayload = true
	tmp47, err := this._io.Pos()
	if err != nil {
		return 0, err
	}
	this.ofsPayload = int(tmp47)
	return this.ofsPayload, nil
}

/**
 * Archive of the package files, compressed using the method specified by
 * `header_tags::payload_compressor`. If this tag is missing, it's almost
 * certainly uncompressed (except for some very old v3 packages built by RPM
 * 3.0.3 or earlier, which didn't use the tag because the payload was always
 * gzipped; RPM 3.0.5 added support for bzip2 payloads and started writing
 * the tag). However, RPM reads the payload as gzip by default - see
 * <https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/lib/rpmte.cc#L643-L645>.
 * Since zlib's gzip reader passes data that is not in gzip format through
 * unchanged (see
 * <https://github.com/madler/zlib/blob/da607da739fa6047df13e66a2af6b8bec7c2a498/zlib.h#L1386-L1389>),
 * this also works for uncompressed payloads.
 * 
 * The archive format is given by `header_tags::payload_format`, which is
 * `"cpio"` for regular packages. In v4/v3 packages, it's a SVR4 cpio archive
 * without a checksum (the `070701` variant) - the [v4 format
 * documentation](https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_v4.md?plain=1#L106-L107)
 * claims "with a CRC checksum", but that's not true since RPM 2.4.4
 * (released in 1997).
 * 
 * v6 packages and v4 packages with a file over 4 GiB use a stripped-down
 * variant of cpio with the magic `07070X`. Its file headers only hold the
 * index of the file in the file lists of the RPM header, which is the only
 * place where the file names, sizes and other metadata are stored.
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_v6.md#payload">Source</a>
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_v4.md#payload">Source</a>
 */
func (this *Rpm) Payload() (v []byte, err error) {
	if (this._f_payload) {
		return this.payload, nil
	}
	this._f_payload = true
	tmp48, err := this.HasPayload()
	if err != nil {
		return nil, err
	}
	if (tmp48) {
		_pos, err := this._io.Pos()
		if err != nil {
			return nil, err
		}
		tmp49, err := this.OfsPayload()
		if err != nil {
			return nil, err
		}
		_, err = this._io.Seek(int64(tmp49), io.SeekStart)
		if err != nil {
			return nil, err
		}
		tmp50, err := this.LenPayload()
		if err != nil {
			return nil, err
		}
		tmp51, err := this._io.ReadBytes(int(tmp50))
		if err != nil {
			return nil, err
		}
		tmp51 = tmp51
		this.payload = tmp51
		_, err = this._io.Seek(_pos, io.SeekStart)
		if err != nil {
			return nil, err
		}
	}
	return this.payload, nil
}
func (this *Rpm) SignatureLongSizeTag() (v *Rpm_HeaderIndexRecord, err error) {
	if (this._f_signatureLongSizeTag) {
		return this.signatureLongSizeTag, nil
	}
	this._f_signatureLongSizeTag = true
	tmp52, err := this.HasSignatureLongSizeTag()
	if err != nil {
		return nil, err
	}
	if (tmp52) {
		tmp53 := this.SignatureTagsSteps
		tmp54, err := tmp53[len(tmp53) - 1].LongSizeTagIdx()
		if err != nil {
			return nil, err
		}
		this.signatureLongSizeTag = this.Signature.IndexRecords[tmp54]
	}
	return this.signatureLongSizeTag, nil
}
func (this *Rpm) SignatureSizeTag() (v *Rpm_HeaderIndexRecord, err error) {
	if (this._f_signatureSizeTag) {
		return this.signatureSizeTag, nil
	}
	this._f_signatureSizeTag = true
	tmp55, err := this.HasSignatureSizeTag()
	if err != nil {
		return nil, err
	}
	if (tmp55) {
		tmp56 := this.SignatureTagsSteps
		tmp57, err := tmp56[len(tmp56) - 1].SizeTagIdx()
		if err != nil {
			return nil, err
		}
		this.signatureSizeTag = this.Signature.IndexRecords[tmp57]
	}
	return this.signatureSizeTag, nil
}
type Rpm_Dummy struct {
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_Header
}
func NewRpm_Dummy() *Rpm_Dummy {
	return &Rpm_Dummy{
	}
}

func (this Rpm_Dummy) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_Dummy) Read(io *kaitai.Stream, parent *Rpm_Header, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	return err
}

/**
 * header structure used for both the "header" and "signature", but some tag
 * values have different meanings in signature and header (hence they use
 * different enums)
 */
type Rpm_Header struct {
	HeaderRecord *Rpm_HeaderRecord
	IndexRecords []*Rpm_HeaderIndexRecord
	StorageSection *Rpm_Dummy
	IsSignature bool
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm
	_raw_StorageSection []byte
	_f_isHeader bool
	isHeader bool
}
func NewRpm_Header(isSignature bool) *Rpm_Header {
	return &Rpm_Header{
		IsSignature: isSignature,
	}
}

func (this Rpm_Header) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_Header) Read(io *kaitai.Stream, parent *Rpm, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp58 := NewRpm_HeaderRecord()
	err = tmp58.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.HeaderRecord = tmp58
	for i := 0; i < int(this.HeaderRecord.NumIndexRecords); i++ {
		_ = i
		tmp59 := NewRpm_HeaderIndexRecord()
		err = tmp59.Read(this._io, this, this._root)
		if err != nil {
			return err
		}
		this.IndexRecords = append(this.IndexRecords, tmp59)
	}
	tmp60, err := this._io.ReadBytes(int(this.HeaderRecord.LenStorageSection))
	if err != nil {
		return err
	}
	tmp60 = tmp60
	this._raw_StorageSection = tmp60
	_io__raw_StorageSection := kaitai.NewStream(bytes.NewReader(this._raw_StorageSection))
	tmp61 := NewRpm_Dummy()
	err = tmp61.Read(_io__raw_StorageSection, this, this._root)
	if err != nil {
		return err
	}
	this.StorageSection = tmp61
	return err
}
func (this *Rpm_Header) IsHeader() (v bool, err error) {
	if (this._f_isHeader) {
		return this.isHeader, nil
	}
	this._f_isHeader = true
	this.isHeader = bool(!(this.IsSignature))
	return this.isHeader, nil
}
type Rpm_HeaderIndexRecord struct {
	TagRaw uint32
	RecordType Rpm_RecordTypes
	OfsBody uint32
	Count uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_Header
	_f_body bool
	body kaitai.Struct
	_f_headerTag bool
	headerTag Rpm_HeaderTags
	_f_lenValue bool
	lenValue uint32
	_f_numValues bool
	numValues uint32
	_f_signatureTag bool
	signatureTag Rpm_SignatureTags
}
func NewRpm_HeaderIndexRecord() *Rpm_HeaderIndexRecord {
	return &Rpm_HeaderIndexRecord{
	}
}

func (this Rpm_HeaderIndexRecord) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_HeaderIndexRecord) Read(io *kaitai.Stream, parent *Rpm_Header, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp62, err := this._io.ReadU4be()
	if err != nil {
		return err
	}
	this.TagRaw = uint32(tmp62)
	tmp63, err := this._io.ReadU4be()
	if err != nil {
		return err
	}
	this.RecordType = Rpm_RecordTypes(tmp63)
	if !this.RecordType.isDefined() {
		return kaitai.NewValidationNotInEnumError(this.RecordType, this._io, "/types/header_index_record/seq/1")
	}
	tmp64, err := this._io.ReadU4be()
	if err != nil {
		return err
	}
	this.OfsBody = uint32(tmp64)
	tmp65, err := this._io.ReadU4be()
	if err != nil {
		return err
	}
	this.Count = uint32(tmp65)
	return err
}
func (this *Rpm_HeaderIndexRecord) Body() (v kaitai.Struct, err error) {
	if (this._f_body) {
		return this.body, nil
	}
	this._f_body = true
	thisIo := this._parent.StorageSection._io
	_pos, err := thisIo.Pos()
	if err != nil {
		return nil, err
	}
	_, err = thisIo.Seek(int64(this.OfsBody), io.SeekStart)
	if err != nil {
		return nil, err
	}
	switch (this.RecordType) {
	case Rpm_RecordTypes__Bin:
		tmp66, err := this.LenValue()
		if err != nil {
			return nil, err
		}
		tmp67 := NewRpm_RecordTypeBin(tmp66)
		err = tmp67.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp67
	case Rpm_RecordTypes__Char:
		tmp68, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp69 := NewRpm_RecordTypeUint8(tmp68)
		err = tmp69.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp69
	case Rpm_RecordTypes__I18nString:
		tmp70, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp71 := NewRpm_RecordTypeStringArray(tmp70)
		err = tmp71.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp71
	case Rpm_RecordTypes__String:
		tmp72 := NewRpm_RecordTypeString()
		err = tmp72.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp72
	case Rpm_RecordTypes__StringArray:
		tmp73, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp74 := NewRpm_RecordTypeStringArray(tmp73)
		err = tmp74.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp74
	case Rpm_RecordTypes__Uint16:
		tmp75, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp76 := NewRpm_RecordTypeUint16(tmp75)
		err = tmp76.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp76
	case Rpm_RecordTypes__Uint32:
		tmp77, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp78 := NewRpm_RecordTypeUint32(tmp77)
		err = tmp78.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp78
	case Rpm_RecordTypes__Uint64:
		tmp79, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp80 := NewRpm_RecordTypeUint64(tmp79)
		err = tmp80.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp80
	case Rpm_RecordTypes__Uint8:
		tmp81, err := this.NumValues()
		if err != nil {
			return nil, err
		}
		tmp82 := NewRpm_RecordTypeUint8(tmp81)
		err = tmp82.Read(thisIo, this, this._root)
		if err != nil {
			return nil, err
		}
		this.body = tmp82
	}
	_, err = thisIo.Seek(_pos, io.SeekStart)
	if err != nil {
		return nil, err
	}
	return this.body, nil
}
func (this *Rpm_HeaderIndexRecord) HeaderTag() (v Rpm_HeaderTags, err error) {
	if (this._f_headerTag) {
		return this.headerTag, nil
	}
	this._f_headerTag = true
	tmp83, err := this._parent.IsHeader()
	if err != nil {
		return nil, err
	}
	if (tmp83) {
		this.headerTag = Rpm_HeaderTags(Rpm_HeaderTags(this.TagRaw))
	}
	return this.headerTag, nil
}
func (this *Rpm_HeaderIndexRecord) LenValue() (v uint32, err error) {
	if (this._f_lenValue) {
		return this.lenValue, nil
	}
	this._f_lenValue = true
	if (this.RecordType == Rpm_RecordTypes__Bin) {
		this.lenValue = uint32(this.Count)
	}
	return this.lenValue, nil
}
func (this *Rpm_HeaderIndexRecord) NumValues() (v uint32, err error) {
	if (this._f_numValues) {
		return this.numValues, nil
	}
	this._f_numValues = true
	if (this.RecordType != Rpm_RecordTypes__Bin) {
		this.numValues = uint32(this.Count)
	}
	return this.numValues, nil
}
func (this *Rpm_HeaderIndexRecord) SignatureTag() (v Rpm_SignatureTags, err error) {
	if (this._f_signatureTag) {
		return this.signatureTag, nil
	}
	this._f_signatureTag = true
	if (this._parent.IsSignature) {
		this.signatureTag = Rpm_SignatureTags(Rpm_SignatureTags(this.TagRaw))
	}
	return this.signatureTag, nil
}

/**
 * prefer to access `signature_tag` and `header_tag` instead
 */

/**
 * internal; access `num_values` and `len_value` instead
 */
type Rpm_HeaderRecord struct {
	Magic []byte
	Reserved []byte
	NumIndexRecords uint32
	LenStorageSection uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_Header
}
func NewRpm_HeaderRecord() *Rpm_HeaderRecord {
	return &Rpm_HeaderRecord{
	}
}

func (this Rpm_HeaderRecord) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_HeaderRecord) Read(io *kaitai.Stream, parent *Rpm_Header, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp84, err := this._io.ReadBytes(int(4))
	if err != nil {
		return err
	}
	tmp84 = tmp84
	this.Magic = tmp84
	if !(bytes.Equal(this.Magic, []uint8{142, 173, 232, 1})) {
		return kaitai.NewValidationNotEqualError([]uint8{142, 173, 232, 1}, this.Magic, this._io, "/types/header_record/seq/0")
	}
	tmp85, err := this._io.ReadBytes(int(4))
	if err != nil {
		return err
	}
	tmp85 = tmp85
	this.Reserved = tmp85
	if !(bytes.Equal(this.Reserved, []uint8{0, 0, 0, 0})) {
		return kaitai.NewValidationNotEqualError([]uint8{0, 0, 0, 0}, this.Reserved, this._io, "/types/header_record/seq/1")
	}
	tmp86, err := this._io.ReadU4be()
	if err != nil {
		return err
	}
	this.NumIndexRecords = uint32(tmp86)
	if !(this.NumIndexRecords >= 1) {
		return kaitai.NewValidationLessThanError(1, this.NumIndexRecords, this._io, "/types/header_record/seq/2")
	}
	var tmp87 int8;
	if (this._parent.IsSignature) {
		tmp87 = 32
	} else {
		tmp87 = 65535
	}
	var tmp88 int8;
	if (this._parent.IsSignature) {
		tmp88 = 32
	} else {
		tmp88 = 65535
	}
	if !(this.NumIndexRecords <= tmp87) {
		return kaitai.NewValidationGreaterThanError(tmp88, this.NumIndexRecords, this._io, "/types/header_record/seq/2")
	}
	tmp89, err := this._io.ReadU4be()
	if err != nil {
		return err
	}
	this.LenStorageSection = uint32(tmp89)
	var tmp90 int;
	if (this._parent.IsSignature) {
		tmp90 = (64 * 1024) * 1024
	} else {
		tmp90 = 268435455
	}
	var tmp91 int;
	if (this._parent.IsSignature) {
		tmp91 = (64 * 1024) * 1024
	} else {
		tmp91 = 268435455
	}
	if !(this.LenStorageSection <= tmp90) {
		return kaitai.NewValidationGreaterThanError(tmp91, this.LenStorageSection, this._io, "/types/header_record/seq/3")
	}
	return err
}

/**
 * Size of the storage area for the data
 * pointed to by the Index Records.
 */

/**
 * Like `signature_tags_step`, but looks for `header_tags::payload_size`,
 * which is where v6 packages store the payload size.
 */
type Rpm_HeaderTagsStep struct {
	Idx int32
	PrevPayloadSizeTagIdx int32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm
	_f_payloadSizeTagIdx bool
	payloadSizeTagIdx int
}
func NewRpm_HeaderTagsStep(idx int32, prevPayloadSizeTagIdx int32) *Rpm_HeaderTagsStep {
	return &Rpm_HeaderTagsStep{
		Idx: idx,
		PrevPayloadSizeTagIdx: prevPayloadSizeTagIdx,
	}
}

func (this Rpm_HeaderTagsStep) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_HeaderTagsStep) Read(io *kaitai.Stream, parent *Rpm, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	return err
}
func (this *Rpm_HeaderTagsStep) PayloadSizeTagIdx() (v int, err error) {
	if (this._f_payloadSizeTagIdx) {
		return this.payloadSizeTagIdx, nil
	}
	this._f_payloadSizeTagIdx = true
	var tmp92 int32;
	if (this.PrevPayloadSizeTagIdx != -1) {
		tmp92 = this.PrevPayloadSizeTagIdx
	} else {
		var tmp93 int32;
		tmp94, err := this._parent.Header.IndexRecords[this.Idx].HeaderTag()
		if err != nil {
			return 0, err
		}
		tmp95, err := this._parent.Header.IndexRecords[this.Idx].NumValues()
		if err != nil {
			return 0, err
		}
		if ( ((tmp94 == Rpm_HeaderTags__PayloadSize) && (this._parent.Header.IndexRecords[this.Idx].RecordType == Rpm_RecordTypes__Uint64) && (tmp95 >= 1)) ) {
			tmp93 = this.Idx
		} else {
			tmp93 = -1
		}
		tmp92 = tmp93
	}
	this.payloadSizeTagIdx = int(tmp92)
	return this.payloadSizeTagIdx, nil
}

/**
 * In 2021, Panu Matilainen (an RPM developer) [described this
 * structure](https://github.com/kaitai-io/kaitai_struct_formats/pull/469#discussion_r718288192)
 * as follows:
 * 
 * > The lead as a structure is 25 years obsolete, the data there is
 * > meaningless. Seriously. Except to check for the magic to detect that
 * > it's an rpm file in the first place, just ignore everything in it.
 * > Literally everything.
 * 
 * RPM 4.19 and older rejected packages that didn't meet the `valid`
 * constraints specified here, while RPM 4.20 and later only check the
 * `magic` - see
 * <https://github.com/rpm-software-management/rpm/commit/b3449a0774487a091bbe59e821b4004b06d4fa66>.
 * Nevertheless, RPM still writes values that pass these checks for backwards
 * compatibility, so any `.rpm` file should pass.
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/docs/manual/format_lead.md">Source</a>
 */
type Rpm_Lead struct {
	Magic []byte
	Version *Rpm_RpmVersion
	Type Rpm_RpmTypes
	Architecture Rpm_Architectures
	PackageName string
	Os Rpm_OperatingSystems
	SignatureType uint16
	Reserved []byte
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm
}
func NewRpm_Lead() *Rpm_Lead {
	return &Rpm_Lead{
	}
}

func (this Rpm_Lead) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_Lead) Read(io *kaitai.Stream, parent *Rpm, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp96, err := this._io.ReadBytes(int(4))
	if err != nil {
		return err
	}
	tmp96 = tmp96
	this.Magic = tmp96
	if !(bytes.Equal(this.Magic, []uint8{237, 171, 238, 219})) {
		return kaitai.NewValidationNotEqualError([]uint8{237, 171, 238, 219}, this.Magic, this._io, "/types/lead/seq/0")
	}
	tmp97 := NewRpm_RpmVersion()
	err = tmp97.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.Version = tmp97
	tmp98, err := this._io.ReadU2be()
	if err != nil {
		return err
	}
	this.Type = Rpm_RpmTypes(tmp98)
	tmp99, err := this._io.ReadU2be()
	if err != nil {
		return err
	}
	this.Architecture = Rpm_Architectures(tmp99)
	tmp100, err := this._io.ReadBytes(int(66))
	if err != nil {
		return err
	}
	tmp100 = kaitai.BytesTerminate(tmp100, 0, false)
	this.PackageName = string(tmp100)
	tmp101, err := this._io.ReadU2be()
	if err != nil {
		return err
	}
	this.Os = Rpm_OperatingSystems(tmp101)
	tmp102, err := this._io.ReadU2be()
	if err != nil {
		return err
	}
	this.SignatureType = uint16(tmp102)
	if !(this.SignatureType == 5) {
		return kaitai.NewValidationNotEqualError(5, this.SignatureType, this._io, "/types/lead/seq/6")
	}
	tmp103, err := this._io.ReadBytes(int(16))
	if err != nil {
		return err
	}
	tmp103 = tmp103
	this.Reserved = tmp103
	return err
}

/**
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/lib/rpmlead.cc#L20-L21">Source</a>
 */
type Rpm_RecordTypeBin struct {
	Values [][]byte
	LenValue uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeBin(lenValue uint32) *Rpm_RecordTypeBin {
	return &Rpm_RecordTypeBin{
		LenValue: lenValue,
	}
}

func (this Rpm_RecordTypeBin) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeBin) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(1); i++ {
		_ = i
		tmp104, err := this._io.ReadBytes(int(this.LenValue))
		if err != nil {
			return err
		}
		tmp104 = tmp104
		this.Values = append(this.Values, tmp104)
	}
	return err
}
type Rpm_RecordTypeString struct {
	Values []string
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeString() *Rpm_RecordTypeString {
	return &Rpm_RecordTypeString{
	}
}

func (this Rpm_RecordTypeString) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeString) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(1); i++ {
		_ = i
		tmp105, err := this._io.ReadBytesTerm(0, false, true, true)
		if err != nil {
			return err
		}
		this.Values = append(this.Values, string(tmp105))
	}
	return err
}
type Rpm_RecordTypeStringArray struct {
	Values []string
	NumValues uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeStringArray(numValues uint32) *Rpm_RecordTypeStringArray {
	return &Rpm_RecordTypeStringArray{
		NumValues: numValues,
	}
}

func (this Rpm_RecordTypeStringArray) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeStringArray) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(this.NumValues); i++ {
		_ = i
		tmp106, err := this._io.ReadBytesTerm(0, false, true, true)
		if err != nil {
			return err
		}
		this.Values = append(this.Values, string(tmp106))
	}
	return err
}
type Rpm_RecordTypeUint16 struct {
	Values []uint16
	NumValues uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeUint16(numValues uint32) *Rpm_RecordTypeUint16 {
	return &Rpm_RecordTypeUint16{
		NumValues: numValues,
	}
}

func (this Rpm_RecordTypeUint16) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeUint16) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(this.NumValues); i++ {
		_ = i
		tmp107, err := this._io.ReadU2be()
		if err != nil {
			return err
		}
		this.Values = append(this.Values, tmp107)
	}
	return err
}
type Rpm_RecordTypeUint32 struct {
	Values []uint32
	NumValues uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeUint32(numValues uint32) *Rpm_RecordTypeUint32 {
	return &Rpm_RecordTypeUint32{
		NumValues: numValues,
	}
}

func (this Rpm_RecordTypeUint32) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeUint32) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(this.NumValues); i++ {
		_ = i
		tmp108, err := this._io.ReadU4be()
		if err != nil {
			return err
		}
		this.Values = append(this.Values, tmp108)
	}
	return err
}
type Rpm_RecordTypeUint64 struct {
	Values []uint64
	NumValues uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeUint64(numValues uint32) *Rpm_RecordTypeUint64 {
	return &Rpm_RecordTypeUint64{
		NumValues: numValues,
	}
}

func (this Rpm_RecordTypeUint64) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeUint64) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(this.NumValues); i++ {
		_ = i
		tmp109, err := this._io.ReadU8be()
		if err != nil {
			return err
		}
		this.Values = append(this.Values, tmp109)
	}
	return err
}
type Rpm_RecordTypeUint8 struct {
	Values []uint8
	NumValues uint32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_HeaderIndexRecord
}
func NewRpm_RecordTypeUint8(numValues uint32) *Rpm_RecordTypeUint8 {
	return &Rpm_RecordTypeUint8{
		NumValues: numValues,
	}
}

func (this Rpm_RecordTypeUint8) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RecordTypeUint8) Read(io *kaitai.Stream, parent *Rpm_HeaderIndexRecord, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	for i := 0; i < int(this.NumValues); i++ {
		_ = i
		tmp110, err := this._io.ReadU1()
		if err != nil {
			return err
		}
		this.Values = append(this.Values, tmp110)
	}
	return err
}
type Rpm_RpmVersion struct {
	Major uint8
	Minor uint8
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm_Lead
}
func NewRpm_RpmVersion() *Rpm_RpmVersion {
	return &Rpm_RpmVersion{
	}
}

func (this Rpm_RpmVersion) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_RpmVersion) Read(io *kaitai.Stream, parent *Rpm_Lead, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp111, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Major = tmp111
	if !(this.Major >= 3) {
		return kaitai.NewValidationLessThanError(3, this.Major, this._io, "/types/rpm_version/seq/0")
	}
	if !(this.Major <= 4) {
		return kaitai.NewValidationGreaterThanError(4, this.Major, this._io, "/types/rpm_version/seq/0")
	}
	tmp112, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Minor = tmp112
	return err
}

/**
 * 3 in v3 and v4 packages, 4 in v6 packages.
 * @see <a href="https://github.com/rpm-software-management/rpm/blob/ec9ea8c43808c346da4b6cb454cdc58aef8e506a/lib/rpmlead.cc#L51-L52">Source</a>
 */

/**
 * Finds the first `signature_tags::size` and `signature_tags::long_size`
 * index record. Since Kaitai Struct doesn't have a built-in way to search an
 * array directly, each step receives the indexes found so far via
 * parameters.
 */
type Rpm_SignatureTagsStep struct {
	Idx int32
	PrevSizeTagIdx int32
	PrevLongSizeTagIdx int32
	_io *kaitai.Stream
	_root *Rpm
	_parent *Rpm
	_f_longSizeTagIdx bool
	longSizeTagIdx int
	_f_sizeTagIdx bool
	sizeTagIdx int
}
func NewRpm_SignatureTagsStep(idx int32, prevSizeTagIdx int32, prevLongSizeTagIdx int32) *Rpm_SignatureTagsStep {
	return &Rpm_SignatureTagsStep{
		Idx: idx,
		PrevSizeTagIdx: prevSizeTagIdx,
		PrevLongSizeTagIdx: prevLongSizeTagIdx,
	}
}

func (this Rpm_SignatureTagsStep) IO_() *kaitai.Stream {
	return this._io
}

func (this *Rpm_SignatureTagsStep) Read(io *kaitai.Stream, parent *Rpm, root *Rpm) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	return err
}
func (this *Rpm_SignatureTagsStep) LongSizeTagIdx() (v int, err error) {
	if (this._f_longSizeTagIdx) {
		return this.longSizeTagIdx, nil
	}
	this._f_longSizeTagIdx = true
	var tmp113 int32;
	if (this.PrevLongSizeTagIdx != -1) {
		tmp113 = this.PrevLongSizeTagIdx
	} else {
		var tmp114 int32;
		tmp115, err := this._parent.Signature.IndexRecords[this.Idx].SignatureTag()
		if err != nil {
			return 0, err
		}
		tmp116, err := this._parent.Signature.IndexRecords[this.Idx].NumValues()
		if err != nil {
			return 0, err
		}
		if ( ((tmp115 == Rpm_SignatureTags__LongSize) && (this._parent.Signature.IndexRecords[this.Idx].RecordType == Rpm_RecordTypes__Uint64) && (tmp116 >= 1)) ) {
			tmp114 = this.Idx
		} else {
			tmp114 = -1
		}
		tmp113 = tmp114
	}
	this.longSizeTagIdx = int(tmp113)
	return this.longSizeTagIdx, nil
}
func (this *Rpm_SignatureTagsStep) SizeTagIdx() (v int, err error) {
	if (this._f_sizeTagIdx) {
		return this.sizeTagIdx, nil
	}
	this._f_sizeTagIdx = true
	var tmp117 int32;
	if (this.PrevSizeTagIdx != -1) {
		tmp117 = this.PrevSizeTagIdx
	} else {
		var tmp118 int32;
		tmp119, err := this._parent.Signature.IndexRecords[this.Idx].SignatureTag()
		if err != nil {
			return 0, err
		}
		tmp120, err := this._parent.Signature.IndexRecords[this.Idx].NumValues()
		if err != nil {
			return 0, err
		}
		if ( ((tmp119 == Rpm_SignatureTags__Size) && (this._parent.Signature.IndexRecords[this.Idx].RecordType == Rpm_RecordTypes__Uint32) && (tmp120 >= 1)) ) {
			tmp118 = this.Idx
		} else {
			tmp118 = -1
		}
		tmp117 = tmp118
	}
	this.sizeTagIdx = int(tmp117)
	return this.sizeTagIdx, nil
}