aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorlcapriotti <lcapriotti@svn>2009-10-02 15:16:16 +0000
committerlcapriotti <lcapriotti@svn>2009-10-02 15:16:16 +0000
commit9ecb660a729c9278fc256f2067e3685112154c45 (patch)
tree1b803b735d0c35b12eab2d3cb0806143ecf2e531 /tools
parent521f3e573ab8102b052601851a6bc688b4891f93 (diff)
now handles combinations of V1, V2, grub-legacy and grub2
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@23329 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'tools')
-rwxr-xr-xtools/XBMCLive/installXBMC178
1 files changed, 106 insertions, 72 deletions
diff --git a/tools/XBMCLive/installXBMC b/tools/XBMCLive/installXBMC
index d6d8e226ba..f14fe3a127 100755
--- a/tools/XBMCLive/installXBMC
+++ b/tools/XBMCLive/installXBMC
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""
"XBMC Live" installer
- V1.004 - 20090930
+ V1.005 - 20091002
Luigi Capriotti @2009
"""
@@ -22,15 +22,18 @@ gFixedDiskMinSizeMB = 5000
gBootPartitionSizeMB = 4096
gSwapPartitionSizeMB = 512
-gPermStorageFilename = "ext3fs.img"
+gPermStorageFilenameV1 = "ext3fs.img"
+gRootFSV1="/rootfs.img"
gPermStorageFilenameV2 = "live-rw"
+gRootFSV2="/live/filesystem.squashfs"
+
gBootPartMountPoint = "/tmp/bootPart"
gLivePartMountPoint = "/tmp/livePart"
gDebugMode = 0
gInstallerLogFileName = "/var/tmp/installXBMC.log"
-gbIsLiveV2 = False
+
def runSilent(aCmdline):
writeLog("Running: " + aCmdline)
@@ -81,7 +84,7 @@ def getKernelParameter(token):
return aParam
-def findBootVolume(lookForRootFS):
+def findBootVolume(rootFS, lookForRootFS):
if not lookForRootFS:
rootPartition = getKernelParameter('root')
if rootPartition.startswith('UUID='):
@@ -90,10 +93,6 @@ def findBootVolume(lookForRootFS):
return rootPartition
driveList = ["sr0","sr1","sr2","sr3","sda","sdb","sdc","sdd","sde","sdf","sdg"]
- if gbIsLiveV2 == False:
- rootFS="/rootfs.img"
- else:
- rootFS="/live/filesystem.squashfs"
# Find the drive we booted from
found = False
@@ -296,9 +295,7 @@ def umountDevice(aDirectory, removeMountPoint=True):
def copySystemFilesV1(srcDirectory, dstDirectory, bIsRemovableDisk, skipLargeFiles):
global gDebugMode
- # This one needs python 2.6, for future use
- # Do not copy storage file
- # shutil.copytree(srcDirectory, dstDirectory, ignore=shutil.ignore_patterns(gPermStorageFilename))
+ global gPermStorageFilenameV1
if not os.path.exists(dstDirectory):
os.mkdir(dstDirectory)
@@ -312,7 +309,7 @@ def copySystemFilesV1(srcDirectory, dstDirectory, bIsRemovableDisk, skipLargeFil
for root, dirs, files in os.walk(srcDirectory):
for file in files:
# Do not copy storage file
- if file == gPermStorageFilename:
+ if file == gPermStorageFilenameV1:
continue
writeLog("Copying file: " + file)
@@ -401,6 +398,7 @@ def copySystemFilesV1(srcDirectory, dstDirectory, bIsRemovableDisk, skipLargeFil
def copySystemFilesV2(srcDirectory, dstDirectory, bIsRemovableDisk, skipLargeFiles):
global gDebugMode
+ global gPermStorageFilenameV2
if not os.path.exists(dstDirectory):
os.mkdir(dstDirectory)
@@ -414,7 +412,7 @@ def copySystemFilesV2(srcDirectory, dstDirectory, bIsRemovableDisk, skipLargeFil
for root, dirs, files in os.walk(srcDirectory):
for file in files:
# Do not copy storage file
- if file == gPermStorageFilename:
+ if file == gPermStorageFilenameV2:
continue
writeLog("Copying file: " + file)
@@ -470,21 +468,20 @@ def copySystemFilesV2(srcDirectory, dstDirectory, bIsRemovableDisk, skipLargeFil
aFileName = os.readlink("/initrd.img")
try:
- writeLog("Copying " + srcDirectory + "/initrd.img")
- shutil.copyfile(srcDirectory + "/initrd.img", dstDirectory + "/" + aFileName)
+ writeLog("Copying " + srcDirectory + "/live/initrd.img")
+ shutil.copyfile(srcDirectory + "/live/initrd.img", dstDirectory + "/" + aFileName)
except:
writeLog("Error copying file: " + "initrd.img")
print "Error copying file: " + "initrd.img" + " - check your media"
aFileName = os.readlink("/vmlinuz")
try:
- writeLog("Copying " + srcDirectory + "/vmlinuz")
- shutil.copyfile(srcDirectory + "/vmlinuz", dstDirectory + "/" + aFileName)
+ writeLog("Copying " + srcDirectory + "/live/vmlinuz")
+ shutil.copyfile(srcDirectory + "/live/vmlinuz", dstDirectory + "/" + aFileName)
except:
writeLog("Error copying file: " + "vmlinuz")
print "Error copying file: " + "vmlinuz" + " - check your media"
- # shutil.copyfile(srcDirectory + "/boot/xbmc.xpm.gz", dstDirectory + "/boot/xbmc.xpm.gz")
for root, dirs, files in os.walk(srcDirectory + "/boot"):
for file in files:
from_ = os.path.join(root, file)
@@ -514,7 +511,11 @@ def findUUID(aPartition):
def installGrub(bootDevice, dstDirectory):
runSilent("grub-install --recheck --root-directory=" + dstDirectory + " " + bootDevice)
-def modifyGrubMenuV1(menuFName, isaRemovableDrive, bootPartition):
+def modifyGrubMenuV1(useGrubLegacy, basePath, isaRemovableDrive, bootPartition):
+ menuFName = basePath + "/boot/grub/menu.lst"
+ if not useGrubLegacy:
+ menuFName = basePath + "/boot/grub/grub.cfg"
+
if isaRemovableDrive:
content = readFile(menuFName)
if isaRemovableDrive == 1:
@@ -542,50 +543,73 @@ def modifyGrubMenuV1(menuFName, isaRemovableDrive, bootPartition):
writeFile(menuFName, content)
-def modifyGrubMenuV2(menuFName, isaRemovableDrive, bootPartition):
+def modifyGrubMenuV2(useGrubLegacy, basePath, isaRemovableDrive, bootPartition):
if not isaRemovableDrive:
- content = ""
- content += ("set default=0" + "\n")
- content += ("\n")
- content += ("insmod video" + "\n")
- content += ("insmod vbe" + "\n")
- content += ("insmod font" + "\n")
- content += ("if loadfont ($root)/boot/grub/unicode.pf2 ; then" + "\n")
- content += (" set gfxmode=800x600" + "\n")
- content += ("# set gfxpayload=keep" + "\n")
- content += (" insmod gfxterm" + "\n")
- content += (" if terminal_output gfxterm ; then true ; else" + "\n")
- content += (" # For backward compatibility with versions of terminal.mod that don't understand terminal_output" + "\n")
- content += (" terminal gfxterm" + "\n")
- content += (" fi" + "\n")
- content += ("fi" + "\n")
- content += ("\n")
- content += ("insmod tga" + "\n")
- content += ("if background_image ($root)/boot/grub/xbmc.tga ; then" + "\n")
- content += (" set color_normal=white/black" + "\n")
- content += (" set color_highlight=cyan/black" + "\n")
- content += ("else" + "\n")
- content += (" set menu_color_normal=cyan/blue" + "\n")
- content += (" set menu_color_highlight=white/blue" + "\n")
- content += ("fi" + "\n")
- content += ("\n")
- content += ('echo -n "Press ESC to enter the menu... "' + "\n")
- content += ("if sleep --verbose --interruptible 2 ; then" + "\n")
- content += (" set timeout=0" + "\n")
- content += ("else" + "\n")
- content += (" set timeout=-1" + "\n")
- content += ("fi" + "\n")
- content += ("\n")
- content += ('menuentry "XBMCLive" {' + "\n")
- content += (" linux /vmlinuz root=UUID=" + findUUID(bootPartition) + " quiet splash xbmc=nodiskmount,setvolume,noredir loglevel=0" + "\n")
- content += (" initrd /initrd.img" + "\n")
- content += ("}" + "\n")
- content += ("\n")
- content += ('menuentry "XBMCLive - SAFE MODE" {' + "\n")
- content += (" linux /vmlinuz root=UUID=" + findUUID(bootPartition) + " xbmc=nodiskmount,noredir loglevel=0" + "\n")
- content += (" initrd /initrd.img" + "\n")
- content += ("}" + "\n")
- content += ("\n")
+ if useGrubLegacy:
+ menuFName = basePath + "/boot/grub/menu.lst"
+
+ content = ("default 0" + "\n")
+ content += ("hiddenmenu" + "\n")
+ content += ("timeout 5" + "\n")
+ content += ("foreground eeeeee" + "\n")
+ content += ("background 333333" + "\n")
+ content += ("splashimage=/boot/grub/splash.xpm.gz" + "\n")
+ content += ("\n")
+ content += ("title XBMCLive" + "\n")
+ content += ("kernel /vmlinuz root=UUID=" + findUUID(bootPartition) + " quiet splash xbmc=nodiskmount,tempfs,setvolume,noredir loglevel=0" + "\n")
+ content += ("initrd /initrd.img" + "\n")
+ content += ("boot" + "\n")
+ content += ("\n")
+ content += ("title XBMCLive - SAFE MODE" + "\n")
+ content += ("kernel /vmlinuz root=UUID=" + findUUID(bootPartition) + " xbmc=nodiskmount,noredir loglevel=0" + "\n")
+ content += ("initrd /initrd.img" + "\n")
+ content += ("boot" + "\n")
+ content += ("\n")
+ else:
+ menuFName = basePath + "/boot/grub/grub.cfg"
+
+ content = ""
+ content += ("set default=0" + "\n")
+ content += ("\n")
+ content += ("insmod video" + "\n")
+ content += ("insmod vbe" + "\n")
+ content += ("insmod font" + "\n")
+ content += ("if loadfont ($root)/boot/grub/unicode.pf2 ; then" + "\n")
+ content += (" set gfxmode=800x600" + "\n")
+ content += ("# set gfxpayload=keep" + "\n")
+ content += (" insmod gfxterm" + "\n")
+ content += (" if terminal_output gfxterm ; then true ; else" + "\n")
+ content += (" # For backward compatibility with versions of terminal.mod that don't understand terminal_output" + "\n")
+ content += (" terminal gfxterm" + "\n")
+ content += (" fi" + "\n")
+ content += ("fi" + "\n")
+ content += ("\n")
+ content += ("insmod tga" + "\n")
+ content += ("if background_image ($root)/boot/grub/xbmc.tga ; then" + "\n")
+ content += (" set color_normal=white/black" + "\n")
+ content += (" set color_highlight=cyan/black" + "\n")
+ content += ("else" + "\n")
+ content += (" set menu_color_normal=cyan/blue" + "\n")
+ content += (" set menu_color_highlight=white/blue" + "\n")
+ content += ("fi" + "\n")
+ content += ("\n")
+ content += ('echo -n "Press ESC to enter the menu... "' + "\n")
+ content += ("if sleep --verbose --interruptible 2 ; then" + "\n")
+ content += (" set timeout=0" + "\n")
+ content += ("else" + "\n")
+ content += (" set timeout=-1" + "\n")
+ content += ("fi" + "\n")
+ content += ("\n")
+ content += ('menuentry "XBMCLive" {' + "\n")
+ content += (" linux /vmlinuz root=UUID=" + findUUID(bootPartition) + " quiet splash xbmc=nodiskmount,setvolume,noredir loglevel=0" + "\n")
+ content += (" initrd /initrd.img" + "\n")
+ content += ("}" + "\n")
+ content += ("\n")
+ content += ('menuentry "XBMCLive - SAFE MODE" {' + "\n")
+ content += (" linux /vmlinuz root=UUID=" + findUUID(bootPartition) + " xbmc=nodiskmount,noredir loglevel=0" + "\n")
+ content += (" initrd /initrd.img" + "\n")
+ content += ("}" + "\n")
+ content += ("\n")
writeFile(menuFName, content)
def changePasswords(liveRootDir):
@@ -674,13 +698,14 @@ def main():
global gFixedDiskMinSizeMB
global gBootPartitionSizeMB
global gSwapPartitionSizeMB
- global gPermStorageFilename
+ global gPermStorageFilenameV1
global gPermStorageFilenameV2
+ global gRootFSV1
+ global gRootFSV2
global gBootPartMountPoint
global gLivePartMountPoint
global gInstallerLogFileName
global gDebugMode
- global gbIsLiveV2
parser = optparse.OptionParser()
parser.add_option("-i", dest="isoFileName", help="Use specified ISO file as source for XBMC Live files", default=None)
@@ -722,10 +747,16 @@ def main():
availableDisks = []
+ bIsLiveV2 = False
+ bUseGrubLegacy = True
+ permStorageFilename = gPermStorageFilenameV1
+ rootFS = gRootFSV1
+
bootMedia = getKernelParameter('boot')
if bootMedia == 'live':
- gbIsLiveV2 = True
- gPermStorageFilename = gPermStorageFilenameV2
+ bIsLiveV2 = True
+ permStorageFilename = gPermStorageFilenameV2
+ rootFS = gRootFSV2
while True:
os.system('clear')
@@ -747,7 +778,7 @@ def main():
print ""
print "Identifying boot disk..."
print ""
- bootVolume = findBootVolume( (cmdLineOptions.isoFileName == None))
+ bootVolume = findBootVolume(rootFS, (cmdLineOptions.isoFileName == None))
if bootVolume == None:
if cmdLineOptions.doNotShutdown == True:
raw_input("Error locating boot media, exiting.")
@@ -817,7 +848,7 @@ def main():
else:
mountDevice(cmdLineOptions.isoFileName, "-o loop", gBootPartMountPoint)
- if gbIsLiveV2 == False:
+ if bIsLiveV2 == False:
copySystemFilesV1(gBootPartMountPoint, gLivePartMountPoint, removableDiskSelected, cmdLineOptions.skipFileCopy)
else:
copySystemFilesV2(gBootPartMountPoint, gLivePartMountPoint, removableDiskSelected, cmdLineOptions.skipFileCopy)
@@ -841,12 +872,15 @@ def main():
if storageSize > 4000:
storageSize = 4000
print "Permanent system storage size = " + str(storageSize) + " MB, Please wait..."
- createPermanentStorageFile(gLivePartMountPoint + "/" + gPermStorageFilename, storageSize)
+ createPermanentStorageFile(gLivePartMountPoint + "/" + permStorageFilename, storageSize)
+
+ if os.path.exists(gLivePartMountPoint + "/boot/grub/grub.cfg"):
+ bUseGrubLegacy = False
- if gbIsLiveV2 == False:
- modifyGrubMenuV1(gLivePartMountPoint + "/boot/grub/menu.lst", removableDiskSelected, availableDisks[diskIndex] + "1")
+ if bIsLiveV2 == False:
+ modifyGrubMenuV1(bUseGrubLegacy, gLivePartMountPoint, removableDiskSelected, availableDisks[diskIndex] + "1")
else:
- modifyGrubMenuV2(gLivePartMountPoint + "/boot/grub/grub.cfg", removableDiskSelected, availableDisks[diskIndex] + "1")
+ modifyGrubMenuV2(bUseGrubLegacy, gLivePartMountPoint, removableDiskSelected, availableDisks[diskIndex] + "1")
if not removableDiskSelected:
print "Applying system changes..."