You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
395 lines
13 KiB
395 lines
13 KiB
13 years ago
|
#!/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
|
||
12 years ago
|
# the Free Software Foundation, either version 2 of the License, or
|
||
13 years ago
|
# (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/>.
|
||
|
# ---------------------------------------------------------------------
|
||
|
|
||
13 years ago
|
|
||
12 years ago
|
#**********************
|
||
|
# functions
|
||
|
#**********************
|
||
|
|
||
|
initializeVariables()
|
||
|
{
|
||
|
MAKE_TAG=true
|
||
|
CREATE_DIENA_DISTRIBUTION_ZIP=false
|
||
12 years ago
|
STANDARD_QT_USED=false
|
||
12 years ago
|
|
||
|
PRODUCT_PATH="build/linux/release/product"
|
||
|
QT_PATH="/usr/local/Trolltech/Qt-4.8.0"
|
||
|
PLUGINS_PATH="$QT_PATH/plugins"
|
||
|
GUI_TRANSLATIONS_DIRECTORY_PATH="../Qt-4.8/translations"
|
||
|
QT_LIBRARY_DEST_PATH="$PRODUCT_PATH/qtlib"
|
||
|
QT_LIBRARY_SOURCE_PATH="$QT_PATH/lib"
|
||
|
ARCHITECTURE=`uname -m`
|
||
|
if [ "$ARCHITECTURE" == "x86_64" ]; then
|
||
|
ARCHITECTURE="amd64"
|
||
|
fi
|
||
|
if [ "$ARCHITECTURE" == "i686" ]; then
|
||
|
ARCHITECTURE="i386"
|
||
|
fi
|
||
|
|
||
|
NOTIFY_CMD=`which notify-send`
|
||
|
QMAKE_PATH="$QT_PATH/bin/qmake"
|
||
|
LRELEASES="$QT_PATH/bin/lrelease"
|
||
|
ZIP_PATH=`which zip`
|
||
12 years ago
|
|
||
12 years ago
|
}
|
||
13 years ago
|
|
||
12 years ago
|
|
||
13 years ago
|
notifyError(){
|
||
12 years ago
|
if [ -e "$NOTIFY_CMD" ]; then
|
||
|
$NOTIFY_CMD -t 0 -i "/usr/share/icons/oxygen/64x64/status/dialog-error.png" "$1"
|
||
|
else
|
||
|
printf "\033[31merror:\033[0m $1\n"
|
||
|
fi
|
||
13 years ago
|
exit 1
|
||
|
}
|
||
|
|
||
12 years ago
|
notifyProgress(){
|
||
|
if [ -e "$NOTIFY_CMD" ]; then
|
||
|
$NOTIFY_CMD "$1" "$2"
|
||
|
else
|
||
|
printf "\033[32m--> Achieved task:\033[0m $1:\n\t$2\n"
|
||
|
fi
|
||
|
}
|
||
|
|
||
13 years ago
|
alertIfPreviousVersionInstalled(){
|
||
|
APT_CACHE=`which apt-cache`
|
||
|
if [ ! -e "$APT_CACHE" ]; then
|
||
|
notifyError "apt-cache command not found"
|
||
|
else
|
||
|
SEARCH_RESULT=`$APT_CACHE search open-sankore`
|
||
|
if [ `echo $SEARCH_RESULT | grep -c open-sankore` -ge 1 ]; then
|
||
|
notifyError "Found a previous version of Open-Sankore. Remove it to avoid to put it as dependency"
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
12 years ago
|
checkDir(){
|
||
|
if [ ! -d "$1" ]; then
|
||
|
notifyError "Directory not found : $1"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
checkExecutable(){
|
||
|
if [ ! -e "$1" ]; then
|
||
|
notifyError "$1 command not found"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
copyQtLibrary(){
|
||
|
if ls "$QT_LIBRARY_SOURCE_PATH/$1.so" &> /dev/null; then
|
||
|
cp $QT_LIBRARY_SOURCE_PATH/$1.so.? "$QT_LIBRARY_DEST_PATH/"
|
||
|
cp $QT_LIBRARY_SOURCE_PATH/$1.so.?.?.? "$QT_LIBRARY_DEST_PATH/"
|
||
|
else
|
||
|
notifyError "$1 library not found in path: $QT_LIBRARY_SOURCE_PATH"
|
||
|
fi
|
||
|
}
|
||
|
|
||
12 years ago
|
|
||
|
buildWithStandardQt(){
|
||
|
STANDARD_QT=`which qmake-qt4`
|
||
|
if [ $? == "0" ]; then
|
||
|
QT_VERSION=`$STANDARD_QT --version | grep -i "Using Qt version" | sed -e "s/Using Qt version \(.*\) in.*/\1/"`
|
||
|
if [ `echo $QT_VERSION | sed -e "s/\.//g"` -gt 480 ]; then
|
||
|
notifyProgress "Standard QT" "A recent enough qmake has been found. Using this one instead of custom one"
|
||
|
STANDARD_QT_USED=true
|
||
|
QMAKE_PATH=$STANDARD_QT
|
||
|
LRELEASES=`which lrelease`
|
||
12 years ago
|
if [ "`arch`" == "i686" ]; then
|
||
|
QT_PATH="/usr/lib/i386-linux-gnu"
|
||
|
else
|
||
|
QT_PATH="/usr/lib/`arch`-linux-gnu"
|
||
|
fi
|
||
12 years ago
|
PLUGINS_PATH="$QT_PATH/qt4/plugins"
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
12 years ago
|
#**********************
|
||
|
# script
|
||
|
#**********************
|
||
|
initializeVariables
|
||
12 years ago
|
buildWithStandardQt
|
||
12 years ago
|
|
||
|
for var in "$@"
|
||
|
do
|
||
|
if [ $var == "notag" ]; then
|
||
|
MAKE_TAG=false;
|
||
|
fi
|
||
|
if [ $var == "diena" ]; then
|
||
|
CREATE_DIENA_DISTRIBUTION_ZIP=true;
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
|
||
13 years ago
|
alertIfPreviousVersionInstalled
|
||
|
|
||
12 years ago
|
#check of directories and executables
|
||
|
checkDir $QT_PATH
|
||
|
checkDir $PLUGINS_PATH
|
||
|
checkDir $GUI_TRANSLATIONS_DIRECTORY_PATH
|
||
13 years ago
|
|
||
12 years ago
|
checkExecutable $QMAKE_PATH
|
||
|
checkExecutable $LRELEASES
|
||
|
checkExecutable $ZIP_PATH
|
||
|
|
||
|
# cleaning the build directory
|
||
13 years ago
|
rm -rf "build/linux/release"
|
||
|
rm -rf install
|
||
|
|
||
12 years ago
|
notifyProgress "QT" "Internalization"
|
||
|
$LRELEASES Sankore_3.1.pro
|
||
|
cd $GUI_TRANSLATIONS_DIRECTORY_PATH
|
||
|
$LRELEASES translations.pro
|
||
|
cd -
|
||
13 years ago
|
|
||
12 years ago
|
notifyProgress "Open-Sankore" "Building Open-Sankore"
|
||
13 years ago
|
|
||
12 years ago
|
if [ "$ARCHITECTURE" == "amd64" ]; then
|
||
13 years ago
|
$QMAKE_PATH Sankore_3.1.pro -spec linux-g++-64
|
||
13 years ago
|
else
|
||
13 years ago
|
$QMAKE_PATH Sankore_3.1.pro -spec linux-g++
|
||
13 years ago
|
fi
|
||
13 years ago
|
|
||
13 years ago
|
make -j 4 release-install
|
||
13 years ago
|
|
||
12 years ago
|
if [ ! -e "$PRODUCT_PATH/Open-Sankore" ]; then
|
||
12 years ago
|
notifyError "Open-Sankore build failed"
|
||
|
fi
|
||
|
|
||
|
notifyProgress "Git Hub" "Make a tag of the delivered version"
|
||
|
|
||
13 years ago
|
VERSION=`cat build/linux/release/version`
|
||
12 years ago
|
|
||
13 years ago
|
if [ ! -f build/linux/release/version ]; then
|
||
|
notifyError "version not found"
|
||
|
else
|
||
|
LAST_COMMITED_VERSION="`git describe $(git rev-list --tags --max-count=1)`"
|
||
|
if [ "v$VERSION" != "$LAST_COMMITED_VERSION" ]; then
|
||
12 years ago
|
if [ $MAKE_TAG == true ]; then
|
||
13 years ago
|
git tag -a "v$VERSION" -m "Generating setup for v$VERSION"
|
||
|
git push origin --tags
|
||
|
fi
|
||
13 years ago
|
fi
|
||
|
fi
|
||
|
|
||
12 years ago
|
cp resources/linux/run.sh $PRODUCT_PATH
|
||
|
chmod a+x $PRODUCT_PATH/run.sh
|
||
13 years ago
|
|
||
12 years ago
|
cp -R resources/linux/qtlinux/* $PRODUCT_PATH/
|
||
13 years ago
|
|
||
12 years ago
|
notifyProgress "QT" "Coping plugins and library ..."
|
||
12 years ago
|
cp -R $PLUGINS_PATH $PRODUCT_PATH/
|
||
13 years ago
|
|
||
12 years ago
|
# copying customization
|
||
|
cp -R resources/customizations $PRODUCT_PATH/
|
||
|
|
||
12 years ago
|
if [ $STANDARD_QT_USED == false ]; then
|
||
13 years ago
|
#copying custom qt library
|
||
12 years ago
|
mkdir -p $QT_LIBRARY_DEST_PATH
|
||
|
copyQtLibrary libQtDBus
|
||
|
copyQtLibrary libQtScript
|
||
|
copyQtLibrary libQtSvg
|
||
|
copyQtLibrary libQtXmlPatterns
|
||
|
copyQtLibrary libQtNetwork
|
||
|
copyQtLibrary libQtXml
|
||
|
copyQtLibrary libQtGui
|
||
|
copyQtLibrary libQtCore
|
||
|
copyQtLibrary libphonon
|
||
|
copyQtLibrary libQtWebKit
|
||
|
fi
|
||
13 years ago
|
|
||
12 years ago
|
notifyProgress "QT" "Internalization"
|
||
|
if [ ! -e $PRODUCT_PATH/i18n ]; then
|
||
|
mkdir $PRODUCT_PATH/i18n
|
||
13 years ago
|
fi
|
||
12 years ago
|
#copying qt gui translation
|
||
|
cp $GUI_TRANSLATIONS_DIRECTORY_PATH/qt_??.qm $PRODUCT_PATH/i18n/
|
||
13 years ago
|
|
||
13 years ago
|
rm -rf install/linux
|
||
|
mkdir -p install/linux
|
||
|
|
||
|
#Removing .svn directories ...
|
||
12 years ago
|
cd $PRODUCT_PATH
|
||
13 years ago
|
find . -name .svn -exec rm -rf {} \; 2> /dev/null
|
||
|
cd -
|
||
|
|
||
12 years ago
|
notifyProgress "Building Sankore" "Finished to build Sankore building the package"
|
||
13 years ago
|
|
||
|
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
|
||
12 years ago
|
cp -R $PRODUCT_PATH $SANKORE_PACKAGE_DIRECTORY
|
||
13 years ago
|
|
||
|
|
||
|
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"
|
||
|
|
||
|
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"
|
||
13 years ago
|
echo "Maintainer: Open-Sankoré Developers team <dev@open-sankore.org>" >> "$CONTROL_FILE"
|
||
|
echo "Homepage: http://dev.open-sankore.org" >> "$CONTROL_FILE"
|
||
13 years ago
|
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;
|
||
|
|
||
|
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
|
||
|
echo "Comment=Logiciel de création de présentations pour tableau numérique interactif (TNI)" >> $SANKORE_SHORTCUT
|
||
|
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"
|
||
12 years ago
|
DEBIAN_PACKAGE_NAME="Open-Sankore_${VERSION}_$ARCHITECTURE.deb"
|
||
13 years ago
|
|
||
13 years ago
|
fakeroot chown -R root:root $BASE_WORKING_DIR
|
||
12 years ago
|
dpkg -b "$BASE_WORKING_DIR" "install/linux/$DEBIAN_PACKAGE_NAME"
|
||
12 years ago
|
notifyProgress "Open-Sankore" "Package built"
|
||
13 years ago
|
|
||
|
#clean up mess
|
||
13 years ago
|
fakeroot rm -rf $BASE_WORKING_DIR
|
||
13 years ago
|
|
||
12 years ago
|
|
||
|
if [ $CREATE_DIENA_DISTRIBUTION_ZIP == true ]; then
|
||
|
|
||
|
ZIP_NAME="Open-Sankoré_`lsb_release -is`_`lsb_release -rs`_${VERSION}_${ARCHITECTURE}.zip"
|
||
|
cd install/linux
|
||
12 years ago
|
$ZIP_PATH -1 --junk-paths ${ZIP_NAME} ${DEBIAN_PACKAGE_NAME} ../../ReleaseNotes.pdf ../../JournalDesModifications.pdf
|
||
12 years ago
|
cd -
|
||
12 years ago
|
notifyProgress "Open-Sankore" "Build Diena zip file for distribution"
|
||
12 years ago
|
fi
|
||
|
|