Newer
Older

Vincent Hatakeyama
committed
#!/bin/sh
# vim: set shiftwidth=4 softtabstop=4:
# Create archive of project sources
# Arguments:
# - directory of the odoo sources
# - name of the tar file (the target file will have this name + .xz) if no name specified, name is <project name>.tar
odoo_dir=$1
tar_file=$2

Vincent Hatakeyama
committed
here=$(dirname "$0")
project_home=$(cd "$here" && cd .. && echo "$PWD")
project_name=$(basename "$project_home")
odoo_modules="$($python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(' '.join(c.get('odoo_scripts', 'modules', '').split()))")"
dependencies="$($python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print(c.has_section('odoo_scripts') and c.has_option('odoo_scripts', 'dependencies') and' '.join(c.get('odoo_scripts', 'dependencies', 'dependencies').split()) or 'dependencies')")"

Vincent Hatakeyama
committed
if [ -z "$tar_file" ];
then
tar_file=${project_name}.tar
fi

Vincent Hatakeyama
committed
cd "$project_home" || exit 1

Vincent Hatakeyama
committed
tar cf "${project_name}.tar" --files-from /dev/null
# Add modules, in odoo_modules directory (whatever the original directory name)

Vincent Hatakeyama
committed
for module in $(eval echo "$odoo_modules") ;

Vincent Hatakeyama
committed
tar uf "$tar_file" --transform="s|^$(dirname "$module")|odoo_modules|" "$module" --show-transform --exclude-vcs --exclude-backups --exclude='*.pyc' --exclude='.drone.yml' --exclude='.gitlab-ci.yml'
done
# Add dependencies, in dependencies directory (whatever the original directory name)

Vincent Hatakeyama
committed
for dep in $(eval echo "$dependencies") ;

Vincent Hatakeyama
committed
tar uf "$tar_file" --transform="s|^$(dirname "$dep")|dependencies|" "$dep" --exclude-vcs --exclude-backups --exclude='*.pyc' --exclude='.drone.yml' --exclude='.gitlab-ci.yml'
done
# Add version number file if present

Vincent Hatakeyama
committed
if [ -f VERSION ];

Vincent Hatakeyama
committed
tar uf "tar_file" VERSION

Vincent Hatakeyama
committed
if [ -d "$odoo_dir" ];

Vincent Hatakeyama
committed
tar uf "$tar_file" --transform="s|^$(echo "$odoo_dir" | sed -e 's|/\(.*\)|\1|')|odoo|" "$odoo_dir" --exclude-vcs --exclude-backups --exclude='*.pyc'