-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPMLead.php
170 lines (151 loc) · 4.86 KB
/
RPMLead.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/*
phpRPMLib 1.0
Copyright (C) 2005-2006, Chris Chabot
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* RPM Lead Class
* This class reads the RPM package lead (info is obsolete, rely on the RPMHeader info)
*
* The lead is the first part of an RPM package file. In previous versions
* of RPM, it was used to store information used internally by RPM. Today,
* however, the lead's sole purpose is to make it easy to identify an RPM
* package file. For example, the file(1) command uses the lead. All the
* information contained in the lead has been duplicated or superseded by
* information contained in the header (RPMHeader class)
* This class is used by the RPMFile class, and unless you know exactly what
* your doing, you won't need to call this class your self.
*
* @see http://www.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html
*
* @access private
* @author Chris Chabot <[email protected]>
*/
class RPMLead extends PEAR
{
/**
* magic
* contains the magic header of a RPM package (has to be 'edabeedb')
* @var string
* @access public
*/
var $magic;
/**
* major
* RPM file format major version. Versions of RPM later than 2.1 create version 3.0 package files.
* @var int
*/
var $major;
/**
* minor
* RPM file format minor version. Versions of RPM later than 2.1 create version 3.0 package files. RPM file format minor version. Versions of RPM later than 2.1 create version 3.0 package files.
* @var int
* @access public
*/
var $minor;
/**
* type
* Type of the RPM file. There are presently two types defined: 0 = binary, 1 = source.
* @var int
* @access public
*/
var $type;
/**
* arch
* The architecture that the package was built for. If its a source package (type = 1) this should be ignored. Architecture-to-number translations can be found in the file /usr/lib/rpm/rpmrc.
* @var int
* @access public
*/
var $arch;
/** name
* The name of the package
* @var string
* @access public
*/
var $name;
/**
* osnum
* The operating system for which the package was built. Translations can be found in the file /usr/lib/rpm/rpmrc.
* @access public
* @var int
*/
var $osnum;
/**
* signature_type
* A type 5 signature (version 3 RPM files and up) means it has a RPM Header instead of an actual signature.
* @access public
* @var int
*/
var $signature_type;
/**
* reserved
* Not used, 16 bytes of padding
* @access public
* @var string
*/
var $reserved;
/**
* _size
* size of lead record (96 bytes)
* @access public
* @var int
*/
var $_size;
/**
* RPMLead constructor
* @param io object RPMIO
* @access public
* @return object PEAR_Error Returns void or an error object
*/
function RPMLead($io)
{
$this->PEAR();
if (PEAR::isError($this->magic = $io->readHex(4))) return $this->raiseError($this->magic);
if ($this->magic != 'edabeedb') return $this->raiseError('RPMLead: invalid magic number in '.$io->file);
if (PEAR::isError($this->major = $io->readByte())) return $this->raiseError($this->major);
if (PEAR::isError($this->minor = $io->readByte())) return $this->raiseError($this->minor);
if (PEAR::isError($this->type = $io->readWord())) return $this->raiseError($this->type);
if (PEAR::isError($this->arch = $io->readWord())) return $this->raiseError($this->arch);
if (PEAR::isError($this->name = $io->readString(66))) return $this->raiseError($this->name);
if (PEAR::isError($this->osnum = $io->readWord())) return $this->raiseError($this->osnum);
if (PEAR::isError($this->signature_type = $io->readWord())) return $this->raiseError($this->signature_type);
if (PEAR::isError($this->reserved = $io->readString(16))) return $this->raiseError($this->reserved);
$this->_size = $io->getRead();
}
/**
* RPMLead destructor
* @access private
*/
function _RPMLead()
{
$this->_PEAR();
}
/**
* getSize returns the (binary on disk) size of the lead record
* @access public
* @return int size of lead record
*/
function getSize()
{
return $this->_size;
}
}
/*
* Local Variables:
* mode: php
* tab-width: 4
* c-basic-offset: 4
* End:
*/
?>