diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-07-21 18:32:55 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-07-21 18:32:55 -0400 |
commit | d9e451fc01041dcbbc7558325c52783abf0efadd (patch) | |
tree | fb4e11774286c18da57ccc4130af2d466cced94f | |
parent | Added bkisofs ISO manipulation library and wrote CLI wrapper for it (diff) | |
download | ingenue-d9e451fc01041dcbbc7558325c52783abf0efadd.tar.gz ingenue-d9e451fc01041dcbbc7558325c52783abf0efadd.tar.bz2 ingenue-d9e451fc01041dcbbc7558325c52783abf0efadd.zip |
Integrated bkisofs-cli into livecd and installcd bundlers, fixed various things in bkisofs-cli and the backend
-rwxr-xr-x | backend/backend.php | 2 | ||||
-rw-r--r-- | backend/bundlers/installcd.php | 12 | ||||
-rw-r--r-- | backend/bundlers/livecd.php | 12 | ||||
-rw-r--r-- | backend/functions/execution.php | 10 | ||||
-rw-r--r-- | backend/functions/makedirs.php | 3 | ||||
-rw-r--r-- | frontend/pages/builds/download.php | 2 | ||||
-rw-r--r-- | lib/bkisofs-cli.c | 22 | ||||
-rw-r--r-- | shared/classes/0sql_row_obj.php | 2 | ||||
-rw-r--r-- | shared/config.php | 2 | ||||
-rw-r--r-- | shared/include/paths.php | 1 | ||||
-rw-r--r-- | todo | 6 |
11 files changed, 46 insertions, 28 deletions
diff --git a/backend/backend.php b/backend/backend.php index 9184694..c88f971 100755 --- a/backend/backend.php +++ b/backend/backend.php @@ -57,7 +57,7 @@ while (true) { $build->status=-1; $build->write(); $S['pdo']->query('UNLOCK TABLES'); - log_msg('Starting build id='.$build->id); + debug('Starting build id='.$build->id); $file=null; try { if ($conf['split_setup']) { diff --git a/backend/bundlers/installcd.php b/backend/bundlers/installcd.php index 90d549d..49420b0 100644 --- a/backend/bundlers/installcd.php +++ b/backend/bundlers/installcd.php @@ -1,12 +1,18 @@ <?php function bundle_installcd($I, $W, &$opts) { - $profile=new sql_gentoo_profile($opts); + $profile=new sql_gentoo_profile($opts['profile']); $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'"); + makedir("$I/boot"); + execute_command('Extract kernel, initrd, and squashfs from CD image ', LIB."/bkisofs-cli '$minimaliso' extract /isolinux/gentoo '$I/boot/kernel' extract /isolinux/gentoo.igz '$I/boot/initrd' extract /image.squashfs '$W/'"); + 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/image.squashfs'"); + execute_command('Compress finished image to tar/bzip2', "tar -p --same-owner -cjvf '$W/image.tar.bz2' -C '$I' ."); + execute_command('Create ISO image', LIB."/bkisofs-cli '$minimaliso' add / '$W/image.tar.bz2' write '$W/image.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/'"); @@ -16,6 +22,6 @@ function bundle_installcd($I, $W, &$opts) { // 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'"); + 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/livecd.php b/backend/bundlers/livecd.php index 6bee4fc..d269bd1 100644 --- a/backend/bundlers/livecd.php +++ b/backend/bundlers/livecd.php @@ -1,12 +1,18 @@ <?php function bundle_livecd($I, $W, &$opts) { - $profile=new sql_gentoo_profile($opts); + $profile=new sql_gentoo_profile($opts['profile']); $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'"); + makedir("$I/boot"); + execute_command('Extract kernel, initrd, and squashfs from CD image ', LIB."/bkisofs-cli '$minimaliso' extract /isolinux/gentoo '$I/boot/kernel' extract /isolinux/gentoo.igz '$I/boot/initrd' extract /image.squashfs '$W/'"); + 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/image.squashfs'"); + execute_command('Compress finished image to squashfs', "mksquashfs '$I' '$W/image.squashfs' -noappend -info"); + execute_command('Create ISO image', LIB."/bkisofs-cli '$minimaliso' replace /image.squashfs '$W/image.squashfs' write '$W/image.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/'"); @@ -17,7 +23,7 @@ function bundle_livecd($I, $W, &$opts) { // 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'"); + 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/functions/execution.php b/backend/functions/execution.php index 0aee4d6..f35e8c9 100644 --- a/backend/functions/execution.php +++ b/backend/functions/execution.php @@ -33,7 +33,7 @@ function execute_command_with_all($description, $command, $fatal=true, $path=nul $env=is_array($env)?array_merge($default_env, $env):$default_env; $task=new sql_task($build->id, task_get_order(), 'exec', $description, $command); $result=$task->execute($path, $env); - unset($task); + unset($GLOBALS['task']); if ($result != 0 && $fatal) { if ($result > 0) throw_exception($command.' returned with exit status '.$result); @@ -68,10 +68,12 @@ function start_internal_task($desc) { function end_internal_task($status=0) { global $task; if (isset($task)) { - $task->finish=time(); - $task->exit=$status; + if (!isset($task->finish)) + $task->finish=time(); + if (!isset($task->exit)) + $task->exit=$status; $task->write(); - unset($task); + unset($GLOBALS['task']); } } function log_msg($msg, $nl=true) { diff --git a/backend/functions/makedirs.php b/backend/functions/makedirs.php index eb572c9..68b0ba4 100644 --- a/backend/functions/makedirs.php +++ b/backend/functions/makedirs.php @@ -13,6 +13,7 @@ function makedir($dir) { global $workdir; if (substr($dir, 0, 1) != '/') $dir="$workdir/$dir"; - fatal(log_status('Creating '.$dir, mkdir($dir, 0700, true))); + if (!is_dir($dir)) + fatal(log_status('Creating '.$dir, mkdir($dir, 0700, true))); } ?> diff --git a/frontend/pages/builds/download.php b/frontend/pages/builds/download.php index 8ce338c..c662cf1 100644 --- a/frontend/pages/builds/download.php +++ b/frontend/pages/builds/download.php @@ -43,7 +43,7 @@ function init_builds_download() { } function body_builds_download() { global $S; - readfile($S['file']); + readfile($S['builds_download']['file']); // Log the download to db after sending data so hopefully HEAD requests won't artificially inflate the # of dls $S['builds_download']['dl']->write(); } diff --git a/lib/bkisofs-cli.c b/lib/bkisofs-cli.c index 5977c64..ee0a3a4 100644 --- a/lib/bkisofs-cli.c +++ b/lib/bkisofs-cli.c @@ -58,39 +58,41 @@ int main( int argv, char** argc) unsigned short i=3; char* slash; - for (i=3; i<argv; i++) { + for (i=2; i<argv; i++) { if (strcmp(argc[i], "replace") == 0 || strcmp(argc[i], "delete") == 0) { - printf("%s %s\n", argc[i], argc[i+1]); + printf("delete %s\n", argc[i+1]); rc = bk_delete(&volInfo, argc[i+1]); if (strcmp(argc[i], "delete") == 0) i++; } if (strcmp(argc[i], "add") == 0 || strcmp(argc[i], "replace") == 0) { - printf("%s %s -> %s\n", argc[i], argc[i+2], argc[i+1]); if (argc[i+1][strlen(argc[i+1])-1] == '/') { + printf("add %s -> %s\n", argc[i+2], argc[i+1]); rc = bk_add(&volInfo, argc[i+2], argc[i+1], addProgressUpdaterCbk); } else { slash=strrchr(argc[i+1], '/'); *slash='\0'; - rc = bk_add_as(&volInfo, argc[i+2], argc[i+1], slash+1, addProgressUpdaterCbk); + printf("add %s -> %s[/]%s\n", argc[i+2], argc[i+1][0]?argc[i+1]:"/", slash+1); + rc = bk_add_as(&volInfo, argc[i+2], argc[i+1][0]?argc[i+1]:"/", slash+1, addProgressUpdaterCbk); } i+=2; } else if (strcmp(argc[i], "rename") == 0) { - printf("%s %s -> %s\n", argc[i], argc[i+1], argc[i+2]); + printf("rename %s -> %s\n", argc[i+1], argc[i+2]); rc = bk_rename(&volInfo, argc[i++], argc[i++]); } else if (strcmp(argc[i], "write") == 0) { - printf("%s %s\n", argc[i], argc[i+1]); + printf("write %s\n", argc[i+1]); rc = bk_write_image(argc[i+1], &volInfo, time(NULL), volInfo.filenameTypes, writeProgressUpdaterCbk); } else if (strcmp(argc[i], "print") == 0) { printNameAndContents(BK_BASE_PTR( &(volInfo.dirTree) ), 0); } else if (strcmp(argc[i], "extract") == 0) { - printf("%s %s -> %s\n", argc[i], argc[i+1], argc[i+2]); - if (argc[i+1][strlen(argc[i+1])-1] == '/') { + if (argc[i+2][strlen(argc[i+2])-1] == '/') { + printf("extract %s -> %s\n", argc[i+1], argc[i+2]); rc = bk_extract(&volInfo, argc[i+1], argc[i+2], true, NULL); } else { - slash=strrchr(argc[i+1], '/'); + slash=strrchr(argc[i+2], '/'); *slash='\0'; - rc = bk_extract_as(&volInfo, argc[i+1], argc[i+2], slash+1, true, NULL); + printf("extract %s -> %s[/]%s\n", argc[i+1], argc[i+2][0]?argc[i+2]:"/", slash+1); + rc = bk_extract_as(&volInfo, argc[i+1], argc[i+2][0]?argc[i+2]:"/", slash+1, true, NULL); } i+=2; } diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php index a86552a..89a7382 100644 --- a/shared/classes/0sql_row_obj.php +++ b/shared/classes/0sql_row_obj.php @@ -271,7 +271,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up } $cols_filled++; } elseif ($from_db) { - throw new Exception('from_array called with $from_db=true, but column '.$name.' not specified.'); + throw new Exception('from_array called with $from_db=true, but column `'.$name.'` not specified.'); } } return $cols_filled; diff --git a/shared/config.php b/shared/config.php index 3920ad1..82efa59 100644 --- a/shared/config.php +++ b/shared/config.php @@ -14,7 +14,7 @@ $debug=true; // Whether to print debugging information // $timezone_root='/usr/share/zoneinfo'; // Directory to search for timezone data (sys-libs/timezone-data) $emailfrom='noreply@gentoo.org'; // Used as the From: field in emails $check_email_dns=true; // Use DNS to check the domain of submitted emails for validity -// $split_setup=false; // Whether the frontend and backend are running on different hosts +$split_setup=true; // Whether the frontend and backend are running on different hosts // Frontend options: // $registration=false; // Whether users can create new accounts without an invite // $invite='admin'; // Who can use the invite function: true or 'user'=users; admin=admins; false=nobody diff --git a/shared/include/paths.php b/shared/include/paths.php index 1efc9d3..d4220bf 100644 --- a/shared/include/paths.php +++ b/shared/include/paths.php @@ -6,6 +6,7 @@ $paths['frontend']=realpath($paths['root'].'/frontend'); $paths['work']=realpath($paths['root'].'/work'); $paths['completed']=realpath($paths['root'].'/completed'); $paths['cache']=realpath($paths['root'].'/cache'); +$paths['lib']=realpath($paths['root'].'/lib'); foreach ($paths as $name => $dest) { define(strtoupper($name), $dest); } @@ -6,13 +6,13 @@ Add a statistics page Add a profiles management page/backend utility Add cleanup functions to the frontend and backend (tasks dir in backend containing scripts that can be launched through frontend) Separate variables we got from the URL from the rest, stop using $request, instead keep super globals and strip slashes on them -Add masked indicator back to step2, support ~arch installation +Add masked indicator back to package selector, support ~arch installation Allow backend to define bail-out functions to call when it dies (things like unmounting the ISO it was copying) Add STDERR (maybe STDOUT) only option to log viewer Move bundler selection out of gentoo module and generalize it Improve the quality of base system creation (if necessary) + Figure out /lib -> /lib64 creation on amd64 Allow config viewing for builds, not just configurations -Write basic command-line wrapper to bkisofs and replace the ISO mounter with it -Fix emerge system cache to discard properly +Check if emerge system cache discards properly Add `flags` column to configurations, builds, use it to implement public and private things Clean up backend API |