Auto merge of #145809 - he32:installer-perf-fix-1, r=Mark-Simulacrum · tshepang/rust@69d4d5f (original) (raw)

`@@ -551,54 +551,47 @@ install_components() {

`

551

551

`# Decide the destination of the file

`

552

552

`local _file_install_path="$_dest_prefix/$_file"

`

553

553

``

554

``

`-

if echo "$_file" | grep "^etc/" > /dev/null

`

555

``

`-

then

`

556

``

`-

local _f="$(echo "$_file" | sed 's/^etc///')"

`

557

``

`-

_file_install_path="$CFG_SYSCONFDIR/$_f"

`

558

``

`-

fi

`

559

``

-

560

``

`-

if echo "$_file" | grep "^bin/" > /dev/null

`

561

``

`-

then

`

562

``

`-

local _f="$(echo "$_file" | sed 's/^bin///')"

`

563

``

`-

_file_install_path="$CFG_BINDIR/$_f"

`

564

``

`-

fi

`

565

``

-

566

``

`-

if echo "$_file" | grep "^lib/" > /dev/null

`

567

``

`-

then

`

568

``

`-

local _f="$(echo "$_file" | sed 's/^lib///')"

`

569

``

`-

_file_install_path="$CFG_LIBDIR/$_f"

`

570

``

`-

fi

`

571

``

-

572

``

`-

if echo "$_file" | grep "^share" > /dev/null

`

573

``

`-

then

`

574

``

`-

local _f="$(echo "$_file" | sed 's/^share///')"

`

575

``

`-

_file_install_path="$CFG_DATADIR/$_f"

`

576

``

`-

fi

`

577

``

-

578

``

`-

if echo "$_file" | grep "^share/man/" > /dev/null

`

579

``

`-

then

`

580

``

`-

local _f="$(echo "$_file" | sed 's/^share/man///')"

`

581

``

`-

_file_install_path="$CFG_MANDIR/$_f"

`

582

``

`-

fi

`

583

``

-

584

``

`-

HACK: Try to support overriding --docdir. Paths with the form

`

585

``

`-

"share/doc/$product/" can be redirected to a single --docdir

`

586

``

`-

path. If the following detects that --docdir has been specified

`

587

``

`-

then it will replace everything preceding the "$product" path

`

588

``

`-

component. The problem here is that the combined rust installer

`

589

``

`-

contains two "products": rust and cargo; so the contents of those

`

590

``

`-

directories will both be dumped into the same directory; and the

`

591

``

`-

contents of those directories are not disjoint. Since this feature

`

592

``

`-

is almost entirely to support 'make install' anyway I don't expect

`

593

``

`-

this problem to be a big deal in practice.

`

594

``

`-

if [ "$CFG_DOCDIR" != "" ]

`

595

``

`-

then

`

596

``

`-

if echo "$_file" | grep "^share/doc/" > /dev/null

`

597

``

`-

then

`

598

``

`-

local _f="$(echo "$_file" | sed 's/^share/doc/[^/]*///')"

`

599

``

`-

_file_install_path="$CFG_DOCDIR/$_f"

`

600

``

`-

fi

`

601

``

`-

fi

`

``

554

`+

local _is_bin=false

`

``

555

`+

case "$_file" in

`

``

556

`+

etc/*)

`

``

557

`+

local _f="$(echo "$_file" | sed 's/^etc///')"

`

``

558

`+

_file_install_path="$CFG_SYSCONFDIR/$_f"

`

``

559

`+

;;

`

``

560

`+

bin/*)

`

``

561

`+

local _f="$(echo "$_file" | sed 's/^bin///')"

`

``

562

`+

_is_bin=true

`

``

563

`+

_file_install_path="$CFG_BINDIR/$_f"

`

``

564

`+

;;

`

``

565

`+

lib/*)

`

``

566

`+

local _f="$(echo "$_file" | sed 's/^lib///')"

`

``

567

`+

_file_install_path="$CFG_LIBDIR/$_f"

`

``

568

`+

;;

`

``

569

`+

share/man/*)

`

``

570

`+

local _f="$(echo "$_file" | sed 's/^share/man///')"

`

``

571

`+

_file_install_path="$CFG_MANDIR/$_f"

`

``

572

`+

;;

`

``

573

`+

share/doc/*)

`

``

574

`+

HACK: Try to support overriding --docdir. Paths with the form

`

``

575

`+

"share/doc/$product/" can be redirected to a single --docdir

`

``

576

`+

path. If the following detects that --docdir has been specified

`

``

577

`+

then it will replace everything preceding the "$product" path

`

``

578

`+

component. The problem here is that the combined rust installer

`

``

579

`+

contains two "products": rust and cargo; so the contents of those

`

``

580

`+

directories will both be dumped into the same directory; and the

`

``

581

`+

contents of those directories are not disjoint. Since this feature

`

``

582

`+

is almost entirely to support 'make install' anyway I don't expect

`

``

583

`+

this problem to be a big deal in practice.

`

``

584

`+

if [ "$CFG_DOCDIR" != "" ]

`

``

585

`+

then

`

``

586

`+

local _f="$(echo "$_file" | sed 's/^share/doc/[^/]*///')"

`

``

587

`+

_file_install_path="$CFG_DOCDIR/$_f"

`

``

588

`+

fi

`

``

589

`+

;;

`

``

590

`+

share/*)

`

``

591

`+

local _f="$(echo "$_file" | sed 's/^share///')"

`

``

592

`+

_file_install_path="$CFG_DATADIR/$_f"

`

``

593

`+

;;

`

``

594

`+

esac

`

602

595

``

603

596

`# Make sure there's a directory for it

`

604

597

` make_dir_recursive "$(dirname "$_file_install_path")"

`

`@@ -617,13 +610,11 @@ install_components() {

`

617

610

``

618

611

` maybe_backup_path "$_file_install_path"

`

619

612

``

620

``

`-

if echo "$_file" | grep "^bin/" > /dev/null || test -x "$_src_dir/$_component/$_file"

`

621

``

`-

then

`

622

613

` run cp "$_src_dir/$_component/$_file" "$_file_install_path"

`

623

``

`-

run chmod 755 "$_file_install_path"

`

``

614

`+

if isbin∣∣test−x"_is_bin || test -x "isbin∣∣testx"_src_dir/$_component/$_file"; then

`

``

615

`+

run chmod 755 "$_file_install_path"

`

624

616

`else

`

625

``

`-

run cp "$_src_dir/$_component/$_file" "$_file_install_path"

`

626

``

`-

run chmod 644 "$_file_install_path"

`

``

617

`+

run chmod 644 "$_file_install_path"

`

627

618

`fi

`

628

619

` critical_need_ok "file creation failed"

`

629

620

``