summaryrefslogtreecommitdiff
path: root/package/package_user_agent.sh
blob: 27723a8d8fb5faee4b743f840a40c3ceaae2255f (plain)
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
#!/bin/bash

set -x
set -e

PACKAGE_VERSION="$1"
BUILD_PATH=/tmp/pix-user-agent-build
PIXELATED_LIB_PATH=$BUILD_PATH/var/lib/pixelated
PIXELATED_WEB_LIB_PATH=$PIXELATED_LIB_PATH/web-ui/app
PIXELATED_VIRTUALENV_PATH=$PIXELATED_LIB_PATH/virtualenv
BIN_PATH=$BUILD_PATH/usr/local/bin

# create build folder
[[ ! -d "$BUILD_PATH" ]] && mkdir $BUILD_PATH
rm -rf $BUILD_PATH/*

# create internal folders
mkdir -p $BIN_PATH
mkdir -p $PIXELATED_LIB_PATH
mkdir -p $PIXELATED_WEB_LIB_PATH
mkdir -p $BUILD_PATH

# build web-ui code
cd web-ui
bundle install --path=~/pixelated-gems
npm install
node_modules/bower/bin/bower install
./go package
cd ..

# copy code
cp -rf service $PIXELATED_LIB_PATH
cp -rf web-ui/dist/* $PIXELATED_WEB_LIB_PATH

# build virtual env
cd service
virtualenv $PIXELATED_VIRTUALENV_PATH
. $PIXELATED_VIRTUALENV_PATH/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools
deactivate
cd $PIXELATED_VIRTUALENV_PATH
for file in $(grep -l '/tmp/pix-user-agent-build' bin/*); do 
        sed -i 's|/tmp/pix-user-agent-build||' $file;
done
cd -
cd ..

cp package/pixelated-user-agent $BIN_PATH

cd $BUILD_PATH
[[ ! -f '/tmp/gems/bin/fpm' ]] && GEM_HOME=/tmp/gems gem install fpm
GEM_HOME=/tmp/gems /tmp/gems/bin/fpm -s dir -v ${PACKAGE_VERSION} -t deb -n pixelated-user-agent -C . .