|
1 | 1 | #! /bin/sh
|
2 | 2 | # Print a version string.
|
3 |
| -scriptversion=2021-04-11.09; # UTC |
| 3 | +scriptversion=2022-01-26.05; # UTC |
4 | 4 |
|
5 | 5 | # Bootstrap this package from checked-out sources.
|
6 | 6 |
|
7 |
| -# Copyright (C) 2003-2021 Free Software Foundation, Inc. |
| 7 | +# Copyright (C) 2003-2022 Free Software Foundation, Inc. |
8 | 8 |
|
9 | 9 | # This program is free software: you can redistribute it and/or modify
|
10 | 10 | # it under the terms of the GNU General Public License as published by
|
@@ -313,6 +313,116 @@ find_tool ()
|
313 | 313 | eval "export $find_tool_envvar"
|
314 | 314 | }
|
315 | 315 |
|
| 316 | +# Strip blank and comment lines to leave significant entries. |
| 317 | +gitignore_entries() { |
| 318 | + sed '/^#/d; /^$/d' "$@" |
| 319 | +} |
| 320 | + |
| 321 | +# If $STR is not already on a line by itself in $FILE, insert it at the start. |
| 322 | +# Entries are inserted at the start of the ignore list to ensure existing |
| 323 | +# entries starting with ! are not overridden. Such entries support |
| 324 | +# whitelisting exceptions after a more generic blacklist pattern. |
| 325 | +insert_if_absent() { |
| 326 | + file=$1 |
| 327 | + str=$2 |
| 328 | + test -f $file || touch $file |
| 329 | + test -r $file || die "Error: failed to read ignore file: $file" |
| 330 | + duplicate_entries=$(gitignore_entries $file | sort | uniq -d) |
| 331 | + if [ "$duplicate_entries" ] ; then |
| 332 | + die "Error: Duplicate entries in $file: " $duplicate_entries |
| 333 | + fi |
| 334 | + linesold=$(gitignore_entries $file | wc -l) |
| 335 | + linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) |
| 336 | + if [ $linesold != $linesnew ] ; then |
| 337 | + { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ |
| 338 | + || die "insert_if_absent $file $str: failed" |
| 339 | + fi |
| 340 | +} |
| 341 | + |
| 342 | +# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with |
| 343 | +# insert_if_absent. |
| 344 | +insert_vc_ignore() { |
| 345 | + vc_ignore_file="$1" |
| 346 | + pattern="$2" |
| 347 | + case $vc_ignore_file in |
| 348 | + *.gitignore) |
| 349 | + # A .gitignore entry that does not start with '/' applies |
| 350 | + # recursively to subdirectories, so prepend '/' to every |
| 351 | + # .gitignore entry. |
| 352 | + pattern=$(echo "$pattern" | sed s,^,/,);; |
| 353 | + esac |
| 354 | + insert_if_absent "$vc_ignore_file" "$pattern" |
| 355 | +} |
| 356 | + |
| 357 | +symlink_to_dir() |
| 358 | +{ |
| 359 | + src=$1/$2 |
| 360 | + dst=${3-$2} |
| 361 | + |
| 362 | + test -f "$src" && { |
| 363 | + |
| 364 | + # If the destination directory doesn't exist, create it. |
| 365 | + # This is required at least for "lib/uniwidth/cjk.h". |
| 366 | + dst_dir=$(dirname "$dst") |
| 367 | + if ! test -d "$dst_dir"; then |
| 368 | + mkdir -p "$dst_dir" |
| 369 | + |
| 370 | + # If we've just created a directory like lib/uniwidth, |
| 371 | + # tell version control system(s) it's ignorable. |
| 372 | + # FIXME: for now, this does only one level |
| 373 | + parent=$(dirname "$dst_dir") |
| 374 | + for dot_ig in x $vc_ignore; do |
| 375 | + test $dot_ig = x && continue |
| 376 | + ig=$parent/$dot_ig |
| 377 | + insert_vc_ignore $ig "${dst_dir##*/}" |
| 378 | + done |
| 379 | + fi |
| 380 | + |
| 381 | + if $copy; then |
| 382 | + { |
| 383 | + test ! -h "$dst" || { |
| 384 | + echo "$me: rm -f $dst" && |
| 385 | + rm -f "$dst" |
| 386 | + } |
| 387 | + } && |
| 388 | + test -f "$dst" && |
| 389 | + cmp -s "$src" "$dst" || { |
| 390 | + echo "$me: cp -fp $src $dst" && |
| 391 | + cp -fp "$src" "$dst" |
| 392 | + } |
| 393 | + else |
| 394 | + # Leave any existing symlink alone, if it already points to the source, |
| 395 | + # so that broken build tools that care about symlink times |
| 396 | + # aren't confused into doing unnecessary builds. Conversely, if the |
| 397 | + # existing symlink's timestamp is older than the source, make it afresh, |
| 398 | + # so that broken tools aren't confused into skipping needed builds. See |
| 399 | + # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>. |
| 400 | + test -h "$dst" && |
| 401 | + src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && |
| 402 | + dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && |
| 403 | + test "$src_i" = "$dst_i" && |
| 404 | + both_ls=$(ls -dt "$src" "$dst") && |
| 405 | + test "X$both_ls" = "X$dst$nl$src" || { |
| 406 | + dot_dots= |
| 407 | + case $src in |
| 408 | + /*) ;; |
| 409 | + *) |
| 410 | + case /$dst/ in |
| 411 | + *//* | */../* | */./* | /*/*/*/*/*/) |
| 412 | + die "invalid symlink calculation: $src -> $dst";; |
| 413 | + /*/*/*/*/) dot_dots=../../../;; |
| 414 | + /*/*/*/) dot_dots=../../;; |
| 415 | + /*/*/) dot_dots=../;; |
| 416 | + esac;; |
| 417 | + esac |
| 418 | + |
| 419 | + echo "$me: ln -fs $dot_dots$src $dst" && |
| 420 | + ln -fs "$dot_dots$src" "$dst" |
| 421 | + } |
| 422 | + fi |
| 423 | + } |
| 424 | +} |
| 425 | + |
316 | 426 | # Override the default configuration, if necessary.
|
317 | 427 | # Make sure that bootstrap.conf is sourced from the current directory
|
318 | 428 | # if we were invoked as "sh bootstrap".
|
@@ -375,47 +485,6 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
375 | 485 | die "Bootstrapping from a non-checked-out distribution is risky."
|
376 | 486 | fi
|
377 | 487 |
|
378 |
| -# Strip blank and comment lines to leave significant entries. |
379 |
| -gitignore_entries() { |
380 |
| - sed '/^#/d; /^$/d' "$@" |
381 |
| -} |
382 |
| - |
383 |
| -# If $STR is not already on a line by itself in $FILE, insert it at the start. |
384 |
| -# Entries are inserted at the start of the ignore list to ensure existing |
385 |
| -# entries starting with ! are not overridden. Such entries support |
386 |
| -# whitelisting exceptions after a more generic blacklist pattern. |
387 |
| -insert_if_absent() { |
388 |
| - file=$1 |
389 |
| - str=$2 |
390 |
| - test -f $file || touch $file |
391 |
| - test -r $file || die "Error: failed to read ignore file: $file" |
392 |
| - duplicate_entries=$(gitignore_entries $file | sort | uniq -d) |
393 |
| - if [ "$duplicate_entries" ] ; then |
394 |
| - die "Error: Duplicate entries in $file: " $duplicate_entries |
395 |
| - fi |
396 |
| - linesold=$(gitignore_entries $file | wc -l) |
397 |
| - linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) |
398 |
| - if [ $linesold != $linesnew ] ; then |
399 |
| - { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ |
400 |
| - || die "insert_if_absent $file $str: failed" |
401 |
| - fi |
402 |
| -} |
403 |
| - |
404 |
| -# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with |
405 |
| -# insert_if_absent. |
406 |
| -insert_vc_ignore() { |
407 |
| - vc_ignore_file="$1" |
408 |
| - pattern="$2" |
409 |
| - case $vc_ignore_file in |
410 |
| - *.gitignore) |
411 |
| - # A .gitignore entry that does not start with '/' applies |
412 |
| - # recursively to subdirectories, so prepend '/' to every |
413 |
| - # .gitignore entry. |
414 |
| - pattern=$(echo "$pattern" | sed s,^,/,);; |
415 |
| - esac |
416 |
| - insert_if_absent "$vc_ignore_file" "$pattern" |
417 |
| -} |
418 |
| - |
419 | 488 | # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
|
420 | 489 | found_aux_dir=no
|
421 | 490 | grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
|
@@ -694,9 +763,25 @@ if $use_gnulib; then
|
694 | 763 | shallow=
|
695 | 764 | if test -z "$GNULIB_REVISION"; then
|
696 | 765 | git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
|
| 766 | + git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ |
| 767 | + || cleanup_gnulib |
| 768 | + else |
| 769 | + git fetch -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' |
| 770 | + mkdir -p "$gnulib_path" |
| 771 | + # Only want a shallow checkout of $GNULIB_REVISION, but git does not |
| 772 | + # support cloning by commit hash. So attempt a shallow fetch by commit |
| 773 | + # hash to minimize the amount of data downloaded and changes needed to |
| 774 | + # be processed, which can drastically reduce download and processing |
| 775 | + # time for checkout. If the fetch by commit fails, a shallow fetch can |
| 776 | + # not be performed because we do not know what the depth of the commit |
| 777 | + # is without fetching all commits. So fallback to fetching all commits. |
| 778 | + git -C "$gnulib_path" init |
| 779 | + git -C "$gnulib_path" remote add origin ${GNULIB_URL:-$default_gnulib_url} |
| 780 | + git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ |
| 781 | + || git -C "$gnulib_path" fetch origin \ |
| 782 | + || cleanup_gnulib |
| 783 | + git -C "$gnulib_path" reset --hard FETCH_HEAD |
697 | 784 | fi
|
698 |
| - git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ |
699 |
| - || cleanup_gnulib |
700 | 785 |
|
701 | 786 | trap - 1 2 13 15
|
702 | 787 | fi
|
@@ -813,75 +898,6 @@ case $SKIP_PO in
|
813 | 898 | fi;;
|
814 | 899 | esac
|
815 | 900 |
|
816 |
| -symlink_to_dir() |
817 |
| -{ |
818 |
| - src=$1/$2 |
819 |
| - dst=${3-$2} |
820 |
| - |
821 |
| - test -f "$src" && { |
822 |
| - |
823 |
| - # If the destination directory doesn't exist, create it. |
824 |
| - # This is required at least for "lib/uniwidth/cjk.h". |
825 |
| - dst_dir=$(dirname "$dst") |
826 |
| - if ! test -d "$dst_dir"; then |
827 |
| - mkdir -p "$dst_dir" |
828 |
| - |
829 |
| - # If we've just created a directory like lib/uniwidth, |
830 |
| - # tell version control system(s) it's ignorable. |
831 |
| - # FIXME: for now, this does only one level |
832 |
| - parent=$(dirname "$dst_dir") |
833 |
| - for dot_ig in x $vc_ignore; do |
834 |
| - test $dot_ig = x && continue |
835 |
| - ig=$parent/$dot_ig |
836 |
| - insert_vc_ignore $ig "${dst_dir##*/}" |
837 |
| - done |
838 |
| - fi |
839 |
| - |
840 |
| - if $copy; then |
841 |
| - { |
842 |
| - test ! -h "$dst" || { |
843 |
| - echo "$me: rm -f $dst" && |
844 |
| - rm -f "$dst" |
845 |
| - } |
846 |
| - } && |
847 |
| - test -f "$dst" && |
848 |
| - cmp -s "$src" "$dst" || { |
849 |
| - echo "$me: cp -fp $src $dst" && |
850 |
| - cp -fp "$src" "$dst" |
851 |
| - } |
852 |
| - else |
853 |
| - # Leave any existing symlink alone, if it already points to the source, |
854 |
| - # so that broken build tools that care about symlink times |
855 |
| - # aren't confused into doing unnecessary builds. Conversely, if the |
856 |
| - # existing symlink's timestamp is older than the source, make it afresh, |
857 |
| - # so that broken tools aren't confused into skipping needed builds. See |
858 |
| - # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>. |
859 |
| - test -h "$dst" && |
860 |
| - src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && |
861 |
| - dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && |
862 |
| - test "$src_i" = "$dst_i" && |
863 |
| - both_ls=$(ls -dt "$src" "$dst") && |
864 |
| - test "X$both_ls" = "X$dst$nl$src" || { |
865 |
| - dot_dots= |
866 |
| - case $src in |
867 |
| - /*) ;; |
868 |
| - *) |
869 |
| - case /$dst/ in |
870 |
| - *//* | */../* | */./* | /*/*/*/*/*/) |
871 |
| - die "invalid symlink calculation: $src -> $dst";; |
872 |
| - /*/*/*/*/) dot_dots=../../../;; |
873 |
| - /*/*/*/) dot_dots=../../;; |
874 |
| - /*/*/) dot_dots=../;; |
875 |
| - esac;; |
876 |
| - esac |
877 |
| - |
878 |
| - echo "$me: ln -fs $dot_dots$src $dst" && |
879 |
| - ln -fs "$dot_dots$src" "$dst" |
880 |
| - } |
881 |
| - fi |
882 |
| - } |
883 |
| -} |
884 |
| - |
885 | 901 | version_controlled_file() {
|
886 | 902 | parent=$1
|
887 | 903 | file=$2
|
@@ -1093,7 +1109,7 @@ bootstrap_epilogue
|
1093 | 1109 |
|
1094 | 1110 | echo "$0: done. Now you can run './configure'."
|
1095 | 1111 |
|
1096 |
| -# Local variables: |
| 1112 | +# Local Variables: |
1097 | 1113 | # eval: (add-hook 'before-save-hook 'time-stamp)
|
1098 | 1114 | # time-stamp-start: "scriptversion="
|
1099 | 1115 | # time-stamp-format: "%:y-%02m-%02d.%02H"
|
|
0 commit comments