summaryrefslogtreecommitdiffstats
path: root/composer-rpm.patch
blob: cbb4b3c82dc1f0bd8cb067eb95bba1e8382f1417 (plain)
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
diff -up ./bin/composer.rpm ./bin/composer
--- ./bin/composer.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./bin/composer	2021-09-14 15:45:33.025118009 +0200
@@ -6,7 +6,7 @@ if (PHP_SAPI !== 'cli' && PHP_SAPI !== '
 }
 
 setlocale(LC_ALL, 'C');
-require __DIR__.'/../src/bootstrap.php';
+require '/usr/share/php/Composer/autoload.php';
 
 use Composer\Console\Application;
 use Composer\XdebugHandler\XdebugHandler;
diff -up ./src/Composer/Autoload/AutoloadGenerator.php.rpm ./src/Composer/Autoload/AutoloadGenerator.php
--- ./src/Composer/Autoload/AutoloadGenerator.php.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./src/Composer/Autoload/AutoloadGenerator.php	2021-09-14 15:45:33.025118009 +0200
@@ -395,7 +395,7 @@ EOF;
         $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
 
         $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
-        $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
+        $filesystem->safeCopy((getenv('BUILDROOT')?:'') . '/usr/share/composer/LICENSE', $targetDir.'/LICENSE');
 
         if ($this->runScripts) {
             $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
diff -up ./src/Composer/Compiler.php.rpm ./src/Composer/Compiler.php
--- ./src/Composer/Compiler.php.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./src/Composer/Compiler.php	2021-09-14 15:45:33.025118009 +0200
@@ -118,7 +118,7 @@ class Compiler
         // Add Composer resources
         $finder = new Finder();
         $finder->files()
-            ->in(__DIR__.'/../../res')
+            ->in((getenv('BUILDROOT')?:'') . '/usr/share/composer/res')
             ->sort($finderSort)
         ;
         foreach ($finder as $file) {
diff -up ./src/Composer/InstalledVersions.php.rpm ./src/Composer/InstalledVersions.php
--- ./src/Composer/InstalledVersions.php.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./src/Composer/InstalledVersions.php	2021-09-14 15:45:33.026118007 +0200
@@ -251,7 +251,7 @@ class InstalledVersions
         if (null === self::$installed) {
             // only require the installed.php file if this file is loaded from its dumped location,
             // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
-            if (substr(__DIR__, -8, 1) !== 'C') {
+            if (substr(__DIR__, -8, 1) !== 'C' && is_file(__DIR__ . '/installed.php')) {
                 self::$installed = include __DIR__ . '/installed.php';
             } else {
                 self::$installed = array();
@@ -324,7 +324,7 @@ class InstalledVersions
         if (null === self::$installed) {
             // only require the installed.php file if this file is loaded from its dumped location,
             // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
-            if (substr(__DIR__, -8, 1) !== 'C') {
+            if (substr(__DIR__, -8, 1) !== 'C' && is_file(__DIR__ . '/installed.php')) {
                 self::$installed = require __DIR__ . '/installed.php';
             } else {
                 self::$installed = array();
diff -up ./src/Composer/Json/JsonFile.php.rpm ./src/Composer/Json/JsonFile.php
--- ./src/Composer/Json/JsonFile.php.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./src/Composer/Json/JsonFile.php	2021-09-14 15:46:22.434026477 +0200
@@ -34,7 +34,7 @@ class JsonFile
     const JSON_PRETTY_PRINT = 128;
     const JSON_UNESCAPED_UNICODE = 256;
 
-    const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
+    const COMPOSER_SCHEMA_PATH = '/usr/share/composer/res/composer-schema.json';
 
     /** @var string */
     private $path;
@@ -191,7 +191,7 @@ class JsonFile
         $isComposerSchemaFile = false;
         if (null === $schemaFile) {
             $isComposerSchemaFile = true;
-            $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
+            $schemaFile = (getenv('BUILDROOT')?:'') . self::COMPOSER_SCHEMA_PATH;
         }
 
         // Prepend with file:// only when not using a special schema already (e.g. in the phar)
diff -up ./tests/Composer/Test/Json/ComposerSchemaTest.php.rpm ./tests/Composer/Test/Json/ComposerSchemaTest.php
--- ./tests/Composer/Test/Json/ComposerSchemaTest.php.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./tests/Composer/Test/Json/ComposerSchemaTest.php	2021-09-14 15:45:33.025118009 +0200
@@ -93,7 +93,8 @@ class ComposerSchemaTest extends TestCas
     private function check($json)
     {
         $validator = new Validator();
-        $validator->check(json_decode($json), (object) array('$ref' => 'file://' . __DIR__ . '/../../../../res/composer-schema.json'));
+        $f = (getenv('BUILDROOT')?:'') . '/usr/share/composer/res/composer-schema.json';
+        $validator->check(json_decode($json), (object) array('$ref' => 'file://' . $f));
 
         if (!$validator->isValid()) {
             $errors = $validator->getErrors();
diff -up ./tests/Composer/Test/PolyfillTestCase.php.rpm ./tests/Composer/Test/PolyfillTestCase.php
--- ./tests/Composer/Test/PolyfillTestCase.php.rpm	2021-09-14 15:45:17.000000000 +0200
+++ ./tests/Composer/Test/PolyfillTestCase.php	2021-09-14 15:45:33.026118007 +0200
@@ -15,10 +15,35 @@ namespace Composer\Test {
     use PHPUnit\Framework\Constraint\LogicalNot;
     use PHPUnit\Framework\Constraint\StringContains;
 
-    if (method_exists('PHPUnit\Framework\TestCase', 'assertStringContainsString')) {
+    if (method_exists('PHPUnit\Framework\TestCase', 'assertFileDoesNotExist')) {
         abstract class PolyfillTestCase extends TestCase
         {
         }
+    } else if (method_exists('PHPUnit\Framework\TestCase', 'assertStringContainsString')) {
+        abstract class PolyfillTestCase extends TestCase {
+            /**
+             * @param string $filename
+             * @param string $message
+             *
+             * @return void
+             */
+            public static function assertFileDoesNotExist($filename, $message = '')
+            {
+                static::assertFileNotExists($filename, $message);
+            }
+
+            /**
+             * @param string $pattern
+             * @param string $string
+             * @param string $message
+             *
+             * @return void
+             */
+            public static function assertMatchesRegularExpression($pattern, $string, $message = '')
+            {
+                static::assertRegExp($pattern, $string, $message);
+            }
+        }
     } else {
         abstract class PolyfillTestCase extends TestCase
         {