# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1612264382 -3600 # Tue Feb 02 12:13:02 2021 +0100 # Node ID 4a962b086393faca63a96852ba9cc7ea9b950c14 # Parent 46ae7be29df7ef036a48f86744b899352333dd04 ✨ Also add expanding in shell scripts diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -2,6 +2,11 @@ History ======= +7.0.1 +----- + +Also add expanding in shell scripts. + 7.0.0 ----- diff --git a/common b/common --- a/common +++ b/common @@ -49,36 +49,20 @@ } function read_odoo_scripts_expandable_configuration_key () { - # return configuration value by appending any expanded values from defined super projects + # return configuration value by appending any expanded values from defined super projects. glob key as appropriate, for module for example. # first argument is the key to use - # second argument is the directory to use, defaults to project home - # third optional argument is the separator to use (default to comma) - # fourth optional argument is to indicate if the expanded project should be used as prefix for the values (default to not use, use True to use), adding a / - # fifth optional argument is a prefix to use (default to none) + # second optional argument is the separator to use (default to comma) configuration_key=${1} - base_dir="${2-${project_home}}" - separator=${3-,} - prefix_with_expand=${4-False} - prefix=$5 - # read expanded configurations - expanded_project_pathes=($($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('$base_dir/setup.cfg') ; print(c.get('odoo_scripts', '$configuration_key.expand') if c.has_option('odoo_scripts', '$configuration_key.expand') else '')")) - for expanded_project_path in $expanded_project_pathes; do - that_project_prefix=$prefix - if [[ "$prefix_with_expand" == True ]]; - then - that_project_prefix=${that_project_prefix}${expanded_project_path}/ + separator=${2-,} + # read expanded configurations, only done with projects in python 3 + if type python3 > /dev/null; then + configuration_value=$(python3 -B -c "from odoo_scripts.config import Configuration ; c = Configuration('$project_home') ; print('$separator'.join(c.$configuration_key))") + else + # read only local values + configuration_value=$($python -B -c "from six.moves import configparser ; import os ; c = configparser.ConfigParser() ; c.read(os.path.join('$project_home', 'setup.cfg')) ; print('$separator'.join(c.get('odoo_scripts', '$configuration_key').split() if c.has_option('odoo_scripts', '$configuration_key') else []))") + if [[ $configuration_key == modules ]]; then + configuration_value=$($python -B -c "import os;from glob import glob;print('$separator'.join([file for file in glob(path) for path in '${configuration_value}'.split('$separator') if os.path.isdir(file)]))") fi - expanded_configuration_value=$(read_odoo_scripts_expandable_configuration_key $configuration_key "$base_dir/$expanded_project_path" "$separator" $prefix_with_expand "$that_project_prefix") - if [[ -n $configuration_value ]]; then - configuration_value+=$separator - fi - configuration_value+=$expanded_configuration_value - done - # then add local values - this_project_configuration_value+=$($python -B -c "from six.moves import configparser ; c = configparser.ConfigParser() ; c.read('$base_dir/setup.cfg') ; print('$separator'.join(['$prefix'+a for a in c.get('odoo_scripts', '$configuration_key').split()] if c.has_option('odoo_scripts', '$configuration_key') else []))") - if [[ -n $this_project_configuration_value && -n $configuration_value ]]; then - configuration_value+=$separator fi - configuration_value+=$this_project_configuration_value echo $configuration_value } diff --git a/create_archive b/create_archive --- a/create_archive +++ b/create_archive @@ -12,8 +12,8 @@ odoo_dir=$1 tar_file=${2-${project_name}.tar} -odoo_modules="$(read_odoo_scripts_expandable_configuration_key modules "$project_home" " ")" -dependencies="$(read_odoo_scripts_expandable_configuration_key dependencies "$project_home" " ")" +odoo_modules="$(read_odoo_scripts_expandable_configuration_key modules " ")" +dependencies="$(read_odoo_scripts_expandable_configuration_key dependencies " ")" cd "$project_home" || exit 1 # Create empty tar @@ -22,13 +22,13 @@ # Add modules, in odoo_modules directory (whatever the original directory name) for module in $(eval echo "$odoo_modules") ; do - tar uf "$tar_file" --transform="s|^$(dirname "$module")|odoo_modules|" --show-transform --exclude-vcs --exclude-backups --exclude='*.pyc' --exclude='.drone.yml' --exclude='.gitlab-ci.yml' --atime-preserve "$module" + tar uf "$tar_file" --dereference --transform="s|^$(dirname "${module[2,-1]}")|odoo_modules|" --show-transform --exclude-vcs --exclude-backups --exclude='*.pyc' --exclude='.drone.yml' --exclude='.gitlab-ci.yml' --atime-preserve "${module}" done # Add dependencies, in dependencies directory (whatever the original directory name) for dep in $(eval echo "$dependencies") ; do - tar uf "$tar_file" --transform="s|^$(dirname "$dep")|dependencies|" --exclude-vcs --exclude-backups --exclude='*.pyc' --exclude='.drone.yml' --exclude='.gitlab-ci.yml' --atime-preserve "$dep" + tar uf "$tar_file" --dereference --transform="s|^$(dirname "$dep")|dependencies|" --exclude-vcs --exclude-backups --exclude='*.pyc' --exclude='.drone.yml' --exclude='.gitlab-ci.yml' --atime-preserve "$dep" done # Add version number file if present @@ -39,7 +39,7 @@ if [ -d "$odoo_dir" ]; then - tar uf "$tar_file" --transform="s|^$(echo "$odoo_dir" | sed -e 's|/\(.*\)|\1|')|odoo|" --exclude-vcs --exclude-backups --exclude='*.pyc' --atime-preserve "$odoo_dir" + tar uf "$tar_file" --dereference --transform="s|^$(echo "$odoo_dir" | sed -e 's|/\(.*\)|\1|')|odoo|" --exclude-vcs --exclude-backups --exclude='*.pyc' --atime-preserve "$odoo_dir" fi # Compress the file diff --git a/start b/start --- a/start +++ b/start @@ -123,12 +123,12 @@ pathes=$ODOO_ADDONS_PATH fi else - modules_to_use=$(read_odoo_scripts_expandable_configuration_key modules ${project_home} , True) + modules_to_use=$(read_odoo_scripts_expandable_configuration_key modules) if [ "$ODOO_TYPE" = "odoo7" ] || [ "$ODOO_TYPE" = "odoo8" ]; then - pathes=$($python -B -c "import os;print(','.join(['$odoo_addons_path/addons']+['${project_home}/'+line for line in set(os.path.dirname(path) for path in '${modules_to_use}'.split(','))]))") + pathes=$($python -B -c "import os;print(','.join(['$odoo_addons_path/addons']+list(set(os.path.dirname(path) for path in '${modules_to_use}'.split(',')))))") else - pathes=$($python -B -c "import os;print(','.join(['${project_home}/'+line for line in set(os.path.dirname(path) for path in '${modules_to_use}'.split(','))]))") + pathes=$($python -B -c "import os;print(','.join(set(os.path.dirname(path) for path in '${modules_to_use}'.split(','))))") fi fi if [ -n "$pathes" ];