Allow a custom (non-Finder) startup app
This commit is contained in:
parent
240a746ab9
commit
8ae22ed428
|
@ -53,11 +53,15 @@ def imgsize(x):
|
|||
x += 'b'
|
||||
return int(x[:-1]) * factor
|
||||
|
||||
def hfspathtpl(s):
|
||||
return tuple(c for c in s.split(':') if c)
|
||||
|
||||
args = argparse.ArgumentParser()
|
||||
|
||||
args.add_argument('dest', metavar='OUTPUT', nargs=1, help='Destination file')
|
||||
args.add_argument('-n', '--name', default='untitled', action='store', help='volume name (default: untitled)')
|
||||
args.add_argument('-i', '--dir', action='store', help='folder to copy into the image')
|
||||
args.add_argument('-a', '--app', default=None, type=hfspathtpl, help='Path:To:Startup:App')
|
||||
args.add_argument('-s', '--size', default='800k', type=imgsize, action='store', help='volume size (default: size of OUTPUT)')
|
||||
args.add_argument('-d', '--date', default='1994', type=hfsdat, action='store', help='creation & mod date (ISO-8601 or "now")')
|
||||
args.add_argument('--mpw-dates', action='store_true', help='''
|
||||
|
@ -166,6 +170,6 @@ if args.mpw_dates:
|
|||
|
||||
########################################################################
|
||||
|
||||
image = vol.write(args.size)
|
||||
image = vol.write(args.size, startapp=args.app)
|
||||
with open(args.dest[0], 'wb') as f:
|
||||
f.write(image)
|
||||
|
|
|
@ -244,7 +244,7 @@ class Volume(directory.AbstractFolder):
|
|||
self.pop('Desktop DB', None)
|
||||
self.pop('Desktop DF', None)
|
||||
|
||||
def write(self, size=800*1024, align=512, desktopdb=True, bootable=True):
|
||||
def write(self, size=800*1024, align=512, desktopdb=True, bootable=True, startapp=None):
|
||||
if align < 512 or align % 512:
|
||||
raise ValueError('align must be multiple of 512')
|
||||
|
||||
|
@ -332,6 +332,10 @@ class Volume(directory.AbstractFolder):
|
|||
systemfolder = path2wrap[path[:-1]].cnid
|
||||
systemfile = wrap
|
||||
|
||||
if isinstance(obj, File) and path[1:] == tuple(startapp):
|
||||
startfolder = path2wrap[path[:-1]].cnid
|
||||
startname = path[-1]
|
||||
|
||||
if isinstance(obj, File):
|
||||
wrap.dfrk = wrap.rfrk = (0, 0)
|
||||
if obj.data:
|
||||
|
@ -434,6 +438,15 @@ class Volume(directory.AbstractFolder):
|
|||
except:
|
||||
bootblocks = bytes(1024)
|
||||
systemfolder = 0
|
||||
bootblocks = bytearray(bootblocks)
|
||||
|
||||
# Set the startup app
|
||||
try:
|
||||
if not systemfolder: raise ValueError
|
||||
apname = bitmanip.pstring(_encode_name(startname))
|
||||
bootblocks[0x5A:0x5A+len(apname)] = apname
|
||||
except:
|
||||
startfolder = 0
|
||||
|
||||
# Create the Volume Information Block
|
||||
drSigWord = b'BD'
|
||||
|
@ -449,7 +462,7 @@ class Volume(directory.AbstractFolder):
|
|||
drAtrb = 1<<8 # volume attributes (hwlock, swlock, CLEANUNMOUNT, badblocks)
|
||||
drVolBkUp = 0 # date and time of last backup
|
||||
drVSeqNum = 0 # volume backup sequence number
|
||||
drFndrInfo = struct.pack('>L28x', systemfolder)
|
||||
drFndrInfo = struct.pack('>LLL28x', systemfolder, startfolder, startfolder)
|
||||
drCrDate, drLsMod, drVolBkUp = self.crdate, self.mddate, self.bkdate
|
||||
|
||||
vib = struct.pack('>2sLLHHHHHLLHLH28pLHLLLHLL32sHHHLHHxxxxxxxxLHHxxxxxxxx',
|
||||
|
|
Loading…
Reference in New Issue