Browse code

Improve clone caching. Don't touch non existing directories.

Nat! authored on 06-06-2017 11:40:11
Showing 6 changed files
... ...
@@ -3,7 +3,9 @@ cmake_minimum_required (VERSION 3.0)
3 3
 project( mulle-bootstrap)
4 4
 
5 5
 #
6
-# primarily used for packaging on Linux
6
+# Primarily used for packaging on Linux
7
+#
8
+# Debian:
7 9
 #
8 10
 # ```
9 11
 # mkdir package
... ...
@@ -69,39 +71,44 @@ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
69 71
             WORLD_EXECUTE WORLD_READ
70 72
 DESTINATION "bin")
71 73
 
74
+#
75
+# future: install into libexec/mulle-bootstrap/${MULLE_BOOTSTRAP_VERSION}
76
+#         allows multiple versions to co-exist (does it really ?)
77
+#
72 78
 INSTALL( FILES ${LIBRARY_SCRIPTS}
73 79
 PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
74 80
             GROUP_EXECUTE GROUP_READ
75 81
             WORLD_EXECUTE WORLD_READ
76 82
 DESTINATION "libexec/mulle-bootstrap")
77 83
 
78
-
79
-
80 84
 #
81 85
 # CPack and project specific stuff
82 86
 #
83 87
 ######
88
+
84 89
 set( CPACK_PACKAGE_NAME "mulle-bootstrap")
85 90
 set( CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
91
+set( CPACK_PACKAGE_CONTACT "Nat! <nat@mulle-kybernetik.de>")
86 92
 set( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
93
+set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "👢 Cross platform dependency manager - using bash and cmake")
87 94
 set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
88 95
 set( CPACK_STRIP_FILES false)
89 96
 
90 97
 # stuff needed for Debian
91 98
 # memo: its impossible to check for chosen generator here
92
-
93
-set( CPACK_PACKAGE_CONTACT "Nat! <nat@mulle-kybernetik.de>")
94
-
99
+#
100
+# CPackDeb doesn't produce 100% proper debian file unfortunately
101
+#
95 102
 set( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/mulle-nat/mulle-bootstrap")
96
-set( CPACK_DEBIAN_PACKAGE_DESCRIPTION "👢 Cross platform dependency manager - using bash and cmake")
103
+# not strictly required
104
+#set( CPACK_DEBIAN_PACKAGE_DEPENDS "cmake (>= 3.0.0)")
105
+
106
+# stuff needed for RPM
97 107
 
98 108
 set( CPACK_RPM_PACKAGE_VENDOR "Mulle kybernetiK")
99
-set( CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}")
100 109
 
101 110
 ######
102 111
 #
103 112
 # must be after CPACK_PACKAGE_VERSION
104 113
 include( CPack)
105 114
 
106
-
107
-
... ...
@@ -1,3 +1,10 @@
1
+## 3.6.4
2
+
3
+* fix accidental create of `.bootstap.local` as a file
4
+* when using clone chaches, mulle-bootstrap update and upgrade now work as one
5
+would expect. It would be good to erase your old clone caches.
6
+
7
+
1 8
 ## 3.6.3
2 9
 
3 10
 * fix missing include in warn scripts
... ...
@@ -1563,6 +1563,9 @@ fetch_loop()
1563 1563
 {
1564 1564
    unpostpone_trace
1565 1565
 
1566
+   # tell this for windows, it's so slow..
1567
+   log_info "Checking dependencies ..."
1568
+
1566 1569
    # this is wrong, we just do "stashes" though
1567 1570
    assume_stashes_are_zombies
1568 1571
 
... ...
@@ -1082,7 +1082,7 @@ mkdir_if_missing()
1082 1082
    if [ ! -d "$1" ]
1083 1083
    then
1084 1084
       log_fluff "Creating \"$1\" ($PWD)"
1085
-      exekutor mkdir -p "$1" || fail "failed to create directory \"$1\""
1085
+      exekutor mkdir -p "$1" || fail "failed to create directory \"$1\" ($PWD)"
1086 1086
    fi
1087 1087
 }
1088 1088
 
... ...
@@ -184,6 +184,43 @@ git_checkout()
184 184
 }
185 185
 
186 186
 
187
+_git_clone_cacheurl()
188
+{
189
+   local url="$1"; shift
190
+
191
+   local cachedir
192
+
193
+   mkdir_if_missing "${CLONE_CACHE}"
194
+   cachedir="${CLONE_CACHE}/`basename ${url}`" # try to keep it global
195
+
196
+   if [ ! -d "${cachedir}" ]
197
+   then
198
+      if ! exekutor git ${GITFLAGS} clone --mirror ${options} ${GITOPTIONS} -- "${url}" "${cachedir}" >&2
199
+      then
200
+         log_error "git clone of \"${url}\" into \"${cachedir}\" failed"
201
+         return 1
202
+      fi
203
+   else
204
+      # refetch
205
+      local refresh_cache
206
+
207
+      refresh_cache="`read_config_setting "refresh_cache" "YES"`"
208
+      if [ "${refresh_cache}" = "YES" ]
209
+      then
210
+      (
211
+         cd "${cachedir}";
212
+         if ! exekutor git ${GITFLAGS} fetch >&2
213
+         then
214
+            log_warning "git fetch from \"${url}\" failed, using old state"
215
+         fi
216
+      )
217
+      fi
218
+   fi
219
+
220
+   echo "${cachedir}"
221
+}
222
+
223
+
187 224
 _git_clone()
188 225
 {
189 226
    [ $# -ge 2 ] || internal_fail "_git_clone: parameters missing"
... ...
@@ -210,7 +247,6 @@ _git_clone()
210 247
       log_info "Cloning ${C_MAGENTA}${C_BOLD}${url}${C_INFO} into \"${stashdir}\" ..."
211 248
    fi
212 249
 
213
-
214 250
    # "remote urls" go through caches
215 251
    case "${url}" in
216 252
       file:*|/*|~*|.*)
... ...
@@ -219,35 +255,7 @@ _git_clone()
219 255
       *:*)
220 256
          if [ ! -z "${CLONE_CACHE}" ]
221 257
          then
222
-            local cachedir
223
-
224
-            mkdir_if_missing "${CLONE_CACHE}"
225
-            cachedir="${CLONE_CACHE}/`basename ${url}`" # try to keep it global
226
-
227
-            if [ ! -d "${cachedir}" ]
228
-            then
229
-               if ! exekutor git ${GITFLAGS} clone --bare ${options} ${GITOPTIONS} -- "${url}" "${cachedir}" >&2
230
-               then
231
-                  log_error "git clone of \"${url}\" into \"${cachedir}\" failed"
232
-                  return 1
233
-               fi
234
-            else
235
-               # refetch (this shjoz)
236
-               local refresh_cache
237
-
238
-               refresh_cache="`read_config_setting "refresh_cache" "YES"`"
239
-               if [ "${refresh_cache}" = "YES" ]
240
-               then
241
-               (
242
-                  cd "${cachedir}";
243
-                  if ! exekutor git ${GITFLAGS} fetch --tags >&2
244
-                  then
245
-                     log_warning "git fetch from \"${url}\" failed, using old state"
246
-                  fi
247
-               )
248
-               fi
249
-            fi
250
-            url="${cachedir}"
258
+            url="`_git_clone_cacheurl ${url}`"
251 259
          fi
252 260
       ;;
253 261
    esac
... ...
@@ -276,7 +284,6 @@ _git_clone()
276 284
 }
277 285
 
278 286
 
279
-
280 287
 git_clone()
281 288
 {
282 289
    [ $# -ge 7 ] || internal_fail "git_clone: parameters missing"
... ...
@@ -313,11 +320,24 @@ git_fetch()
313 320
    local tag="$1"; shift
314 321
    local stashdir="$1"; shift
315 322
 
323
+   # "remote urls" going through cache will be refreshed here
324
+   case "${url}" in
325
+      file:*|/*|~*|.*)
326
+      ;;
327
+
328
+      *:*)
329
+         if [ ! -z "${CLONE_CACHE}" ]
330
+         then
331
+            url="`_git_clone_cacheurl ${url}`"
332
+         fi
333
+      ;;
334
+   esac
335
+
316 336
    log_info "Fetching ${C_MAGENTA}${C_BOLD}${stashdir}${C_INFO} ..."
317 337
 
318 338
    (
319 339
       exekutor cd "${stashdir}" &&
320
-      exekutor git ${GITFLAGS} fetch "$@" ${GITOPTIONS}  >&2
340
+      exekutor git ${GITFLAGS} fetch "$@" ${GITOPTIONS} >&2
321 341
    ) || fail "git fetch of \"${stashdir}\" failed"
322 342
 }
323 343
 
... ...
@@ -334,6 +354,19 @@ git_pull()
334 354
    local tag="$1"; shift
335 355
    local stashdir="$1"; shift
336 356
 
357
+   # "remote urls" going through cache will be refreshed here
358
+   case "${url}" in
359
+      file:*|/*|~*|.*)
360
+      ;;
361
+
362
+      *:*)
363
+         if [ ! -z "${CLONE_CACHE}" ]
364
+         then
365
+            url="`_git_clone_cacheurl ${url}`"
366
+         fi
367
+      ;;
368
+   esac
369
+
337 370
    log_info "Pulling ${C_MAGENTA}${C_BOLD}${stashdir}${C_INFO} ..."
338 371
 
339 372
    (
... ...
@@ -1102,7 +1102,12 @@ _setting_write()
1102 1102
 
1103 1103
    filename="${directory}/${key}"
1104 1104
    redirect_exekutor "${filename}" echo "${value}"
1105
-   exekutor touch "${bootstrapdir}"
1105
+
1106
+   # avoid creating "files"
1107
+   if [ -d "${bootstrapdir}" ]
1108
+   then
1109
+      exekutor touch "${bootstrapdir}"
1110
+   fi
1106 1111
 }
1107 1112
 
1108 1113
 
... ...
@@ -1143,7 +1148,10 @@ _setting_append()
1143 1148
       ;;
1144 1149
    esac
1145 1150
 
1146
-   exekutor touch "${bootstrapdir}"
1151
+   if [ -d "${bootstrapdir}" ]
1152
+   then
1153
+      exekutor touch "${bootstrapdir}"
1154
+   fi
1147 1155
 }
1148 1156
 
1149 1157
 
... ...
@@ -1159,7 +1167,11 @@ _setting_delete()
1159 1167
 
1160 1168
    filename="${directory}/${key}"
1161 1169
    remove_file_if_present "${filename}"
1162
-   exekutor touch "${bootstrapdir}" 2> /dev/null
1170
+
1171
+   if [ -d "${bootstrapdir}" ]
1172
+   then
1173
+      exekutor touch "${bootstrapdir}"
1174
+   fi
1163 1175
 }
1164 1176
 
1165 1177
 
... ...
@@ -1202,13 +1214,20 @@ _config_write()
1202 1214
 
1203 1215
    if [ "${OPTION_USER}" = "YES" ]
1204 1216
    then
1205
-      configdir="${HOME}/.mulle-bootstrap"
1217
+      case "${UNAME}" in
1218
+         *)
1219
+            configdir="${HOME}/.mulle-bootstrap"
1220
+         ;;
1221
+      esac
1206 1222
    fi
1207 1223
 
1208 1224
    mkdir_if_missing "${configdir}"
1209 1225
    exekutor echo "${value}" > "${configdir}/${key}"
1210 1226
 
1211
-   exekutor touch "${BOOTSTRAP_DIR}.local"
1227
+   if [ -d "${BOOTSTRAP_DIR}.local" ]
1228
+   then
1229
+      exekutor touch "${BOOTSTRAP_DIR}.local"
1230
+   fi
1212 1231
 }
1213 1232
 
1214 1233
 
... ...
@@ -1229,7 +1248,10 @@ _config_delete()
1229 1248
    if [ -f "${configdir}/$1" ]
1230 1249
    then
1231 1250
       exekutor rm "${configdir}/$1"  >&2
1232
-      exekutor touch "${BOOTSTRAP_DIR}.local"  >&2
1251
+      if [ -d "${bootstrapdir}" ]
1252
+      then
1253
+         exekutor touch "${BOOTSTRAP_DIR}.local"
1254
+      fi
1233 1255
    fi
1234 1256
 }
1235 1257