Tarball build target and script

This commit is contained in:
Dave Page 2016-06-03 10:56:53 +01:00
parent ab9f63d960
commit a989840460
3 changed files with 89 additions and 3 deletions

1
.gitignore vendored
View File

@ -25,4 +25,5 @@ pgadmin4.log
/MANIFEST.in
/build
/mac-build
/src-build
/dist

View File

@ -13,9 +13,11 @@ SHELL = /bin/sh
# High-level targets
#########################################################################
all: docs install-pip-requirements pip appbundle
# Include only platform-independent builds in all
all: docs install-pip-requirements pip src
clean: clean-pip clean-docs clean-appbundle
# Include all clean sub-targets in clean
clean: clean-dist clean-docs clean-pip clean-appbundle clean-src
#########################################################################
# Python PIP package
@ -35,6 +37,7 @@ PGADMIN_SRC_DIR = pgadmin4
PGADMIN_EGG = ${PGADMIN_SRC_DIR}.egg-info
PGADMIN_BUILD = build
PGADMIN_MACBUILD = mac-build
PGADMIN_SRCBUILD = src-build
PGADMIN_DIST = dist
PGADMIN_MANIFEST = MANIFEST.in
PGADMIN_INSTALL_CMD = pip install --use-wheel --find-links=${PGADMIN_DIST} ${PGADMIN_SRC_DIR}
@ -97,11 +100,19 @@ clean-pip:
rm -rf ${PGADMIN_SRC_DIR}
rm -rf ${PGADMIN_EGG}
rm -rf ${PGADMIN_BUILD}
rm -rf ${PGADMIN_DIST}
rm -f ${PGADMIN_MANIFEST}
clean-appbundle:
rm -rf ${PGADMIN_MACBUILD}
rm -rf ${PGADMIN_DIST}/pgadmin4*.dmg*
src:
./pkg/src/build.sh
clean-src:
rm -rf ${PGADMIN_SRCBUILD}
rm -rf ${PGADMIN_DIST}/pgadmin4*.tar.gz
clean-dist:
rm -rf ${PGADMIN_DIST}
.PHONY: docs

74
pkg/src/build.sh Executable file
View File

@ -0,0 +1,74 @@
#!/bin/bash
########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
#########################################################################
# Runtime checks
if [ ! -d runtime -a ! -d web ]; then
echo This script must be run from the top-level directory of the source tree.
exit 1
fi
if [ ! -d .git -a ! -f .git/config ]; then
echo This script must be run from a git checkout of the source tree.
exit 1
fi
# Get the required package info
APP_RELEASE=`grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g'`
APP_REVISION=`grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g'`
APP_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //'`
APP_LONG_VERSION=$APP_RELEASE.$APP_REVISION
APP_SHORT_VERSION=`echo $APP_LONG_VERSION | cut -d . -f1,2`
APP_SUFFIX=`grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g"`
if [ ! -z $APP_SUFFIX ]; then
export APP_LONG_VERSION=$APP_LONG_VERSION-$APP_SUFFIX
fi
TARBALL_NAME=`echo $APP_NAME-$APP_LONG_VERSION | sed 's/ //g' | awk '{print tolower($0)}'`
# Output basic details to show we're working
echo Building tarballs for $APP_NAME version $APP_LONG_VERSION...
# Create/clearout the build directory
echo Creating/cleaning required directories...
if [ ! -d src-build ]; then
mkdir src-build
fi
if [ -d src-build/$TARBALL_NAME ]; then
rm -rf src-build/$TARBALL_NAME
fi
mkdir src-build/$TARBALL_NAME
# Create the output directory if not present
if [ ! -d dist ]; then
mkdir dist
fi
if [ -f dist/$TARBALL_NAME.tar.gz ]; then
rm -f dist/$TARBALL_NAME.tar.gz
fi
# Build the clean tree
for FILE in `git ls-files`
do
echo Adding $FILE
# We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents
tar cf - $FILE | (cd src-build/$TARBALL_NAME; tar xf -)
done
# Create the tarball
echo Creating tarball...
cd src-build
tar zcvf ../dist/$TARBALL_NAME.tar.gz $TARBALL_NAME
cd ..
# Fin!
echo Created tarball dist/$TARBALL_NAME.tar.gz