Beispiel #1
0
    def setupEnvironment(self):
        print("setup environment")
        home = _eintr_retry_call(getpwnam, self.user).pw_dir

        def cp(x):
            _eintr_retry_call(copyfile, x, join(home, x))

        #t1 = Thread(target=cp, args=[".bash_profile"])
        #t2 = Thread(target=cp, args=[".bashrc"])
        #t1.start()
        #t2.start()
        #t1.join()
        #t2.join()
        def sed(x):
            with open(x, 'r') as f:
                s = f.read()
            s.replace('/mnt/lfs', self.lfs)
            s.replace('LFS_TGT=$(uname -m)-lfs-linux-gnu', self.lfs_tgt)
            with open(join(home, x), 'w') as f:
                f.write(s)

        parallelize([
            (sed, [".bash_profile"]),
            # TODO sed /mnt/lfs with self.lfs
            (cp, [".bashrc"])
        ])
        """ https://stackoverflow.com/questions/8365394/set-environment-variable-in-python-script#8365493 """
        term = os.environ['TERM']
        os.environ = {
            'HOME':
            home,
            'TERM':
            term,
            'PS1':
            """\\u:\\w\\$ """,
            'LFS':
            self.lfs,
            'LC_ALL':
            'POSIX',
            'LFS_TGT':
            '%s-lfs-linux-gnu' % uname()[4],
            'PATH':
            ':'.join([
                join(self.toolsym, 'bin'),
                join(sep, 'bin'),
                join(sep, 'usr', 'bin')
            ])
        }

        umask(0o22)
Beispiel #2
0
 def createLFSUser2(self):
     print("create LFS user (stage 2)")
     #chown(self.tools,   self.group, self.user)
     #chown(self.sources, self.group, self.user)
     #t1 = Thread(target=chown, args=[self.tools,   self.group, self.user])
     #t2 = Thread(target=chown, args=[self.sources, self.group, self.user])
     #t1.start()
     #t2.start()
     #t1.join()
     #t2.join()
     parallelize([
         (_eintr_retry_call, [chown, self.tools, self.group, self.user]),
         (_eintr_retry_call, [chown, self.sources, self.group, self.user]),
         (_eintr_retry_call, [chown, self.srcx, self.group, self.user])
     ])
Beispiel #3
0
def getLists(wgetList, md5sums, destdir):
    def getLines(l):
        downloadIfNewer(l, destdir)
        with open(join(destdir, basename(l)), 'r') as f:
            lines = f.readlines()
        return map(chomp, lines)

    wl, ml = {}, {}

    def urlHelper():
        for k in getLines(wgetList):
            wl[basename(k)] = k

    def md5Helper():
        for k, p in map(lambda s: s.split(), getLines(md5sums)):
            ml[p] = k

    parallelize([(urlHelper, []), (md5Helper, [])])
    return wl, ml
Beispiel #4
0
    def removeToolsDirectory(self):
        print("remove tools directory")

        #rmtree(self.tools)
        #remove(self.toolsym)
        #t1 = Thread(target=rmtree, args=[self.tools])
        #t2 = Thread(target=remove, args=[self.toolsym])
        #t1.start()
        #t2.start()
        #t1.join()
        #t2.join()
        def rmtools():
            if not self.is_persistent:
                removeRamdisk(self.tools)
            if not self.is_persistent:
                rmdir(self.tools)

        parallelize([
            #(_eintr_retry_call, [rmtree, self.tools]),
            (_eintr_retry_call, [rmtools]),
            (_eintr_retry_call, [remove, self.toolsym])
        ])
Beispiel #5
0
def phash_c_download_old(wgetList, md5sums, destdir):
    parallelize([(pdownloadList, [wgetList, destdir]),
                 (downloadIfNewer, [md5sums, destdir])])
    return sum(pmd5_c_open(join(destdir, basename(md5sums)), destdir))