Browse code

Make incremental builds work. Symlinks and cached stuff aren't asked for anymore. Configure your choices by using command line arguments or config settings.

Nat! authored on 16/03/2017 14:43:10
Showing 4 changed files
... ...
@@ -2123,6 +2123,10 @@ build_if_alive()
2123 2123
       if [ "$xdone" = "" ]
2124 2124
       then
2125 2125
          build_wrapper "${name}" "${stashdir}"
2126
+
2127
+         # memorize what we build
2128
+         redirect_append_exekutor "${REPOS_DIR}/.build_done" echo "${name}"
2129
+
2126 2130
          BUILT="${name}
2127 2131
 ${BUILT}"
2128 2132
       else
... ...
@@ -2160,6 +2164,11 @@ build_stashes()
2160 2160
 
2161 2161
    if [ "$#" -eq 0 ]
2162 2162
    then
2163
+      #
2164
+      # don't redo builds (if no names are specified)
2165
+      #
2166
+
2167
+      BUILT="`read_setting "${REPOS_DIR}/.build_done"`"
2163 2168
       stashnames="`read_root_setting "build_order"`"
2164 2169
       if [ ! -z "${stashnames}" ]
2165 2170
       then
... ...
@@ -2362,34 +2371,35 @@ build_main()
2362 2362
    [ -z "${MULLE_BOOTSTRAP_REPOSITORIES_SH}" ] && . mulle-bootstrap-repositories.sh
2363 2363
    [ -z "${MULLE_BOOTSTRAP_SCRIPTS_SH}" ] && . mulle-bootstrap-scripts.sh
2364 2364
 
2365
-   remove_file_if_present "${REPOS_DIR}/.bootstrap_build_done"
2366
-   create_file_if_missing "${REPOS_DIR}/.bootstrap_build_started"
2367 2365
 
2368
-   if [ $# -eq 0 ]
2366
+   #
2367
+   #
2368
+   #
2369
+   if [ "${MULLE_FLAG_MAGNUM_FORCE}" = "YES" ]
2369 2370
    then
2370
-      log_fluff "Setting up dependencies directory as \"${DEPENDENCIES_DIR}\""
2371
-      clean="`read_config_setting "clean_dependencies_before_build" "YES"`"
2372
-      if [ "${clean}" = "YES" ]
2373
-      then
2374
-         rmdir_safer "${DEPENDENCIES_DIR}"
2375
-      fi
2376
-   else
2377
-      if [ -d "${DEPENDENCIES_DIR}" ]
2378
-      then
2379
-         log_fluff "Unprotecting \"${DEPENDENCIES_DIR}\" (as this is a partial build)."
2380
-         exekutor chmod -R u+w "${DEPENDENCIES_DIR}"
2381
-      fi
2371
+      remove_file_if_present "${REPOS_DIR}/.build_done"
2382 2372
    fi
2383 2373
 
2384
-   # if present then we didnt't want to clean and we do nothing special
2385
-   if [ ! -d "${DEPENDENCIES_DIR}" ]
2374
+   if [ ! -f "${REPOS_DIR}/.build_done" ]
2386 2375
    then
2387
-      install_tars "$@"
2388
-   else
2376
+      _create_file_if_missing "${REPOS_DIR}/.build_done"
2377
+
2378
+      log_fluff "Cleaning dependencies directory as \"${DEPENDENCIES_DIR}\""
2379
+      rmdir_safer "${DEPENDENCIES_DIR}"
2380
+   fi
2381
+
2382
+   # parameter ? partial build!
2383
+
2384
+   if [ -d "${DEPENDENCIES_DIR}" ]
2385
+   then
2386
+      log_fluff "Unprotecting \"${DEPENDENCIES_DIR}\" (as this is a partial build)."
2387
+      exekutor chmod -R u+w "${DEPENDENCIES_DIR}"
2389 2388
       if have_tars
2390 2389
       then
2391 2390
          log_warning "Tars have not been installed, as \"${DEPENDENCIES_DIR}\" already exists."
2392 2391
       fi
2392
+   else
2393
+      install_tars "$@"
2393 2394
    fi
2394 2395
 
2395 2396
    build_stashes "$@"
... ...
@@ -2401,9 +2411,6 @@ build_main()
2401 2401
       log_fluff "No dependencies have been generated"
2402 2402
    fi
2403 2403
 
2404
-   remove_file_if_present "${REPOS_DIR}/.bootstrap_build_started"
2405
-   create_file_if_missing "${REPOS_DIR}/.bootstrap_build_done"
2406
-
2407 2404
    log_debug "::: build end :::"
2408 2405
 }
2409 2406
 
... ...
@@ -238,34 +238,6 @@ can_symlink_it()
238 238
 }
239 239
 
240 240
 
241
-ask_symlink_it()
242
-{
243
-   local  directory
244
-
245
-   directory="$1"
246
-
247
-   if ! can_symlink_it "${directory}"
248
-   then
249
-      return 1
250
-   fi
251
-
252
-   #
253
-   # check if checked out
254
-   #
255
-   local prompt
256
-
257
-   prompt="Should ${directory} be symlinked instead of cloned ?
258
-NO is safe, but you often say YES here."
259
-
260
-   if [ ! -z "${tag}" ]
261
-   then
262
-      prompt="${prompt} (Since tag ${tag} is set, NO is more reasonable)"
263
-   fi
264
-
265
-   user_say_yes "$prompt"
266
-}
267
-
268
-
269 241
 _search_for_git_repository_in_cache()
270 242
 {
271 243
    local directory
... ...
@@ -546,7 +518,7 @@ clone_or_symlink()
546 546
 
547 547
    case "${url}" in
548 548
       /*)
549
-         if ask_symlink_it "${url}"
549
+         if can_symlink_it "${directory}"
550 550
          then
551 551
             operation=link_command
552 552
          fi
... ...
@@ -570,23 +542,26 @@ clone_or_symlink()
570 570
 
571 571
          if [ ! -z "${found}" ]
572 572
          then
573
-            user_say_yes "There is \"${found}\" in the cache.
574
-(\"${PWD}\"). Use it ?"
575
-            if [ $? -eq 0 ]
576
-            then
577
-               url="${found}"
578
-
579
-               case "${scm}" in
580
-                  git)
581
-                     ask_symlink_it "${url}"
582
-                     if [ $? -eq 0 ]
583
-                     then
584
-                        operation=link_command
585
-                     fi
586
-                  ;;
587
-               esac
588
-               log_info "Using cached item \"${found}\""
589
-            fi
573
+            url="${found}"
574
+
575
+            case "${scm}" in
576
+               git)
577
+                  if can_symlink_it "${url}"
578
+                  then
579
+                     operation=link_command
580
+                  fi
581
+               ;;
582
+            esac
583
+
584
+            case "${operation}" in
585
+               link_command)
586
+                 log_info "Using symlink to cached item \"${found}\""
587
+               ;;
588
+
589
+               *)
590
+                 log_info "Using cached item \"${found}\""
591
+               ;;
592
+            esac
590 593
          fi
591 594
       ;;
592 595
    esac
... ...
@@ -1793,6 +1768,7 @@ _common_main()
1793 1793
       ;;
1794 1794
    esac
1795 1795
 
1796
+   remove_file_if_present "${REPOS_DIR}/.build_done"
1796 1797
    remove_file_if_present "${REPOS_DIR}/.bootstrap_fetch_done"
1797 1798
    create_file_if_missing "${REPOS_DIR}/.bootstrap_fetch_started"
1798 1799
 
... ...
@@ -1143,26 +1143,41 @@ rmdir_if_empty()
1143 1143
 }
1144 1144
 
1145 1145
 
1146
-create_file_if_missing()
1146
+_create_file_if_missing()
1147 1147
 {
1148
-   [ -z "$1" ] && internal_fail "empty path"
1148
+   local path="$1" ; shift
1149
+
1150
+   [ -z "${path}" ] && internal_fail "empty path"
1149 1151
 
1150
-   if [ ! -f "$1" ]
1152
+   if [ -f "${path}" ]
1151 1153
    then
1152
-      local dir
1154
+      return
1155
+   fi
1153 1156
 
1154
-      dir="`dirname "$1"`"
1155
-      if [ ! -z "${dir}" ]
1156
-      then
1157
-         mkdir_if_missing "${dir}"
1158
-      fi
1157
+   local directory
1158
+
1159
+   directory="`dirname "${path}"`"
1160
+   if [ ! -z "${directory}" ]
1161
+   then
1162
+      mkdir_if_missing "${directory}"
1163
+   fi
1159 1164
 
1160
-      log_fluff "Creating \"$1\""
1161
-      redirect_exekutor "$1" echo "# intentionally blank file" || fail "failed to create \"$1\""
1165
+   log_fluff "Creating \"${path}\""
1166
+   if [ -z "$*" ]
1167
+   then
1168
+      redirect_exekutor "${path}" echo "$*" || fail "failed to create \"{path}\""
1169
+   else
1170
+      exekutor touch "${path}"  || fail "failed to create \"${path}\""
1162 1171
    fi
1163 1172
 }
1164 1173
 
1165 1174
 
1175
+create_file_if_missing()
1176
+{
1177
+  _create_file_if_missing "$1" "# intentionally blank file"
1178
+}
1179
+
1180
+
1166 1181
 remove_file_if_present()
1167 1182
 {
1168 1183
    [ -z "$1" ] && internal_fail "empty path"
... ...
@@ -518,15 +518,25 @@ build_needed()
518 518
 
519 519
    [ -z "${REPOS_DIR}" ] && internal_fail "REPOS_DIR undefined"
520 520
 
521
-   if [ ! -f "${REPOS_DIR}/.bootstrap_build_done" ]
521
+   if [ ! -f "${REPOS_DIR}/build_done" ]
522 522
    then
523
-      log_verbose "Need build because \"${REPOS_DIR}/.bootstrap_build_done\" does not exist."
523
+      log_verbose "Need build because \"${REPOS_DIR}/.build_done\" does not exist."
524 524
       return 0
525 525
    fi
526 526
 
527
-   if [ "${REPOS_DIR}/.bootstrap_build_done" -ot "${REPOS_DIR}/.bootstrap_fetch_done" ]
527
+   local progress
528
+   local complete
529
+
530
+   #
531
+   # sort  and unique, because people can redo builds manually
532
+   # which will add duplicate lines
533
+   #
534
+   progress="`read_setting "${REPOS_DIR}/.build_done" | sort | sort -u`"
535
+   complete="`read_root_setting "build_order" | sort`"
536
+
537
+   if [ "${progress}" != "${complete}" ]
528 538
    then
529
-      log_verbose "Need build because \"${REPOS_DIR}/.bootstrap_fetch_done\" is younger"
539
+      log_verbose "Need build because \"${REPOS_DIR}/build_done\" is different to \"build_order\""
530 540
       return 0
531 541
    fi
532 542