Changeset 525


Ignore:
Timestamp:
08/14/2011 17:15:31 (9 months ago)
Author:
blee
Message:

Create new CONF_EXPORT_INCREMENTAL configuration option.

When enabled, this optimizes confexport performance by only regenerating
export tarballs that have been changed since the previous confexport run.

This option has no effect when using repository-style exports.

See #140

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/confexport.in

    r522 r525  
    117117fi 
    118118 
    119 if ! conf_export "${temp_conf_export}"; then 
     119if ! conf_export "${temp_conf_export}" "${sys_revision}" "${export_revision}"; then 
    120120    echo "Error: The export failed. Exiting." >&2 
    121121    rm -rf "${temp_conf_export}" 
  • trunk/confman.conf.5.in

    r512 r525  
    107107The export style to be used by 
    108108.Xr confexport 8 . Valid options are: repository, module, recipe. 
     109.It CONF_EXPORT_INCREMENTAL 
     110This 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 
     115exports. 
    109116.It CONF_FETCH_SSH_KEY 
    110117This is a private SSH keyfile for use with "sftp://" and "scp://" URIs above. 
  • trunk/confman.conf.in

    r515 r525  
    8080CONF_EXPORT_WORK_PATH="" 
    8181CONF_EXPORT_STYLE="repository" 
     82CONF_EXPORT_INCREMENTAL="false" 
    8283EXPORT_REPO_PROTOCOL="" 
    8384EXPORT_REPO_HOSTNAME="" 
  • trunk/confmanlib.sh.in

    r523 r525  
    402402function conf_export { 
    403403    local exportpath="$1" 
     404    local sys_revision="$2" 
     405    local export_revision="$3" 
    404406    local modules 
    405407    local module 
    406     local recipefile 
     408    local changed_recipes 
     409    local changed_modules 
     410    local updated_recipes 
    407411    local recipe 
    408  
     412    local changed_module 
     413    local changed_recipe 
     414    local recipes 
     415     
    409416    case ${CONF_EXPORT_STYLE} in 
    410417        repository) 
    411             tar -czf "$exportpath" -C "${WORK_PATH}" . 
     418            tar -czf "$exportpath" -C "${WORK_PATH}" . || return 1 
    412419            ;; 
    413420        module) 
    414             modules=$(ls -1 ${WORK_PATH} | egrep -v '^(\.svn|checkpoints)$') # until ticket $40 is resolved 
    415             for module in $modules; do 
    416                 tar -hczf "$exportpath/$module.tgz" -C "${WORK_PATH}" $module 
     421            if ! ${FORCE} && ${CONF_EXPORT_INCREMENTAL}; then 
     422                cd "${WORK_PATH}" 
     423                changed_modules=$(@SVN@ diff -r ${sys_revision}:${export_revision} --summarize | sed 's/^.[ ]*//' | cut -d '/' -f 1 | sort | uniq | egrep -v '^(meta|checkpoints)$') 
     424                cd - >/dev/null 
     425 
     426                # Preserve old module exports where possible 
     427                for module in $(ls -1 ${WORK_PATH} | egrep -v '^(\.svn|checkpoints)$'); do 
     428                    # If this module has changed, move on to the next one 
     429                    for changed_module in ${changed_modules}; do 
     430                        if [ "${module}" = "${changed_module}" ]; then 
     431                            continue 2 
     432                        fi 
     433                    done 
     434 
     435                    # This module was not changed, so preserve its old export 
     436                    echo "Preserving old export for module: ${module}" 
     437                    cp -p "${CONF_EXPORT_FILE}/${module}.tgz" "${exportpath}" || return 1 
     438                done 
     439 
     440                modules="${changed_modules}" 
     441            else 
     442                modules=$(ls -1 ${WORK_PATH} | egrep -v '^(\.svn|checkpoints)$') # until ticket $40 is resolved 
     443            fi 
     444 
     445            for module in ${modules}; do 
     446                echo "Generating new export for module: ${module}" 
     447                tar -hczf "${exportpath}/${module}.tgz" -C "${WORK_PATH}" ${module} || return 1 
    417448            done 
    418449            ;; 
    419450        recipe) 
    420             for recipefile in $(conf_recipe_dir)/*; do 
    421                 recipe=${recipefile#$(conf_recipe_dir)/} 
    422                 modules=$(conf_get_recipe ${recipefile}) 
    423                 tar -hczf "${exportpath}/${recipe}.tgz" -C "${WORK_PATH}" "meta/.svn/entries" "meta/recipes/${recipe}" ${modules} 
     451            if ! ${FORCE} && ${CONF_EXPORT_INCREMENTAL}; then 
     452                # Get the list of changed recipes 
     453                cd "$(conf_recipe_dir)" 
     454                changed_recipes=$(@SVN@ diff -r ${sys_revision}:${export_revision} --summarize | sed 's/^.[ ]*//' | cut -d '/' -f 1) 
     455                cd - >/dev/null 
     456                conf_debug "changed_recipes: ${changed_recipes}" 
     457 
     458                # Get the list of changed modules 
     459                cd "${WORK_PATH}" 
     460                changed_modules=$(@SVN@ diff -r ${sys_revision}:${export_revision} --summarize | sed 's/^.[ ]*//' | cut -d '/' -f 1 | sort | uniq | egrep -v '^(meta|checkpoints)$') 
     461                cd - >/dev/null 
     462                conf_debug "changed_modules: ${changed_modules}" 
     463 
     464                # Check all recipes for changes 
     465                for recipe in $(ls -1 "$(conf_recipe_dir)" | egrep -v '^\.svn$'); do 
     466                    # If this recipe is in the list of changed recipes, 
     467                    # there's no need to check it any further since it will 
     468                    # be regenerated anyway 
     469                    for changed_recipe in ${changed_recipes}; do 
     470                        if [ "${recipe}" = "${changed_recipe}" ]; then 
     471                            continue 2 
     472                        fi 
     473                    done 
     474 
     475                    # If an unchanged recipe references a changed module, 
     476                    # its export needs to be regenerated 
     477                    modules=$(conf_get_recipe $(conf_recipe_dir)/${recipe}) 
     478                    for module in ${modules}; do 
     479                        for changed_module in ${changed_modules}; do 
     480                            if [ "${module}" = "${changed_module}" ]; then 
     481                                updated_recipes="${updated_recipes} ${recipe}" 
     482                                continue 3 
     483                            fi 
     484                        done 
     485                    done 
     486 
     487                    # This recipe has neither changed nor references a 
     488                    # changed module, so preserve its old export 
     489                    echo "Preserving old export for recipe: ${recipe}" 
     490                    cp -p "${CONF_EXPORT_FILE}/${recipe}.tgz" "${exportpath}" || return 1 
     491                done 
     492                conf_debug "updated_recipes: ${updated_recipes}" 
     493 
     494                recipes="${changed_recipes} ${updated_recipes}" 
     495            else 
     496                recipes=$(ls -1 "$(conf_recipe_dir)"| egrep -v '^\.svn$') 
     497            fi 
     498 
     499            for recipe in ${recipes}; do 
     500                echo "Generating new export for recipe: ${recipe}" 
     501                modules=$(conf_get_recipe $(conf_recipe_dir)/${recipe}) 
     502                tar -hczf "${exportpath}/${recipe}.tgz" -C "${WORK_PATH}" "meta/.svn/entries" "meta/recipes/${recipe}" ${modules} || return 1 
    424503            done 
    425504            ;; 
Note: See TracChangeset for help on using the changeset viewer.