mirror of
https://github.com/drasko/codezero.git
synced 2026-04-22 03:39:05 +02:00
Building of linux and rootfs as containers nicely getting in shape
Created a Linux builder that takes a container object as its parameter. Build of linux kernel will be coordinated by input from this container parameter
This commit is contained in:
@@ -18,24 +18,36 @@ from config.configuration import *
|
|||||||
|
|
||||||
LINUX_KERNEL_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_KERNELDIR, PROJROOT))
|
LINUX_KERNEL_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_KERNELDIR, PROJROOT))
|
||||||
|
|
||||||
def main():
|
class LinuxBuilder:
|
||||||
config_symbols = configuration_retrieve()
|
@staticmethod
|
||||||
os.chdir(LINUX_KERNELDIR)
|
def build_linux(container):
|
||||||
if not os.path.exists(LINUX_KERNEL_BUILDDIR):
|
print '\nBuilding the linux kernel...'
|
||||||
os.makedirs(LINUX_KERNEL_BUILDDIR)
|
|
||||||
os.system("make defconfig ARCH=arm O=" + LINUX_KERNEL_BUILDDIR)
|
|
||||||
os.system("make ARCH=arm " + \
|
|
||||||
"CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \
|
|
||||||
LINUX_KERNEL_BUILDDIR)
|
|
||||||
|
|
||||||
def clean():
|
# Create linux kernel build directory path
|
||||||
if os.path.exists(LINUX_KERNEL_BUILDDIR):
|
cont_builddir = join(BUILDDIR, "cont" + str(container.id))
|
||||||
shutil.rmtree(LINUX_KERNEL_BUILDDIR)
|
LINUX_KERNEL_BUILDDIR = join(cont_builddir, \
|
||||||
|
os.path.relpath(LINUX_KERNELDIR, \
|
||||||
|
PROJROOT))
|
||||||
|
|
||||||
|
os.chdir(LINUX_KERNELDIR)
|
||||||
|
if not os.path.exists(LINUX_KERNEL_BUILDDIR):
|
||||||
|
os.makedirs(LINUX_KERNEL_BUILDDIR)
|
||||||
|
os.system("make defconfig ARCH=arm O=" + LINUX_KERNEL_BUILDDIR)
|
||||||
|
os.system("make ARCH=arm " + \
|
||||||
|
"CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \
|
||||||
|
LINUX_KERNEL_BUILDDIR)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def clean(self):
|
||||||
|
if os.path.exists(LINUX_KERNEL_BUILDDIR):
|
||||||
|
shutil.rmtree(LINUX_KERNEL_BUILDDIR)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
container = Container()
|
||||||
|
container.id = 0
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
main()
|
LinuxBuilder.build_linux(container)
|
||||||
elif "clean" == sys.argv[1]:
|
elif "clean" == sys.argv[1]:
|
||||||
clean()
|
LinuxBuilder.clean()
|
||||||
else:
|
else:
|
||||||
print " Usage: %s [clean]" % (sys.argv[0])
|
print " Usage: %s [clean]" % (sys.argv[0])
|
||||||
|
|||||||
@@ -21,24 +21,28 @@ rootfs_lds_in = join(LINUX_ROOTFSDIR, "rootfs.lds.in")
|
|||||||
rootfs_lds_out = join(LINUX_ROOTFS_BUILDDIR, "rootfs.lds")
|
rootfs_lds_out = join(LINUX_ROOTFS_BUILDDIR, "rootfs.lds")
|
||||||
rootfs_elf_out = join(LINUX_ROOTFS_BUILDDIR, "rootfs.elf")
|
rootfs_elf_out = join(LINUX_ROOTFS_BUILDDIR, "rootfs.elf")
|
||||||
|
|
||||||
def main():
|
class BuildRootfs:
|
||||||
os.chdir(LINUX_ROOTFSDIR)
|
@staticmethod
|
||||||
config_symbols = configuration_retrieve()
|
def build_rootfs():
|
||||||
if not os.path.exists(LINUX_ROOTFS_BUILDDIR):
|
print 'Building the root filesystem...'
|
||||||
os.makedirs(LINUX_ROOTFS_BUILDDIR)
|
os.chdir(LINUX_ROOTFSDIR)
|
||||||
os.system("arm-none-linux-gnueabi-cpp -P " + \
|
config_symbols = configuration_retrieve()
|
||||||
"%s > %s" % (rootfs_lds_in, rootfs_lds_out))
|
if not os.path.exists(LINUX_ROOTFS_BUILDDIR):
|
||||||
os.system("arm-none-linux-gnueabi-gcc " + \
|
os.makedirs(LINUX_ROOTFS_BUILDDIR)
|
||||||
"-nostdlib -o %s -T%s rootfs.S" % (rootfs_elf_out, rootfs_lds_out))
|
os.system("arm-none-linux-gnueabi-cpp -P " + \
|
||||||
|
"%s > %s" % (rootfs_lds_in, rootfs_lds_out))
|
||||||
|
os.system("arm-none-linux-gnueabi-gcc " + \
|
||||||
|
"-nostdlib -o %s -T%s rootfs.S" % (rootfs_elf_out, rootfs_lds_out))
|
||||||
|
|
||||||
def clean():
|
@staticmethod
|
||||||
if os.path.exists(LINUX_ROOTFS_BUILDDIR):
|
def clean():
|
||||||
shutil.rmtree(LINUX_ROOTFS_BUILDDIR)
|
if os.path.exists(LINUX_ROOTFS_BUILDDIR):
|
||||||
|
shutil.rmtree(LINUX_ROOTFS_BUILDDIR)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
main()
|
BuildRootfs.build_rootfs()
|
||||||
elif "clean" == sys.argv[1]:
|
elif "clean" == sys.argv[1]:
|
||||||
clean()
|
BuildRootfs.clean()
|
||||||
else:
|
else:
|
||||||
print " Usage: %s [clean]" % (sys.argv[0])
|
print " Usage: %s [clean]" % (sys.argv[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user