summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-08-13 17:35:58 -0400
committerEudyptula <eitan@mosenkis.net>2009-08-13 17:35:58 -0400
commit3d5c48d6d0c249d5a51318d3524c2d40e8bf1df9 (patch)
treeb4f5d2c673aadbc786eb54c7f4dc32dba8dcdf46 /shared
parentVarious improvements to HTML forms classes; Updated login to use form object;... (diff)
downloadingenue-3d5c48d6d0c249d5a51318d3524c2d40e8bf1df9.tar.gz
ingenue-3d5c48d6d0c249d5a51318d3524c2d40e8bf1df9.tar.bz2
ingenue-3d5c48d6d0c249d5a51318d3524c2d40e8bf1df9.zip
Wrote a script for automatically keeping cache files (stage3, install ISO, etc.) up to date by ftp, updated frontend and backend to reflect storing stage3 and iso filenames in the 'cache' table instead of 'gentoo_profiles'
Diffstat (limited to 'shared')
-rw-r--r--shared/classes/cache_entry.php21
-rw-r--r--shared/classes/gentoo_baseinit.php10
-rw-r--r--shared/classes/gentoo_basepkg.php11
-rw-r--r--shared/classes/gentoo_profile.php38
-rw-r--r--shared/config.php1
-rw-r--r--shared/functions/load_config.php2
-rw-r--r--shared/include/defaults.php1
-rw-r--r--shared/include/includes.php3
8 files changed, 43 insertions, 44 deletions
diff --git a/shared/classes/cache_entry.php b/shared/classes/cache_entry.php
new file mode 100644
index 0000000..4395632
--- /dev/null
+++ b/shared/classes/cache_entry.php
@@ -0,0 +1,21 @@
+<?php
+class sql_cache_entry extends sql_row_obj {
+ protected $table='cache', $primary_key=array('type', 'key'), $columns=array(
+ 'type' => array (
+ 'type' => 'ENUM',
+ 'length' => '\'cd\',\'portage\',\'stage3\'',
+ 'not_null' => true
+ ),
+ 'key' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
+ ),
+ 'file' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255
+ )
+
+ );
+}
+?>
diff --git a/shared/classes/gentoo_baseinit.php b/shared/classes/gentoo_baseinit.php
index 03c9569..c9acc4e 100644
--- a/shared/classes/gentoo_baseinit.php
+++ b/shared/classes/gentoo_baseinit.php
@@ -1,12 +1,10 @@
<?php
class sql_gentoo_baseinit extends sql_row_obj {
protected $table='gentoo_baseinit', $columns=array(
- 'profile' => array (
- 'type' => 'TINYINT',
- 'length' => 3,
- 'unsigned' => true,
- 'not_null' => true,
- 'default' => 0
+ 'key' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
),
'name' => array (
'type' => 'VARCHAR',
diff --git a/shared/classes/gentoo_basepkg.php b/shared/classes/gentoo_basepkg.php
index d61b3dc..c140ee9 100644
--- a/shared/classes/gentoo_basepkg.php
+++ b/shared/classes/gentoo_basepkg.php
@@ -1,13 +1,10 @@
<?php
class sql_gentoo_basepkg extends sql_row_obj {
protected $table='gentoo_basepkgs', $columns=array(
- 'profile' => array (
- 'type' => 'TINYINT',
- 'length' => 3,
- 'unsigned' => true,
- 'not_null' => true,
- 'default' => 0,
- 'refers_to' => 'gentoo_profiles.id'
+ 'key' => array (
+ 'type' => 'VARCHAR',
+ 'length' => 255,
+ 'not_null' => true
),
'pkg' => array (
'type' => 'VARCHAR',
diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php
index d7726f8..d41497b 100644
--- a/shared/classes/gentoo_profile.php
+++ b/shared/classes/gentoo_profile.php
@@ -15,12 +15,6 @@ class sql_gentoo_profile extends sql_row_obj {
'default' => '',
'unique' => true
),
- 'stage3' => array (
- 'type' => 'VARCHAR',
- 'length' => 255,
- 'not_null' => true,
- 'default' => ''
- ),
'name' => array (
'type' => 'VARCHAR',
'length' => 255,
@@ -171,30 +165,6 @@ class sql_gentoo_profile extends sql_row_obj {
if ($update)
query('DELETE FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.($exists?' AND `id` NOT IN ('.implode(',', $exists).')':''));
}
- public function read_stage3($update=false) {
- global $S;
- if ($update) {
- query('DELETE FROM `gentoo_basepkgs` WHERE `profile`='.$this->id);
- query('DELETE FROM `gentoo_baseinit` WHERE `profile`='.$this->id);
- }
- $file=realpath(CACHE.'/stage3/'.$this->stage3);
- if (!is_readable($file)) return false;
- $opt='-tv'.(substr($file, -3) == 'bz2'?'j':'z').'f';
- $prefix='./var/db/pkg/';
- $files=explode("\n", is_readable("$file.CONTENTS")?file_get_contents("$file.CONTENTS"):shell_exec('tar '.$opt.' '.escapeshellarg($file)));
- if (!is_file("$file.CONTENTS"))
- file_put_contents("$file.CONTENTS", implode("\n", $files));
- foreach ($files as $file) {
- if (preg_match('#^[^.]+\./var/db/pkg/(.*/.*)/$#', $file, $match)) {
- $pkg=new sql_gentoo_basepkg($this->id, $match[1]);
- $pkg->write();
- } elseif (preg_match('#^[^.]+\./etc/runlevels/([^/]+)/([^/]+) -> /etc/init\.d/#', $file, $match)) {
- $init=new sql_gentoo_baseinit($this->id, $match[2], $match[1]);
- $init->write();
- }
- }
- return true;
- }
public function &get_packages($omit_masked=false, $trim=null) {
global $S;
$skip_masked=!in_array('masked', $trim);
@@ -214,5 +184,13 @@ class sql_gentoo_profile extends sql_row_obj {
$arch=ltrim($arch[0], '~');
return $arch;
}
+ function is_hardened() {
+ $profile=$this->get_headers();
+ $profile=$profile['profile'];
+ return (strpos(strtolower($profile), 'hardened') !== false);
+ }
+ function get_identifier() {
+ return ($this->is_hardened()?'hardened-':'').$this->get_arch();
+ }
}
?>
diff --git a/shared/config.php b/shared/config.php
index 8a93454..e8ed1e2 100644
--- a/shared/config.php
+++ b/shared/config.php
@@ -25,4 +25,5 @@ $pkgdir_root='/home/eitan/soc/tinderbox'; // The directory to recursively search
// $emerge_default_opts='-v --color=y'; // Options to add to all emerge commands
// $portdir='/usr/portage'; // The directory conatining the portage tree to use (/usr/portage unless you have a reason to think otherwise)
$backend_id='red'; // A name or other way of identifying this backend as opposed to other backends working for the same frontend
+// $tmpdir=isset($_ENV['TMPDIR'])?$_ENV['TMPDIR'].'/ingenue':'/var/tmp/ingenue'; // The directory to use for temporary files
?>
diff --git a/shared/functions/load_config.php b/shared/functions/load_config.php
index d719fb9..4560f5d 100644
--- a/shared/functions/load_config.php
+++ b/shared/functions/load_config.php
@@ -3,7 +3,7 @@ function load_config() {
require(SHARED.'/include/defaults.php');
require(SHARED.'/config.php');
$modules=explode(' ', $modules);
- foreach (explode(' ', 'title url sqlhost sqluser sqlpass sqldb debug modules bundlers cookiename sessionlength mod_rewrite timezone_root emailfrom check_email_dns registration invite logview_max progressbar_width pkgdir_root emerge_default_opts portdir backend_id') as $var) {
+ foreach (explode(' ', 'title url sqlhost sqluser sqlpass sqldb debug modules bundlers cookiename sessionlength mod_rewrite timezone_root emailfrom check_email_dns registration invite logview_max progressbar_width pkgdir_root emerge_default_opts portdir backend_id tmpdir') as $var) {
if (isset($$var)) {
$GLOBALS['S']['conf'][$var]=$$var;
}
diff --git a/shared/include/defaults.php b/shared/include/defaults.php
index 95cbfc2..057e5fd 100644
--- a/shared/include/defaults.php
+++ b/shared/include/defaults.php
@@ -30,4 +30,5 @@ $progressbar_width=350;
$emerge_default_opts='-v --color=y';
$portdir='/usr/portage';
//$backend_id=gethostname(); // TODO Uncomment in 5.3.0
+$tmpdir=isset($_ENV['TMPDIR'])?$_ENV['TMPDIR'].'/ingenue':'/var/tmp/ingenue';
?>
diff --git a/shared/include/includes.php b/shared/include/includes.php
index 8a75b58..c7491ae 100644
--- a/shared/include/includes.php
+++ b/shared/include/includes.php
@@ -11,4 +11,7 @@ foreach (array('functions', 'classes') as $type) {
}
unset($dir, $file, $type);
load_config();
+define('TMPDIR', $S['conf']['tmpdir']);
+if (!is_dir(TMPDIR))
+ mkdir(TMPDIR, 0700);
?>