Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BinaryInstaller.php

function BinaryInstaller::installBinaries

File

vendor/composer/composer/src/Composer/Installer/BinaryInstaller.php, line 55

Class

BinaryInstaller
Utility to handle installation of package "bin"/binaries

Namespace

Composer\Installer

Code

public function installBinaries(PackageInterface $package, string $installPath, bool $warnOnOverwrite = true) : void {
    $binaries = $this->getBinaries($package);
    if (!$binaries) {
        return;
    }
    Platform::workaroundFilesystemIssues();
    foreach ($binaries as $bin) {
        $binPath = $installPath . '/' . $bin;
        if (!file_exists($binPath)) {
            $this->io
                ->writeError('    <warning>Skipped installation of bin ' . $bin . ' for package ' . $package->getName() . ': file not found in package</warning>');
            continue;
        }
        if (is_dir($binPath)) {
            $this->io
                ->writeError('    <warning>Skipped installation of bin ' . $bin . ' for package ' . $package->getName() . ': found a directory at that path</warning>');
            continue;
        }
        if (!$this->filesystem
            ->isAbsolutePath($binPath)) {
            // in case a custom installer returned a relative path for the
            // $package, we can now safely turn it into a absolute path (as we
            // already checked the binary's existence). The following helpers
            // will require absolute paths to work properly.
            $binPath = realpath($binPath);
        }
        $this->initializeBinDir();
        $link = $this->binDir . '/' . basename($bin);
        if (file_exists($link)) {
            if (!is_link($link)) {
                if ($warnOnOverwrite) {
                    $this->io
                        ->writeError('    Skipped installation of bin ' . $bin . ' for package ' . $package->getName() . ': name conflicts with an existing file');
                }
                continue;
            }
            if (realpath($link) === realpath($binPath)) {
                // It is a linked binary from a previous installation, which can be replaced with a proxy file
                $this->filesystem
                    ->unlink($link);
            }
        }
        $binCompat = $this->binCompat;
        if ($binCompat === "auto" && (Platform::isWindows() || Platform::isWindowsSubsystemForLinux())) {
            $binCompat = 'full';
        }
        if ($binCompat === "full") {
            $this->installFullBinaries($binPath, $link, $bin, $package);
        }
        else {
            $this->installUnixyProxyBinaries($binPath, $link);
        }
        Silencer::call('chmod', $binPath, 0777 & ~umask());
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal