[go: up one dir, main page]

Menu

[9157ac]: / onixos / iso.py  Maximize  Restore  History

Download this file

128 lines (107 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import os
from .proc import Proc
from onixos.uploader import SSH_Uploader
class ISO:
profile = ""
debug = []
syncConfig = {
'server': 'frs.sourceforge.net',
'user': 'olproject',
'port': '22',
'path': '/home/frs/project/onixos/Daily/',
'keyfile': '/home/ted/.ssh/id_ed25519'
}
isomakedepends = [
"rsync",
"go",
"xmlto",
"python-sphinx",
"base-devel",
"gnome-shell",
"git",
"qt",
"qtcreator",
"gperf",
"ninja",
"nasm",
"git-lfs ",
"base-devel",
"arch-install-scripts",
"squashfs-tools",
"dosfstools",
"syslinux ",
"git ",
"imagemagick",
"archiso",
"sudo",
]
command_list = {
"pacinst": 'sudo pacman -S --noconfirm --needed --asdeps --overwrite "*"',
"build": 'sudo mkarchiso -C "{sourcedir}/pacman.conf" -v -w "{workdir}/" -o "{outdir}" -L "ONIXOS" "$@" "{sourcedir}"',
"clean": 'sudo rm -rf {workdir}',
}
source_dir = ""
profile_dir = ""
build_dir = ""
work_dir = ""
build_command = ""
profiles = []
profile_file = ""
def __init__(self, profile_file = "sources/profiles.list"):
self.profile_file = profile_file
directory_path = os.getcwd()
self.log_dir = directory_path+"/logs"
if os.path.exists(self.log_dir) == False:
os.mkdir(self.log_dir)
def mkarchiso(self, profile="", source_dir="sources", output="output"):
directory_path = os.getcwd()
self.profile = profile
self.source_dir = directory_path+"/"+source_dir+"/profiles/"+profile
self.work_dir = directory_path+"/"+output+"/iso/"+profile+"/work"
self.build_dir = directory_path+"/"+output+"/iso/"+profile+"/output"
if os.path.exists(output) == False:
os.mkdir(output)
if os.path.exists(output+"/iso/") == False:
os.mkdir(output+"/iso/")
if os.path.exists(output+"/iso/"+profile) == False:
os.mkdir(output+"/iso/"+profile)
self.build_command = self.command_list["build"]
self.build_command = self.build_command.replace("{sourcedir}", self.source_dir)
self.build_command = self.build_command.replace("{workdir}", self.work_dir)
self.build_command = self.build_command.replace("{outdir}", self.build_dir)
self.clean_command = self.command_list["clean"]
self.clean_command = self.clean_command.replace("{workdir}", self.work_dir)
os.chdir(self.source_dir)
print("[Clean] "+self.clean_command)
debug = Proc(self.clean_command)
self.debug.append(debug)
debug.appendLog(self.log_dir+"/isobuild.log")
print("[Build] "+self.build_command)
debug = Proc(self.build_command)
self.debug.append(debug)
debug.appendLog(self.log_dir+"/isobuild.log")
os.chdir(directory_path)
def build(self):
f = open(self.profile_file,"r")
self.profiles = f.readlines()
for prof in self.profiles:
prof = prof.replace("\n", "")
prof = prof.replace("\t", "")
prof = prof.replace(" ", "")
self.mkarchiso(prof)
self.upload(prof)
def install(self):
os_command = self.command_list["pacinst"]+' '.join(self.isomakedepends)
debug = Proc(os_command)
self.debug.append(debug)
debug.appendLog(self.log_dir+"/pacinst.log")
def upload(self, profile):
iso = SSH_Uploader("output/iso/"+profile+"/output",
self.syncConfig['server'],
self.syncConfig['user'],
self.syncConfig['port'],
self.syncConfig['path']+'/ISO',
"",
self.syncConfig['keyfile'],
)
iso.upload()