Mailspring/app/script/mkdeb
2017-08-11 01:48:56 -07:00

65 lines
2 KiB
Bash
Executable file

#!/bin/bash
# mkdeb version arch control-file-path desktop-file-path icon-file-path sources-file-path deb-file-path
set -e
SCRIPT=`readlink -f "$0"`
ROOT=`readlink -f $(dirname $SCRIPT)/..`
cd $ROOT
VERSION="$1"
ARCH="$2"
ICON_FILE="$3"
LINUX_ASSETS_DIRECTORY="$4"
APP_CONTENTS_DIRECTORY="$5"
OUTPUT_PATH="$6"
FILE_MODE=755
TARGET_ROOT="`mktemp -d`"
chmod $FILE_MODE "$TARGET_ROOT"
TARGET="$TARGET_ROOT/merani-$VERSION-$ARCH"
mkdir -m $FILE_MODE -p "$TARGET/usr"
mkdir -m $FILE_MODE -p "$TARGET/usr/share"
cp -r "$APP_CONTENTS_DIRECTORY" "$TARGET/usr/share/merani"
mkdir -m $FILE_MODE -p "$TARGET/DEBIAN"
cp "$OUTPUT_PATH/control" "$TARGET/DEBIAN/control"
cp "$LINUX_ASSETS_DIRECTORY/debian/postinst" "$TARGET/DEBIAN/postinst"
cp "$LINUX_ASSETS_DIRECTORY/debian/postrm" "$TARGET/DEBIAN/postrm"
mkdir -m $FILE_MODE -p "$TARGET/usr/bin"
ln -s "../share/merani/merani" "$TARGET/usr/bin/merani"
chmod +x "$TARGET/usr/bin/merani"
mkdir -m $FILE_MODE -p "$TARGET/usr/share/applications"
cp "$OUTPUT_PATH/merani.desktop" "$TARGET/usr/share/applications"
mkdir -m $FILE_MODE -p "$TARGET/usr/share/pixmaps"
cp "$ICON_FILE" "$TARGET/usr/share/pixmaps/merani.png"
mkdir -m $FILE_MODE -p "$TARGET/usr/share/icons/hicolor"
for i in 256 128 64 32 16; do
mkdir -p "$TARGET/usr/share/icons/hicolor/${i}x${i}/apps"
cp "$LINUX_ASSETS_DIRECTORY/icons/${i}.png" "$TARGET/usr/share/icons/hicolor/${i}x${i}/apps/merani.png"
done
# Copy generated LICENSE.md to /usr/share/doc/merani/copyright
mkdir -m $FILE_MODE -p "$TARGET/usr/share/doc/merani"
cp "$TARGET/usr/share/merani/LICENSE" "$TARGET/usr/share/doc/merani/copyright"
# Add lintian overrides
mkdir -m $FILE_MODE -p "$TARGET/usr/share/lintian/overrides"
cp "$ROOT/build/resources/linux/debian/lintian-overrides" "$TARGET/usr/share/lintian/overrides/merani"
# Remove group write from all files
chmod -R g-w "$TARGET";
# Remove executable bit from .node files
find "$TARGET" -type f -name "*.node" -exec chmod a-x {} \;
fakeroot dpkg-deb -b "$TARGET"
mv "$TARGET_ROOT/merani-$VERSION-$ARCH.deb" "$OUTPUT_PATH"
rm -rf "$TARGET_ROOT"