summaryrefslogtreecommitdiff
path: root/system/crashplan/crashplan.SlackBuild
blob: 9eaa7412d67b2fe9d23c62d72a4438643f31013f (plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# Generated by Alien's SlackBuild Toolkit: http://slackware.com/~alien/AST
# Copyright 2009, 2010, 2011  Eric Hameleers, Eindhoven, Netherlands
# Slackware build script for crashplan
# Written by Lionel Young <redtricycle@gmail.com>
# Based on http://slackbuilds.org/template.SlackBuild

PRGNAM=crashplan
VERSION=${VERSION:-3.5.3}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

SRCNAM=CrashPlan
TARGETDIR=/opt/crashplan
MANIFESTDIR=/var/crashplan # Directory to store backups to

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

# Pre-compiled binaries included only for i486 and x86_64
if [ ! "$ARCH" = "i486" -a ! "$ARCH" = "x86_64" ]; then
  echo "$ARCH architecture not supported."
  exit 1
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-install
tar xvf $CWD/${SRCNAM}_${VERSION}_Linux.tgz
cd $SRCNAM-install
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

# Repackage everything into /opt
mkdir -p $PKG/$TARGETDIR/bin/
mkdir -p $PKG/usr/bin
mkdir -p $PKG/etc/rc.d/
mkdir -p $PKG/usr/share/applications/
mkdir -p $PKG/$MANIFESTDIR

# Expand the archive
( cd $PKG/$TARGETDIR
  cat $TMP/$SRCNAM-install/${SRCNAM}_${VERSION}.cpi | gzip -d -c - | cpio -i --no-preserve-owner
)

# Make the log file world writable
chmod 777 $PKG/$TARGETDIR/log

# create a file that has our install vars, which is required to run
echo "" > $PKG/${TARGETDIR}/install.vars
echo "TARGETDIR=${TARGETDIR}" >> $PKG/${TARGETDIR}/install.vars
echo "BINSDIR=${TARGETDIR}/bin" >> $PKG/${TARGETDIR}/install.vars
echo "MANIFESTDIR=${MANIFESTDIR}" >> $PKG/${TARGETDIR}/install.vars
echo "INITDIR=/etc/rc.d" >> $PKG/${TARGETDIR}/install.vars
echo "RUNLVLDIR=/etc/rc.d" >> $PKG/${TARGETDIR}/install.vars
NOW=`date +%Y%m%d`
echo "INSTALLDATE=$NOW" >> $PKG/${TARGETDIR}/install.vars
cat install.defaults >> $PKG/${TARGETDIR}/install.vars
JAVACOMMON=`which java`
echo "JAVACOMMON=${JAVACOMMON}" >> $PKG/${TARGETDIR}/install.vars

# Repackage the binaries in the appropriate directories
cp -a scripts/CrashPlanDesktop scripts/CrashPlanEngine scripts/run.conf $PKG/$TARGETDIR/bin/
ln -s $TARGETDIR/bin/CrashPlanDesktop $PKG/usr/bin/CrashPlanDesktop

# Repackage the init script
# Perform substitution on the init script; we need to make the value of INITSCRIPT available
# to what lives in /etc/rc.d
INITSCRIPT=$TARGETDIR/bin/CrashPlanEngine
SEDEXPRSUB=`echo $INITSCRIPT | sed 's/\//\\\\\//g'`
SEDEXPR="s/<INITSCRIPT>/$SEDEXPRSUB/g"
sed $SEDEXPR scripts/crashplan > $PKG/etc/rc.d/rc.crashplan.new
chmod 0755 $PKG/etc/rc.d/rc.crashplan.new

# Desktop icon
cp -a scripts/CrashPlan.desktop $PKG/usr/share/applications/
sed -i \
  -e "s#Categories=;#Categories=System;Utility;#" \
  -e "s#Exec=.*#Exec=${TARGETDIR}/bin/CrashPlanDesktop#" \
  -e "s#Icon=.*#Icon=${TARGETDIR}/skin/icon_app_128x128.png#" \
  $PKG/usr/share/applications/CrashPlan.desktop

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  EULA.txt README \
  $PKG/$TARGETDIR/doc/* \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}