Code: Select all
#!/bin/bash
# SRC = Source Link
# TMP = /tmp/$NAME folder
# TMP_SRC = /tmp/$NAME-src
clear
SRC_32=http://repository.slacky.eu/slackware-13.37/office/adobe-reader/9.4.2/adobe-reader-9.4.2-i486-2sl.txz
######################################################################
NAME='Adobe Reader'
F_NAME=areader
TMP=/tmp/$F_NAME
TMP_SRC=/tmp/$F_NAME-src
######################################################################
F_32=$TMP_SRC/adobe-reader-9.4.2-i486-2sl.txz
#######################################################################
MCH_FULL=`uname -a && cat /var/log/dmesg | tail`
P_VER=`cat /etc/porteus-version`
#####################################
#Functions
mkfolder () {
if [ -e $1 ]; then
rm -Rf $1
else
mkdir $1
fi }
progressbar () {
# Set wget for display the progress bar only
local flag=false c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c
do
if $flag
then
printf '%c' "$c"
else
if [[ $c != $cr && $c != $nl ]]
then
count=0
else
((count++))
if ((count > 1))
then
flag=true
fi
fi
fi
done
}
download () {
# Download with progressbar function
wget --progress=bar:force $1 2>&1 | progressbar
}
txz2xzm () {
# Convert Slackware's Pkgs in Porteus modules
PATH=.:$(dirname $0):/usr/lib:$PATH
. liblinuxlive || exit 1
TMPDIR=/tmp/txz2xzm$$
installpkg -root $TMPDIR $1
if [ $? != 0 ]; then echo "error installing $NAME"; exit; fi
# optimalization procedures, this doesn't hurt
find $TMPDIR/usr{/local,/}{man,info} -type l -name "*.gz" 2>/dev/null | xargs -r gunzip -f
find $TMPDIR/usr{/local,/}{man,info} -type f -name "*.gz" 2>/dev/null | xargs -r gunzip
rm -f $TMPDIR/{usr,usr/local,var}/man/cat*/*
rm -f $TMPDIR/install > /dev/null 2>&1
mksquashfs $TMPDIR "$2" -b 256K
if [ $? != 0 ]; then echo "error building $NAME"; exit; fi
rm -Rf $TMPDIR
}
dir2xzm () {
# Compress directory in module
PATH=.:$(dirname $0):/usr/lib:$PATH
. liblinuxlive || exit 1
if [ ! -d "$1" -o "$2" = "" ]; then
echo
echo "Convert directory tree into .xzm compressed module"
echo "usage: $0 source_directory output_file.xzm"
exit 1
fi
create_module "$1" "$2"
if [ $? != 0 ]; then echo "error building compressed image"; exit 1; fi
}
xzm2dir () {
# Unpack module in directory
if [ ! -d "$2" ]; then
echo
echo "Convert .xzm compressed module back into directory tree"
echo "usage: $0 source_file.xzm existing_output_directory"
exit 1
fi
PATH=.:$(dirname $0):/usr/lib:$PATH
. liblinuxlive || exit 1
unsquashfs -f -dest "$2" "$1"
}
cleaner () {
# Cleanning of the system
if [ -d $TMP ]; then
rm -Rf $TMP
fi
if [ -d $TMP_SRC ]; then
rm -Rf $TMP_SRC
fi
if [ -d /tmp/$F_NAME-merged ]; then
rm -Rf /tmp/$F_NAME-merged
fi
}
mksquashfs_check () {
# Download the last version of MKFS if not already installed
mkdir /tmp/mkfs-version && cd /tmp/mkfs-version && wget -q http://porteus.org/squashfs-tool/version.txt
## Check if SQUASHFS is up-to-date ##
MKFS_LAST=`cat /tmp/mkfs-version/version.txt`
MKFS_CURRENT=`/usr/bin/mksquashfs -version | grep "version" | head -n1`
if [ "$MKFS_CURRENT" = "$MKFS_LAST" ]; then
echo "Your Squashfs-Tool is up-to-date !"
else
echo "Your Squashfs-Tool is out-dated/unsupported."
exit
fi
}
echo "What is your name ?"
read builder
if [ "$builder" = "" ]; then
builder=porteus
fi
VER_APP=9.4.2
CWD=`pwd`
F_LAST=$CWD/${F_NAME}-$VER_APP-1$builder.xzm
LOG_XZM=$CWD/${F_NAME}-$VER_APP-1$builder.log
clear
echo "===============> PORTEUS <==============="
echo
echo "Welcome to $NAME Installer for Porteus"
echo "Press any key to begin the installation"
read
clear
echo "Downloading...."
cleaner
mkfolder $TMP
mkfolder $TMP_SRC
cd $TMP_SRC
download $SRC_32
checker () {
if [ -e "$1" ]; then
echo $1 : OK
else
echo $1 : Failed
exit
fi
}
echo "Checking of files..."
checker $F_32
echo "Preparing of $NAME..."
mkdir /tmp/${F_NAME}-merged
cd $TMP_SRC
for x in `ls *.t?z`; do installpkg -root /tmp/$F_NAME-merged $x; done
clear
if [ -d /tmp/$F_NAME-merged ]; then
echo "Building the module..."
echo "Type your block size for compression of the module OR press ENTER"
echo "Block Sizes available :"
echo "64K"
echo "128K"
echo "256K"
echo "512K"
echo "1024K"
echo "Type your block size : "
read B_SIZE
if [ "$B_SIZE" != "" ]; then
if [ -e $F_LAST ]; then
rm -Rf $F_LAST
fi
mksquashfs /tmp/$F_NAME-merged $F_LAST -b $B_SIZE
else
if [ -e $F_LAST ]; then
rm -Rf $F_LAST
fi
mksquashfs /tmp/$F_NAME-merged $F_LAST -b 256K
fi
else
echo "Build failed!"
fi
clear
if [ -e "$F_LAST" ]; then
echo "===============> PORTEUS <==============="
echo "Your module $NAME is ready!"
echo "Thanks to the Porteus Community!"
echo "-----------------------------------------"
echo "Your module is saved in the folder $CWD"
echo "-----------------------------------------"
echo "Cleaning the system..."
rm -Rf $TMP
rm -Rf $TMP_SRC
if [ -e $LOG_XZM ]; then rm -Rf $LOG_XZM
fi
touch $LOG_XZM
LOG_PKGS=`cd /tmp/$F_NAME-merged/var/log/packages && ls -1`
touch $LOG_XZM
echo '=====> Compiled on Porteus <=====' >> $LOG_XZM
echo 'Compiled with success' >> $LOG_XZM
echo 'App: '$NAME >> $LOG_XZM
echo '=== Version ===' >> $LOG_XZM
echo $VER_APP >> $LOG_XZM
echo '=== Name of Builder ===' >> $LOG_XZM
echo $builder >> $LOG_XZM
echo '=== Included Packages ===' >> $LOG_XZM
echo $LOG_PKGS >> $LOG_XZM
echo '=== Settings ===' >> $LOG_XZM
echo '$TMP: '$TMP >> $LOG_XZM
echo 'TMP_SRC: '$TMP_SRC >> $LOG_XZM
echo '=== CPU ===' >> $LOG_XZM
echo $CPU >> $LOG_XZM
echo '==== Support Details ====' >> $LOG_XZM
echo $MCH_FULL >> $LOG_XZM
rm -Rf /tmp/${F_NAME}-merged
else
clear
echo "Build failed!"
echo "Please report this bug to the Porteus Forum!"
echo "Do you make a log?"
read ans_log
if [ "$ans_log" = "y" ]; then
LOG_PKGS=`cd /tmp/$F_NAME-merged/var/log/packages && ls -1`
touch $LOG_XZM
echo '=====> Compiled on Porteus <=====' >> $LOG_XZM
echo 'Compiled without success' >> $LOG_XZM
echo 'App: '$NAME >> $LOG_XZM
echo '=== Version ===' >> $LOG_XZM
echo $VER_APP >> $LOG_XZM
echo '=== Name of Builder ===' >> $LOG_XZM
echo $builder >> $LOG_XZM
echo '=== Included Packages ===' >> $LOG_XZM
echo $LOG_PKGS >> $LOG_XZM
echo '=== Settings ===' >> $LOG_XZM
echo '$TMP: '$TMP >> $LOG_XZM
echo 'TMP_SRC: '$TMP_SRC >> $LOG_XZM
echo '=== CPU ===' >> $LOG_XZM
echo $CPU >> $LOG_XZM
echo '==== Support Details ====' >> $LOG_XZM
echo $MCH_FULL >> $LOG_XZM
echo "Cleaning the system"
cleaner
rm -Rf /tmp/${F_NAME}-merged
fi
fi