summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-07-10 14:09:00 -0400
committerEudyptula <eitan@mosenkis.net>2009-07-10 14:09:00 -0400
commit06ab593e5dd40df96f79179a68ba8f3d7c70033a (patch)
tree75f4d351328893b2cf7f6f9e74951409212ac576 /backend
parentFinished porting package selection to new wizard format - everything works again (diff)
downloadingenue-06ab593e5dd40df96f79179a68ba8f3d7c70033a.tar.gz
ingenue-06ab593e5dd40df96f79179a68ba8f3d7c70033a.tar.bz2
ingenue-06ab593e5dd40df96f79179a68ba8f3d7c70033a.zip
Made bundling finished images separate from modules in backend; added metadata for frontend modules; added default config options and simplified config file; added verbose output to update_gentoo_profiles.php; etc.
Diffstat (limited to 'backend')
-rwxr-xr-xbackend/backend.php7
-rw-r--r--backend/bundlers/ext2.php12
-rw-r--r--backend/bundlers/installcd.php21
-rw-r--r--backend/bundlers/jffs2.php6
-rw-r--r--backend/bundlers/livecd.php23
-rw-r--r--backend/bundlers/tbz2.php6
-rw-r--r--backend/bundlers/tgz.php6
-rw-r--r--backend/modules/gentoo_portage/build.php44
8 files changed, 80 insertions, 45 deletions
diff --git a/backend/backend.php b/backend/backend.php
index d078191..5c77fc3 100755
--- a/backend/backend.php
+++ b/backend/backend.php
@@ -66,7 +66,7 @@ while (true) {
unset($opt);
}
$opts=$build->get_opts();
- $module=$opts['backend_module'];
+ $module=$opts['module'];
$build_proc=$module.'_build';
foreach (glob(BACKEND."/modules/$module/*.php") as $inc) {
require_once($inc);
@@ -74,7 +74,10 @@ while (true) {
// TODO check that build_proc exists
$workdir=WORK.'/build-'.$build->id;
fatal(log_status('Creating work directory '.$workdir, mkdir($workdir, 0700)));
- $file=$build_proc($build, $opts, $workdir);
+ $image=$build_proc($build, $opts, $workdir);
+ require_once(BACKEND."/bundlers/{$opts['bundler']}.php");
+ $proc='bundle_'.$opts['bundler'];
+ $file=$proc($image, $workdir, $opts);
if (!$conf['debug']) {
execute_command('Delete work directory', 'rm -rf "'.$workdir.'"');
}
diff --git a/backend/bundlers/ext2.php b/backend/bundlers/ext2.php
new file mode 100644
index 0000000..239b5bb
--- /dev/null
+++ b/backend/bundlers/ext2.php
@@ -0,0 +1,12 @@
+<?php
+function bundle_ext2($I, $W) {
+ execute_command('Make blank file for ext2 image', "dd if=/dev/zero of='$W/image.ext2' bs=1024 count=1048576");
+ execute_command('Make ext2 filesystem', "mke2fs -t ext2 -F '$W/image.ext2'");
+ makedir('ext2');
+ execute_command('Mount ext2 image', "mount -o loop -t ext2 '$W/image.ext2' '$W/ext2'");
+ execute_command('Copy files to ext2', "cp -va '$I/*' '$W/ext2/'");
+ execute_command('Unmount ext2 image', "umount '$W/ext2'");
+ execute_command('Compress ext2 image', "gzip '$W/image.ext2'");
+ return "$W/image.ext2.gz";
+}
+?>
diff --git a/backend/bundlers/installcd.php b/backend/bundlers/installcd.php
new file mode 100644
index 0000000..90d549d
--- /dev/null
+++ b/backend/bundlers/installcd.php
@@ -0,0 +1,21 @@
+<?php
+function bundle_installcd($I, $W, &$opts) {
+ $profile=new sql_gentoo_profile($opts);
+ $headers=$profile->get_headers();
+ if (strpos($headers['chost'], 'x86_64') === false)
+ $minimaliso='/home/eitan/soc/install-x86-minimal-20090623.iso';
+ else
+ $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
+ execute_command('Mount minimal CD image', "mount -o loop -t iso9660 '$minimaliso' '$W/tmp'");
+ execute_command('Copy CD image to writable temp directory', "cp -va '$W/tmp' '$W/cd'");
+ execute_command('Unmount CD image', "umount '$W/tmp'");
+ execute_command('Copy kernel and initrd from CD to image', "cp -va '$W/cd/isolinux/gentoo' '$W/cd/isolinux/gentoo.igz' '$I/boot/'");
+ file_put_contents("$W/unsquashfs-files", "/lib64/modules\n\lib\modules\n");
+ execute_command('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/cd/image.squashfs'");
+ execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/cd/image.tar.bz2' -C '$I' .");
+ // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh to support other bootloaders
+ // ISOLINUX bootloader
+ // mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}
+ execute_command('Create ISO image', "mkisofs -J -R -l -V 'Ingenue Build $build->id' -o '$W/image.iso' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table '$W/cd'");
+ return "$W/image.iso";
+}
diff --git a/backend/bundlers/jffs2.php b/backend/bundlers/jffs2.php
new file mode 100644
index 0000000..c8e5de2
--- /dev/null
+++ b/backend/bundlers/jffs2.php
@@ -0,0 +1,6 @@
+<?php
+function bundle_jffs2($I, $W) {
+ execute_command('Create JFFS2 image', "mkfs.jffs2 -x lzo -n -e 0x20000 -l -p -r '$I' -o '$W/image.jffs2'");
+ return "$W/image.jffs2";
+}
+?>
diff --git a/backend/bundlers/livecd.php b/backend/bundlers/livecd.php
new file mode 100644
index 0000000..6bee4fc
--- /dev/null
+++ b/backend/bundlers/livecd.php
@@ -0,0 +1,23 @@
+<?php
+function bundle_livecd($I, $W, &$opts) {
+ $profile=new sql_gentoo_profile($opts);
+ $headers=$profile->get_headers();
+ if (strpos($headers['chost'], 'x86_64') === false)
+ $minimaliso='/home/eitan/soc/install-x86-minimal-20090623.iso';
+ else
+ $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
+ execute_command('Mount minimal CD image', "mount -o loop -t iso9660 '$minimaliso' '$W/tmp'");
+ execute_command('Copy CD image to writable temp directory', "cp -va '$W/tmp' '$W/cd'");
+ execute_command('Unmount CD image', "umount '$W/tmp'");
+ execute_command('Copy kernel and initrd from CD to image', "cp -va '$W/cd/isolinux/gentoo' '$W/cd/isolinux/gentoo.igz' '$I/boot/'");
+ file_put_contents("$W/unsquashfs-files", "/lib64/modules\n\lib\modules\n");
+ execute_command('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/cd/image.squashfs'");
+ rename("$W/cd/image.squashfs", "$W/image.squashfs.old") || debug('Failed to move old SquashFS');
+ execute_command('Compress finished image to squashfs', "mksquashfs '$I' '$W/cd/image.squashfs' -noappend -info");
+ // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh to support other bootloaders
+ // ISOLINUX bootloader
+ // mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}
+ execute_command('Create ISO image', "mkisofs -J -R -l -V 'Ingenue Build $build->id' -o '$W/image.iso' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table '$W/cd'");
+ return "$W/image.iso";
+}
+?>
diff --git a/backend/bundlers/tbz2.php b/backend/bundlers/tbz2.php
new file mode 100644
index 0000000..ee69825
--- /dev/null
+++ b/backend/bundlers/tbz2.php
@@ -0,0 +1,6 @@
+<?php
+function bundle_tbz2($I, $W) {
+ execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/image.tar.bz2' -C '$I' .");
+ return "$W/image.tar.bz2";
+}
+?>
diff --git a/backend/bundlers/tgz.php b/backend/bundlers/tgz.php
new file mode 100644
index 0000000..3b604d3
--- /dev/null
+++ b/backend/bundlers/tgz.php
@@ -0,0 +1,6 @@
+<?php
+function bundle_tgz($I, $W) {
+ execute_command('Compress finished image to tar/gz', "tar -p --same-owner -czvf '$W/image.tar.gz' -C '$I' .");
+ return "$W/image.tar.gz";
+}
+?>
diff --git a/backend/modules/gentoo_portage/build.php b/backend/modules/gentoo_portage/build.php
index aa8e8b5..7d8b1bc 100644
--- a/backend/modules/gentoo_portage/build.php
+++ b/backend/modules/gentoo_portage/build.php
@@ -48,48 +48,6 @@ function gentoo_portage_build(&$build, &$opts, &$W) {
foreach ($pkgs as $atom)
execute_command_with_env('Install extra package '.$atom, 'emerge '.$atom, $prtg_cfgrt);
}
- $imgtype=isset($opts['image_type'])?$opts['image_type']:'tbz2';
- if ($imgtype == 'tbz2') {
- execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/image.tar.bz2' -C '$I' .");
- return "$W/image.tar.bz2";
- } elseif ($imgtype == 'tgz') {
- execute_command('Compress finished image to tar/gz', "tar -p --same-owner -czvf '$W/image.tar.gz' -C '$I' .");
- return "$W/image.tar.gz";
- } elseif ($imgtype == 'livecd' || $imgtype == 'installcd') {
- if (strpos($headers['chost'], 'x86_64') === false)
- $minimaliso='/home/eitan/soc/install-x86-minimal-20090623.iso';
- else
- $minimaliso='/home/eitan/soc/install-amd64-minimal-20090625.iso';
- execute_command('Mount minimal CD image', "mount -o loop -t iso9660 '$minimaliso' '$W/tmp'");
- execute_command('Copy CD image to writable temp directory', "cp -va '$W/tmp' '$W/cd'");
- execute_command('Unmount CD image', "umount '$W/tmp'");
- execute_command('Copy kernel and initrd from CD to image', "cp -va '$W/cd/isolinux/gentoo' '$W/cd/isolinux/gentoo.igz' '$I/boot/'");
- file_put_contents("$W/unsquashfs-files", "/lib64/modules\n\lib\modules\n");
- execute_command('Copy kernel modules from SquashFS to image', "unsquashfs -i -d '$I' -e '$W/unsquashfs-files' '$W/cd/image.squashfs'");
- if ($imgtype == 'livecd') {
- rename("$W/cd/image.squashfs", "$W/image.squashfs.old") || debug('Failed to move old SquashFS');
- execute_command('Compress finished image to squashfs', "mksquashfs '$I' '$W/cd/image.squashfs' -noappend -info");
- } else // Install CD
- execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/cd/image.tar.bz2' -C '$I' .");
- // TODO port the rest of /usr/lib/catalyst/targets/support/create-iso.sh to support other bootloaders
- // ISOLINUX bootloader
- // mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o ${1} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${clst_target_path}
- execute_command('Create ISO image', "mkisofs -J -R -l -V 'Ingenue Build $build->id' -o '$W/image.iso' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table '$W/cd'");
- return "$W/image.iso";
- } elseif ($imgtype == 'jffs2') {
- execute_command('Create JFFS2 image', "mkfs.jffs2 -x lzo -n -e 0x20000 -l -p -r '$I' -o '$W/image.jffs2'");
- return "$W/image.jffs2";
- } elseif ($imgtype == 'ext2') {
- execute_command('Make blank file for ext2 image', "dd if=/dev/zero of='$W/image.ext2' bs=1024 count=1048576");
- execute_command('Make ext2 filesystem', "mke2fs -t ext2 -F '$W/image.ext2'");
- makedir('ext2');
- execute_command('Mount ext2 image', "mount -o loop -t ext2 '$W/image.ext2' '$W/ext2'");
- execute_command('Copy files to ext2', "cp -va '$I/*' '$W/ext2/'");
- execute_command('Unmount ext2 image', "umount '$W/ext2'");
- execute_command('Compress ext2 image', "gzip '$W/image.ext2'");
- return "$W/image.ext2.gz";
- } else {
- throw_exception('invalid image type: '.$imgtype);
- }
+ return $I;
}
?>