Re: [sabayon] Manually Zipping Profiles



If anyone else is interested I fixed it.

How to use :-
a) create a directory somewhere i.e. /tmp/TEST and unzip your existing sabayon profile.
b) make any changes in that directory and manually update the metadata file
c) create a new archive run the script(below) from the /tmp/test directory
    will create a new profile /etc/desktop-profiles/test.zip
d) test the profile running sabayon, select test and edit, make sure it opens
    any errors will show on the screen, correct then recreate.

Sabayon is a great tool, just bites now and again.

#!/usr/bin/python
import zipfile, os

def makeArchive(fileList, archive):
    try:
        a = zipfile.ZipFile(archive, 'w' )
        for f in fileList:
            print "archiving file %s" % (f)
            a.write(f)
        a.close()
        return True
    except: return False

def dirEntries(dir_name, subdir, *args):
    fileList = []
    for file in os.listdir(dir_name):
        dirfile = os.path.join(dir_name, file)
        if os.path.isfile(dirfile):
            if not args:
                fileList.append(dirfile)
            else:
                if os.path.splitext(dirfile)[1][1:] in args:
                    fileList.append(dirfile)
        # recursively access file names in subdirectories
        elif os.path.isdir(dirfile) and subdir:
            print "Accessing directory:", dirfile
            fileList.extend(dirEntries(dirfile, subdir, *args))
    return fileList

if __name__ == '__main__':
    folder = r'.'
    zipname = r'/etc/desktop-profiles/test.zip'
    makeArchive(dirEntries(folder, True), zipname)


On 10/13/2009 01:25 PM, Grant Williamson wrote:
Does anyone have a script which will repack sabayon profiles manually.
Sometimes it is quicker to manually make a change to the profile than use
the UI.
I tried in the past with a python script using zipfile, never successfully managed to
get something that worked.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]