chiark / gitweb /
Look for CuraEngine in ..../CuraEngine/build/CuraEngine[.exe]
[cura.git] / package.sh
index c1403caa4d5965d8c42dd59f2251d57f568b43a7..06cd8a3b94294e2b2e17a285af0bed016baad03b 100755 (executable)
@@ -75,7 +75,7 @@ function extract
 {
        echo "Extracting $*"
        echo "7z x -y $*" >> log.txt
-       7z x -y $* >> log.txt
+       $EXTRACT x -y $* >> log.txt
        if [ $? != 0 ]; then
         echo "Failed to extract $*"
         exit 1
@@ -118,6 +118,12 @@ else
        MAKE=make
 fi
 
+if [ -z `which 7za` ]; then
+       EXTRACT=7z
+else
+       EXTRACT=7za
+fi
+
 # Change working directory to the directory the script is in
 # http://stackoverflow.com/a/246128
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -128,7 +134,7 @@ checkTool curl "curl: http://curl.haxx.se/"
 if [ $BUILD_TARGET = "win32" ]; then
        checkTool avr-gcc "avr-gcc: http://winavr.sourceforge.net/ "
        #Check if we have 7zip, needed to extract and packup a bunch of packages for windows.
-       checkTool 7z "7zip: http://www.7-zip.org/"
+       checkTool $EXTRACT "7zip: http://www.7-zip.org/"
        checkTool $MAKE "mingw: http://www.mingw.org/"
 fi
 #For building under MacOS we need gnutar instead of tar
@@ -262,12 +268,14 @@ if [ "$BUILD_TARGET" = "debian_i386" ]; then
        cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
        echo $BUILD_VERSION > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
        cat scripts/linux/debian_control | sed "s/\[BUILD_VERSION\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/i386/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
-       sudo chown root:root scripts/linux/${BUILD_TARGET} -R
-       sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
-       sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
-       cd scripts/linux
-       dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_i386.deb
-       sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
+       fakeroot sh -ec "
+        chown root:root scripts/linux/${BUILD_TARGET} -R
+        chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
+        chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
+        cd scripts/linux
+        dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_i386.deb
+        chown `id -un`:`id -gn` ${BUILD_TARGET} -R
+        "
        exit
 fi
 
@@ -292,12 +300,14 @@ if [ "$BUILD_TARGET" = "debian_amd64" ]; then
        cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
        echo $BUILD_VERSION > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
        cat scripts/linux/debian_control | sed "s/\[BUILD_VERSION\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/amd64/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
-       sudo chown root:root scripts/linux/${BUILD_TARGET} -R
-       sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
-       sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
-       cd scripts/linux
-       dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_amd64.deb
-       sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
+       fakeroot sh -ec "
+        chown root:root scripts/linux/${BUILD_TARGET} -R
+        chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
+        chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
+        cd scripts/linux
+        dpkg-deb -Zgzip --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${FULL_VERSION}_amd64.deb
+        chown `id -un`:`id -gn` ${BUILD_TARGET} -R
+       "
        exit
 fi
 
@@ -322,12 +332,14 @@ if [ "$BUILD_TARGET" = "debian_armhf" ]; then
        cp -a Power/power scripts/linux/${BUILD_TARGET}/usr/share/cura/
        echo $BUILD_VERSION > scripts/linux/${BUILD_TARGET}/usr/share/cura/Cura/version
        cat scripts/linux/debian_control | sed "s/\[BUILD_VERSION\]/${FULL_VERSION}/" | sed 's/\[ARCH\]/armhf/' > scripts/linux/${BUILD_TARGET}/DEBIAN/control
-       sudo chown root:root scripts/linux/${BUILD_TARGET} -R
-       sudo chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
-       sudo chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
-       cd scripts/linux
-       dpkg-deb --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${BUILD_VERSION}-${BUILD_TARGET}.deb
-       sudo chown `id -un`:`id -gn` ${BUILD_TARGET} -R
+       fakeroot sh -ec "
+        chown root:root scripts/linux/${BUILD_TARGET} -R
+        chmod 755 scripts/linux/${BUILD_TARGET}/usr -R
+        chmod 755 scripts/linux/${BUILD_TARGET}/DEBIAN -R
+        cd scripts/linux
+        dpkg-deb --build ${BUILD_TARGET} $(dirname ${TARGET_DIR})/cura_${BUILD_VERSION}-${BUILD_TARGET}.deb
+        chown `id -un`:`id -gn` ${BUILD_TARGET} -R
+       "
        exit
 fi
 
@@ -433,7 +445,9 @@ function buildFedora() {
     fi
 
     mkdir -pv "$_dstRpmDir/$_mockRelease"
-    mock \
+    # Need to use /usr/bin/mock because depending on $PATH, if /usr/sbin/mock is
+    # run instead, it will give an error.
+    /usr/bin/mock \
       $_mockReleaseArg \
       --resultdir="$_dstRpmDir/$_mockRelease" \
       "$_srpmFile"