-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgo.sh
executable file
·195 lines (168 loc) · 6.09 KB
/
go.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# MongoDB Builder
# This script will:
# - Get the MongoDB code directly from GitHub
# - Compiled it with full SSL support
# - Create a DEB package for it ready to be installed/distributed
#
# Tested on: Ubuntu Server 12.04 64 bit
#
# Author: Ben Cessa <[email protected]>
# BASICS
ARCH=amd64
BASE=$PWD
PKG_NAME=mongodb-ssl
# Text color variables
underline=$(tput sgr 0 1)
bold=$(tput bold)
red=${bold}$(tput setaf 1)
green=${bold}$(tput setaf 2)
yellow=${bold}$(tput setaf 3)
blue=${bold}$(tput setaf 4)
purple=${bold}$(tput setaf 5)
cyan=${bold}$(tput setaf 6)
reset=$(tput sgr0)
# UPGRADE SYSTEM
printf "${green}*${reset} Update the base system. This is HIGHLY recommended ( ${blue}'yes'${reset} or ${red}'no'${reset} ): "
read UPDSRV
if [ "$UPDSRV" == 'yes' ]; then
sudo apt-get update
sudo apt-get upgrade
fi
# CONFIGURATION
echo "${blue}>${reset} Some personal details required for package signature"
printf "${green}*${reset} Enter your full name: "
read REALNAME
printf "${green}*${reset} Enter your email address: "
read EMAIL
# DEPENDENCIES
# Install needed packages
echo "${blue}>${reset} Ok, lets install the required packages now"
sleep 2
sudo apt-get install git-core build-essential scons devscripts lintian dh-make \
libpcre3 libpcre3-dev libboost-dev libboost-date-time-dev libboost-filesystem-dev \
libboost-program-options-dev libboost-system-dev libboost-thread-dev \
libpcap-dev libreadline-dev libssl-dev rng-tools
# GET ORIGINAL CODE AND COMPILE
echo "${blue}>${reset} Get a clone of the original MongoDB repo."
sleep 2
git clone https://github.com/mongodb/mongo.git source
# Show a list of the latest revisions and ask the user for one
cd source
echo "${blue}>${reset} Latest versions on the repository: "
git tag -l | tail
printf "${green}*${reset} Enter the MongoDB version to build ( without the 'r' ): "
read VERSION
TEMP=/var/tmp/$PKG_NAME-$VERSION
mkdir $TEMP
printf "${green}*${reset} Specify how many packages in parallel to build: "
read PARALLEL
# Checkout selected version and start compilation process
echo "${blue}>${reset} Checking out the selected release"
sleep 2
git checkout r$VERSION
echo "${blue}>${reset} Compilation ahead, this may take a while, go grab a book or something!"
sleep 3
scons --64 --ssl --release --no-glibc-check -j $PARALLEL --prefix=$TEMP install
# PACKING
echo "${blue}>${reset} Binaries are ready, let's create the package."
sleep 3
# Move binaries, man, conf and upstart files
cd $BASE
mkdir -p $PKG_NAME/$PKG_NAME-$VERSION/{compiled,conf,man,upstart}
mv $TEMP/bin/* $PKG_NAME/$PKG_NAME-$VERSION/compiled/.
cp source/debian/*.1 $PKG_NAME/$PKG_NAME-$VERSION/man/.
cp source/debian/mongod.conf $PKG_NAME/$PKG_NAME-$VERSION/conf/.
cp source/debian/mongod.upstart $PKG_NAME/$PKG_NAME-$VERSION/upstart/mongod.conf
# Create the basic package layout
export DEBFULLNAME=$REALNAME
export DEBEMAIL=$EMAIL
cd $PKG_NAME/$PKG_NAME-$VERSION
dh_make -c gpl3 -e $EMAIL -n -s
cd debian
rm *.ex *.EX README*
cp $BASE/template/* .
cd ..
# Any modifications to the changelog?
printf "${green}*${reset} Any modifications to the default changelog file? ( ${blue}'yes'${reset} or ${red}'no'${reset} ): "
read MODCLOG
if [ "$MODCLOG" == 'yes' ]; then
nano debian/changelog
fi
# Add a description to the control file?
printf "${green}*${reset} Any modifications to the default control file (description)? ( ${blue}'yes'${reset} or ${red}'no'${reset} ): "
read MODCTRL
if [ "$MODCTRL" == 'yes' ]; then
nano debian/control
fi
# GPG key
echo "${blue}>${reset} Let's create a brand new GPG key to sign the package."
echo "${red}!!${reset} Use the same name and email that was used on the package itself!"
sleep 2
sudo rngd -b -r /dev/urandom
gpg --gen-key --no-use-agent
# Build the actual package
debuild -b
# CLIENTS EXTRA PACKAGE
printf "${green}*${reset} Do you wish to create an additional clients-apps-only package? ( ${blue}'yes'${reset} or ${red}'no'${reset} ): "
read DO_CLIENTS
if [ "$DO_CLIENTS" == 'yes' ]; then
# Working dirs
PKG_CLIENTS=${PKG_NAME}-clients
PKG_CLIENTS_DIR=$PKG_CLIENTS/$PKG_CLIENTS-$VERSION
# Move binaries, and man files
cd $BASE
mkdir -p $PKG_CLIENTS_DIR/{compiled,man}
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongo $PKG_CLIENTS_DIR/compiled/.
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongodump $PKG_CLIENTS_DIR/compiled/.
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongoexport $PKG_CLIENTS_DIR/compiled/.
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongofiles $PKG_CLIENTS_DIR/compiled/.
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongoimport $PKG_CLIENTS_DIR/compiled/.
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongorestore $PKG_CLIENTS_DIR/compiled/.
cp $PKG_NAME/$PKG_NAME-$VERSION/compiled/mongostat $PKG_CLIENTS_DIR/compiled/.
cp source/debian/mongo.1 $PKG_CLIENTS_DIR/man/.
cp source/debian/mongodump.1 $PKG_CLIENTS_DIR/man/.
cp source/debian/mongoexport.1 $PKG_CLIENTS_DIR/man/.
cp source/debian/mongofiles.1 $PKG_CLIENTS_DIR/man/.
cp source/debian/mongoimport.1 $PKG_CLIENTS_DIR/man/.
cp source/debian/mongorestore.1 $PKG_CLIENTS_DIR/man/.
cp source/debian/mongostat.1 $PKG_CLIENTS_DIR/man/.
# Create the basic package layout
export DEBFULLNAME=$REALNAME
export DEBEMAIL=$EMAIL
cd $PKG_CLIENTS_DIR
dh_make -c gpl3 -e $EMAIL -n -s
cd debian
rm *.ex *.EX README*
cp $BASE/template/clients/* .
cd ..
# Any modifications to the changelog?
printf "${green}*${reset} Any modifications to the clients package changelog file? ( ${blue}'yes'${reset} or ${red}'no'${reset} ): "
read MODCLOG_C
if [ "$MODCLOG_C" == 'yes' ]; then
nano debian/changelog
fi
# Add a description to the control file?
printf "${green}*${reset} Any modifications to the clients package control file (description)? ( ${blue}'yes'${reset} or ${red}'no'${reset} ): "
read MODCTRL_C
if [ "$MODCTRL_C" == 'yes' ]; then
nano debian/control
fi
# Build the clients package
debuild -b
fi
# CLEANUP
echo "${blue}>${reset} All is done, let's clean up!"
sleep 2
cd $BASE
mv $PKG_NAME/*.deb .
if [ "$DO_CLIENTS" == 'yes' ]; then
mv $PKG_CLIENTS/*.deb .
rm -rf $PKG_CLIENTS
fi
rm -rf $TEMP
rm -rf $BASE/source
rm -rf $PKG_NAME
# EXIT
echo "${blue}>${reset} Package ready for installation and distribution!"
sleep 1