Mercurial > octave
comparison bootstrap-funclib.sh @ 33467:c51b07a71421
update to latest gnulib revision d4ec02b3cc70cddaaa5183cc5a45814e0afb2292
This version is current as of the date of this commit and now uses
the Python implementation of gnulib-tool if a suitable puthon3
program is found in $PATH.
* autogen.sh, autopull.sh, bootstrap, bootstrap-funclib.sh:
Update from gnulib.
* bootstrap.conf: Set GNULIB_REVISION and update comments about our
local changes to bootstrap-funclib.sh.
* build-aux/gnulib-bootstrap-git-fetch.diff: Delete.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 26 Apr 2024 13:33:37 -0400 |
parents | e6d339b9309d |
children | 321f49a98a85 |
comparison
equal
deleted
inserted
replaced
33466:65cbf92800ed | 33467:c51b07a71421 |
---|---|
1 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. | 1 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. |
2 | 2 |
3 scriptlibversion=2023-08-29.21; # UTC | 3 scriptlibversion=2024-04-13.15; # UTC |
4 | 4 |
5 # Copyright (C) 2003-2023 Free Software Foundation, Inc. | 5 # Copyright (C) 2003-2024 Free Software Foundation, Inc. |
6 # | 6 # |
7 # This program is free software: you can redistribute it and/or modify | 7 # This program is free software: you can redistribute it and/or modify |
8 # it under the terms of the GNU General Public License as published by | 8 # it under the terms of the GNU General Public License as published by |
9 # the Free Software Foundation, either version 3 of the License, or | 9 # the Free Software Foundation, either version 3 of the License, or |
10 # (at your option) any later version. | 10 # (at your option) any later version. |
439 } | 439 } |
440 | 440 |
441 # --------------------- Preparing GNULIB_SRCDIR for use. --------------------- | 441 # --------------------- Preparing GNULIB_SRCDIR for use. --------------------- |
442 # This is part of autopull.sh, but bootstrap needs it too, for self-upgrading. | 442 # This is part of autopull.sh, but bootstrap needs it too, for self-upgrading. |
443 | 443 |
444 # cleanup_gnulib fails, removing the directory $gnulib_path first. | |
444 cleanup_gnulib() { | 445 cleanup_gnulib() { |
445 status=$? | 446 status=$? |
446 # XXX It's a bad idea to erase the submodule directory if it contains local | |
447 # modifications. | |
448 rm -fr "$gnulib_path" | 447 rm -fr "$gnulib_path" |
449 exit $status | 448 exit $status |
450 } | 449 } |
451 | 450 |
452 git_modules_config () { | 451 git_modules_config () { |
460 # We already checked that $GNULIB_SRCDIR references a directory. | 459 # We already checked that $GNULIB_SRCDIR references a directory. |
461 # Verify that it contains a gnulib checkout. | 460 # Verify that it contains a gnulib checkout. |
462 test -f "$GNULIB_SRCDIR/gnulib-tool" \ | 461 test -f "$GNULIB_SRCDIR/gnulib-tool" \ |
463 || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \ | 462 || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \ |
464 "but does not contain gnulib-tool" | 463 "but does not contain gnulib-tool" |
465 elif $use_git; then | 464 if test -n "$GNULIB_REVISION" && $use_git; then |
465 (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || exit $? | |
466 fi | |
467 else | |
468 if ! $use_git; then | |
469 die "Error: --no-git is specified," \ | |
470 "but neither --gnulib-srcdir nor \$GNULIB_SRCDIR is specified" | |
471 fi | |
472 if git submodule -h | grep -- --reference > /dev/null; then | |
473 : | |
474 else | |
475 die "git version is too old, git >= 1.6.4 is required" | |
476 fi | |
466 gnulib_path=$(git_modules_config submodule.gnulib.path) | 477 gnulib_path=$(git_modules_config submodule.gnulib.path) |
467 test -z "$gnulib_path" && gnulib_path=gnulib | 478 if test -n "$gnulib_path"; then |
468 | 479 # A submodule 'gnulib' is configured. |
469 # Get gnulib files. Populate $gnulib_path, possibly updating a | 480 # Get gnulib files. Populate $gnulib_path, updating the submodule. |
470 # submodule, for use in the rest of the script. | 481 if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then |
471 | 482 # Use GNULIB_REFDIR as a reference. |
472 if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git \ | 483 echo "$0: getting gnulib files..." |
473 && git_modules_config submodule.gnulib.url >/dev/null; then | 484 git submodule update --init --reference "$GNULIB_REFDIR" "$gnulib_path" \ |
474 # Use GNULIB_REFDIR as a reference. | 485 || exit $? |
475 echo "$0: getting gnulib files..." | |
476 if git submodule -h|grep -- --reference > /dev/null; then | |
477 # Prefer the one-liner available in git 1.6.4 or newer. | |
478 git submodule update --init --reference "$GNULIB_REFDIR" \ | |
479 "$gnulib_path" || exit $? | |
480 else | 486 else |
481 # This fallback allows at least git 1.5.5. | 487 # GNULIB_REFDIR is not set or not usable. Ignore it. |
482 if test -f "$gnulib_path"/gnulib-tool; then | 488 if git_modules_config submodule.gnulib.url >/dev/null; then |
483 # Since file already exists, assume submodule init already complete. | 489 echo "$0: getting gnulib files..." |
490 git submodule init -- "$gnulib_path" || exit $? | |
484 git submodule update -- "$gnulib_path" || exit $? | 491 git submodule update -- "$gnulib_path" || exit $? |
485 else | 492 else |
486 # Older git can't clone into an empty directory. | 493 die "Error: submodule 'gnulib' has no configured url" |
487 rmdir "$gnulib_path" 2>/dev/null | |
488 git clone --reference "$GNULIB_REFDIR" \ | |
489 "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \ | |
490 && git submodule init -- "$gnulib_path" \ | |
491 && git submodule update -- "$gnulib_path" \ | |
492 || exit $? | |
493 fi | 494 fi |
494 fi | 495 fi |
495 else | 496 else |
496 # GNULIB_REFDIR is not set or not usable. Ignore it. | 497 gnulib_path='gnulib' |
497 if git_modules_config submodule.gnulib.url >/dev/null; then | 498 if test ! -d "$gnulib_path"; then |
499 # The subdirectory 'gnulib' does not yet exist. Clone into it. | |
498 echo "$0: getting gnulib files..." | 500 echo "$0: getting gnulib files..." |
499 git submodule init -- "$gnulib_path" || exit $? | |
500 git submodule update -- "$gnulib_path" || exit $? | |
501 | |
502 elif [ ! -d "$gnulib_path" ]; then | |
503 echo "$0: getting gnulib files..." | |
504 | |
505 trap cleanup_gnulib HUP INT PIPE TERM | 501 trap cleanup_gnulib HUP INT PIPE TERM |
506 | |
507 shallow= | 502 shallow= |
508 if test -z "$GNULIB_REVISION"; then | 503 if test -z "$GNULIB_REVISION"; then |
509 if git clone -h 2>&1 | grep -- --depth > /dev/null; then | 504 if git clone -h 2>&1 | grep -- --depth > /dev/null; then |
510 shallow='--depth 2' | 505 shallow='--depth 2' |
511 fi | 506 fi |
523 # time for checkout. If the fetch by commit fails, a shallow fetch can | 518 # time for checkout. If the fetch by commit fails, a shallow fetch can |
524 # not be performed because we do not know what the depth of the commit | 519 # not be performed because we do not know what the depth of the commit |
525 # is without fetching all commits. So fall back to fetching all | 520 # is without fetching all commits. So fall back to fetching all |
526 # commits. | 521 # commits. |
527 git -C "$gnulib_path" init | 522 git -C "$gnulib_path" init |
528 git -C "$gnulib_path" remote add origin \ | 523 git -C "$gnulib_path" remote add origin ${GNULIB_URL:-$default_gnulib_url} |
529 ${GNULIB_URL:-$default_gnulib_url} | |
530 git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ | 524 git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ |
531 || git -C "$gnulib_path" fetch origin \ | 525 || git -C "$gnulib_path" fetch origin \ |
532 || cleanup_gnulib | 526 || cleanup_gnulib |
533 git -C "$gnulib_path" reset --hard FETCH_HEAD | 527 git -C "$gnulib_path" reset --hard FETCH_HEAD |
528 (cd "$gnulib_path" && git checkout "$GNULIB_REVISION") || cleanup_gnulib | |
534 fi | 529 fi |
535 | |
536 trap - HUP INT PIPE TERM | 530 trap - HUP INT PIPE TERM |
537 | 531 else |
538 elif test -n "$GNULIB_REVISION" \ | 532 # The subdirectory 'gnulib' already exists. |
539 && ! git --git-dir="$gnulib_path"/.git cat-file \ | 533 if test -n "$GNULIB_REVISION"; then |
540 commit "$GNULIB_REVISION"; then | 534 if test -d "$gnulib_path/.git"; then |
541 git --git-dir="$gnulib_path"/.git fetch | 535 (cd "$gnulib_path" && git checkout "$GNULIB_REVISION") || exit 1 |
536 else | |
537 die "Error: GNULIB_REVISION is specified in bootstrap.conf," \ | |
538 "but '$gnulib_path' contains no git history" | |
539 fi | |
540 fi | |
542 fi | 541 fi |
543 fi | 542 fi |
543 # Verify that $gnulib_path contains a gnulib checkout. | |
544 test -f "$gnulib_path/gnulib-tool" \ | |
545 || die "Error: '$gnulib_path' is supposed to contain a gnulib checkout," \ | |
546 "but does not contain gnulib-tool" | |
544 GNULIB_SRCDIR=$gnulib_path | 547 GNULIB_SRCDIR=$gnulib_path |
545 # Verify that the submodule contains a gnulib checkout. | 548 fi |
546 test -f "$gnulib_path/gnulib-tool" \ | |
547 || die "Error: $gnulib_path is supposed to contain a gnulib checkout," \ | |
548 "but does not contain gnulib-tool" | |
549 fi | |
550 | |
551 # XXX Should this be done if $use_git is false? | |
552 if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \ | |
553 && ! git_modules_config submodule.gnulib.url >/dev/null; then | |
554 if ! git --git-dir="$GNULIB_SRCDIR"/.git cat-file \ | |
555 commit "$GNULIB_REVISION"; then | |
556 git --git-dir="$GNULIB_SRCDIR"/.git fetch | |
557 fi | |
558 (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib | |
559 fi | |
560 | |
561 # $GNULIB_SRCDIR now points to the version of gnulib to use, and | 549 # $GNULIB_SRCDIR now points to the version of gnulib to use, and |
562 # we no longer need to use git or $gnulib_path below here. | 550 # we no longer need to use git or $gnulib_path below here. |
563 } | 551 } |
564 | 552 |
565 # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. -------- | 553 # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. -------- |
617 # -------- Fetch auxiliary files from the network. -------------------------- | 605 # -------- Fetch auxiliary files from the network. -------------------------- |
618 | 606 |
619 autopull_usage() { | 607 autopull_usage() { |
620 cat <<EOF | 608 cat <<EOF |
621 Usage: $me [OPTION]... | 609 Usage: $me [OPTION]... |
622 Bootstrap this package from the checked-out sources. | 610 Bootstrap this package from the checked-out sources, phase 1: |
611 Pull files from the network. | |
623 | 612 |
624 Optional environment variables: | 613 Optional environment variables: |
625 GNULIB_SRCDIR Specifies the local directory where gnulib | 614 GNULIB_SRCDIR Specifies the local directory where gnulib |
626 sources reside. Use this if you already | 615 sources reside. Use this if you already |
627 have gnulib sources on your machine, and | 616 have gnulib sources on your machine, and |
634 GNULIB_URL URL of the gnulib repository. The default is | 623 GNULIB_URL URL of the gnulib repository. The default is |
635 $default_gnulib_url, | 624 $default_gnulib_url, |
636 which is Gnulib's upstream repository. | 625 which is Gnulib's upstream repository. |
637 | 626 |
638 Options: | 627 Options: |
639 --bootstrap-sync if this bootstrap script is not identical to | 628 |
629 --bootstrap-sync If this bootstrap script is not identical to | |
640 the version in the local gnulib sources, | 630 the version in the local gnulib sources, |
641 update this script, and then restart it with | 631 update this script, and then restart it with |
642 /bin/sh or the shell \$CONFIG_SHELL | 632 /bin/sh or the shell \$CONFIG_SHELL. |
643 --no-bootstrap-sync do not check whether bootstrap is out of sync | 633 --no-bootstrap-sync Do not check whether bootstrap is out of sync. |
644 --force attempt to bootstrap even if the sources seem | 634 |
645 not to have been checked out | 635 --force Attempt to bootstrap even if the sources seem |
646 --no-git do not use git to update gnulib. Requires that | 636 not to have been checked out. |
647 \$GNULIB_SRCDIR or the --gnulib-srcdir option | 637 --no-git Do not use git to update gnulib. Requires that |
648 points to a gnulib repository with the correct | 638 \$GNULIB_SRCDIR points to a gnulib repository |
649 revision | 639 with the correct revision. |
650 --skip-po do not download po files | 640 --skip-po Do not download *.po files. |
651 EOF | 641 EOF |
652 bootstrap_print_option_usage_hook | 642 bootstrap_print_option_usage_hook |
653 cat <<EOF | 643 cat <<EOF |
654 If the file bootstrap.conf exists in the same directory as this script, its | 644 If the file bootstrap.conf exists in the same directory as this script, its |
655 contents are read as shell variables to configure the bootstrap. | 645 contents are read as shell variables to configure the bootstrap. |
657 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR | 647 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR |
658 are honored. | 648 are honored. |
659 | 649 |
660 Gnulib sources can be fetched in various ways: | 650 Gnulib sources can be fetched in various ways: |
661 | 651 |
662 * If the environment variable GNULIB_SRCDIR is set (either as an | 652 * If the environment variable GNULIB_SRCDIR is set, then sources are |
663 environment variable or via the --gnulib-srcdir option), then sources | 653 fetched from that local directory. If it is a git repository and the |
664 are fetched from that local directory. If it is a git repository and | 654 configuration variable GNULIB_REVISION is set in bootstrap.conf, then |
665 the configuration variable GNULIB_REVISION is set in bootstrap.conf, | 655 that revision is checked out. |
666 then that revision is checked out. | |
667 | 656 |
668 * Otherwise, if this package is in a git repository with a 'gnulib' | 657 * Otherwise, if this package is in a git repository with a 'gnulib' |
669 submodule configured, then that submodule is initialized and updated | 658 submodule configured, then that submodule is initialized and updated |
670 and sources are fetched from there. If GNULIB_REFDIR is set (either | 659 and sources are fetched from there. If the environment variable |
671 as an environment variable or via the --gnulib-refdir option) and is | 660 GNULIB_REFDIR is set and is a git repository, then it is used as a |
672 a git repository, then it is used as a reference. | 661 reference. |
673 | 662 |
674 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources | 663 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources |
675 are cloned into that directory using git from \$GNULIB_URL, defaulting | 664 are cloned into that directory using git from \$GNULIB_URL, defaulting |
676 to $default_gnulib_url. | 665 to $default_gnulib_url. |
677 If the configuration variable GNULIB_REVISION is set in bootstrap.conf, | 666 If the configuration variable GNULIB_REVISION is set in bootstrap.conf, |
747 check_build_prerequisites $use_git | 736 check_build_prerequisites $use_git |
748 | 737 |
749 if $use_gnulib || $bootstrap_sync; then | 738 if $use_gnulib || $bootstrap_sync; then |
750 prepare_GNULIB_SRCDIR | 739 prepare_GNULIB_SRCDIR |
751 if $bootstrap_sync; then | 740 if $bootstrap_sync; then |
752 upgrade_bootstrap | 741 upgrade_bootstrap "$@" |
753 fi | 742 fi |
754 fi | 743 fi |
755 | 744 |
756 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6. | 745 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6. |
757 # Also find the compatible sha1 utility on the BSDs | 746 # Also find the compatible sha1 utility on the BSDs |
860 # -------- Generate files automatically from existing sources. -------------- | 849 # -------- Generate files automatically from existing sources. -------------- |
861 | 850 |
862 autogen_usage() { | 851 autogen_usage() { |
863 cat <<EOF | 852 cat <<EOF |
864 Usage: $me [OPTION]... | 853 Usage: $me [OPTION]... |
865 Bootstrap this package from the checked-out sources. | 854 Bootstrap this package from the checked-out sources, phase 2: |
855 Generate files from local files (no network access). | |
866 | 856 |
867 Optional environment variables: | 857 Optional environment variables: |
868 GNULIB_SRCDIR Specifies the local directory where gnulib | 858 GNULIB_SRCDIR Specifies the local directory where gnulib |
869 sources reside. Use this if you already | 859 sources reside. Use this if you already |
870 have gnulib sources on your machine, and | 860 have gnulib sources on your machine, and |
871 you want to use these sources. | 861 you want to use these sources. |
872 | 862 |
873 Options: | 863 Options: |
874 --copy copy files instead of creating symbolic links | 864 --copy Copy files instead of creating symbolic links. |
875 --force attempt to bootstrap even if the sources seem | 865 --force Attempt to bootstrap even if the sources seem |
876 not to have been checked out | 866 not to have been checked out. |
877 EOF | 867 EOF |
878 bootstrap_print_option_usage_hook | 868 bootstrap_print_option_usage_hook |
879 cat <<EOF | 869 cat <<EOF |
880 If the file bootstrap.conf exists in the same directory as this script, its | 870 If the file bootstrap.conf exists in the same directory as this script, its |
881 contents are read as shell variables to configure the bootstrap. | 871 contents are read as shell variables to configure the bootstrap. |