Browse code

fix embedded repository clone during update

Nat! authored on 08-06-2016 11:16:38
Showing 2 changed files
... ...
@@ -10,7 +10,6 @@
10 10
 * Make the Dirty Harry check less foolproof, but also less annoying.
11 11
 
12 12
 
13
-
14 13
 0.25
15 14
 ===
16 15
 
... ...
@@ -436,7 +436,6 @@ search_git_repo_in_parent_directory()
436 436
 }
437 437
 
438 438
 
439
-
440 439
 checkout()
441 440
 {
442 441
    local url
... ...
@@ -468,24 +467,6 @@ checkout()
468 467
    fi
469 468
    name2="`basename -- "${url}"`"  # only works for git really
470 469
 
471
-
472
-   #
473
-   # this implicitly ensures, that these folders are
474
-   # movable and cleanable by mulle-bootstrap
475
-   # so ppl can't really use  src mistakenly
476
-
477
-   if [ -e "${DEPENDENCY_SUBDIR}" -o -e "${CLONESBUILD_SUBDIR}" ]
478
-   then
479
-      # if this is a "refetch" don't bother to warn
480
-      if [ ! -e "${BOOTSTRAP_SUBDIR}.auto" ]
481
-      then
482
-         log_error "Stale folders \"${DEPENDENCY_SUBDIR}\" and/or \"${CLONESBUILD_SUBDIR}\" found."
483
-         log_error "Please remove them before continuing."
484
-         log_info  "Suggested command: ${C_RESET_BOLD}mulle-bootstrap clean output${C_INFO}"
485
-         exit 1
486
-      fi
487
-   fi
488
-
489 470
    local operation
490 471
    local map
491 472
    local scmflagsdefault
... ...
@@ -609,6 +590,23 @@ Suggested fix:
609 590
    fi
610 591
 }
611 592
 
593
+
594
+did_clone_repository()
595
+{
596
+   local name
597
+   local url
598
+   local branch
599
+
600
+   name="$1"
601
+   url="$2"
602
+   branch="$3"
603
+
604
+   local dstdir
605
+
606
+   dstdir="${CLONESFETCH_SUBDIR}/${name}"
607
+   run_build_settings_script "${name}" "${url}" "${dstdir}" "did-install" "${dstdir}" "${name}"
608
+}
609
+
612 610
 #
613 611
 # Use git clones for stuff that gets tagged
614 612
 # if you specify ../ it will assume you have
... ...
@@ -643,7 +641,7 @@ checkout_repository()
643 641
          old_bootstrap="${BOOTSTRAP_SUBDIR}"
644 642
 
645 643
          BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
646
-         install_embedded_repositories "${dstdir}/"
644
+         clone_embedded_repositories "${dstdir}/"
647 645
          BOOTSTRAP_SUBDIR="${old_bootstrap}"
648 646
 
649 647
          bootstrap_auto_update "${name}" "${url}" "${dstdir}"
... ...
@@ -662,21 +660,27 @@ checkout_repository()
662 660
 
663 661
       log_fluff "Repository \"${dstdir}\" already exists"
664 662
    fi
663
+
665 664
    return 0
666 665
 }
667 666
 
668 667
 
668
+
669 669
 clone_repository()
670 670
 {
671
+   local clone
672
+
673
+   clone="${1}"
674
+
671 675
    local name
672 676
    local url
673 677
    local branch
674 678
    local scm
675 679
 
676
-   name="$1"
677
-   url="$2"
678
-   branch="$3"
679
-   scm="$4"
680
+   name="`canonical_name_from_clone "${clone}"`"
681
+   url="`url_from_clone "${clone}"`"
682
+   branch="`branch_from_clone "${clone}"`"
683
+   scm="`scm_from_clone "${clone}"`"
680 684
 
681 685
    local tag
682 686
    local dstdir
... ...
@@ -689,29 +693,17 @@ clone_repository()
689 693
    # mark the checkout progress, so that we don't do incomplete fetches and
690 694
    # later on happily build
691 695
 
696
+   create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
697
+
692 698
    checkout_repository "${name}" "${url}" "${dstdir}" "${branch}" "${tag}" "${scm}"
693 699
    flag=$?
694 700
 
701
+   remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
702
+
695 703
    return $flag
696 704
 }
697 705
 
698 706
 
699
-did_clone_repository()
700
-{
701
-   local name
702
-   local url
703
-   local branch
704
-
705
-   name="$1"
706
-   url="$2"
707
-   branch="$3"
708
-
709
-   local dstdir
710
-
711
-   dstdir="${CLONESFETCH_SUBDIR}/${name}"
712
-   run_build_settings_script "${name}" "${url}" "${dstdir}" "did-install" "${dstdir}" "${name}"
713
-}
714
-
715 707
 
716 708
 clone_repositories()
717 709
 {
... ...
@@ -725,6 +717,7 @@ clone_repositories()
725 717
    local match
726 718
    local branch
727 719
    local scm
720
+   local rval
728 721
 
729 722
    old="${IFS:-" "}"
730 723
    fetched=""
... ...
@@ -754,17 +747,7 @@ clone_repositories()
754 747
                fetched="${fetched}
755 748
 ${clone}"
756 749
 
757
-               name="`canonical_name_from_clone "${clone}"`"
758
-               url="`url_from_clone "${clone}"`"
759
-               branch="`branch_from_clone "${clone}"`"
760
-               scm="`scm_from_clone "${clone}"`"
761
-
762
-               create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
763
-
764
-               clone_repository "${name}" "${url}" "${branch}" "${scm}"
765
-
766
-               remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
767
-
750
+               clone_repository "${clone}"
768 751
                if [ $? -eq 1 ]
769 752
                then
770 753
                   stop=0
... ...
@@ -792,87 +775,103 @@ ${clone}"
792 775
 }
793 776
 
794 777
 
795
-install_embedded_repositories()
778
+clone_embedded_repository()
796 779
 {
797 780
    local dstprefix
781
+   local clone
798 782
 
799 783
    dstprefix="$1"
784
+   clone="$2"
800 785
 
801
-   local clones
802
-   local clone
803
-   local old
804 786
    local name
805 787
    local url
806 788
    local dstdir
807 789
    local branch
790
+   local tag
808 791
    local scm
809 792
 
810
-   old="${IFS:-" "}"
793
+   name="`canonical_name_from_clone "${clone}"`"
794
+   url="`url_from_clone "${clone}"`"
795
+   branch="`branch_from_clone "${clone}"`"
796
+   scm="`scm_from_clone "${clone}"`"
797
+   tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
798
+   dstdir="${dstprefix}${name}"
811 799
 
812
-   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
813
-   export MULLE_BOOTSTRAP_SETTINGS_NO_AUTO
800
+   log_fetch_action "${name}" "${dstdir}"
814 801
 
815
-   clones="`read_fetch_setting "embedded_repositories"`"
816
-   if [ "${clones}" != "" ]
802
+   if [ ! -d "${dstdir}" ]
817 803
    then
818
-      IFS="
819
-"
820
-      for clone in ${clones}
821
-      do
822
-         IFS="${old}"
804
+      create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
823 805
 
824
-         name="`canonical_name_from_clone "${clone}"`"
825
-         url="`url_from_clone "${clone}"`"
826
-         branch="`branch_from_clone "${clone}"`"
827
-         scm="`scm_from_clone "${clone}"`"
806
+      #
807
+      # embedded_repositories are just cloned, no symlinks,
808
+      #
809
+      local old_forbidden
828 810
 
829
-         tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
830
-         dstdir="${dstprefix}${name}"
831
-         log_fetch_action "${name}" "${dstdir}"
811
+      old_forbidden="${SYMLINK_FORBIDDEN}"
832 812
 
833
-         create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
813
+      SYMLINK_FORBIDDEN="YES"
814
+      checkout "${name}" "${url}" "${dstdir}" "${branch}" "${tag}" "${scm}"
815
+      SYMLINK_FORBIDDEN="${old_forbidden}"
834 816
 
835
-         if [ ! -d "${dstdir}" ]
817
+      if read_yes_no_config_setting "update_gitignore" "YES"
818
+      then
819
+         if [ -d .git ]
836 820
          then
837
-            #
838
-            # embedded_repositories are just cloned, no symlinks,
839
-            #
840
-            local old_forbidden
821
+            append_dir_to_gitignore_if_needed "${dstdir}"
822
+         fi
823
+      fi
841 824
 
842
-            old_forbidden="${SYMLINK_FORBIDDEN}"
825
+      # memo that we did this with a symlink
826
+      # store it inside the possibly recursed dstprefix dependency
827
+      local symlinkcontent
828
+      local symlinkdir
829
+      local symlinkrelative
843 830
 
844
-            SYMLINK_FORBIDDEN="YES"
845
-            checkout "${name}" "${url}" "${dstdir}" "${branch}" "${tag}" "${scm}"
846
-            SYMLINK_FORBIDDEN="$old_forbidden"
831
+      symlinkrelative=`compute_relative "${CLONESFETCH_SUBDIR}/.embedded"`
832
+      symlinkdir="${dstprefix}${CLONESFETCH_SUBDIR}/.embedded"
833
+      mkdir_if_missing "${symlinkdir}"
834
+      symlinkcontent="${symlinkrelative}/${dstdir}"
847 835
 
848
-            if read_yes_no_config_setting "update_gitignore" "YES"
849
-            then
850
-               if [ -d .git ]
851
-               then
852
-                  append_dir_to_gitignore_if_needed "${dstdir}"
853
-               fi
854
-            fi
836
+      log_fluff "Remember embedded repository \"${name}\" via \"${symlinkdir}/${name}\""
837
+      exekutor ln -s "${symlinkcontent}" "${symlinkdir}/${name}"
838
+
839
+      run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
840
+   else
841
+      ensure_clone_branch_is_correct "${dstdir}" "${branch}"
855 842
 
856
-            # memo that we did this with a symlink
857
-            # store it inside the possibly recursed dstprefix dependency
858
-            local symlinkcontent
859
-            local symlinkdir
860
-            local symlinkrelative
843
+      log_fluff "Repository \"${dstdir}\" already exists"
844
+   fi
861 845
 
862
-            symlinkrelative=`compute_relative "${CLONESFETCH_SUBDIR}/.embedded"`
863
-            symlinkdir="${dstprefix}${CLONESFETCH_SUBDIR}/.embedded"
864
-            mkdir_if_missing "${symlinkdir}"
865
-            symlinkcontent="${symlinkrelative}/${dstdir}"
846
+   remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
847
+}
866 848
 
867
-            log_fluff "Remember embedded repository \"${name}\" via \"${symlinkdir}/${name}\""
868
-            exekutor ln -s "${symlinkcontent}" "${symlinkdir}/${name}"
869 849
 
870
-            run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
871
-         else
872
-            ensure_clone_branch_is_correct "${dstdir}" "${branch}"
850
+clone_embedded_repositories()
851
+{
852
+   local dstprefix
873 853
 
874
-           log_fluff "Repository \"${dstdir}\" already exists"
875
-         fi
854
+   dstprefix="$1"
855
+
856
+   local clones
857
+   local clone
858
+   local old
859
+
860
+   old="${IFS:-" "}"
861
+
862
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
863
+   export MULLE_BOOTSTRAP_SETTINGS_NO_AUTO
864
+
865
+   clones="`read_fetch_setting "embedded_repositories"`"
866
+   if [ "${clones}" != "" ]
867
+   then
868
+      IFS="
869
+"
870
+      for clone in ${clones}
871
+      do
872
+         IFS="${old}"
873
+
874
+         clone_embedded_repository "${dstprefix}" "${clone}"
876 875
       done
877 876
 
878 877
       remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
... ...
@@ -950,7 +949,7 @@ update()
950 949
       run_repo_settings_script "${name}" "${dstdir}" "post-update" "$@"
951 950
    else
952 951
       ensure_clone_branch_is_correct "${dstdir}" "${branch}"
953
-      log_fluff "Repository \"${name}\" exists, so not updated."
952
+      log_info "Repository ${C_MAGENTA}${C_BOLD}${name}${C_INFO} exists and is symlinked, so not updated."
954 953
 
955 954
       rval=1
956 955
    fi
... ...
@@ -983,7 +982,6 @@ update_repository()
983 982
    local tag
984 983
    local rval
985 984
 
986
-
987 985
    tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
988 986
 
989 987
    exekutor [ -x "${dstdir}" ] || fail "\"${name}\" is not accesible anymore in \"repositories\""
... ...
@@ -1192,11 +1190,9 @@ update_embedded_repositories()
1192 1190
          then
1193 1191
             update "${name}" "${url}" "${dstdir}" "${branch}" "${tag}"
1194 1192
          else
1195
-            scm="`scm_from_clone "${clone}"`"
1196
-            clone_repository  "${name}" "${url}" "${branch}" "${scm}"
1193
+            clone_embedded_repository "${dstprefix}" "${clone}"
1197 1194
          fi
1198 1195
 
1199
-
1200 1196
          remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
1201 1197
       done
1202 1198
    fi
... ...
@@ -1246,7 +1242,7 @@ main()
1246 1242
       install_pips
1247 1243
 
1248 1244
       clone_repositories
1249
-      install_embedded_repositories
1245
+      clone_embedded_repositories
1250 1246
 
1251 1247
       check_tars
1252 1248
    else