#!/bin/sh
# Copyright 2008 Loris Vincenzi (http://www.slacky.eu)
# All rights reserved.
#
# Heavily based on the Slackware 12.0 SlackBuild
# http://www.adobe.com
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG1=$TMP/package-flash-plugin
PKG2=$TMP/package-flash-standalone
NAME=flash-player
NAME1=flash-player-plugin
VERSION=9.0.124.0
ARCH=i386
BUILD=1sl

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG1 ]; then
 mkdir -p $PKG1
fi
if [ ! -d $PKG2 ]; then
 mkdir -p $PKG2
fi

cd $TMP
tar xzvf $CWD/install_flash_player_9_linux.tar.gz

(cd install_flash_player_9_linux
 chown -R root:root .
 find . \( -perm 777 -o -perm 775 -o -perm 711 \) -exec chmod 755 {} \;
 find . \( -perm 700 -o -perm 555 -o -perm 511 \) -exec chmod 755 {} \;
 find . \( -perm 666 -o -perm 664 -o -perm 600 \) -exec chmod 644 {} \;
 find . \( -perm 444 -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
 mkdir -p $PKG1/usr/doc/$NAME1-$VERSION/SlackBuild
 mkdir -p $PKG1/usr/lib/mozilla/plugins
 install -m 755 libflashplayer.so $PKG1/usr/lib/mozilla/plugins
 mkdir -p $PKG1/install
 cat $CWD/slack-desc-plugin > $PKG1/install/slack-desc
 cat $CWD/slack-desc-plugin > $PKG1/usr/doc/$NAME1-$VERSION/SlackBuild/slack-desc-plugin
 cat $CWD/$NAME.SlackBuild > $PKG1/usr/doc/$NAME1-$VERSION/SlackBuild/$NAME.SlackBuild
 cd $PKG1
 requiredbuilder -v -y -s $CWD $PKG1
 makepkg -l y -c n $CWD/$NAME1-$VERSION-$ARCH-$BUILD.tgz
)

if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP
fi
