Skip to content

Instantly share code, notes, and snippets.

@mvaled
Last active October 30, 2023 09:15
Show Gist options
  • Save mvaled/04ff872a7e7bb96ab424 to your computer and use it in GitHub Desktop.
Save mvaled/04ff872a7e7bb96ab424 to your computer and use it in GitHub Desktop.
A file to build OpenERP 7.0/8.0 distributions.
#!/bin/sh
# Build OpenERP 7.0 and 8.0 sdists.
#
# You MUST place this in the root of your odoo repository. It expects you
# have the local branches 7.0 and any other you may use.
#
# Usage:
#
# ./builddist.sh [BRANCH] [VERSION]
#
# The default for BRANCH is "7.0". If BRANCH is set but VERSION is not, it
# defaults to the part of BRANCH after the first "-" which starts with a
# digit.
#
# Copyright (c) 2014 Merchise Autrement and Contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
if [ -z "$1" ]; then
BRANCH="7.0"
else
BRANCH="$1"
fi
if [ -z "$2" ]; then
VERSION=`python -c "import re; \
P=re.compile(r'-(\d[\d\.]+.*)$'); \
P2=re.compile(r'(\d[\d\.]+.*)$'); \
match=P.search('$BRANCH') or P2.search('$BRANCH'); \
print(match.groups()[-1] if match else '')"`
if [ -z "$VERSION" ]; then
echo "ERROR: Impossible to detect the version from branch '$BRANCH'" >&2
echo "Either use a branch with a trailing '-VERSION' or pass the"\
"VERSION argument" >&2
exit 1
fi
else
VERSION="$2"
fi
if [ "$VERSION" = "7.0" ]; then
DISTRIBUTION='openerp'
else
# Now 8.0 is odoo
DISTRIBUTION='odoo'
fi
# Save the liver...
CWD=`pwd`
if [ ! -f ./openerp-server ]; then
cd `dirname $0`
fi
RELEASE=`git log $BRANCH -1 --pretty=%h`
COMMITER_DATE=`git log $BRANCH -1 --pretty=%cd --date=iso`
STAMP=`date --date="$COMMITER_DATE" +"%Y%m%d-%H%M%S"`
PKGNAME="$DISTRIBUTION-$VERSION-$STAMP-$RELEASE"
PKG="$PKGNAME.tar.gz"
# Test that the file is not already built.
if [ `ls "$CWD/$PKG" 2>/dev/null| wc -l` -gt 0 ]; then
echo "WARNING: A build with for commit $RELEASE is already here." >&2
echo "Refusing to proceed." >&2
exit 1;
fi
TMPDIR=`python -c "import tempfile; print tempfile.mkdtemp(prefix='odoo-')"`
mkdir "$TMPDIR/src"
mkdir "$TMPDIR/pkg"
git archive $BRANCH > "$TMPDIR/src/openerp.tar"
cd "$TMPDIR/src"
tar -xf openerp.tar
# Need to dist the addons
mv addons/* openerp/addons/
# Rewrite the version
sed -i "s/FINAL, 0/FINAL, \"-$STAMP-$RELEASE\"/" openerp/release.py
python setup.py --quiet sdist -d "$TMPDIR/pkg"
# The following incantation is to avoid a directory not found in Odoo v8.
cd "$TMPDIR/pkg"
gunzip "$PKG"
mkdir -p "$PKGNAME/addons/"
echo "#" > "$PKGNAME/addons/__dummy__.py"
tar -f "$PKGNAME.tar" -r "$PKGNAME/addons/__dummy__.py"
gzip "$PKGNAME.tar"
# Clean up
mv "$TMPDIR/pkg/$PKG" "$CWD/"
rm -rf "$TMPDIR"
cd "$CWD"
echo "Built $PKG"
@mvaled
Copy link
Author

mvaled commented Sep 19, 2014

I'm tired of waiting for a response about how to create .tar.gz distributions for OpenERP 7.0. Furthermore, since August they are no longer publishing nightly builds.

Place this in your odoo github clone and voilà, build your own cooked sdists.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment