Browse code

Various bug fixes, with respect to refresh and update.

Nat! authored on 06/04/2016 12:16:39
Showing 6 changed files
... ...
@@ -1,3 +1,17 @@
1
+0.21
2
+===
3
+
4
+*  Fix a bug when updating
5
+*  When updating ignore symlinked repositories and do not update embedded
6
+   repositories of said symlinks.
7
+*  Fixed option handling, so now -y -v and -v -y are possible. It used to be
8
+   that the order was -y -v.
9
+*  Embeded repository settings do not get inherited, from other repos, which is
10
+   just confusing.
11
+*  Make the zombiefication code a bit more clever, when expected repos aren't
12
+   there (yet).
13
+
14
+
1 15
 0.20
2 16
 ===
3 17
 
... ...
@@ -29,7 +29,7 @@
29 29
 #   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 
32
-VERSION=0.20
32
+VERSION=0.21
33 33
 
34 34
 #
35 35
 # This is the main user interface to mulle-bootstrap
... ...
@@ -43,39 +43,46 @@ export PATH
43 43
 #
44 44
 # simple option handling
45 45
 #
46
-if [ "$1" = "-a" ]
47
-then
48
-   MULLE_BOOTSTRAP_ANSWER="NO"
49
-   export MULLE_BOOTSTRAP_ANSWER
50
-   [ $# -eq 0 ] || shift
51
-else
46
+while :
47
+do
48
+   if [ "$1" = "-a" ]
49
+   then
50
+      MULLE_BOOTSTRAP_ANSWER="NO"
51
+      export MULLE_BOOTSTRAP_ANSWER
52
+      [ $# -eq 0 ] || shift
53
+      continue
54
+   fi
55
+
52 56
    if [ "$1" = "-y" ] #  basically auto symlink everything
53 57
    then
54 58
       MULLE_BOOTSTRAP_ANSWER="YES"
55 59
       export MULLE_BOOTSTRAP_ANSWER
56 60
       [ $# -eq 0 ] || shift
61
+      continue
57 62
    fi
58
-fi
59 63
 
60 64
 
61
-if [ "$1" = "-n" ]
62
-then
63
-   MULLE_BOOTSTRAP_DRY_RUN="YES"
64
-   export MULLE_BOOTSTRAP_DRY_RUN
65
-   [ $# -eq 0 ] || shift
66
-fi
65
+   if [ "$1" = "-n" ]
66
+   then
67
+      MULLE_BOOTSTRAP_DRY_RUN="YES"
68
+      export MULLE_BOOTSTRAP_DRY_RUN
69
+      [ $# -eq 0 ] || shift
70
+      continue
71
+   fi
67 72
 
68
-if [ "$1" = "-t" ]
69
-then
70
-   MULLE_BOOTSTRAP_TRACE="1848"
71
-   export MULLE_BOOTSTRAP_TRACE
73
+   if [ "$1" = "-t" ]
74
+   then
75
+      MULLE_BOOTSTRAP_TRACE="1848"
76
+      export MULLE_BOOTSTRAP_TRACE
77
+
78
+      COPYMOVEFLAGS="-v"
79
+      export COPYMOVEFLAGS
80
+      GITFLAGS="-v"
81
+      export GITFLAGS
82
+      [ $# -eq 0 ] || shift
83
+      continue
84
+   fi
72 85
 
73
-   COPYMOVEFLAGS="-v"
74
-   export COPYMOVEFLAGS
75
-   GITFLAGS="-v"
76
-   export GITFLAGS
77
-   [ $# -eq 0 ] || shift
78
-else
79 86
    if [ "$1" = "-v" ]
80 87
    then
81 88
       if [ -z "${MULLE_BOOTSTRAP_TRACE}" ]
... ...
@@ -89,35 +96,39 @@ else
89 89
       GITFLAGS="-v"
90 90
       export GITFLAGS
91 91
       [ $# -eq 0 ] || shift
92
-   else
93
-      if [ "$1" = "-V" ]
92
+      continue
93
+   fi
94
+
95
+   if [ "$1" = "-V" ]
96
+   then
97
+      if [ -z "${MULLE_BOOTSTRAP_TRACE}" ]
94 98
       then
95
-         if [ -z "${MULLE_BOOTSTRAP_TRACE}" ]
96
-         then
97
-            MULLE_BOOTSTRAP_TRACE="ALL"
98
-            export MULLE_BOOTSTRAP_TRACE
99
-         fi
100
-
101
-         COPYMOVEFLAGS="-v"
102
-         export COPYMOVEFLAGS
103
-         GITFLAGS="-v"
104
-         export GITFLAGS
105
-         [ $# -eq 0 ] || shift
106
-      else
107
-         if [ "$1" = "-s" ] # silent
108
-         then
109
-            MULLE_BOOTSTRAP_TRACE=
110
-            MULLE_BOOTSTRAP_TERSE="YES"
111
-            export MULLE_BOOTSTRAP_TERSE
112
-
113
-            GITFLAGS="-q"
114
-            export GITFLAGS
115
-            [ $# -eq 0 ] || shift
116
-         fi
99
+         MULLE_BOOTSTRAP_TRACE="ALL"
100
+         export MULLE_BOOTSTRAP_TRACE
117 101
       fi
102
+
103
+      COPYMOVEFLAGS="-v"
104
+      export COPYMOVEFLAGS
105
+      GITFLAGS="-v"
106
+      export GITFLAGS
107
+      [ $# -eq 0 ] || shift
108
+      continue
109
+   fi
110
+
111
+   if [ "$1" = "-s" ] # silent
112
+   then
113
+      MULLE_BOOTSTRAP_TRACE=
114
+      MULLE_BOOTSTRAP_TERSE="YES"
115
+      export MULLE_BOOTSTRAP_TERSE
116
+
117
+      GITFLAGS="-q"
118
+      export GITFLAGS
119
+      [ $# -eq 0 ] || shift
120
+      continue
118 121
    fi
119
-fi
120 122
 
123
+   break
124
+done
121 125
 
122 126
 usage()
123 127
 {
... ...
@@ -704,6 +704,9 @@ install_embedded_repositories()
704 704
 
705 705
    old="${IFS:-" "}"
706 706
 
707
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
708
+   export MULLE_BOOTSTRAP_SETTINGS_NO_AUTO
709
+
707 710
    clones="`read_fetch_setting "embedded_repositories"`"
708 711
    if [ "${clones}" != "" ]
709 712
    then
... ...
@@ -762,6 +765,8 @@ install_embedded_repositories()
762 762
    fi
763 763
 
764 764
    IFS="${old}"
765
+
766
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO=
765 767
 }
766 768
 
767 769
 
... ...
@@ -800,8 +805,7 @@ update()
800 800
 
801 801
    local script
802 802
 
803
-   log_info "Updating \"${dstdir}\""
804
-   if [ ! -L "${dstdir}"  ]
803
+   if [ ! -L "${dstdir}" ]
805 804
    then
806 805
       run_repo_settings_script "${name}" "${dstdir}" "pre-update" "$@"
807 806
 
... ...
@@ -814,6 +818,9 @@ update()
814 814
       fi
815 815
 
816 816
       run_repo_settings_script "${name}" "${dstdir}" "post-update" "$@"
817
+   else
818
+      log_fluff "Repository \"${name}\" exists, so not updated."
819
+      return 1
817 820
    fi
818 821
 }
819 822
 
... ...
@@ -840,17 +847,23 @@ update_repository()
840 840
 
841 841
    update "${name}" "${url}" "${dstdir}" "${tag}"
842 842
 
843
-   if [ "${DONT_RECURSE}" = "" ]
843
+   #update will return 1 if repo is symlinked
844
+
845
+   if [ $? -eq 0 -a "${DONT_RECURSE}" = "" ]
844 846
    then
845 847
       local old
848
+      local oldfetch
846 849
 
847 850
       old="${BOOTSTRAP_SUBDIR}"
851
+      oldfetch="${CLONESFETCH_SUBDIR}"
848 852
 
849 853
       BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
850
-      CLONESFETCH_SUBDIR="${dstdir}/.repos"
854
+#      CLONESFETCH_SUBDIR="${dstdir}/.repos"
851 855
 
852 856
       update_embedded_repositories "${dstdir}/"
857
+
853 858
       BOOTSTRAP_SUBDIR="${old}"
859
+#      CLONESFETCH_SUBDIR="${oldfetch}"
854 860
    fi
855 861
 }
856 862
 
... ...
@@ -950,6 +963,9 @@ update_embedded_repositories()
950 950
    local name
951 951
    local url
952 952
 
953
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
954
+   export MULLE_BOOTSTRAP_SETTINGS_NO_AUTO
955
+
953 956
    old="${IFS:-" "}"
954 957
 
955 958
    clones="`read_fetch_setting "embedded_repositories"`"
... ...
@@ -972,6 +988,7 @@ update_embedded_repositories()
972 972
    fi
973 973
 
974 974
    IFS="${old}"
975
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO=
975 976
 }
976 977
 
977 978
 
... ...
@@ -182,17 +182,15 @@ mark_all_repositories_zombies()
182 182
 }
183 183
 
184 184
 
185
-mark_repository_alive()
185
+_mark_repository_alive()
186 186
 {
187 187
    local dstdir
188 188
    local name
189
+   local zombie
189 190
 
190 191
    name="$1"
191 192
    dstdir="$2"
192
-
193
-   local zombie
194
-
195
-   zombie="`dirname -- "${dstdir}"`/.zombies/${name}"
193
+   zombie="$3"
196 194
 
197 195
    # mark as alive
198 196
    if [ -d "${dstdir}" -o -L "${dstdir}" ]
... ...
@@ -206,11 +204,40 @@ mark_repository_alive()
206 206
          log_fluff "Marked \"${dstdir}\" is already alive"
207 207
       fi
208 208
    else
209
-      log_fluff "\"${dstdir}\" is neither a symlink nor a directory"
209
+      if [ -e "${dstdir}" ]
210
+      then
211
+         log_fail "\"${dstdir}\" is neither a symlink nor a directory"
212
+      fi
213
+
214
+      # repository should be there but hasn't been fetched yet
215
+      # so not really a zmbie
216
+      if [ -e "${zombie}" ]
217
+      then
218
+         log_fluff "\"${dstdir}\" is not there, so not a zombie"
219
+
220
+         exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
221
+      fi
210 222
    fi
211 223
 }
212 224
 
213 225
 
226
+
227
+mark_repository_alive()
228
+{
229
+   local dstdir
230
+   local name
231
+
232
+   name="$1"
233
+   dstdir="$2"
234
+
235
+   local zombie
236
+
237
+   zombie="`dirname -- "${dstdir}"`/.zombies/${name}"
238
+
239
+   _mark_repository_alive "${name}" "${dstdir}" "${zombie}"
240
+}
241
+
242
+
214 243
 bury_zombies()
215 244
 {
216 245
    local i
... ...
@@ -302,20 +329,7 @@ mark_embedded_repository_alive()
302 302
 
303 303
    zombie="${CLONESFETCH_SUBDIR}/.embedded/.zombies/${name}"
304 304
 
305
-   # mark as alive
306
-   if [ -d "${dstdir}" -o -L "${dstdir}" ]
307
-   then
308
-      if [ -e "${zombie}" ]
309
-      then
310
-         log_fluff "Mark \"${dstdir}\" as alive"
311
-
312
-         exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
313
-      else
314
-         log_fluff "Marked \"${dstdir}\" is already alive"
315
-      fi
316
-   else
317
-      log_fluff "\"${dstdir}\" is neither a symlink nor a directory"
318
-   fi
305
+   _mark_repository_alive "${name}" "${dstdir}" "${zombie}"
319 306
 }
320 307
 
321 308
 
... ...
@@ -46,18 +46,27 @@ git_checkout_tag()
46 46
       flags=""
47 47
    fi
48 48
 
49
-   log_info "Checking out ${C_MAGENTA}${C_BOLD}${tag}${C_INFO} ..."
50
-   ( exekutor cd "${dst}" ; exekutor git checkout ${flags} "${tag}" )
49
+   local branch
51 50
 
52
-   if [ $? -ne 0 ]
53
-   then
54
-      log_error "Checkout failed, moving ${C_CYAN}${C_BOLD}${dst}${C_ERROR} to ${C_CYAN}${C_BOLD}${dst}.failed${C_ERROR}"
55
-      log_error "You need to fix this manually and then move it back."
56
-      log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename -- "${dst}"`/TAG" >&2
51
+   branch="`( cd "$dst" ; git rev-parse --abbrev-ref HEAD )`"
57 52
 
58
-      rmdir_safer "${dst}.failed"
59
-      exekutor mv "${dst}" "${dst}.failed"
60
-      exit 1
53
+   if [ "${branch}" != "${tag}" ]
54
+   then
55
+      log_info "Checking out version ${C_WHITE}${C_BOLD}${tag}${C_INFO} of ${C_MAGENTA}${C_BOLD}${dst}${C_INFO} ..."
56
+      ( exekutor cd "${dst}" ; exekutor git checkout ${flags} "${tag}" )
57
+
58
+      if [ $? -ne 0 ]
59
+      then
60
+         log_error "Checkout failed, moving ${C_CYAN}${C_BOLD}${dst}${C_ERROR} to ${C_CYAN}${C_BOLD}${dst}.failed${C_ERROR}"
61
+         log_error "You need to fix this manually and then move it back."
62
+         log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename -- "${dst}"`/TAG" >&2
63
+
64
+         rmdir_safer "${dst}.failed"
65
+         exekutor mv "${dst}" "${dst}.failed"
66
+         exit 1
67
+      fi
68
+   else
69
+      log_fluff "Already on proper branch \"${branch}\""
61 70
    fi
62 71
 }
63 72
 
... ...
@@ -228,6 +228,15 @@ _read_bootstrap_setting()
228 228
       suffix="${1}"
229 229
       shift
230 230
 
231
+      if [ "${MULLE_BOOTSTRAP_SETTINGS_NO_AUTO}" = "YES" ]
232
+      then
233
+         case "$suffix" in
234
+            .auto*)
235
+               continue
236
+               ;;
237
+         esac
238
+      fi
239
+
231 240
       value="`_read_setting "${BOOTSTRAP_SUBDIR}${suffix}/${name}"`"
232 241
       if [ $? -eq 0 ]
233 242
       then
... ...
@@ -250,7 +259,6 @@ _read_repo_setting()
250 250
 
251 251
    [ ! -z "$name" ]    || internal_fail "empty name in _read_repo_setting( $*)"
252 252
    [ ! -z "$package" ] || internal_fail "empty package in _read_repo_setting( $*)"
253
-
254 253
    # need to conserve return value 2 if empty
255 254
    _read_bootstrap_setting  "settings/${package}/${name}" ".local" "" ".auto"
256 255
 }