User Scripts & Dragons - insert firmware onto aptosid iso

kelmo - 25.07.2011, 12:28
Post subject: insert firmware onto aptosid iso
This script can add firmware onto an aptosid iso image.


# Copyright:    Copyright (c) Kel Modderman
# License:      GPL-2
# 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
# of the License, 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
# GNU General Public License for more details.
# On Debian GNU/Linux systems, the text of the GPL license,
# version 2, can be found in /usr/share/common-licenses/GPL-2.

import argparse
import glob
import os
import shutil
import signal
import subprocess
import sys
import tempfile

def restore_sigpipe():
    signal.signal(signal.SIGPIPE, signal.SIG_DFL)

def cmd(string):
    subprocess.check_call(string.split(), preexec_fn=restore_sigpipe)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-f', '--file', action='store',
                        help='file (tar.gz) containing firmware .deb\'s')
    parser.add_argument('-d', '--dir', action='store',
                        help='directory containing firmware binaries')
    parser.add_argument('input_iso', help='Input ISO9660 image file')
    parser.add_argument('output_iso', help='Output ISO9660 image file')
    args = parser.parse_args()

    fw_dir = None
    tmpdir = None
        if args.dir:
            fw_dir = args.dir
            tmpdir = tempfile.mkdtemp()

            if args.file:
                cmd('tar -C %s -xf %s' % (tmpdir, args.file))
                cmd('wget -nv -Nc http://cdimage.debian.org/cdimage/unofficial/' \
                cmd('tar -C %s -xf firmware.tar.gz' % tmpdir)

            for deb in glob.glob('%s/*.deb' % tmpdir):
                cmd('dpkg -x %s %s' % (deb, tmpdir))

            fw_dir = os.path.join(tmpdir, 'lib/firmware')

        if os.path.isfile(args.output_iso):

        cmd('xorriso -indev %s -outdev %s -boot_image isolinux patch ' \
            '-pathspecs on -add /aptosid/firmware/=%s' % \
            (args.input_iso, args.output_iso, fw_dir))

        cmd('isohybrid %s' % args.output_iso)
    except subprocess.CalledProcessError, e:
        if os.path.isfile(args.output_iso):
        if tmpdir and os.path.isdir(tmpdir):

wannek3 - 26.07.2011, 11:42
Post subject: RE: insert firmware onto aptosid iso
Hi kelmo,

nice idea! But unfortunately it doesn't work here:

# apt-get install python-argparse

$ ls -l
-rw-r--r-- 1  579862528 16. Jul 16:25 aptosid-2011-02-imera-kde-lite-i386-201107131633.iso
-rwxr-xr-x 1       2676 26. Jul 13:17 aptosid-iso_add-firmware.py
-rw-r--r-- 1   12796669 18. Jul 10:32 firmware.tar.gz

$ ./aptosid-iso_add-firmware.py -f firmware.tar.gz aptosid-2011-02-imera-kde-lite-i386-201107131633.iso aptosid_firmware.iso
Traceback (most recent call last):
  File "./aptosid-iso_add-firmware.py", line 69, in <module>
    (args.input_iso, args.output_iso, fw_dir))
  File "./aptosid-iso_add-firmware.py", line 32, in cmd
    subprocess.check_call(string.split(), preexec_fn=restore_sigpipe)
  File "/usr/lib/python2.6/subprocess.py", line 483, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python2.6/subprocess.py", line 470, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

==> Which file is missing?

The same happens, if i concatenate the strings seperated by '\'.

Edit: added code boxes - hubi
bfree - 26.07.2011, 13:15
Post subject: RE: insert firmware onto aptosid iso
I think you just need to "apt-get install xorriso"
wannek3 - 26.07.2011, 15:22
Post subject: RE: insert firmware onto aptosid iso
Shame on me! Yes, bfree, You are so right.
And also syslinux for the isohybrid.
Works, thanks, solved!
$ ls -l
-rw-r--r-- 1 603979776 26. Jul 17:20 aptosid_firmware.iso

iotaka - 28.07.2011, 13:01
Post subject:
Useful, thank you.
Barlafuss - 28.07.2011, 16:05
Post subject:
thanks a lot also from my side.
All times are GMT - 12 Hours
Powered by PNphpBB2 © 2003-2010 The Zafenio Group