release.linux.sh 13.3 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1
#!/bin/bash
Claudio Valerio's avatar
Claudio Valerio committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# --------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------

Claudio Valerio's avatar
Claudio Valerio committed
17

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#######################################################################
#                     functions                                       #
#######################################################################
notifyError(){
    notify-send -t 0 "Error occoured" "An error occours during the sankore build:\n\t$1" -i /usr/share/icons/oxygen/64x64/status/dialog-error.png
    exit 1
}

checkExecutable(){
    if [ ! -x $1 ]; then
        notify-send "$1 executable not found"
    fi
}

checkDirectory(){
    if [ ! -d $1 ]; then
        notify-send "$1 directory not found"
    fi
}
Claudio Valerio's avatar
Claudio Valerio committed
37

38 39 40
#######################################################################
#                     path definition                                 #
#######################################################################
41
QT_PATH="/usr/local/Trolltech/Qt-4.7.3"
42
QT_PLUGINS_PATH="$QT_PATH/plugins"
43 44 45 46
RELEASE_DIR=build/linux/release
BUILD_DIR=$RELEASE_DIR/product
GUI_TRANSLATIONS_DIRECTORY_PATH="../Qt-sankore3.1/translations"
QT_LIBRARY_SOURCE_PATH="$QT_PATH/lib"
47 48 49
SANKORE_SRC_PLUGINS_PATH="plugins"
SANKORE_DST_PLUGINS_PATH=build/linux/release/product/plugins
CFF_ADAPTOR_SRC_PLUGIN_PATH=$SANKORE_SRC_PLUGINS_PATH/cffadaptor/build/linux/release/lib
50

51
QMAKE_PATH="$QT_PATH/bin/qmake"
52 53
LRELEASE="../Qt-sankore3.1/bin/lrelease"
#LRELEASE="/usr/local/Trolltech/Qt-4.7.3/bin/lrelease"
54

55
ARCHITECTURE=`uname -m`
56

57 58 59 60 61
#######################################################################
#                     initials checks                                 #
#######################################################################
checkExecutable $QMAKE_PATH
checkExecutable $LRELEASE
62

63
checkDirectory $GUI_TRANSLATIONS_DIRECTORY_PATH
64
checkDirectory $QT_PLUGINS_PATH
65 66
checkDirectory $QT_LIBRARY_SOURCE_PATH

67 68
checkDirectory $CFF_ADAPTOR_PLUGIN_PATH

69 70 71
#######################################################################
#                            cleaning                                 #
#######################################################################
72
#rm -rf $RELEASE_DIR
73 74 75 76 77 78 79 80 81 82 83 84


#######################################################################
#                       Internalization                               #
#######################################################################
notify-send "QT" "Internalization ..."

cd $GUI_TRANSLATIONS_DIRECTORY_PATH
$LRELEASE translations.pro
cd -
if [ ! -e $BUILD_DIR/i18n ]; then
    mkdir -p $BUILD_DIR/i18n
85
fi
86 87 88 89 90 91 92 93 94 95 96
#copying qt gui translation    
cp $GUI_TRANSLATIONS_DIRECTORY_PATH/qt_??.qm $BUILD_DIR/i18n/


$LRELEASE Sankore_3.1.pro


#######################################################################
#                            building                                 #
#######################################################################
notify-send "Open-Sankore" "Building Open-Sankore ..."
97

98 99 100 101 102
if [ "$ARCHITECTURE" == "x86_64" ]; then
    $QMAKE_PATH -spec linux-g++-64
else
    $QMAKE_PATH -spec linux-g++
fi
Claudio Valerio's avatar
Claudio Valerio committed
103

104 105
checkDirectory $BUILD_DIR

shibakaneki's avatar
shibakaneki committed
106 107
make -j 4 release-install

108

109 110 111 112 113 114 115
#######################################################################
#                            github tag                               #
#######################################################################
notify-send "Git Hub" "Make a tag of the delivered version"
VERSION=`cat $RELEASE_DIR/version`
if [ ! -f $RELEASE_DIR/version ]; then
    notifyError "version not found"
116 117 118
else
    LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`"
    if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then
119
        echo creating a tag with the version $VERSION
120 121
        git tag -a "v$VERSION" -m "Generating setup for v$VERSION"
        git push origin --tags 
122
    fi
Claudio Valerio's avatar
Claudio Valerio committed
123 124
fi

125 126 127 128 129
#######################################################################
#                       coping resources                              #
#######################################################################
cp resources/linux/run.sh $BUILD_DIR
chmod +x $BUILD_DIR/run.sh
Claudio Valerio's avatar
Claudio Valerio committed
130

131
cp -R resources/linux/qtlinux/* $BUILD_DIR
Claudio Valerio's avatar
Claudio Valerio committed
132

133 134
cp -R resources/customizations $BUILD_DIR

135 136 137 138 139
notify-send "Sankore" "Copying plugins..."
mkdir "$SANKORE_DST_PLUGINS_PATH"
mkdir "$SANKORE_DST_PLUGINS_PATH/cffadaptor"
cp -R $CFF_ADAPTOR_SRC_PLUGIN_PATH/*.so* "$SANKORE_DST_PLUGINS_PATH/cffadaptor"

140
notify-send "QT" "Coping plugins and library ..."
141
cp -R $QT_PLUGINS_PATH $BUILD_DIR
142 143

#copying custom qt library
144
QT_LIBRARY_DEST_PATH="$BUILD_DIR/qtlib"
145 146 147
mkdir $QT_LIBRARY_DEST_PATH

copyQtLibrary(){
148
    if [ ! -e "$QT_LIBRARY_SOURCE_PATH/$1.so.4" ]; then
149
        notifyError "$1 library not found in path: $QT_LIBRARY_SOURCE_PATH"
150
    fi
151
    cp $QT_LIBRARY_SOURCE_PATH/$1.so.4.* $QT_LIBRARY_DEST_PATH/
152 153
}

154
copyQtLibrary libphonon
155 156 157 158 159 160 161 162 163
copyQtLibrary libQtWebKit
copyQtLibrary libQtDBus
copyQtLibrary libQtScript
copyQtLibrary libQtSvg
copyQtLibrary libQtXmlPatterns
copyQtLibrary libQtNetwork
copyQtLibrary libQtXml
copyQtLibrary libQtGui
copyQtLibrary libQtCore
164 165
# uncomment for Qt 4.8
#copyQtLibrary libQtOpenGL
166

167 168 169 170
#######################################################################
#                  Removing unwanted files                            #
#######################################################################
cd $BUILD_DIR
Kindov's avatar
Kindov committed
171

172 173
#Removing .svn directories ...
find . -name .svn -exec rm -rf {} \; 2> /dev/null
Claudio Valerio's avatar
Claudio Valerio committed
174

175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
cd -
notify-send "Building Sankore" "Finished to build Sankore building the package"

#######################################################################
#                          build debian                               #
#######################################################################
BASE_WORKING_DIR="packageBuildDir"

#creating package directory
mkdir $BASE_WORKING_DIR
mkdir "$BASE_WORKING_DIR/DEBIAN"
mkdir -p "$BASE_WORKING_DIR/usr/share/applications"
mkdir -p "$BASE_WORKING_DIR/usr/local"


cat > "$BASE_WORKING_DIR/DEBIAN/prerm" << EOF
#!/bin/bash
# --------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------

xdg-desktop-menu uninstall /usr/share/applications/Open-Sankore.desktop
exit 0
#DEBHELPER#
EOF

cat > "$BASE_WORKING_DIR/DEBIAN/postint" << EOF
#!/bin/bash
# --------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------

xdg-desktop-menu install --novendor /usr/share/applications/Open-Sankore.desktop
exit 0
#DEBHELPER#
EOF


SANKORE_DIRECTORY_NAME="Open-Sankore-$VERSION"
SANKORE_PACKAGE_DIRECTORY="$BASE_WORKING_DIR/usr/local/$SANKORE_DIRECTORY_NAME"
#move sankore build directory to packages directory
cp -R $BUILD_DIR $SANKORE_PACKAGE_DIRECTORY 


cat > $BASE_WORKING_DIR/usr/local/$SANKORE_DIRECTORY_NAME/run.sh << EOF
!/bin/bash
# --------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------

env LD_LIBRARY_PATH=/usr/local/$SANKORE_DIRECTORY_NAME/qtlib:$LD_LIBRARY_PATH /usr/local/$SANKORE_DIRECTORY_NAME/Open-Sankore
EOF


CHANGE_LOG_FILE="$BASE_WORKING_DIR/DEBIAN/changelog-sankore-$VERSION.txt"
CONTROL_FILE="$BASE_WORKING_DIR/DEBIAN/control"
CHANGE_LOG_TEXT="changelog.txt"

if [ "$ARCHITECTURE" == "x86_64" ]; then
    ARCHITECTURE="amd64"
fi

if [ "$ARCHITECTURE" == "i686" ]; then
    ARCHITECTURE="i386"
fi

echo "Open-Sankore ($VERSION) $ARCHITECTURE; urgency=low" > "$CHANGE_LOG_FILE"
echo >> "$CHANGE_LOG_FILE"
cat $CHANGE_LOG_TEXT >> "$CHANGE_LOG_FILE"
echo >> "$CHANGE_LOG_FILE"
echo "-- Claudio Valerio <claudio@open-sankore.org>  `date`" >> "$CHANGE_LOG_FILE"

echo "Package: open-sankore" > "$CONTROL_FILE"
echo "Version: $VERSION" >> "$CONTROL_FILE"
echo "Section: education" >> "$CONTROL_FILE"
echo "Priority: optional" >> "$CONTROL_FILE"
echo "Architecture: $ARCHITECTURE" >> "$CONTROL_FILE"
echo "Essential: no" >> "$CONTROL_FILE"
echo "Installed-Size: `du -s $SANKORE_PACKAGE_DIRECTORY | awk '{ print $1 }'`" >> "$CONTROL_FILE"
287
echo "Maintainer: Open-Sankore Developers team <dev@open-sankore.org>" >> "$CONTROL_FILE"
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
echo "Homepage: http://dev.open-sankore.org" >> "$CONTROL_FILE"
echo -n "Depends: " >> "$CONTROL_FILE"
unset tab
declare -a tab
let count=0
for l in `objdump -p $SANKORE_PACKAGE_DIRECTORY/Open-Sankore | grep NEEDED | awk '{ print $2 }'`; do 
    for lib in `dpkg -S  $l | awk -F":" '{ print $1 }'`; do
        #echo $lib
        presence=`echo ${tab[*]} | grep -c "$lib"`; 
        if [ "$presence" == "0" ]; then   
            tab[$count]=$lib;
            ((count++));
        fi; 
    done; 
done; 

#additional dependencies
tab[$count]="gtk2-engines-pixbuf"
((count++))
tab[$count]="ttf-mscorefonts-installer"
((count++))

for ((i=0;i<${#tab[@]};i++)); do
    if [ $i -ne "0" ]; then
        echo -n ",    " >> "$CONTROL_FILE"
    fi
    echo -n "${tab[$i]} (>= "`dpkg -p ${tab[$i]} | grep "Version: " | awk '{      print $2 }'`") " >> "$CONTROL_FILE"
done
echo "" >> "$CONTROL_FILE"
echo "Description: This a interactive white board that uses a free standard format." >> "$CONTROL_FILE"

find $BASE_WORKING_DIR/usr/ -exec md5sum {} > $BASE_WORKING_DIR/DEBIAN/md5sums 2>/dev/null \; 
SANKORE_SHORTCUT="$BASE_WORKING_DIR/usr/share/applications/Open-Sankore.desktop"
echo "[Desktop Entry]" > $SANKORE_SHORTCUT
echo "Version=$VERSION" >> $SANKORE_SHORTCUT
echo "Encoding=UTF-8" >> $SANKORE_SHORTCUT
echo "Name=Open-Sankore ($VERSION)" >> $SANKORE_SHORTCUT
echo "GenericName=Open-Sankore" >> $SANKORE_SHORTCUT
326
echo "Comment=Logiciel de creation de presentations pour tableau numerique interactif (TNI)" >> $SANKORE_SHORTCUT 
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
echo "Exec=/usr/local/$SANKORE_DIRECTORY_NAME/run.sh" >> $SANKORE_SHORTCUT
echo "Icon=/usr/local/$SANKORE_DIRECTORY_NAME/sankore.png" >> $SANKORE_SHORTCUT
echo "StartupNotify=true" >> $SANKORE_SHORTCUT
echo "Terminal=false" >> $SANKORE_SHORTCUT
echo "Type=Application" >> $SANKORE_SHORTCUT
echo "Categories=Education" >> $SANKORE_SHORTCUT
echo "Name[fr_FR]=Open-Sankore ($VERSION)" >> $SANKORE_SHORTCUT
cp "resources/images/uniboard.png" "$SANKORE_PACKAGE_DIRECTORY/sankore.png"
chmod 755 "$BASE_WORKING_DIR/DEBIAN"
chmod 755 "$BASE_WORKING_DIR/DEBIAN/prerm"
chmod 755 "$BASE_WORKING_DIR/DEBIAN/postint"

mkdir -p "install/linux"

rm install/linux/Open-Sankore_*.deb

fakeroot  chown -R root:root $BASE_WORKING_DIR 
dpkg -b "$BASE_WORKING_DIR" install/linux/Open-Sankore_${VERSION}_$ARCHITECTURE.deb
notify-send "Open-Sankore" "Package built"

#clean up mess
fakeroot rm -rf $BASE_WORKING_DIR


#######################################################################
#                             tar.gz                                  #
#######################################################################
echo `pwd`
cp -R $RELEASE_DIR/product $RELEASE_DIR/Open-Sankore.$VERSION
cd $RELEASE_DIR

rm ../../../install/linux/Open-Sankore.tar.gz
Claudio Valerio's avatar
Claudio Valerio committed
359

Claudio Valerio's avatar
Claudio Valerio committed
360
tar cvzf ../../../install/linux/Open-Sankore.tar.gz Open-Sankore.$VERSION -C . 
361
notify-send "Open-Sankore"  "tar.gz Build done"