-
Notifications
You must be signed in to change notification settings - Fork 2k
/
build.sh
executable file
·98 lines (88 loc) · 4.47 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# This is a script which uses BuildKit 0.2.0 to automatically package CKAN and
# its dependencies for use as Debian packages on Ubuntu 12.04 and 10.04.
#
# See the BuildKit documentation or look at the help to see what these commands
# do. eg:
#
# buildkit --help
#
# The licenses and solrpy packages have to be built separately from the others
# because they are slighlty non-standard. All other CKAN dependencies are
# automatically handled by the --deps option to the CKAN build command.
#
# Over time, as CKAN and its dependencies follow conventions more closely the
# edge cases handled by this script should go away and the build should become
# simpler.
#
# Install:
#
# sudo apt-get update
# sudo apt-get install -y wget
# echo "deb http://apt.3aims.com/buildkit-0.2.2 lucid universe" | sudo tee /etc/apt/sources.list.d/3aims.list
# wget -qO- "http://apt.3aims.com/packages_public.key" | sudo apt-key add -
# sudo apt-get update
# sudo apt-get install buildkit-deb buildkit-apt-repo
CKAN_PACKAGE_VERSION=$1
DEPS_PACKAGE_VERSION=$2
# If you don't run this command from the CKAN source directory, specify the
# path to CKAN here
CKAN_PATH=$PWD
PIP_DOWNLOAD_CACHE=${CKAN_PATH}/build/env/cache
EMAIL=packaging@okfn.org
NAME="James Gardner"
# Clean the build environment
echo "Cleaning the environment ..."
rm -r ${CKAN_PATH}/dist/
rm -rf ${CKAN_PATH}/build/env/src
mkdir -p ${CKAN_PATH}/dist/buildkit
echo "done."
# In lieu of a requires directory, copy the pip-requirements into
# requires/lucid_conflict. This ensures that all requirements
# are installed as src.
mkdir "${CKAN_PATH}/requires"
cp "${CKAN_PATH}/pip-requirements.txt" "${CKAN_PATH}/requires/lucid_conflict.txt"
echo "Building the packages ..."
# Create the python-ckan debian package
buildkit pkg python -p $CKAN_PACKAGE_VERSION \
--delete "solrpy" \
--distro-dep "python-solr" \
--delete "licenses" \
--distro-dep "python-licenses" \
--delete "repoze.who-friendlyform" \
--rename "repoze.who.plugins.openid -> repoze.who-plugins" \
--rename "babel -> pybabel" \
--author-email="$EMAIL" \
--author-name="$NAME" \
--packager-email="$EMAIL" \
--packager-name="$NAME" \
--deps \
--exclude=test/generate_package \
--conflict-module "sqlalchemy-migrate -> migrate" \
--conflict-module "sqlalchemy -> lib/sqlalchemy" \
--debian-dir \
--url http://ckan.org \
${CKAN_PATH}
# Creates the ckan debian package (of which python-ckan is a dependency)
buildkit pkg nonpython -p $CKAN_PACKAGE_VERSION \
--deb \
--output-dir ${CKAN_PATH}/dist/buildkit \
${CKAN_PATH}/ckan_deb
# Build python-solr
${CKAN_PATH}/build/buildkit/env/bin/pip install --download-cache ${CKAN_PATH}/build/buildkit/env/cache --no-install --upgrade "solrpy==0.9.4"
mv ${CKAN_PATH}/build/buildkit/env/build/solrpy ${CKAN_PATH}/build/buildkit/env/build/solr
# We need to rename the package here
sed -e "s,solrpy,solr," -i ${CKAN_PATH}/build/buildkit/env/build/solr/setup.py
# We need to specify an author explicitly since it is missing we'll use the CKAN one
buildkit pkg python -p $DEPS_PACKAGE_VERSION --author-email="$EMAIL" --author-name="$NAME" --packager-email="$EMAIL" --packager-name="$NAME" --debian-dir ${CKAN_PATH}/build/buildkit/env/build/solr/
cp ${CKAN_PATH}/build/buildkit/env/build/solr/dist/buildkit/*.deb ${CKAN_PATH}/dist/buildkit/
# Build python-licenses
${CKAN_PATH}/build/buildkit/env/bin/pip install --download-cache ${CKAN_PATH}/build/buildkit/env/cache --no-install --upgrade "licenses==0.6.1"
buildkit pkg python --deb -p $DEPS_PACKAGE_VERSION --author-email="$EMAIL" --author-name="$NAME" --packager-email="$EMAIL" --packager-name="$NAME" ${CKAN_PATH}/build/buildkit/env/build/licenses
cp ${CKAN_PATH}/build/buildkit/env/build/licenses/dist/buildkit/*.deb ${CKAN_PATH}/dist/buildkit/
echo "done."
# Add the .debs to the repository and the export the latest files for upload
# echo "Adding the packages to the $REPO_NAME repo using files in ${CKAN_PATH}/dist/buildkit/*.deb ..."
# sudo -u buildkit buildkit repo remove -a $REPO_NAME dummy_arg
# sudo -u buildkit buildkit repo add $REPO_NAME ${CKAN_PATH}/dist/buildkit/*.deb
# echo "done."