Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
kelmoOffline
Post subject: insert firmware onto aptosid iso  PostPosted: 25.07.2011, 12:28



Joined: 2010-09-21
Posts: 15

Status: Offline
This script can add firmware onto an aptosid iso image.

      Code:

#!/usr/bin/python
#
# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# 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
    try:
        if args.dir:
            fw_dir = args.dir
        else:
            tmpdir = tempfile.mkdtemp()

            if args.file:
                cmd('tar -C %s -xf %s' % (tmpdir, args.file))
            else:
                cmd('wget -nv -Nc http://cdimage.debian.org/cdimage/unofficial/' \
                    'non-free/firmware/sid/current/firmware.tar.gz')
                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):
            os.unlink(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):
            os.unlink(args.output_iso)
        sys.exit(1)
    finally:
        if tmpdir and os.path.isdir(tmpdir):
            shutil.rmtree(tmpdir)
 
 View user's profile Send private message  
Reply with quote Back to top
wannek3Offline
Post subject: RE: insert firmware onto aptosid iso  PostPosted: 26.07.2011, 11:42



Joined: 2010-09-13
Posts: 6

Status: Offline
Hi kelmo,

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

      Code:
# apt-get install python-argparse


      Code:
$ 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


      Code:
$ ./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
 
 View user's profile Send private message  
Reply with quote Back to top
bfreeOffline
Post subject: RE: insert firmware onto aptosid iso  PostPosted: 26.07.2011, 13:15
Team Member


Joined: 2010-08-26
Posts: 247

Status: Offline
I think you just need to "apt-get install xorriso"
 
 View user's profile Send private message  
Reply with quote Back to top
wannek3Offline
Post subject: RE: insert firmware onto aptosid iso  PostPosted: 26.07.2011, 15:22



Joined: 2010-09-13
Posts: 6

Status: Offline
Shame on me! Yes, bfree, You are so right.
And also syslinux for the isohybrid.
Works, thanks, solved!
      Code:
$ ls -l
-rw-r--r-- 1 603979776 26. Jul 17:20 aptosid_firmware.iso
 
 View user's profile Send private message  
Reply with quote Back to top
iotakaOffline
Post subject:   PostPosted: 28.07.2011, 13:01



Joined: 2010-10-06
Posts: 11

Status: Offline
Useful, thank you.
 
 View user's profile Send private message  
Reply with quote Back to top
BarlafussOffline
Post subject:   PostPosted: 28.07.2011, 16:05



Joined: 2010-09-14
Posts: 45

Status: Offline
thanks a lot also from my side.
Barlafuss
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by Zafenio