Browse code

Added subgits, so move the version number to 0.10

Nat! authored on 17-10-2015 21:00:51
Showing 6 changed files
... ...
@@ -1,9 +1,14 @@
1
-0.9.9
1
+0.10
2 2
 ===
3 3
    Fetch settings can be platform specific by using the `uname` as a file
4 4
    extension. e.g. gits.Darwin. Other settings may follow, if the need arises.
5 5
    So far it hasn't.
6 6
 
7
+   Added "subgits" for those special moments, where you don't want to link
8
+   another project, but just steal a few files. These gits are installed in
9
+   your projects root and they are not built. You can not symlink them into
10
+   your project, just clone them.
11
+
7 12
 0.9.8
8 13
 ===
9 14
    Brings more Linux fixes
... ...
@@ -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.9.9
32
+VERSION=0.10
33 33
 
34 34
 #
35 35
 # This is the main user interface to mulle-bootstrap
... ...
@@ -40,6 +40,30 @@ DIST_CLEANABLE_SUBDIRS="`read_sane_config_path_setting "dist_clean_folders" "${C
40 40
 CLEAN_EMPTY_PARENTS="`read_config_setting "clean_empty_parent_folders" "YES"`"
41 41
 
42 42
 
43
+subgits()
44
+{
45
+   local clones
46
+   local clone
47
+   local dir
48
+   local name
49
+
50
+   clones="`read_fetch_setting "subgits"`"
51
+   if [ "${clones}" != "" ]
52
+   then
53
+      for clone in ${clones}
54
+      do
55
+         name="`basename "${clone}" .git`"
56
+         dir="${name}"
57
+         echo "${dir}"
58
+      done
59
+   fi
60
+}
61
+
62
+
63
+DIST_CLEANABLE_SUBDIRS="${DIST_CLEANABLE_SUBDIRS}
64
+`subgits`"
65
+
66
+
43 67
 usage()
44 68
 {
45 69
    cat <<EOF
... ...
@@ -133,6 +157,7 @@ clean_parent_folders_if_empty()
133 157
 }
134 158
 
135 159
 
160
+
136 161
 #
137 162
 # cleanability is checked, because in some cases its convenient
138 163
 # to have other tools provide stuff besides /include and /lib
... ...
@@ -163,6 +163,7 @@ install_brews()
163 163
 #
164 164
 # future, download tarballs...
165 165
 # we check for existance during fetch, but install during build
166
+#
166 167
 check_tars()
167 168
 {
168 169
    local tarballs
... ...
@@ -264,27 +265,44 @@ link_command()
264 265
    local src
265 266
    local dst
266 267
    local tag
267
-   local name
268 268
 
269 269
    src="$1"
270 270
    dst="$2"
271 271
    tag="$3"
272 272
 
273
-   if [ -e "${src}" ]
273
+   local dstdir
274
+   dstdir="`dirname "${dst}"`"
275
+
276
+   if [ ! -e "${dstdir}/${src}" ]
274 277
    then
275
-      echo "${src} does not exist ($PWD)" >&2
276
-      exit 1
278
+      fail "${C_RESET}${dstdir}/${src}${C_ERROR} does not exist ($PWD)"
277 279
    fi
278 280
 
279 281
    if [ "${COMMAND}" = "install" ]
280 282
    then
283
+      #
284
+      # relative paths look nicer, but could fail in more complicated
285
+      # settings, when you symlink something, and that repo has symlinks
286
+      # itself
287
+      #
288
+      if read_yes_no_config_setting "absolute_symlinks" "NO"
289
+      then
290
+         local real
291
+
292
+         real="`( cd "${dstdir}" ; realpath "${src}")`"
293
+         log_fluff "Converted symlink ${C_RESET}${src}${C_FLUFF} to ${C_RESET}${real}${C_FLUFF}"
294
+         src="${real}"
295
+      fi
296
+
281 297
       exekutor ln -s -f "$src" "$dst" || fail "failed to setup symlink \"$dst\" (to \"$src\")"
282 298
       if [ "$tag" != "" ]
283 299
       then
300
+         local name
301
+
284 302
          name="`basename "${dst}"`"
285
-         echo "tag ${tag} will be ignored, due to symlink" >&2
286
-         echo "if you want to checkout this tag do:" >&2
287
-         echo "(cd .repos/${name}; git ${GITFLAGS} checkout \"${tag}\" )" >&2
303
+         log_warning "tag ${tag} will be ignored, due to symlink" >&2
304
+         log_warning "if you want to checkout this tag do:" >&2
305
+         log_warning "${C_RESET}(cd .repos/${name}; git ${GITFLAGS} checkout \"${tag}\" )${C_WARNING}" >&2
288 306
       fi
289 307
    fi
290 308
 
... ...
@@ -299,11 +317,9 @@ ask_symlink_it()
299 317
    clone="$1"
300 318
    if [ ! -d "${clone}" ]
301 319
    then
302
-      echo "You need to check out ${clone} yourself, as it's not there." >&2 || exit 1
320
+      fail "You need to check out ${clone} yourself, as it's not there."
303 321
    fi
304 322
 
305
-   SYMLINK_FORBIDDEN="`read_config_setting "symlink_forbidden"`"
306
-
307 323
    # check if checked out
308 324
    if [ -d "${clone}"/.git ]
309 325
    then
... ...
@@ -321,21 +337,20 @@ ask_symlink_it()
321 337
     # if bare repo, we can only clone anyway
322 338
    if [ -f "${clone}"/HEAD -a -d "${clone}/refs" ]
323 339
    then
324
-      echo "${clone} looks like a bare git repository. So cloning" >&2
325
-      echo "is the only way to go." >&2
340
+      log_info "${clone} looks like a bare git repository. So cloning"
341
+      log_info "is the only way to go."
326 342
       return 1
327 343
    fi
328 344
 
329 345
    # can only symlink because not a .git repo yet
330 346
    if [ "${SYMLINK_FORBIDDEN}" != "YES" ]
331 347
    then
332
-      echo "${clone} is not a git repository (yet ?)" >&2
333
-      echo "So symlinking is the only way to go." >&2
348
+      log_info "${clone} is not a git repository (yet ?)"
349
+      log_info "So symlinking is the only way to go."
334 350
       return 0
335 351
    fi
336 352
 
337
-   echo "SYMLINK_FORBIDDEN=YES, can't symlink" >&2
338
-   exit 1
353
+   fail "Can't symlink"
339 354
 }
340 355
 
341 356
 
... ...
@@ -373,8 +388,8 @@ git_clone()
373 388
    dst="$2"
374 389
    tag="$3"
375 390
 
376
-   [ -z "$src" ] && internal_fail "src is empty"
377
-   [ -z "$dst" ] && internal_fail "dst is empty"
391
+   [ ! -z "$src" ] || internal_fail "src is empty"
392
+   [ ! -z "$dst" ] || internal_fail "dst is empty"
378 393
 
379 394
    log_info "Cloning ${C_MAGENTA}${src}${C_INFO} ..."
380 395
    exekutor git clone ${GITFLAGS} "${src}" "${dst}" || fail "git clone of \"${src}\" into \"${dst}\" failed"
... ...
@@ -394,7 +409,7 @@ git_pull()
394 409
    dst="$1"
395 410
    tag="$2"
396 411
 
397
-   [ -z "$dst" ] && internal_fail "dst is empty"
412
+   [ ! -z "$dst" ] || internal_fail "dst is empty"
398 413
 
399 414
    log_info "Updating ${C_RESET}${dst}${C_INFO} ..."
400 415
    ( exekutor cd "${dst}" ; exekutor git pull ${GITFLAGS} ) || fail "git pull of \"${dst}\" failed"
... ...
@@ -412,13 +427,14 @@ INHERIT_SETTINGS="taps brews gits pips gems settings/build_order settings/build_
412 427
 bootstrap_auto_update()
413 428
 {
414 429
    local dst
415
-   local name
416 430
 
417 431
    dst="$1"
418 432
 
419 433
    [ ! -z "${dst}" ] || internal_fail "dst was empty"
420 434
    [ "${PWD}" != "${dst}" ] || internal_fail "configuration error"
421 435
 
436
+   local name
437
+
422 438
    name="`basename "${dst}"`"
423 439
 
424 440
    # contains own bootstrap ? and not a symlink
... ...
@@ -630,7 +646,14 @@ checkout()
630 646
    local flag
631 647
    local found
632 648
    local name2
649
+   local relative
633 650
 
651
+   relative="`dirname "${dstdir}"`"
652
+   relative="`compute_relative "${relative}"`"
653
+   if [ ! -z "${relative}" ]
654
+   then
655
+      relative="${relative}/"
656
+   fi
634 657
    name2="`basename "${clone}"`"
635 658
 
636 659
    #
... ...
@@ -640,9 +663,9 @@ checkout()
640 663
 
641 664
    if [ -e "${DEPENDENCY_SUBDIR}" -o -e "${CLONESBUILD_SUBDIR}" ]
642 665
    then
643
-      log_error "Stale folders ${DEPENDENCY_SUBDIR} and/or ${CLONESBUILD_SUBDIR} found."
666
+      log_error "Stale folders ${C_RESET}${DEPENDENCY_SUBDIR}${C_ERROR} and/or ${C_RESET}${CLONESBUILD_SUBDIR}${C_ERROR} found."
644 667
       log_error "Please remove them before continuing."
645
-      log_info  "Suggested command: ${C_RESET}mulle-bootstrap clean output"
668
+      log_info  "Suggested command: ${C_RESET}mulle-bootstrap clean output${C_INFO}"
646 669
       exit 1
647 670
    fi
648 671
 
... ...
@@ -668,7 +691,7 @@ checkout()
668 691
             if [ $? -eq 0 ]
669 692
             then
670 693
                operation=link_command
671
-               srcname="${CLONES_RELATIVE}/${clone}"
694
+               srcname="${relative}${clone}"
672 695
             fi
673 696
          ;;
674 697
 
... ...
@@ -703,7 +726,7 @@ Use it ?"
703 726
                   if [ $? -eq 0 ]
704 727
                   then
705 728
                      operation=link_command
706
-                     srcname="${CLONES_RELATIVE}/${found}"
729
+                     srcname="${relative}${found}"
707 730
                   fi
708 731
                fi
709 732
             fi
... ...
@@ -833,6 +856,44 @@ clone_repositories()
833 856
 }
834 857
 
835 858
 
859
+install_subgits()
860
+{
861
+   local clones
862
+   local clone
863
+
864
+   clones="`read_fetch_setting "subgits"`"
865
+   if [ "${clones}" != "" ]
866
+   then
867
+      for clone in ${clones}
868
+      do
869
+         name="`basename "${clone}" .git`"
870
+         tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
871
+         dstdir="${name}"
872
+         log_fetch_action "${name}" "${dstdir}"
873
+
874
+         #
875
+         # subgits are just cloned, no symlinks,
876
+         #
877
+         local old
878
+
879
+         old="${SYMLINK_FORBIDDEN}"
880
+
881
+         SYMLINK_FORBIDDEN="YES"
882
+         checkout "${clone}" "${name}" "${dstdir}" "${tag}"
883
+         SYMLINK_FORBIDDEN="$old"
884
+
885
+         if read_yes_no_config_setting "update_gitignore" "YES"
886
+         then
887
+            if [ -d .git ]
888
+            then
889
+               append_dir_to_gitignore_if_needed "${dstdir}"
890
+            fi
891
+         fi
892
+      done
893
+   fi
894
+}
895
+
896
+
836 897
 update()
837 898
 {
838 899
    local clone
... ...
@@ -954,6 +1015,27 @@ update_repositories()
954 1015
 }
955 1016
 
956 1017
 
1018
+update_subgits()
1019
+{
1020
+   local clones
1021
+   local clone
1022
+
1023
+   clones="`read_fetch_setting "subgits"`"
1024
+   if [ "${clones}" != "" ]
1025
+   then
1026
+      for clone in ${clones}
1027
+      do
1028
+         name="`basename "${clone}" .git`"
1029
+         tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
1030
+         dstdir="${name}"
1031
+         log_fetch_action "${name}" "${dstdir}"
1032
+
1033
+         # again, just refresh no specialties
1034
+         exekutor git_pull "${dstdir}" "${tag}"
1035
+      done
1036
+   fi
1037
+}
1038
+
957 1039
 
958 1040
 append_dir_to_gitignore_if_needed()
959 1041
 {
... ...
@@ -970,6 +1052,9 @@ main()
970 1052
 {
971 1053
    log_fluff "::: fetch :::"
972 1054
 
1055
+   SYMLINK_FORBIDDEN="`read_config_setting "symlink_forbidden"`"
1056
+   export SYMLINK_FORBIDDEN
1057
+
973 1058
    #
974 1059
    # Run prepare scripts if present
975 1060
    #
... ...
@@ -984,12 +1069,15 @@ main()
984 1069
 
985 1070
       clone_repositories
986 1071
 
1072
+      install_subgits
987 1073
       install_brews
988 1074
       install_gems
989 1075
       install_pips
990 1076
       check_tars
991 1077
    else
992 1078
       update_repositories "$@"
1079
+
1080
+      update_subgits
993 1081
    fi
994 1082
 
995 1083
    #
... ...
@@ -308,6 +308,12 @@ compute_relative()
308 308
          depth=`expr $depth - 1`
309 309
       done
310 310
    fi
311
+
312
+#   if [ -z "$relative" ]
313
+#   then
314
+#      relative="."
315
+#   fi
316
+
311 317
    echo "${relative}"
312 318
 }
313 319
 
... ...
@@ -160,9 +160,9 @@ run_repo_settings_script()
160 160
    scriptname="$1"
161 161
    shift
162 162
 
163
-   exekutor [ -d "$srcdir" ] || internal_fail "directory srcdir \"${srcdir}\" is wrong ($PWD)"
164
-   [ ! -z "$name" ]           || internal_fail "name is empty"
165
-   [ ! -z "$scriptname" ]     || internal_fail "scriptname is empty"
163
+   exekutor [ -e "$srcdir" ] || internal_fail "directory srcdir \"${srcdir}\" is wrong ($PWD)"
164
+   [ ! -z "$name" ]          || internal_fail "name is empty"
165
+   [ ! -z "$scriptname" ]    || internal_fail "scriptname is empty"
166 166
 
167 167
    local script
168 168
 
... ...
@@ -187,7 +187,7 @@ run_build_settings_script()
187 187
    scriptname="$1"
188 188
    shift
189 189
 
190
-   exekutor [ -d "$srcdir" ]  || internal_fail "srcdir \"${srcdir}\" is wrong ($PWD)"
190
+   exekutor [ -e "$srcdir" ]  || internal_fail "srcdir \"${srcdir}\" is wrong ($PWD)"
191 191
    [ ! -z "$name" ]           || internal_fail "name is empty"
192 192
    [ ! -z "$scriptname" ]     || internal_fail "scriptname is empty"
193 193