Changes of Revision 2

php-seld-phar-utils.spec Changed
x
 
1
@@ -1,19 +1,19 @@
2
-# spec file for php-seld-phar-utils
3
+# remirepo/fedora spec file for php-seld-phar-utils
4
 #
5
-# Copyright (c) 2015 Remi Collet
6
+# Copyright (c) 2015-2016 Remi Collet
7
 # License: CC-BY-SA
8
 # http://creativecommons.org/licenses/by-sa/4.0/
9
 #
10
 # Please, preserve the changelog entries
11
 #
12
-%global gh_commit    336bb5ee20de511f3c1a164222fcfd194afcab3a
13
+%global gh_commit    7009b5139491975ef6486545a39f3e6dad5ac30a
14
 %global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
15
 %global gh_owner     Seldaek
16
 %global gh_project   phar-utils
17
 
18
 Name:           php-seld-phar-utils
19
-Version:        1.0.0
20
-Release:        1%{?dist}
21
+Version:        1.0.1
22
+Release:        5%{?dist}
23
 Summary:        PHAR file format utilities
24
 
25
 Group:          Development/Libraries
26
@@ -21,18 +21,26 @@
27
 URL:            https://github.com/%{gh_owner}/%{gh_project}
28
 Source0:        https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz
29
 
30
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
31
+# Autoloader
32
+Source1:        %{gh_project}-autoload.php
33
+
34
 BuildArch:      noarch
35
 BuildRequires:  php(language) >= 5.3
36
+# For test
37
+BuildRequires:  php-cli
38
+# Autoloader
39
+BuildRequires:  php-composer(fedora/autoloader)
40
 
41
 # From composer.json
42
 #       "php": ">=5.3.0",
43
 Requires:       php(language) >= 5.3.0
44
-# From phpcompatifo report for 1.0.0
45
+# From phpcompatifo report for 1.0.1
46
 Requires:       php-date
47
 Requires:       php-hash
48
 Requires:       php-pcre
49
 Requires:       php-spl
50
+# Autoloader
51
+Requires:       php-composer(fedora/autoloader)
52
 
53
 Provides:       php-composer(seld/phar-utils) = %{version}
54
 
55
@@ -40,34 +48,66 @@
56
 %description
57
 PHAR file format utilities, for when PHP phars you up.
58
 
59
+To use this library, you just have to add, in your project:
60
+  require_once '%{_datadir}/php/Seld/PharUtils/autoload.php';
61
+
62
 
63
 %prep
64
 %setup -q -n %{gh_project}-%{gh_commit}
65
 
66
+cp %{SOURCE1} src/autoload.php
67
+
68
 
69
 %build
70
 # Nothing
71
 
72
 
73
 %install
74
-rm -rf       %{buildroot}
75
 # Restore PSR-0 tree
76
 mkdir -p     %{buildroot}%{_datadir}/php/Seld/PharUtils/
77
 cp -pr src/* %{buildroot}%{_datadir}/php/Seld/PharUtils/
78
 
79
 
80
-%clean
81
-rm -rf %{buildroot}
82
+%check
83
+: Check if our autoloader works
84
+php -r '
85
+require "%{buildroot}%{_datadir}/php/Seld/PharUtils/autoload.php";
86
+$a = new \Seld\PharUtils\Timestamps("%{SOURCE1}");
87
+echo "Ok\n";
88
+exit(0);
89
+'
90
 
91
 
92
 %files
93
-%defattr(-,root,root,-)
94
 %{!?_licensedir:%global license %%doc}
95
 %license LICENSE
96
-%doc README.md composer.json
97
+%doc README.md
98
+%doc composer.json
99
 %{_datadir}/php/Seld
100
 
101
 
102
 %changelog
103
+* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-5
104
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
105
+
106
+* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-4
107
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
108
+
109
+* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-3
110
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
111
+
112
+* Fri Oct 21 2016 Remi Collet <remi@fedoraproject.org> - 1.0.1-2
113
+- switch from symfony/class-loader to fedora/autoloader
114
+
115
+* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-2
116
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
117
+
118
+* Wed Oct 14 2015 Remi Collet <remi@fedoraproject.org> - 1.0.1-1
119
+- update to 1.0.1
120
+- add autoloader
121
+
122
+* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.0-2
123
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
124
+
125
 * Mon May  4 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-1
126
 - initial package
127
\ No newline at end of file
128
phar-utils-1.0.0-336bb5e.tar.gz/src/Timestamps.php -> phar-utils-1.0.1-7009b51.tar.gz/src/Timestamps.php Changed
84
 
1
@@ -98,8 +98,7 @@
2
      */
3
     public function save($path, $signatureAlgo)
4
     {
5
-        // detect signature position
6
-        $pos = strrpos($this->contents, "\n") + 1;
7
+        $pos = $this->determineSignatureBegin();
8
 
9
         $algos = array(
10
             \Phar::MD5 => 'md5',
11
@@ -120,7 +119,8 @@
12
             . pack('L', $signatureAlgo)
13
             // ohai Greg & Marcus
14
             . 'GBMB';
15
-        $this->contents = substr_replace($this->contents, $signature, $pos, strlen($this->contents) - $pos);
16
+
17
+        $this->contents = substr($this->contents, 0, $pos) . $signature;
18
 
19
         return file_put_contents($path, $this->contents);
20
     }
21
@@ -131,4 +131,62 @@
22
 
23
         return $res1;
24
     }
25
+
26
+    /**
27
+     * Determine the beginning of the signature.
28
+     *
29
+     * @return int
30
+     */
31
+    private function determineSignatureBegin()
32
+    {
33
+        // detect signature position
34
+        if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
35
+            throw new \RuntimeException('Could not detect the stub\'s end in the phar');
36
+        }
37
+
38
+        // set starting position and skip past manifest length
39
+        $pos = $match01 + strlen($match00);
40
+        $stubEnd = $pos + $this->readUint($pos, 4);
41
+
42
+        $pos += 4;
43
+        $numFiles = $this->readUint($pos, 4);
44
+
45
+        $pos += 4;
46
+
47
+        // skip API version (YOLO)
48
+        $pos += 2;
49
+
50
+        // skip PHAR flags
51
+        $pos += 4;
52
+
53
+        $aliasLength = $this->readUint($pos, 4);
54
+        $pos += 4 + $aliasLength;
55
+
56
+        $metadataLength = $this->readUint($pos, 4);
57
+        $pos += 4 + $metadataLength;
58
+
59
+        $compressedSizes = 0;
60
+        while ($pos < $stubEnd) {
61
+            $filenameLength = $this->readUint($pos, 4);
62
+            $pos += 4 + $filenameLength;
63
+
64
+            // skip filesize and timestamp
65
+            $pos += 2*4;
66
+
67
+            $compressedSizes += $this->readUint($pos, 4);
68
+            // skip compressed file size, crc32 checksum and file flags
69
+            $pos += 3*4;
70
+
71
+            $metadataLength = $this->readUint($pos, 4);
72
+            $pos += 4 + $metadataLength;
73
+
74
+            $numFiles--;
75
+        }
76
+
77
+        if ($numFiles !== 0) {
78
+            throw new \LogicException('All files were not processed, something must have gone wrong');
79
+        }
80
+
81
+        return $pos + $compressedSizes;
82
+    }
83
 }
84
phar-utils-autoload.php Added
11
 
1
@@ -0,0 +1,9 @@
2
+<?php
3
+/* Autoloader for seld/phar-utils and its dependencies */
4
+
5
+if (!class_exists('Fedora\\Autoloader\\Autoload', false)) {
6
+    require_once '/usr/share/php/Fedora/Autoloader/autoload.php';
7
+}
8
+
9
+\Fedora\Autoloader\Autoload::addPsr4('Seld\\PharUtils\\', __DIR__);
10
+
11