summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'versioncp/update_versions.php')
-rw-r--r--versioncp/update_versions.php494
1 files changed, 0 insertions, 494 deletions
diff --git a/versioncp/update_versions.php b/versioncp/update_versions.php
deleted file mode 100644
index 10feedf..0000000
--- a/versioncp/update_versions.php
+++ /dev/null
@@ -1,494 +0,0 @@
-<?php
-
-# == Settings ==
-
-$dbuser = 'root';
-$dbpass = 'root';
-$dbname = 'versioncp';
-$debug = 'off';
-
-// one of 'off', 'normal', 'full'
-
-$overbasepath = '/usr/overlays';
-$upstscriptsbasepath = '/var/www/localhost/htdocs/versioncp/upstscripts';
-
-# == End Settings ==
-# Update the main Portage tree
-
-if($debug === 'normal'
- || $debug === 'full')
-{
- echo 'Running emerge --sync now ...' . "\n";
-}
-
-$emergesync = shell_exec('emerge --sync');
-
-if($debug === 'full')
-{
- echo $emergesync . "\n";
-}
-
-# Connect to the database
-
-$db = mysql_connect(':/var/run/mysqld/mysqld.sock', $dbuser, $dbpass);
-mysql_select_db($dbname, $db);
-
-# Get the overlay data, then update it
-
-$overlays_dbresult = mysql_query('SELECT `overname`,`overtype`,`overbranch` FROM `overlays`', $db);
-$alloverlayspath = '';
-
-while($overlays = mysql_fetch_array($overlays_dbresult))
-{
- $overpath = '';
- $overpath = $overbasepath . '/' . $overlays['overtype'] . '/' . $overlays['overname'] . '/' . $overlays['overbranch'] . '/';
-
- if($debug === 'normal'
- || $debug === 'full')
- {
- echo 'Working on overlay: ' . $overlays['overtype'] . ' ' . $overlays['overname'] . ', branch: ' . $overlays['overbranch'] . "\n";
- echo 'at path: ' . $overpath . "\n";
- }
-
- if(file_exists($overpath))
- {
- $overupdout = '';
- $overupdout = shell_exec('cd "' . $overpath . '" && svn up');
-
- if($debug === 'normal'
- || $debug === 'full')
- {
- echo 'Updating overlay ...' . "\n";
- }
-
- if($debug === 'full')
- {
- echo $overupdout . "\n";
- }
- }
- else
- {
- $overcotout = '';
- $overcotout = shell_exec('svn co "http://overlays.gentoo.org/svn/' . $overlays['overtype'] . '/' . $overlays['overname'] . '/' . $overlays['overbranch'] . '/" "' . $overpath . '"');
-
- if($debug === 'normal'
- || $debug === 'full')
- {
- echo 'Checking out overlay ...' . "\n";
- }
-
- if($debug === 'full')
- {
- echo $overcotout . "\n";
- }
- }
-
- $alloverlayspath = $alloverlayspath . $overpath . ' ';
-}
-
-$alloverlayspath = trim($alloverlayspath);
-exec('sed -e "s|^PORTDIR_OVERLAY=.*|PORTDIR_OVERLAY=\"' . $alloverlayspath . '\"|g" -i "/etc/make.conf"');
-
-# Generate two arrays of all the project and developer overlays
-
-$overlays_overdbresult = mysql_query('SELECT `overname`,`overtype` FROM `overlays`', $db);
-$proj_array = array();
-$dev_array = array();
-
-while($overlays_result = mysql_fetch_array($overlays_overdbresult))
-{
- if($overlays_result['overtype'] === 'proj')
- {
- $proj_temp_array = '';
- $proj_temp_array[$overlays_result['overname']] = $overlays_result['overname'];
- $proj_array = array_merge($proj_array, $proj_temp_array);
- }
- else
- {
- $dev_temp_array = '';
- $dev_temp_array[$overlays_result['overname']] = $overlays_result['overname'];
- $dev_array = array_merge($dev_array, $dev_temp_array);
- }
-}
-
-if($debug === 'full')
-{
- echo 'Proj Array:' . "\n";
- var_dump($proj_array) . "\n\n";
- echo 'Dev Array:' . "\n";
- var_dump($dev_array) . "\n\n";
-}
-
-# Work on the project overlays
-
-foreach($proj_array as $proj)
-{
- # Get the overlay data
-
- $overlays_dbresult = '';
- $overlays_dbresult = mysql_query('SELECT `overbranch` FROM `overlays` WHERE `overtype` = "proj" AND `overname` = "' . $proj . '"', $db);
-
- # Prepare the list of overlays to exclude
-
- $alloverlayspathproj = '';
- $alloverlayspathproj = $alloverlayspath;
-
- while($overlaysproj = mysql_fetch_array($overlays_dbresult))
- {
- $overpath = '';
- $overpath = $overbasepath . '/proj/' . $proj . '/' . $overlaysproj['overbranch'] . '/';
- $alloverlayspathproj = str_replace($overpath, '', $alloverlayspathproj);
- }
-
- $alloverlayspathproj = str_replace(' ', ' ', $alloverlayspathproj);
- $alloverlayspathproj = str_replace(' ', ' ', $alloverlayspathproj);
- $alloverlayspathproj = str_replace(' ', ' ', $alloverlayspathproj);
- $alloverlayspathproj = str_replace(' ', ' ', $alloverlayspathproj);
- $alloverlayspathproj = trim($alloverlayspathproj);
- $projtoexcludecmd = '--exclude-overlay /usr/portage/ ';
-
- if($alloverlayspathproj != '')
- {
- $alloverlayspathproj = explode(' ', $alloverlayspathproj);
- foreach($alloverlayspathproj as $projpaths)
- {
- $projtoexcludecmd = $projtoexcludecmd . '--exclude-overlay ' . $projpaths . ' ';
- }
- }
-
- $projtoexcludecmd = trim($projtoexcludecmd);
-
- # Update eix, excluding the other overlays and /usr/portage/
-
- $updateeix = shell_exec('update-eix ' . $projtoexcludecmd);
-
- if($debug === 'full')
- {
- echo $updateeix . "\n";
- }
-
- # Get the package data, for latest Overlay
-
- $packages_dbresult = '';
- $packages_dbresult = mysql_query('SELECT `name` FROM `packages` WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" ORDER BY `name` ASC', $db);
-
- # Get the latest version in the Overlay, and store it into MySQL
-
- while($projpkg_result = mysql_fetch_array($packages_dbresult))
- {
- $latestpkgover = shell_exec('eix -e ' . $projpkg_result['name'] . ' | grep -i available | head -n 1 | awk \'{print $NF}\'');
-
- if($latestpkgover == '')
- {
- $latestpkgover = '-';
- }
-
- $latestpkgover = str_replace('~', '', $latestpkgover);
- $latestpkgover = str_replace('!', '', $latestpkgover);
- $latestpkgover = str_replace('[M]', '', $latestpkgover);
- $latestpkgover = str_replace('_', '', $latestpkgover);
- $latestpkgover = str_replace('-r', 'pl', $latestpkgover);
- $latestpkgover = trim($latestpkgover);
-
- if($debug === 'full')
- {
- echo 'Latest in Overlay for proj ' . $proj . ': ' . $projpkg_result['name'] . ' - ' . $latestpkgover . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versover` = "' . $latestpkgover . '" WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" AND `name` = "' . $projpkg_result['name'] . '"', $db);
- }
-
- # Prepare the list of all overlays to exclude
-
- $alloverlayspathproj = '';
- $alloverlayspathproj = $alloverlayspath;
- $alloverlayspathproj = explode(' ', $alloverlayspathproj);
- $projtoexcludecmd = '';
- foreach($alloverlayspathproj as $projpaths)
- {
- $projtoexcludecmd = $projtoexcludecmd . '--exclude-overlay ' . $projpaths . ' ';
- }
-
- $projtoexcludecmd = trim($projtoexcludecmd);
-
- # Update eix, including only /usr/portage/
-
- $updateeix = shell_exec('update-eix ' . $projtoexcludecmd);
-
- if($debug === 'full')
- {
- echo $updateeix . "\n";
- }
-
- # Get the package data, for latest Portage
-
- $packages_dbresult = '';
- $packages_dbresult = mysql_query('SELECT `name` FROM `packages` WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" ORDER BY `name` ASC', $db);
-
- # Get the latest version in the Portage tree, and store it into MySQL
-
- while($projpkgp_result = mysql_fetch_array($packages_dbresult))
- {
- $latestpkgport = shell_exec('eix -e ' . $projpkgp_result['name'] . ' | grep -i available | head -n 1 | awk \'{print $NF}\'');
-
- if($latestpkgport == '')
- {
- $latestpkgport = '-';
- }
-
- $latestpkgport = str_replace('~', '', $latestpkgport);
- $latestpkgport = str_replace('!', '', $latestpkgport);
- $latestpkgport = str_replace('[M]', '', $latestpkgport);
- $latestpkgport = str_replace('_', '', $latestpkgport);
- $latestpkgport = str_replace('-r', 'pl', $latestpkgport);
- $latestpkgport = trim($latestpkgport);
-
- if($debug === 'full')
- {
- echo 'Latest in Portage for proj ' . $proj . ': ' . $projpkgp_result['name'] . ' - ' . $latestpkgport . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versport` = "' . $latestpkgport . '" WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" AND `name` = "' . $projpkgp_result['name'] . '"', $db);
- }
-
- # Get the package data, for latest Upstream
-
- $packages_dbresult = '';
- $packages_dbresult = mysql_query('SELECT `name`,`versupst`,`upstscript` FROM `packages` WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" ORDER BY `name` ASC', $db);
-
- # Get the latest version Upstream, and store it into MySQL
-
- while($projpkgu_result = mysql_fetch_array($packages_dbresult))
- {
- if($projpkgu_result['upstscript'] != '')
- {
- $latestpkgupst = shell_exec($upstscriptsbasepath . '/' . $projpkgu_result['upstscript'] . ' ' . $projpkgu_result['name']);
-
- if($latestpkgupst == '')
- {
- $latestpkgupst = '-';
- }
-
- $latestpkgupst = trim($latestpkgupst);
-
- if($latestpkgupst == '-'
- && $projpkgu_result['versupst'] != ''
- && $projpkgu_result['versupst'] != '-')
- {
- if($debug === 'full')
- {
- echo 'Latest Upstream for proj ' . $proj . ': ' . $projpkgu_result['name'] . ' - ' . $projpkgu_result['versupst'] . "\n";
- }
- }
- else
- {
- if($debug === 'full')
- {
- echo 'Latest Upstream for proj ' . $proj . ': ' . $projpkgu_result['name'] . ' - ' . $latestpkgupst . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versupst` = "' . $latestpkgupst . '" WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" AND `name` = "' . $projpkgu_result['name'] . '"', $db);
- }
- }
- else
- {
- $latestpkgupst = '-';
- $latestpkgupst = trim($latestpkgupst);
-
- if($debug === 'full')
- {
- echo 'Latest Upstream for proj ' . $proj . ': ' . $projpkgu_result['name'] . ' - ' . $latestpkgupst . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versupst` = "' . $latestpkgupst . '" WHERE `projtype` = "proj" AND `projname` = "' . $proj . '" AND `name` = "' . $projpkgu_result['name'] . '"', $db);
- }
- }
-}
-
-# Work on the developer overlays
-
-foreach($dev_array as $dev)
-{
- # Get the overlay data
-
- $overlays_dbresult = '';
- $overlays_dbresult = mysql_query('SELECT `overbranch` FROM `overlays` WHERE `overtype` = "dev" AND `overname` = "' . $dev . '"', $db);
-
- # Prepare the list of overlays to exclude
-
- $alloverlayspathdev = '';
- $alloverlayspathdev = $alloverlayspath;
-
- while($overlaysdev = mysql_fetch_array($overlays_dbresult))
- {
- $overpath = '';
- $overpath = $overbasepath . '/dev/' . $dev . '/' . $overlaysdev['overbranch'] . '/';
- $alloverlayspathdev = str_replace($overpath, '', $alloverlayspathdev);
- }
-
- $alloverlayspathdev = str_replace(' ', ' ', $alloverlayspathdev);
- $alloverlayspathdev = str_replace(' ', ' ', $alloverlayspathdev);
- $alloverlayspathdev = str_replace(' ', ' ', $alloverlayspathdev);
- $alloverlayspathdev = str_replace(' ', ' ', $alloverlayspathdev);
- $alloverlayspathdev = trim($alloverlayspathdev);
- $devtoexcludecmd = '--exclude-overlay /usr/portage/ ';
-
- if($alloverlayspathdev != '')
- {
- $alloverlayspathdev = explode(' ', $alloverlayspathdev);
- foreach($alloverlayspathdev as $devpaths)
- {
- $devtoexcludecmd = $devtoexcludecmd . '--exclude-overlay ' . $devpaths . ' ';
- }
- }
-
- $devtoexcludecmd = trim($devtoexcludecmd);
-
- # Update eix, excluding the other overlays and /usr/portage/
-
- $updateeix = shell_exec('update-eix ' . $devtoexcludecmd);
-
- if($debug === 'full')
- {
- echo $updateeix . "\n";
- }
-
- # Get the package data, for latest Overlay
-
- $packages_dbresult = '';
- $packages_dbresult = mysql_query('SELECT `name` FROM `packages` WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" ORDER BY `name` ASC', $db);
-
- # Get the latest version in the Overlay, and store it into MySQL
-
- while($devpkg_result = mysql_fetch_array($packages_dbresult))
- {
- $latestpkgover = shell_exec('eix -e ' . $devpkg_result['name'] . ' | grep -i available | head -n 1 | awk \'{print $NF}\'');
-
- if($latestpkgover == '')
- {
- $latestpkgover = '-';
- }
-
- $latestpkgover = str_replace('~', '', $latestpkgover);
- $latestpkgover = str_replace('!', '', $latestpkgover);
- $latestpkgover = str_replace('[M]', '', $latestpkgover);
- $latestpkgover = str_replace('_', '', $latestpkgover);
- $latestpkgover = str_replace('-r', 'pl', $latestpkgover);
- $latestpkgover = trim($latestpkgover);
-
- if($debug === 'full')
- {
- echo 'Latest in Overlay for dev ' . $dev . ': ' . $devpkg_result['name'] . ' - ' . $latestpkgover . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versover` = "' . $latestpkgover . '" WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" AND `name` = "' . $devpkg_result['name'] . '"', $db);
- }
-
- # Prepare the list of all overlays to exclude
-
- $alloverlayspathdev = '';
- $alloverlayspathdev = $alloverlayspath;
- $alloverlayspathdev = explode(' ', $alloverlayspathdev);
- $devtoexcludecmd = '';
- foreach($alloverlayspathdev as $devpaths)
- {
- $devtoexcludecmd = $devtoexcludecmd . '--exclude-overlay ' . $devpaths . ' ';
- }
-
- $devtoexcludecmd = trim($devtoexcludecmd);
-
- # Update eix, including only /usr/portage/
-
- $updateeix = shell_exec('update-eix ' . $devtoexcludecmd);
-
- if($debug === 'full')
- {
- echo $updateeix . "\n";
- }
-
- # Get the package data, for latest Portage
-
- $packages_dbresult = '';
- $packages_dbresult = mysql_query('SELECT `name` FROM `packages` WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" ORDER BY `name` ASC', $db);
-
- # Get the latest version in the Portage tree, and store it into MySQL
-
- while($devpkgp_result = mysql_fetch_array($packages_dbresult))
- {
- $latestpkgport = shell_exec('eix -e ' . $devpkgp_result['name'] . ' | grep -i available | head -n 1 | awk \'{print $NF}\'');
-
- if($latestpkgport == '')
- {
- $latestpkgport = '-';
- }
-
- $latestpkgport = str_replace('~', '', $latestpkgport);
- $latestpkgport = str_replace('!', '', $latestpkgport);
- $latestpkgport = str_replace('[M]', '', $latestpkgport);
- $latestpkgport = str_replace('_', '', $latestpkgport);
- $latestpkgport = str_replace('-r', 'pl', $latestpkgport);
- $latestpkgport = trim($latestpkgport);
-
- if($debug === 'full')
- {
- echo 'Latest in Portage for dev ' . $dev . ': ' . $devpkgp_result['name'] . ' - ' . $latestpkgport . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versport` = "' . $latestpkgport . '" WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" AND `name` = "' . $devpkgp_result['name'] . '"', $db);
- }
-}
-
-# Get the package data, for latest Upstream
-
-$packages_dbresult = '';
-$packages_dbresult = mysql_query('SELECT `name`,`versupst`,`upstscript` FROM `packages` WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" ORDER BY `name` ASC', $db);
-
-# Get the latest version Upstream, and store it into MySQL
-
-while($devpkgu_result = mysql_fetch_array($packages_dbresult))
-{
- if($devpkgu_result['upstscript'] != '')
- {
- $latestpkgupst = shell_exec($upstscriptsbasepath . '/' . $devpkgu_result['upstscript'] . ' ' . $devpkgu_result['name']);
-
- if($latestpkgupst == '')
- {
- $latestpkgupst = '-';
- }
-
- $latestpkgupst = trim($latestpkgupst);
-
- if($latestpkgupst == '-'
- && $devpkgu_result['versupst'] != ''
- && $devpkgu_result['versupst'] != '-')
- {
- if($debug === 'full')
- {
- echo 'Latest Upstream for dev ' . $dev . ': ' . $devpkgu_result['name'] . ' - ' . $devpkgu_result['versupst'] . "\n";
- }
- }
- else
- {
- if($debug === 'full')
- {
- echo 'Latest Upstream for dev ' . $dev . ': ' . $devpkgu_result['name'] . ' - ' . $latestpkgupst . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versupst` = "' . $latestpkgupst . '" WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" AND `name` = "' . $devpkgu_result['name'] . '"', $db);
- }
- }
- else
- {
- $latestpkgupst = '-';
- $latestpkgupst = trim($latestpkgupst);
-
- if($debug === 'full')
- {
- echo 'Latest Upstream for dev ' . $dev . ': ' . $devpkgu_result['name'] . ' - ' . $latestpkgupst . "\n";
- }
-
- mysql_query('UPDATE `packages` SET `versupst` = "' . $latestpkgupst . '" WHERE `projtype` = "dev" AND `projname` = "' . $dev . '" AND `name` = "' . $devpkgu_result['name'] . '"', $db);
- }
-}
-
-?> \ No newline at end of file