Browse code

Various bug fixes, with respect to refresh and update.

Nat! authored on 06-04-2016 12:16:39 • Nat! committed on 07-04-2016 11:42:21
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 96
       GITFLAGS="-v"
90 97
       export GITFLAGS
91 98
       [ $# -eq 0 ] || shift
92
-   else
93
-      if [ "$1" = "-V" ]
99
+      continue
100
+   fi
101
+
102
+   if [ "$1" = "-V" ]
103
+   then
104
+      if [ -z "${MULLE_BOOTSTRAP_TRACE}" ]
94 105
       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
106
+         MULLE_BOOTSTRAP_TRACE="ALL"
107
+         export MULLE_BOOTSTRAP_TRACE
117 108
       fi
109
+
110
+      COPYMOVEFLAGS="-v"
111
+      export COPYMOVEFLAGS
112
+      GITFLAGS="-v"
113
+      export GITFLAGS
114
+      [ $# -eq 0 ] || shift
115
+      continue
116
+   fi
117
+
118
+   if [ "$1" = "-s" ] # silent
119
+   then
120
+      MULLE_BOOTSTRAP_TRACE=
121
+      MULLE_BOOTSTRAP_TERSE="YES"
122
+      export MULLE_BOOTSTRAP_TERSE
123
+
124
+      GITFLAGS="-q"
125
+      export GITFLAGS
126
+      [ $# -eq 0 ] || shift
127
+      continue
118 128
    fi
119
-fi
120 129
 
130
+   break
131
+done
121 132
 
122 133
 usage()
123 134
 {
... ...
@@ -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 765
    fi
763 766
 
764 767
    IFS="${old}"
768
+
769
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO=
765 770
 }
766 771
 
767 772
 
... ...
@@ -800,8 +805,7 @@ update()
800 805
 
801 806
    local script
802 807
 
803
-   log_info "Updating \"${dstdir}\""
804
-   if [ ! -L "${dstdir}"  ]
808
+   if [ ! -L "${dstdir}" ]
805 809
    then
806 810
       run_repo_settings_script "${name}" "${dstdir}" "pre-update" "$@"
807 811
 
... ...
@@ -814,6 +818,9 @@ update()
814 818
       fi
815 819
 
816 820
       run_repo_settings_script "${name}" "${dstdir}" "post-update" "$@"
821
+   else
822
+      log_fluff "Repository \"${name}\" exists, so not updated."
823
+      return 1
817 824
    fi
818 825
 }
819 826
 
... ...
@@ -840,17 +847,23 @@ update_repository()
840 847
 
841 848
    update "${name}" "${url}" "${dstdir}" "${tag}"
842 849
 
843
-   if [ "${DONT_RECURSE}" = "" ]
850
+   #update will return 1 if repo is symlinked
851
+
852
+   if [ $? -eq 0 -a "${DONT_RECURSE}" = "" ]
844 853
    then
845 854
       local old
855
+      local oldfetch
846 856
 
847 857
       old="${BOOTSTRAP_SUBDIR}"
858
+      oldfetch="${CLONESFETCH_SUBDIR}"
848 859
 
849 860
       BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
850
-      CLONESFETCH_SUBDIR="${dstdir}/.repos"
861
+#      CLONESFETCH_SUBDIR="${dstdir}/.repos"
851 862
 
852 863
       update_embedded_repositories "${dstdir}/"
864
+
853 865
       BOOTSTRAP_SUBDIR="${old}"
866
+#      CLONESFETCH_SUBDIR="${oldfetch}"
854 867
    fi
855 868
 }
856 869
 
... ...
@@ -950,6 +963,9 @@ update_embedded_repositories()
950 963
    local name
951 964
    local url
952 965
 
966
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
967
+   export MULLE_BOOTSTRAP_SETTINGS_NO_AUTO
968
+
953 969
    old="${IFS:-" "}"
954 970
 
955 971
    clones="`read_fetch_setting "embedded_repositories"`"
... ...
@@ -972,6 +988,7 @@ update_embedded_repositories()
972 988
    fi
973 989
 
974 990
    IFS="${old}"
991
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO=
975 992
 }
976 993
 
977 994
 
... ...
@@ -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 204
          log_fluff "Marked \"${dstdir}\" is already alive"
207 205
       fi
208 206
    else
209
-      log_fluff "\"${dstdir}\" is neither a symlink nor a directory"
207
+      if [ -e "${dstdir}" ]
208
+      then
209
+         log_fail "\"${dstdir}\" is neither a symlink nor a directory"
210
+      fi
211
+
212
+      # repository should be there but hasn't been fetched yet
213
+      # so not really a zmbie
214
+      if [ -e "${zombie}" ]
215
+      then
216
+         log_fluff "\"${dstdir}\" is not there, so not a zombie"
217
+
218
+         exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
219
+      fi
210 220
    fi
211 221
 }
212 222
 
213 223
 
224
+
225
+mark_repository_alive()
226
+{
227
+   local dstdir
228
+   local name
229
+
230
+   name="$1"
231
+   dstdir="$2"
232
+
233
+   local zombie
234
+
235
+   zombie="`dirname -- "${dstdir}"`/.zombies/${name}"
236
+
237
+   _mark_repository_alive "${name}" "${dstdir}" "${zombie}"
238
+}
239
+
240
+
214 241
 bury_zombies()
215 242
 {
216 243
    local i
... ...
@@ -302,20 +329,7 @@ mark_embedded_repository_alive()
302 329
 
303 330
    zombie="${CLONESFETCH_SUBDIR}/.embedded/.zombies/${name}"
304 331
 
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
332
+   _mark_repository_alive "${name}" "${dstdir}" "${zombie}"
319 333
 }
320 334
 
321 335
 
... ...
@@ -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 259
 
251 260
    [ ! -z "$name" ]    || internal_fail "empty name in _read_repo_setting( $*)"
252 261
    [ ! -z "$package" ] || internal_fail "empty package in _read_repo_setting( $*)"
253
-
254 262
    # need to conserve return value 2 if empty
255 263
    _read_bootstrap_setting  "settings/${package}/${name}" ".local" "" ".auto"
256 264
 }