Changeset 940 for lliurex-meta-maker/trunk
- Timestamp:
- Mar 23, 2016, 2:42:41 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-meta-maker/trunk/fuentes/src/metamaker/__init__.py
r934 r940 10 10 import mmap 11 11 import re 12 import tempfile 13 import fileinput 12 14 13 15 class MetaMaker(cmd.Cmd): … … 25 27 26 28 def loadStructure(self): 29 ''' 30 load on self.structure seeds and depends 31 self.structure = { 32 "llx-base":[], 33 "llx-common":[], 34 "llx-desktop":["llx-base","llx-common"] 35 } 36 ''' 27 37 structurefiles = [] 28 38 for (dirpath,dirname,filelist) in os.walk(self.root+"/seeds"): … … 30 40 if seed.lower() == "structure": 31 41 structurefiles.append(dirpath + "/" + seed) 42 32 43 for strucfilepath in structurefiles: 33 44 fd = open(strucfilepath,'r') … … 72 83 sys.stdout.flush() 73 84 85 86 def renameSeeds(self,flavour,tempfolder): 87 baseflavour = flavour.rsplit('.',1)[0] 88 basedir = os.path.join(tempfolder,flavour) 89 structurefile = os.path.join(basedir,'STRUCTURE') 90 seedstorename = [] 91 92 if not os.path.exists(structurefile): 93 return 0 94 95 dfstructure = open(structurefile,'r') 96 lines = dfstructure.readlines() 97 dfstructure.close() 98 for line in lines: 99 seeds = line.split(":") 100 if len(seeds) <= 1: 101 continue 102 if os.path.exists(os.path.join(basedir,seeds[0])): 103 seedstorename.append(seeds[0]) 104 105 for seed in seedstorename: 106 pathseed = os.path.join(basedir,seed) 107 dfstructure = fileinput.FileInput(pathseed,inplace=True) 108 for line in dfstructure: 109 if line.lower(): 110 continue 111 for seed in seedstorename: 112 line = re.sub(r"^"+seed+":",baseflavour+"-"+seed+":",line) 113 line = re.sub(r"(\s*)"+seed+r"(\s+|$)",r"\1"+baseflavour+"-"+seed+r"\2",line) 114 print(line,end="") 115 dfstructure.close() 116 os.rename(pathseed ,os.path.join(basedir,baseflavour+"-"+seed)) 117 118 dfstructure = fileinput.FileInput(structurefile,inplace=True) 119 for line in dfstructure: 120 if len(line.split(":")) <= 1: 121 continue 122 for seed in seedstorename: 123 line = re.sub(r"^"+seed+":",baseflavour+"-"+seed+":",line) 124 line = re.sub(r"(\s*)"+seed+r"(\s+|$)",r"\1"+baseflavour+"-"+seed+r"\2",line) 125 print(line,end="") 126 74 127 def complete_create(self,text,line,begidx,endidx): 75 128 if len(self.flavours) == 0: … … 84 137 return [i for i in self.flavours if i.startswith(text)] 85 138 139 def downloadPlatformSeed(self,flavour): 140 base = flavour.rsplit('.',1)[-1] 141 platformurl = "http://people.canonical.com/~ubuntu-archive/seeds/platform."+base 142 print("Downloading platform " + base) 143 self.downloadFile(platformurl,self.root + "/seeds/") 144 print("") 145 146 def downloadFlavourSeed(self,flavour): 147 flavoururl = "http://people.canonical.com/~ubuntu-archive/seeds/"+flavour 148 tempfolder = tempfile.mkdtemp() 149 print("Downloading flavour " + flavour) 150 self.downloadFile(flavoururl,tempfolder) 151 print("Done") 152 print("Renaming seeds") 153 self.renameSeeds(flavour,tempfolder) 154 86 155 def downloadSeeds(self,flavour): 87 base = flavour.rsplit('.',1)[-1] 88 originseeds = ["http://people.canonical.com/~ubuntu-archive/seeds/"+flavour,"http://people.canonical.com/~ubuntu-archive/seeds/platform."+base] 89 for urlseed in originseeds : 90 try: 91 print("Downloading " + urlseed) 92 self.downloadFile(urlseed,self.root + "/seeds/") 93 print("") 94 except Exception as e: 95 print(e) 156 self.downloadPlatformSeed(flavour) 157 self.downloadFlavourSeed(flavour) 96 158 97 159 def createNeededStructure(self,codename): … … 106 168 f.write("["+codename+"]\n") 107 169 f.write("seeds:\n") 108 f.write("output_seeds:\n")109 170 f.write("architectures: i386 amd64\n") 110 f.write("seed_base: "+self.root+"/seeds \n") 111 f.write("archive_base/default: \n") 171 f.write("seed_base: seeds \n") 172 f.write("seed_dist: lliurex \n") 173 f.write("archive_base/default: http://archive.ubuntu.com/ubuntu http://ppa.launchpad.net/llxdev/"+codename+"/ubuntu\n") 112 174 f.write("components: main restricted universe multiverse\n") 113 175 f.close()
Note: See TracChangeset
for help on using the changeset viewer.