Merge branch 'master' of github.com:OpenELEC/OpenELEC.tv

This commit is contained in:
Stephan Raue 2013-05-10 21:10:14 +02:00
commit 4f40fdaf72
5 changed files with 266 additions and 0 deletions

View File

@ -0,0 +1,4 @@
f 1
w
q
EOF

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,262 @@
#!/bin/bash
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2013 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2011-2013 Christian Hewitt (chewitt@openelec.tv)
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
VERBOSE="FALSE" # set to TRUE to put this script in debug mode
banner(){
clear
echo ""
echo "********************************************************************************"
echo "* *"
echo "* Welcome to the OpenELEC Mac OS X Livestick Creator! *"
echo "* *"
echo "********************************************************************************"
}
check_root(){
if [ $UID != 0 ];then
echo ""
echo "FAIL: This script *must* be run as root!"
echo ""
exit 1
fi
}
check_runlocation(){
SCRIPT=$(pwd)
}
check_localtargetfolder(){
if [ ! -f target/SYSTEM -a ! -f target/KERNEL ]; then
echo ""
echo "FAIL: Could not detect SYSTEM and KERNEL files. This script *must* be run from"
echo " the root folder of the OpenELEC image you downloaded!"
echo ""
exit 1
fi
}
check_distro(){
DISTRO=$(uname -s)
if [ $DISTRO != "Darwin" ]; then
echo ""
echo "FAIL: This script is only for Mac OS X systems, aborting!"
echo ""
exit 1
fi
}
read_input(){
local MESSAGE="${1}"
if [ -n "${MESSAGE}" ];then
echo -n "${MESSAGE}"
fi
read INPUT
}
check_target(){
echo ""
echo "INFO: The following drives are available to create the OpenELEC USB on:"
echo ""
diskutil list | grep 0: | grep -v disk0 | awk '{print "/dev/"$5 " "$3 $4}'
echo ""
while [ -z ${INPUT} ];do
read_input "INFO: Please enter the target device (e.g. /dev/disk1): "
echo ""
done
TARGET=${INPUT}
}
warning(){
local OUTPUT
OUTPUT=$(fdisk ${TARGET} 2>/dev/null)
if [ -z "${OUTPUT}" ];then
echo "FAIL: Installation aborted! Device ${TARGET} is invalid"
echo ""
exit 1
else
diskutil list ${TARGET}
echo ""
fi
CONTINUE=""
echo -n "WARN: Continuing will erase all data from $TARGET, continue? (Y/n): "
read CONTINUE
if [ "${CONTINUE}" = "N" -o "${CONTINUE}" = "n" -o "${CONTINUE}" = "" ]; then
echo ""
echo "FAIL: Installation aborted!"
echo ""
exit 1
elif [ "${CONTINUE}" = "Y" -o "${CONTINUE}" = "y" ]; then
echo ""
fi
}
logoutput(){
if [ "${VERBOSE}" = "TRUE" ]; then
exec 3>&1
exec 4>&2
else
exec 3> /dev/null
exec 4> /dev/null
fi
}
unmount_target(){
for i in $(jot 10 1 10); do
MOUNTED=$(mount | grep ${TARGET})
if [ -z "${MOUNTED}" ]; then
break
else
diskutil unmountDisk ${TARGET} 1>&3 2>&4
sleep 1
fi
done
}
mount_target(){
for i in $(jot 10 1 10); do
MOUNTED=$(mount | grep ${TARGET})
if [ -z "${MOUNTED}" ]; then
diskutil mountDisk ${TARGET} 1>&3 2>&4
sleep 1
else
break
fi
done
}
prepare_target(){
echo "INFO: Erasing existing partition schemes on ${TARGET}"
dd if=/dev/zero of=${TARGET} bs=512 count=100 1>&3 2>&4
gpt destroy ${TARGET} 1>&3 2>&4
echo "INFO: Creating MBR 'OPENELEC' disk on ${TARGET}"
diskutil eraseDisk MS-DOS OPENELEC MBR ${TARGET} 1>&3 2>&4
unmount_target
chmod 755 3rdparty/macfiles/*
cat 3rdparty/macfiles/mbr.bin > ${TARGET}
mount_target
3rdparty/macfiles/syslinux-mac -f --install ${TARGET}s1 1>&3 2>&4
}
create_partitions(){
unmount_target
echo "INFO: Creating partitions"
fdisk -e ${TARGET} < 3rdparty/macfiles/fdisk.input 1>&3 2>&4
}
check_checksums(){
MD5_KERNEL=$(md5 target/KERNEL | awk '{print $4}')
MD5_SYSTEM=$(md5 target/SYSTEM | awk '{print $4}')
KERNEL_DOT_MD5=$(cat target/KERNEL.md5 | awk '{print $1}')
SYSTEM_DOT_MD5=$(cat target/SYSTEM.md5 | awk '{print $1}')
if [ "${MD5_KERNEL}" = "${KERNEL_DOT_MD5}" -a "${MD5_SYSTEM}" = "${SYSTEM_DOT_MD5}" ]; then
echo "INFO: MD5 checksums for SYSTEM and KERNEL match"
else
echo "FAIL: MD5 checksums for SYSTEM and KERNEL do not match!"
exit 1
fi
}
copy_files(){
mount_target
echo "INFO: Copying SYSTEM and KERNEL files to 'OPENELEC'"
cp -a target/KERNEL /Volumes/OPENELEC/
cp -a target/SYSTEM /Volumes/OPENELEC/
echo "INFO: Copying syslinux files to 'OPENELEC'"
cp -a 3rdparty/macfiles/vesamenu.c32 /Volumes/OPENELEC/
cp -a splash.png /Volumes/OPENELEC/
echo "INFO: Creating syslinux.cfg on 'OPENELEC'"
cat >/Volumes/OPENELEC/syslinux.cfg << EOF
UI vesamenu.c32
PROMPT 0
MENU TITLE Boot Menu
MENU BACKGROUND splash.png
TIMEOUT 50
DEFAULT live
MENU WIDTH 70
MENU MARGIN 15
MENU ROWS 2
MENU HSHIFT 4
MENU VSHIFT 13
MENU TIMEOUTROW 10
MENU TABMSGROW 8
MENU CMDLINEROW 8
MENU HELPMSGROW 13
MENU HELPMSGENDROW 26
MENU CLEAR
MENU COLOR border 30;44 #40ffffff #00000000 std
MENU COLOR title 1;36;44 #ff8bbfe3 #00000000 std
MENU COLOR sel 7;37;40 #80f0f0f0 #ff606060 all
MENU COLOR unsel 37;44 #50ffffff #00000000 std
MENU COLOR help 37;40 #c0ffffff #a0000000 std
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #ff868787 #00000000 std
LABEL installer
MENU LABEL Run OpenELEC Installer
KERNEL /KERNEL
APPEND boot=LABEL=OPENELEC installer quiet vga=current
LABEL live
MENU LABEL Run OpenELEC Live
KERNEL /KERNEL
APPEND boot=LABEL=OPENELEC disk=FILE=STORAGE,512 quiet vga=current
EOF
}
check_filesystem(){
unmount_target
echo "INFO: Checking filesystem on ${TARGET}"
fsck_msdos -y ${TARGET}s1 1>&3 2>&4
unmount_target
}
end(){
echo ""
echo "INFO: Livestick USB creation is complete!"
echo ""
}
main(){
check_root
check_runlocation
check_localtargetfolder
check_distro
check_target
warning
logoutput
unmount_target
prepare_target
create_partitions
check_checksums
copy_files
check_filesystem
}
main
end
exit 0