2019-12-21 04:37:38 +00:00
|
|
|
import sys
|
2019-12-26 06:20:41 +00:00
|
|
|
import os
|
|
|
|
import shutil
|
2019-12-21 04:37:38 +00:00
|
|
|
|
|
|
|
pJoin = os.path.join
|
|
|
|
|
|
|
|
opus.version = Munch()
|
|
|
|
opus.version.distro = "opus-nt"
|
|
|
|
opus.version.major = 0
|
|
|
|
opus.version.median = 0
|
|
|
|
opus.version.minor = 0
|
|
|
|
opus.version.state = "dev"
|
|
|
|
opus.version.string = \
|
|
|
|
opus.version.distro + " " +\
|
|
|
|
str(opus.version.major) + "." +\
|
|
|
|
str(opus.version.median) + "." +\
|
|
|
|
str(opus.version.minor) + " " +\
|
|
|
|
opus.version.state
|
|
|
|
|
|
|
|
opus.path = Munch()
|
|
|
|
opus.path.main = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
opus.path.api = pJoin(opus.path.main,"scripts","api")
|
2019-12-26 06:20:41 +00:00
|
|
|
opus.path.tweaks = pJoin(opus.path.main,"tweaks")
|
|
|
|
opus.path.temp = pJoin(opus.path.main,"tmp")
|
|
|
|
opus.path.wim = pJoin(opus.path.temp,"wim")
|
2019-12-21 04:37:38 +00:00
|
|
|
opus.path.target = sys.argv[1]
|
2019-12-26 06:20:41 +00:00
|
|
|
opus.verbosity = 2
|
2019-12-21 04:37:38 +00:00
|
|
|
|
|
|
|
with open(pJoin(opus.path.main,"scripts","api","main.py")) as script:
|
|
|
|
exec(script.read())
|
|
|
|
|
2019-12-26 06:20:41 +00:00
|
|
|
opus.main.output("\nmain-api loaded!",1)
|
|
|
|
opus.script.execute(pJoin(opus.path.main,"scripts","hello.py"))
|
|
|
|
opus.main.output("",1)
|
|
|
|
|
2019-12-21 04:37:38 +00:00
|
|
|
if opus.verbosity > 0:
|
2019-12-26 06:20:41 +00:00
|
|
|
opus.main.output("-- paths --")
|
2019-12-21 04:37:38 +00:00
|
|
|
for path in opus.path:
|
2019-12-26 06:20:41 +00:00
|
|
|
opus.main.output(path + ": " +opus.path[path])
|
|
|
|
|
|
|
|
opus.main.output("")
|
|
|
|
|
|
|
|
opus.main.output("-- loading misc APIs --", 1)
|
|
|
|
|
|
|
|
opus.script.execute(pJoin(opus.path.api,"path.py"))
|
|
|
|
opus.script.execute(pJoin(opus.path.api,"wim.py"))
|
|
|
|
opus.script.execute(pJoin(opus.path.api,"registry.py"))
|
|
|
|
opus.script.execute(pJoin(opus.path.api,"detection.py"))
|
|
|
|
opus.script.execute(pJoin(opus.path.api,"tweak.py"))
|
|
|
|
|
|
|
|
opus.main.output("",1)
|
|
|
|
|
|
|
|
opus.script.execute(pJoin(opus.path.main,"scripts","path.py"))
|
|
|
|
|
|
|
|
opus.main.output("",1)
|
|
|
|
|
|
|
|
if os.path.isdir(opus.path.temp):
|
|
|
|
opus.main.output("clearing temp directory...",1)
|
|
|
|
try:
|
|
|
|
opus.reg.unmount()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
shutil.rmtree(opus.path.temp)
|
|
|
|
|
|
|
|
os.makedirs(opus.path.temp)
|
|
|
|
opus.wim.location = pJoin(opus.path.target,"sources","install.wim")
|
|
|
|
opus.wim.index = int(input("\nwim index: "))
|
|
|
|
opus.main.output("",1)
|
|
|
|
|
|
|
|
opus.wim.extractFiles([
|
|
|
|
pJoin("Windows","System32","config","SOFTWARE"),
|
|
|
|
pJoin("Windows","System32","config","SYSTEM"),
|
|
|
|
pJoin("Users","Default","NTUSER.DAT")
|
|
|
|
])
|
|
|
|
|
|
|
|
opus.main.output("",1)
|
|
|
|
|
|
|
|
opus.os = opus.detect.os(opus.wim.path())
|
|
|
|
|
|
|
|
for tag in opus.os.tags:
|
|
|
|
if not os.path.isdir(pJoin(opus.path.tweaks,tag)): continue
|
|
|
|
|
|
|
|
rtgName = "SOFTWARE"
|
|
|
|
rtgFile = pJoin("Windows","System32","config","SOFTWARE")
|
|
|
|
opus.main.output("\n>> [" +tag+ "] applying tweaks: registry -> " +rtgName, 1)
|
|
|
|
opus.reg.mount(opus.wim.path(rtgFile))
|
|
|
|
for tweakRoot,tweaks,_ in opus.path.walklevel(pJoin(opus.path.tweaks,tag)):
|
|
|
|
for tweak in tweaks:
|
|
|
|
ftweak = os.path.join(tweakRoot,tweak)
|
|
|
|
if not os.path.isfile(pJoin(ftweak,"reg",rtgName + ".REG")): continue
|
|
|
|
opus.reg.imprt(pJoin(ftweak,"reg",rtgName + ".REG"))
|
|
|
|
|
|
|
|
rtgName = "SYSTEM"
|
|
|
|
rtgFile = pJoin("Windows","System32","config","SYSTEM")
|
|
|
|
opus.main.output("\n>> [" +tag+ "] applying tweaks: registry -> " +rtgName, 1)
|
|
|
|
opus.reg.mount(opus.wim.path(rtgFile))
|
|
|
|
for tweakRoot,tweaks,_ in opus.path.walklevel(pJoin(opus.path.tweaks,tag)):
|
|
|
|
for tweak in tweaks:
|
|
|
|
ftweak = os.path.join(tweakRoot,tweak)
|
|
|
|
if not os.path.isfile(pJoin(ftweak,"reg",rtgName + ".REG")): continue
|
|
|
|
opus.reg.imprt(pJoin(ftweak,"reg",rtgName + ".REG"))
|
2019-12-21 04:37:38 +00:00
|
|
|
|
2019-12-26 06:20:41 +00:00
|
|
|
rtgName = "NTUSER"
|
|
|
|
rtgFile = pJoin("Users","Default","NTUSER.DAT")
|
|
|
|
opus.main.output("\n>> [" +tag+ "] applying tweaks: registry -> " +rtgName, 1)
|
|
|
|
opus.reg.mount(opus.wim.path(rtgFile))
|
|
|
|
for tweakRoot,tweaks,_ in opus.path.walklevel(pJoin(opus.path.tweaks,tag)):
|
|
|
|
for tweak in tweaks:
|
|
|
|
ftweak = os.path.join(tweakRoot,tweak)
|
|
|
|
if not os.path.isfile(pJoin(ftweak,"reg",rtgName + ".REG")): continue
|
|
|
|
opus.reg.imprt(pJoin(ftweak,"reg",rtgName + ".REG"))
|
2019-12-21 04:37:38 +00:00
|
|
|
|
2019-12-26 06:20:41 +00:00
|
|
|
opus.main.output("\nif you'd like to make manual changes, please do so now. press enter to finalize or ctrl+c to cancel.")
|
|
|
|
input()
|
|
|
|
opus.reg.unmount()
|
|
|
|
opus.wim.update()
|