Exemple #1
0
def initramfs(temproot, extract, to, verbose):
    """
    Extract user initramfs

    @return: bool
    """
    # copy initramfs to /usr/src/linux/usr/initramfs_data.cpio.gz, should we care?
    print green(' * ') + turquoise('initramfs.extract.initramfs ') + 'to ' + to

    # clean previous root
    if os.path.isdir(to):
        from time import strftime
        os.system('mv %s %s-%s ' % (to, to, strftime("%Y-%m-%d-%H-%M-%S")))
    process('mkdir -p %s' % to, verbose)

    # create dir if needed
    if not os.path.isdir(to):
        os.makedirs(to)

    process('cp %s %s/initramfs_data.cpio.gz' % (extract, to), verbose)

    # extract gzip archive
    process('gzip -d -f %s/initramfs_data.cpio.gz' % to, verbose)

    # extract cpio archive
    os.chdir(to)
    os.system('cpio -id < initramfs_data.cpio &>/dev/null')
    os.system('rm initramfs_data.cpio')
Exemple #2
0
    def import_user_initramfs(self, initramfs_from_cli_or_config):
        """
        Import user initramfs into the kernel

        @return: bool
        """
        kinitramfsdir = self.temp['initramfs']

        # copy initramfs to /usr/src/linux/usr/initramfs_data.cpio.gz, should we care?
        print green(' * ') + turquoise('kernel.import_user_initramfs ') + initramfs_from_cli_or_config
        process('cp %s %s/usr/initramfs_data.cpio.gz' % (initramfs_from_cli_or_config, self.kerneldir), self.verbose)

        # extract gzip archive
        process('gzip -d -f %s/usr/initramfs_data.cpio.gz' % self.kerneldir, self.verbose)

        # clean previous root
        if os.path.isdir(kinitramfsdir):
            from time import strftime
            os.system('mv %s %s-%s ' % (kinitramfsdir, kinitramfsdir, str(strftime("%Y-%m-%d-%H-%M-%S"))))
        process('mkdir -p %s' % kinitramfsdir, self.verbose)

        # copy initramfs to /usr/src/initramfs/
        os.system('cp %s/usr/initramfs_data.cpio %s ' % (self.kerneldir, kinitramfsdir))

        # extract cpio archive
        self.chgdir(kinitramfsdir)
        os.system('cpio -id < initramfs_data.cpio &>/dev/null')
        os.system('rm initramfs_data.cpio')
Exemple #3
0
    def strip(self):
        """
        Busybox binary strip routine
        """
        print green(" * ") + "... busybox.strip"
        self.chgdir(self.bb_tmp)

        return os.system("strip %s/busybox " % (self.bb_tmp))
Exemple #4
0
 def extract(self):
     """
     screen tarball extraction routine
 
     @return: bool
     """
     print green(' * ') + '... screen.extract'
 
     os.system('tar xvfz %s/screen-%s.tar.gz -C %s %s' % (get_distdir(self.temp), str(self.screen_ver), self.temp['work'], self.verbose['std']))
Exemple #5
0
    def rsakey(self):
        """
        dropbear rsakey creation
        """
        print green(' * ') + '... dropbear.rsakey'
        self.chgdir(self.dropbeartmp)
        process('mkdir -p %s/etc/dropbear' % self.dropbeartmp, self.verbose)

        return process('./dropbearkey -t rsa -s 4096 -f %s/etc/dropbear/dropbear_rsa_host_key' % self.dropbeartmp, self.verbose)
Exemple #6
0
    def extract(self):
    	"""
    	lvm2 tarball extraction routine
    
    	@return: bool
    	"""
    	print green(' * ') + '... lvm2.extract'

    	os.system('tar xvfz %s/LVM2.%s.tgz -C %s %s' % (get_distdir(self.temp), self.lvm2_ver, self.temp['work'], self.verbose['std']))
Exemple #7
0
 def extract(self):
     """
     dmraid tarball extraction routine
 
     @return: bool
     """
     print green(' * ') + '... dmraid.extract'
 
     os.system('tar xvfj %s/dmraid-%s.tar.bz2 -C %s %s' % (get_distdir(self.temp), str(self.dmraid_ver), self.temp['work'], self.verbose['std']))
Exemple #8
0
    def patch_debug_header(self):
        """
        Patch debug.h by adding
        #define DEBUG_TRACE
        """
        print green(' * ') + '... dropbear.patch_debug_header #define DEBUG_TRACE'
        self.chgdir(self.dropbeartmp)

        return os.system('mv debug.h debug.h.tmp && echo "#define DEBUG_TRACE" > debug.h && cat debug.h.tmp >> debug.h && rm debug.h.tmp')
Exemple #9
0
    def dsskey(self):
        """
        dropbear dsskey creation
        """
        print green(' * ') + '... dropbear.dsskey'
        self.chgdir(self.dropbeartmp)
        process('mkdir -p %s/etc/dropbear' % self.dropbeartmp, self.verbose)

        return process('./dropbearkey -t dss -f %s/etc/dropbear/dropbear_dss_host_key' % self.dropbeartmp, self.verbose)
Exemple #10
0
    def extract(self):
    	"""
    	Extract device-mapper tarball
    
    	@return: bool
    	"""
    	print green(' * ') + '... device_mapper.extract'

    	os.system('tar xvfz %s/device-mapper.%s.tgz -C %s %s' % (utils.get_distdir(self.temp), self.dm_ver, self.temp['work'], self.verbose['std']))
Exemple #11
0
 def strip(self):
 	"""
 	Strip dmsetup binary
 
 	@return: bool
 	"""
 	print green(' * ') + '... device_mapper.strip'
 	self.chgdir(self.temp['work'])
 
 	return os.system('strip %s/device-mapper/sbin/dmsetup' % (self.temp['work']))
Exemple #12
0
    def configure(self):
    	"""
    	Configure device-mapper source code

    	@return: bool
    	"""
    	print green(' * ') + '... device_mapper.configure'
    	self.chgdir(self.dm_tmp)
    
    	return os.system('./configure --prefix=%s/device-mapper --enable-static_link --disable-selinux %s' % (self.temp['work'], self.verbose['std']))
Exemple #13
0
 def configure(self):
     """
     dmraid Makefile interface to configure
 
     @return: bool
     """
     print green(' * ') + '... dmraid.configure'
     self.chgdir(self.dmraidtmp)
 
     return os.system('LIBS=-ldevmapper ./configure --enable-static_link %s' % self.verbose['std'])
Exemple #14
0
 def cache(self):
     """
     dmraid tarball cache routine
 
     @return: bool
     """
     print green(' * ') + '... dmraid.cache'
     self.chgdir(self.dmraidtmp)
 
     return process('mv %s/tools/dmraid.bz2 %s/dmraid.static-%s.bz2' % (self.dmraidtmp, self.temp['cache'], self.dmraid_ver), self.verbose)
Exemple #15
0
    def compress(self):
        """
        blkid compression routine
    
        @return: bool
        """
        print green(" * ") + "... luks.compress"
        self.chgdir(self.lukstmp)

        return process("bzip2 %s/src/cryptsetup" % self.lukstmp, self.verbose)
Exemple #16
0
 def cache(self):
     """
     screen tarball cache routine
 
     @return: bool
     """
     print green(' * ') + '... screen.cache'
     self.chgdir(self.screentmp)
 
     return process('mv %s/screen.bz2 %s/screen-%s.bz2' % (self.screentmp, self.temp['cache'], self.screen_ver), self.verbose)
Exemple #17
0
    def remove_option(self, option):
        """
        Remove kernel config option from dotconfig

        @return: bool
        """
        print green(' * ') + turquoise('kernel.remove_option ') + option + ' from ' + self.kerneldir + '/.config'
        os.system('grep -v %s %s > %s' % (option, self.kerneldir+'/.config', self.kerneldir+'/.config.kigen.temp'))

        return os.system('mv %s %s' % (self.kerneldir+'/.config.kigen.temp', self.kerneldir+'/.config'))
Exemple #18
0
 def make(self):
     """
     dropbear interface to Makefile
 
     @return: bool
     """
     print green(' * ') + '... dropbear.make'
     self.chgdir(self.dropbeartmp)
 
     return os.system('STATIC=1 PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" %s %s %s' % (self.master_config['DEFAULT_UTILS_MAKE'], self.master_config['DEFAULT_MAKEOPTS'], self.verbose['std']))
Exemple #19
0
 def configure(self):
     """
     dropbear interface to configure
 
     @return: bool
     """
     print green(' * ') + '... dropbear.configure'
     self.chgdir(self.dropbeartmp)
 
     return os.system('CFLAGS="-Os -static -Wall" LDFLAGS="-static" ./configure --disable-zlib %s' % self.verbose['std'])
Exemple #20
0
    def configure(self):
        """
        luks Makefile interface to configure
    
        @return: bool
        """
        print green(" * ") + "... luks.configure"
        self.chgdir(self.lukstmp)

        return os.system("./configure --disable-selinux --enable-static %s" % self.verbose["std"])
Exemple #21
0
 def compress(self):
 	"""
 	Compress dmsetup binary
 
 	@return: bool
 	"""
 	print green(' * ') + '... device_mapper.compress'
 	self.chgdir(self.temp['work'])
 
 	return os.system('tar -jcf %s device-mapper %s' % (self.temp['cache']+'/dmsetup-device-mapper-'+self.dm_ver+'.tar.bz2', self.verbose['std']))
Exemple #22
0
    def extract(self):
        """
        dropbear tarball extraction routine
    
        @return: bool
        """
        print green(' * ') + '... dropbear.extract'
        self.chgdir(self.temp['work'])

        os.system('tar xvfz %s/dropbear-%s.tar.gz -C %s %s' % (get_distdir(self.temp), str(self.dropbear_ver), self.temp['work'], self.verbose['std']))
Exemple #23
0
 def configure(self):
     """
     strace Makefile interface to configure
 
     @return: bool
     """
     print green(' * ') + '... strace.configure'
     self.chgdir(self.stracetmp)
 
     return os.system('LDFLAGS=-static ./configure %s' % self.verbose['std'])
Exemple #24
0
 def compress(self):
 	"""
 	lvm.static compression routine
 
 	@return: bool
 	"""
 	print green(' * ') + '... lvm2.compress'
 	self.chgdir(self.lvm2_tmp)
 
     return os.system('bzip2 tools/lvm.static')
Exemple #25
0
    def strip(self):
        """
        blkid strip binary routine
    
        @return: bool
        """
        print green(" * ") + "... luks.strip"
        self.chgdir(self.lukstmp)

        return process("strip %s/src/cryptsetup" % self.lukstmp, self.verbose)
Exemple #26
0
 def cache(self):
     """
     dropbear tarball cache routine
 
     @return: bool
     """
     print green(' * ') + '... dropbear.cache'
     self.chgdir(self.dropbeartmp)
 
     return process('mv %s/dropbear.tar %s/dropbear-%s.tar' % (self.dropbeartmp, self.temp['cache'], self.dropbear_ver), self.verbose)
Exemple #27
0
 def make(self):
     """
     dmraid Makefile interface to make
 
     @return: bool
     """
     print green(' * ') + '... dmraid.make'
     self.chgdir(self.dmraidtmp)
 
     return os.system('%s %s %s' % (self.master_config['DEFAULT_UTILS_MAKE'], self.master_config['DEFAULT_MAKEOPTS'], self.verbose['std']))
Exemple #28
0
 def cache(self):
     """
     blkid tarball cache routine
 
     @return: bool
     """
     print green(' * ') + '... e2fsprogs.cache'
     self.chgdir(self.e2tmp)
 
     return process('mv %s/misc/blkid.bz2 %s/blkid-e2fsprogs-%s.bz2' % (self.e2tmp, self.temp['cache'], self.e2fsprogs_ver), self.verbose)
Exemple #29
0
def extract(fuse_ver, temp, verbose):
	"""
	Extract fuse tarball

	@arg: string
	@arg: dict
	@arg: string
	@return: bool
	"""
	print green(' * ') + '... fuse.extract'
	os.system('tar xvfz %s/fuse-%s.tar.gz -C %s %s' % (utils.get_distdir(temp), str(fuse_ver), temp['work'], verbose['std']))
Exemple #30
0
    def make_menuconfig(self):
        """
        Kernel command interface for menuconfig
        
        @return: bool
        """
        print green(' * ') + turquoise('kernel.menuconfig ') + self.KV
        self.chgdir(self.kerneldir)
        command = self.build_command('menuconfig', '')

        return os.system(command)