Changeset 563
- Timestamp:
- 12/16/2011 18:15:38 (5 months ago)
- Location:
- branches/confman-1.9
- Files:
-
- 6 edited
-
. (modified) (1 prop)
-
confexport.8 (modified) (2 diffs)
-
confexport.in (modified) (4 diffs)
-
confman.conf.5.in (modified) (1 diff)
-
confman.conf.in (modified) (1 diff)
-
confmanlib.sh.in (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/confman-1.9
- Property svn:mergeinfo changed
/trunk merged: 522-527,530-532,539,542
- Property svn:mergeinfo changed
-
branches/confman-1.9/confexport.8
r429 r563 45 45 repository for use by hosts running 46 46 .Xr confsync 8 . 47 .Pp 48 If the system is already up to date, 49 .Nm 50 will exit without making any changes. This behavior can be overridden with the 51 .Fl f 52 option, which will force 53 .Nm 54 to run even if the system revision equals the export revision. Note that the 55 .Fl f 56 option cannot be used to export a revision less than the system revision. 47 57 .Pp 48 58 The … … 103 113 .Xr confman.conf 5 , 104 114 .Xr cron 8 115 .Sh BUGS 116 When using 117 .Nm 118 with the CONF_EXPORT_INCREMENTAL option, changes to files that are 119 referenced in other modules by in-repository symlinks do not cause 120 all relevant exports to be regenerated. This can be worked around by 121 either disabling the CONF_EXPORT_INCREMENTAL option or running 122 .Nm 123 with the 124 .Fl f 125 flag when such changes are made. 105 126 .Sh AUTHORS 106 127 .An Chris Cowart Aq ccowart@timesinks.net -
branches/confman-1.9/confexport.in
r556 r563 29 29 # This script prepares an "export" of the confman repository for system 30 30 # processes to be able to pull. It is intended to be prepared regularly 31 # by a cron. It may be useful to modify this script to only prepare 32 # the export if the repository's most recent commit post-dates the 33 # tarball. 31 # by an automated process like cron. 34 32 35 33 if [ -r @pkgdatadir@/confmancommon.sh ] ; then … … 41 39 42 40 # This changes the behavior of some library functions (e.g. URIs, locks) 43 CONF_EXPORT= "true"41 CONF_EXPORT=true 44 42 45 43 function print_help { 46 echo "usage: $0 [- d]" >&444 echo "usage: $0 [-f] [-d]" >&4 47 45 echo "Type '$0 -h' to display this help and exit." >&4 48 46 conf_cleanExit ${1:-0} 49 47 } 50 48 51 while getopts "dh" OPT 2>&4 ; do 49 FORCE=false 50 DEBUG=false 51 52 while getopts "fdh" OPT 2>&4 ; do 52 53 case "$OPT" in 54 f) FORCE=true ;; 53 55 d) DEBUG=true ;; 54 56 h) print_help 0;; … … 64 66 exec 1>/dev/null 65 67 fi 68 69 echo "Export operation started" | conf_logger 66 70 67 71 confexport_lock_system … … 82 86 esac 83 87 84 if [ -z "$ temp_conf_export" ] ; then88 if [ -z "${temp_conf_export}" ] ; then 85 89 echo "Could not create tempfile. Exiting." >&2 86 90 exit 1 87 91 fi 88 92 89 echo "Beginning export operation." | conf_logger 90 if ! conf_export $temp_conf_export ; then 91 echo "The export failed. Exiting." >&2 92 rm -rf $temp_conf_export 93 exit 1 93 if [ -z "${CONF_EXPORT_WORK_PATH}" ]; then 94 WORK_PATH=$(conf_tmp_dir) 95 conf_debug "Using temporary export working copy at ${WORK_PATH}" 94 96 else 95 # Prepare the new export 96 chown -R ${CONF_EXPORT_USER}:${CONF_EXPORT_GROUP} $temp_conf_export 97 chmod -R ${CONF_EXPORT_MODE} $temp_conf_export 98 # Switch to the new export 99 old_conf_export=$(conf_tmp_dir) 100 mv ${CONF_EXPORT_FILE} $old_conf_export 101 mv $temp_conf_export ${CONF_EXPORT_FILE} 102 # Remove the old export 103 rm -rf $old_conf_export 97 WORK_PATH="${CONF_EXPORT_WORK_PATH}" 98 conf_debug "Using persistent export working copy at ${WORK_PATH}" 104 99 fi 105 100 106 conf export_unlock_system101 conf_checkout_tree 107 102 108 echo "Export complete." | conf_logger 103 repo_export="${CONF_EXPORT_STYLE}:$(conf_revision)" 104 sys_export="$(conf_export_sysrev)" 105 106 conf_debug "repo_export: ${repo_export}" 107 conf_debug "sys_export: ${sys_export}" 108 109 if [ "${sys_export}" = "${repo_export}" ]; then 110 if ! ${FORCE}; then 111 echo "System is up to date." | conf_logger 112 conf_cleanExit 0 113 fi 114 fi 115 116 repo_method=$(echo ${repo_export} | cut -d ':' -f 1) 117 sys_method=$(echo ${sys_export} | cut -d ':' -f 1) 118 repo_revision=$(echo ${repo_export} | cut -d ':' -f 2) 119 sys_revision=$(echo ${sys_export} | cut -d ':' -f 2) 120 121 if [ "${sys_method}" != "${repo_method}" ]; then 122 echo "Export style change detected: ${sys_method} -> ${repo_method}" 123 if ${CONF_EXPORT_INCREMENTAL}; then 124 echo "Ignoring CONF_EXPORT_INCREMENTAL during export style change" 125 CONF_EXPORT_INCREMENTAL="false" 126 fi 127 fi 128 129 if [ "${sys_revision}" -gt "${repo_revision}" ]; then 130 echo "Error: The last export was newer than the current repository. Exiting without making changes." >&2 131 conf_cleanExit 1 132 fi 133 134 if ! conf_export "${temp_conf_export}" "${sys_revision}" "${repo_revision}"; then 135 echo "Error: The export failed. Exiting." >&2 136 rm -rf "${temp_conf_export}" 137 conf_cleanExit 1 138 fi 139 140 # Prepare the new export 141 chown -R ${CONF_EXPORT_USER}:${CONF_EXPORT_GROUP} "${temp_conf_export}" || exit 1 142 chmod -R ${CONF_EXPORT_MODE} "${temp_conf_export}" || exit 1 143 144 # Switch to the new export 145 old_conf_export=$(conf_tmp_dir) 146 if [ -e "${CONF_EXPORT_FILE}" ]; then 147 mv "${CONF_EXPORT_FILE}" "${old_conf_export}" || exit 1 148 fi 149 mv "${temp_conf_export}" "${CONF_EXPORT_FILE}" 150 151 conf_record_export 152 153 echo "Export operation finished successfully" | conf_logger 154 155 confexport_unlock_system "${system_lock}" 156 157 # Remove the old export 158 rm -rf "${old_conf_export}" 159 160 # If CONF_EXPORT_WORK_PATH is not set, we were using a temporary 161 # directory, so clean it up 162 if [ -z "${CONF_EXPORT_WORK_PATH}" ]; then 163 rm -rf "${WORK_PATH}" 164 fi 109 165 110 166 conf_cleanExit 0 -
branches/confman-1.9/confman.conf.5.in
r560 r563 107 107 The export style to be used by 108 108 .Xr confexport 8 . Valid options are: repository, module, recipe. 109 .It CONF_EXPORT_INCREMENTAL 110 This option optimizes 111 .Xr confexport 8 performance. When enabled, 112 .Xr confexport 8 will only export the changes made to the 113 .Xr confman 8 repository since the last 114 .Xr confexport 8 run. This option has no effect when using repository-style 115 exports. 116 .It CONF_EXPORT_INCREMENTAL_LN 117 This option further optimizes 118 .Xr confexport 8 performance when using CONF_EXPORT_INCREMENTAL. When enabled, 119 .Xr confexport 8 will use 120 .Xr ln 1 to copy unchanged exports into the new export rather than 121 .Xr cp 1 . This option can only be used if temporary files are created 122 on the same filesystem partition as CONF_EXPORT_FILE. 109 123 .It CONF_FETCH_SSH_KEY 110 124 This is a private SSH keyfile for use with "sftp://" and "scp://" URIs above. -
branches/confman-1.9/confman.conf.in
r559 r563 80 80 CONF_EXPORT_WORK_PATH="" 81 81 CONF_EXPORT_STYLE="repository" 82 CONF_EXPORT_INCREMENTAL="false" 83 CONF_EXPORT_INCREMENTAL_LN="false" 82 84 EXPORT_REPO_PROTOCOL="" 83 85 EXPORT_REPO_HOSTNAME="" -
branches/confman-1.9/confmanlib.sh.in
r559 r563 28 28 29 29 REPO_ACTION="${REPO_DB}/last_action" 30 EXPORT_REV_FILE="${REPO_DB}/last_export" 30 31 REPO_SYNC_STATE="${REPO_DB}/state" 31 32 RECIPE_NAME="$(cat "$RECIPE_FILE" 2>/dev/null)" … … 377 378 function conf_export { 378 379 local exportpath="$1" 380 local sys_revision="$2" 381 local export_revision="$3" 379 382 local modules 380 381 if [ -z "${CONF_EXPORT_WORK_PATH}" ]; then382 WORK_PATH=$(conf_tmp_dir)383 else384 WORK_PATH="${CONF_EXPORT_WORK_PATH}"385 fi386 387 conf_checkout_tree388 383 local module 384 local changed_recipes 385 local changed_modules 386 local updated_recipes 387 local recipe 388 local changed_module 389 local changed_recipe 390 local recipes 391 389 392 case ${CONF_EXPORT_STYLE} in 390 393 repository) 391 tar -czf "$exportpath" -C "${WORK_PATH}" . 394 tar -czf "$exportpath" -C "${WORK_PATH}" . || return 1 392 395 ;; 393 396 module) 394 modules=$(ls -1 ${WORK_PATH} | egrep -v '^(\.svn|checkpoints)$') # until ticket $40 is resolved 395 for module in $modules; do 396 tar -hczf "$exportpath/$module.tgz" -C "${WORK_PATH}" $module 397 if ! ${FORCE} && ${CONF_EXPORT_INCREMENTAL}; then 398 # Get the list of changed modules 399 # TODO: Catch in-repository symlinks, ticket #144 400 cd "${WORK_PATH}" 401 changed_modules=$(@SVN@ diff -r ${sys_revision}:${export_revision} --summarize | egrep -v '^D[^/]*$' | sed 's/^[^ ][ ]*//' | cut -d '/' -f 1 | sort | uniq | egrep -v '^(meta|checkpoints)$') 402 cd - >/dev/null 403 404 # Preserve old module exports where possible 405 for module in $(ls -1 ${WORK_PATH} | egrep -v '^(\.svn|checkpoints)$'); do 406 # If this module has changed, move on to the next one 407 for changed_module in ${changed_modules}; do 408 if [ "${module}" = "${changed_module}" ]; then 409 continue 2 410 fi 411 done 412 413 # This module was not changed, so preserve its old export 414 echo "Preserving old export for module: ${module}" 415 if ${CONF_EXPORT_INCREMENTAL_LN}; then 416 ln "${CONF_EXPORT_FILE}/${module}.tgz" "${exportpath}" || return 1 417 else 418 cp -p "${CONF_EXPORT_FILE}/${module}.tgz" "${exportpath}" || return 1 419 fi 420 done 421 422 modules="${changed_modules}" 423 else 424 modules=$(ls -1 ${WORK_PATH} | egrep -v '^(\.svn|checkpoints)$') # until ticket $40 is resolved 425 fi 426 427 for module in ${modules}; do 428 echo "Generating new export for module: ${module}" 429 tar -hczf "${exportpath}/${module}.tgz" -C "${WORK_PATH}" ${module} || return 1 397 430 done 398 431 ;; 399 432 recipe) 400 for recipefile in $(conf_recipe_dir)/*; do 401 modules="meta $(conf_get_recipe $recipefile)" 402 tar -hczf "$exportpath/${recipefile#$(conf_recipe_dir)/}.tgz" -C "${WORK_PATH}" $modules 433 if ! ${FORCE} && ${CONF_EXPORT_INCREMENTAL}; then 434 # Get the list of changed recipes 435 cd "$(conf_recipe_dir)" 436 changed_recipes=$(@SVN@ diff -r ${sys_revision}:${export_revision} --summarize | grep -v '^D' | sed 's/^[^ ]*[ ]*//' | cut -d '/' -f 1) 437 cd - >/dev/null 438 conf_debug "changed_recipes: ${changed_recipes}" 439 440 # Get the list of changed modules 441 # TODO: Catch in-repository symlinks, ticket #144 442 cd "${WORK_PATH}" 443 changed_modules=$(@SVN@ diff -r ${sys_revision}:${export_revision} --summarize | sed 's/^[^ ]*[ ]*//' | cut -d '/' -f 1 | sort | uniq | egrep -v '^(meta|checkpoints)$') 444 cd - >/dev/null 445 conf_debug "changed_modules: ${changed_modules}" 446 447 # Check all recipes for changes 448 for recipe in $(ls -1 "$(conf_recipe_dir)" | egrep -v '^\.svn$'); do 449 # If this recipe is in the list of changed recipes, 450 # there's no need to check it any further since it will 451 # be regenerated anyway 452 for changed_recipe in ${changed_recipes}; do 453 if [ "${recipe}" = "${changed_recipe}" ]; then 454 continue 2 455 fi 456 done 457 458 # If an unchanged recipe references a changed module, 459 # its export needs to be regenerated 460 modules=$(conf_get_recipe $(conf_recipe_dir)/${recipe}) 461 for module in ${modules}; do 462 for changed_module in ${changed_modules}; do 463 if [ "${module}" = "${changed_module}" ]; then 464 updated_recipes="${updated_recipes} ${recipe}" 465 continue 3 466 fi 467 done 468 done 469 470 # This recipe has neither changed nor references a 471 # changed module, so preserve its old export 472 echo "Preserving old export for recipe: ${recipe}" 473 if ${CONF_EXPORT_INCREMENTAL_LN}; then 474 ln "${CONF_EXPORT_FILE}/${recipe}.tgz" "${exportpath}" || return 1 475 else 476 cp -p "${CONF_EXPORT_FILE}/${recipe}.tgz" "${exportpath}" || return 1 477 fi 478 done 479 conf_debug "updated_recipes: ${updated_recipes}" 480 481 recipes="${changed_recipes} ${updated_recipes}" 482 else 483 recipes=$(ls -1 "$(conf_recipe_dir)"| egrep -v '^\.svn$') 484 fi 485 486 for recipe in ${recipes}; do 487 echo "Generating new export for recipe: ${recipe}" 488 modules=$(conf_get_recipe $(conf_recipe_dir)/${recipe}) 489 tar -hczf "${exportpath}/${recipe}.tgz" -C "${WORK_PATH}" "meta/.svn/entries" "meta/recipes/${recipe}" ${modules} || return 1 403 490 done 404 491 ;; … … 409 496 esac 410 497 411 if [ -z "${CONF_EXPORT_WORK_PATH}" ]; then412 rm -rf ${WORK_PATH}413 fi414 415 498 return 0 416 499 } … … 999 1082 } 1000 1083 1084 # Returns the revision of the last export operation on stdout 1085 function conf_export_sysrev { 1086 local export_sysrev 1087 local rv 1088 1089 export_sysrev="none:0" 1090 rv=0 1091 1092 if [ -f "${EXPORT_REV_FILE}" ]; then 1093 if ! export_sysrev=$(cat "${EXPORT_REV_FILE}"); then 1094 echo "Could not read file: ${EXPORT_REV_FILE}" >&2 1095 export_sysrev="none:0" 1096 rv=1 1097 fi 1098 fi 1099 1100 echo "${export_sysrev}" 1101 return ${rv} 1102 } 1103 1001 1104 # Returns the last action of the repository on stdout 1002 1105 function conf_lastact { … … 1013 1116 local revision=`conf_revision` 1014 1117 $SUDO sh -c "echo '${action}:${revision}' > $REPO_ACTION" 1118 } 1119 1120 # Records the export operation 1121 function conf_record_export { 1122 local revision=$(conf_revision) 1123 1124 if ! echo "${CONF_EXPORT_STYLE}:${revision}" > "${EXPORT_REV_FILE}"; then 1125 echo "Could not record export to file: ${EXPORT_REV_FILE}" >&2 1126 return 1 1127 fi 1015 1128 } 1016 1129
Note: See TracChangeset
for help on using the changeset viewer.
