boot_ini.close() os.system('cp -a %s %s/' % ('/usr/share/grldr', win_mntdir)) umount_dev(win_mntdir) return 0 else: if os.path.exists('/tmpfs/debug/nobootloader'): dolog('TURN ON: nobootloader\n') return 0 # Get the command arguments for grub. #floppy = kudzu.probe(kudzu.CLASS_FLOPPY, # kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC, # kudzu.PROBE_ALL) floppy = getdev.probe(getdev.CLASS_FLOPPY) # Because --batch will cause a bus error, we don not use this # option. #grubopt = '--batch' grubopt = '' if floppy == []: grubopt = grubopt + ' --no-floppy' os.system('cp -p %s/*stage1* %s 2>/dev/null || true' % \ (os.path.join(CONF_TGTSYS_ROOT, 'usr/lib/grub'), os.path.join(CONF_TGTSYS_ROOT, 'boot/grub'))) os.system('cp -p %s/*/*stage1* %s 2>/dev/null || true' % \ (os.path.join(CONF_TGTSYS_ROOT, 'usr/lib/grub'), os.path.join(CONF_TGTSYS_ROOT, 'boot/grub'))) os.system('dd if=%s/stage2 of=%s/stage2 bs=256k' % \
def _gen_fstab(mount_all_list): # Generate fstab. mountmap = {} for (mntdir, devfn, fstype) in mount_all_list: if fstype == 'linux-swap': continue if fstype in ('fat32', 'fat16'): mountmap[mntdir] = (devfn, CONF_FSTYPE_MAP[fstype][0], 'iocharset=cp936,umask=0,defaults', 0, 0) elif mntdir == '/': mountmap[mntdir] = (devfn, CONF_FSTYPE_MAP[fstype][0], 'defaults', 1, 1) else: mountmap[mntdir] = (devfn, CONF_FSTYPE_MAP[fstype][0], 'defaults', 0, 0) mountmap['/dev/pts'] = ('none', 'devpts', 'gid=5,mode=620', 0, 0) mountmap['/proc'] = ('none', 'proc', 'defaults', 0, 0) mountmap['/sys'] = ('none', 'sysfs', 'defaults', 0, 0) mountmap['/dev/shm'] = ('none', 'tmpfs', 'defaults', 0, 0) fdlist = getdev.probe(getdev.CLASS_FLOPPY) cdlist = getdev.probe(getdev.CLASS_CDROM) for fd in fdlist: mntdir = string.replace(fd.device, 'fd', '/media/floppy') if mntdir == '/media/floppy0': mntdir = '/media/floppy' mountmap[mntdir] = (os.path.join('/dev', fd.device), #'auto', 'iocharset=cp936,noauto,user,kudzu,rw,exec,sync', 0, 0) 'auto', 'iocharset=cp936,noauto,user,rw,exec,sync', 0, 0) os.system('mkdir -p %s' % os.path.join(CONF_TGTSYS_ROOT, mntdir[1:])) #if cdlist != []: if 0: # remove cdrom entries cddevlist = map(lambda cd: cd.device, cdlist) cddevlist.sort() for cnt in range(len(cddevlist)): if cnt == 0: mntdir = '/mnt/cdrom' else: mntdir = '/mnt/cdrom%d' % cnt mountmap[mntdir] = (os.path.join('/dev', cddevlist[cnt]), #'iso9660,udf', 'iocharset=cp936,noauto,user,kudzu,ro,exec', 0, 0) 'iso9660,udf', 'iocharset=cp936,noauto,user,ro,exec', 0, 0) devdir = os.path.join(CONF_TGTSYS_ROOT, 'dev') os.system('mkdir -p %s' % devdir) os.system('ln -s %s %s' % \ (cddevlist[cnt], os.path.join(devdir, os.path.basename(mntdir)))) os.system('mkdir -p %s' % os.path.join(CONF_TGTSYS_ROOT, mntdir[1:])) cnt = cnt + 1 etcpath = os.path.join(CONF_TGTSYS_ROOT, 'etc') if not os.path.isdir(etcpath): os.makedirs(etcpath) try: fstab = file(os.path.join(etcpath, 'fstab'), 'w') fstab.write('#%-14s\t%-23s\t%-15s\t%-15s\t%s %s\n' % \ ('device', 'mountpoint', 'filesystem', 'options', \ 'dump', 'checkpassno')) mdkeys = mountmap.keys() mdkeys.sort() for mntdir in mdkeys: (dev, fstype, opts, v1, v2) = mountmap[mntdir] fstab.write('%-15s\t%-23s\t%-15s\t%-15s\t%d %d\n' % \ (dev, mntdir, fstype, opts, v1, v2)) for (mntdir, devfn, fstype) in mount_all_list: if fstype == 'linux-swap': fstab.write('%-15s\t%-23s\t%-15s\t%-15s\t%d %d\n' % \ (devfn, 'swap', 'swap', 'defaults', 0, 0)) fstab.close() except Exception, errmsg: dolog('Generate fstab failed: %s\n' % str(errmsg))
except Exception, errmsg: syslog.syslog(syslog.LOG_ERR, "Load %s failed(%s)." % (localfn, str(errmsg))) return None remotefn = 'allpa/%s.%d.%s' % (os.path.basename(new_device), pos_id, os.path.basename(localfn)) dolog('tftpc update %s to remote %s...' % (localfn, remotefn)) cli.put(localfn, remotefn) return [remotefn, new_device, fstype, reldir, isofn] # The format like ('allpa/hdc.1.pkgarr.py', '/dev/hdc', 'iso9660', 'MagicLinux/base', '') # ['allpa/sda6.100.pkgarr.py', '/dev/sda6', 'ext3', 'MagicLinux/base', 'MagicLinux-3.0-1.iso'] mia.set_step(operid, 0, -1) cli = tftpc.TFtpClient() cli.connect('127.0.0.1') result = [] all_drives = hdpartlist cdlist = getdev.probe(getdev.CLASS_CDROM) map(lambda cd: all_drives.append((os.path.join('/dev', cd.device), 'iso9660', os.path.join('/dev', cd.device))), cdlist) dolog('all_drives: %s' % all_drives) pos_id = -1 for (device, fstype, new_device) in all_drives: if not CONF_FSTYPE_MAP.has_key(fstype): continue if CONF_FSTYPE_MAP[fstype][0] == '': continue midev = MiDevice(device, CONF_FSTYPE_MAP[fstype][0]) for f, reldir in midev.iter_searchfiles([CONF_PKGARR_FILE, CONF_BOOTCDFN], CONF_PKGARR_SER_HDPATH): if f.endswith('iso'): midev_iso = MiDevice(f, 'iso9660')