build.sh 2.42 KB
Newer Older
Dirk Wilden's avatar
Dirk Wilden committed
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
#!/bin/bash

# Absolute path to the script
SCRIPT=$(readlink -f $0);
# Absolute path of the directory
SCRIPTPATH=`dirname $SCRIPT`"/";

base=$SCRIPTPATH"../../";

ACG=$base"ACG/lib/";
OpenMeshCore=$base"OpenMesh/Core/lib/";
OpenMeshTools=$base"OpenMesh/Tools/lib/";
OpenFlipper=$base"OpenFlipper/";
PluginLib=$OpenFlipper"PluginLib/lib/";
Icons=$OpenFlipper"Icons/*.png";
Plugins=$OpenFlipper"Plugins/Linux/";

shareBase=$SCRIPTPATH"tmp/usr/share/OpenFlipper/";
shareIcons=$shareBase"Icons";
sharePlugins=$shareBase"Plugins/Linux/";


for Architecture in "32" "64"; do

  Arch="Debian_"${Architecture}"_Release/";

  #check if the architecture was build
  if [[ ! -e ${OpenFlipper}${Arch}"OpenFlipper"\
     || ! -e ${ACG}${Arch}"libACG.so.1"\
     || ! -e ${OpenMeshCore}${Arch}"libCore.so.1"\
     || ! -e ${OpenMeshTools}${Arch}"libTools.so.1"\
     || ! -e ${PluginLib}${Arch}"libPluginLib.so.1.0.0" ]]; then
    continue;
  fi

  echo "Found Architecture: "${Architecture}"-Bit";

  allArch=${allArch}" "${Architecture};

  #copy Libs/Binary
  mkdir -p ${shareBase}${Arch}
  cp -f ${OpenFlipper}${Arch}"OpenFlipper" ${shareBase}${Arch};
  cp -f ${ACG}${Arch}"libACG.so.1" ${shareBase}${Arch};
  cp -f ${OpenMeshCore}${Arch}"libCore.so.1" ${shareBase}${Arch};
  cp -f ${OpenMeshTools}${Arch}"libTools.so.1" ${shareBase}${Arch};
  cp -f ${PluginLib}${Arch}"libPluginLib.so.1" ${shareBase}${Arch};

  #copy Plugins
  mkdir -p $sharePlugins$Architecture"/Release/";
  cp -f ${Plugins}${Architecture}/Release/*.so $sharePlugins$Architecture"/Release/";

done

#check which architectures we have copied
if [[ $allArch == *32* && $allArch == *64* ]]; then
  Architecture="all";
elif [[ $allArch == *32* ]]; then
  Architecture="i386";
elif [[ $allArch == *64* ]]; then
  Architecture="amd64";
else
  #abort
  rm -rf tmp;
  exit;
fi

#copy Icons
mkdir -p $shareIcons;
cp -f $Icons $shareIcons;

#copy config files
cp -rf $SCRIPTPATH"DEBIAN" $SCRIPTPATH"/tmp/DEBIAN";
mkdir -p $SCRIPTPATH"/tmp/usr/share/applications/";
cp -f $SCRIPTPATH"OpenFlipper.desktop" $SCRIPTPATH"/tmp/usr/share/applications/";

#modify architecture/size in config file
sed -i 's/Architecture: all/Architecture: '${Architecture}'/g' $SCRIPTPATH"/tmp/DEBIAN/control"
Size=`du -s tmp|tr -d ' tmp/'`;
echo "Project Size: "$Size;
sed -i "s/Installed-Size:/Installed-Size: $Size/g" $SCRIPTPATH"/tmp/DEBIAN/control"

#build the package
dpkg -b tmp OpenFlipper-1.0_${Architecture}.deb

#remove temp files
rm -rf tmp;