From 70b66c71298399529ef32cb583973fd3f68a8a97 Mon Sep 17 00:00:00 2001 From: Eric Barboni Date: Tue, 25 Feb 2025 11:37:03 +0100 Subject: [PATCH] helper to have status of redirect + htaccess uc for usage in vm as root --- release-helpers/pmcrm.php | 108 +++++++++++++++++++++++++++++++++++ release-helpers/testpmcrm.sh | 4 ++ 2 files changed, 112 insertions(+) create mode 100644 release-helpers/pmcrm.php create mode 100755 release-helpers/testpmcrm.sh diff --git a/release-helpers/pmcrm.php b/release-helpers/pmcrm.php new file mode 100644 index 0000000..19c37ff --- /dev/null +++ b/release-helpers/pmcrm.php @@ -0,0 +1,108 @@ + 0 ? substr($haystack, -$length) === $needle : true; +} + +function getXML($filepath) { + if (endsWith($filepath, '.gz')) { + return simplexml_load_string(implode(gzfile($filepath))); + } else { + return simplexml_load_string(file_get_contents($filepath)); + } +} + +function checkUpdateFiles($filename, $version_name) { + global $baseuc; + $filepath = $baseuc . $version_name . '/' . $filename; + if (file_exists($filepath)) { + $xml = getXML($filepath); + echo str_pad($version_name, 6); + if ($xml->notification) { + if ($xml->notification != "A new version of Apache NetBeans IDE is available!") { + echo " $filename notified to " . $xml->notification; + } + return false; + } else { + echo " $filename not notified"; + } + echo " "; + } + return true; +} + +function displayActiveHtaccessLine($version_name) { + global $baseuc; + $filepath = $baseuc . $version_name . '/.htaccess'; + if (file_exists($filepath)) { + echo " htaccess[ "; + $content = file($filepath); + foreach ($content as $line) { + if (!((startsWith($line, '#') || empty(trim($line))))) { + echo str_replace("\n", "", $line) . " "; + } + } + echo "] "; + } +} + +function readInformationforBranch($branch_name, $data) { + $release_info = $data[$branch_name]; + echo "\n[" . str_pad($branch_name, 13) . "]... " . str_pad($release_info['position'], 3) . " "; + $version_name = str_replace('/updates.xml.gz', '', str_replace('/updates.xml.gz?{$netbeans.hash.code}', '', str_replace('https://netbeans.apache.org/nb/updates/', '', $release_info['update_url']))); +// check for update.xml + + $nonefound = true; + $nonefound &= checkUpdateFiles('updates.xml', $version_name); + $nonefound &= checkUpdateFiles('updates.xml.gz', $version_name); + + if ($nonefound) { + echo 'no notification found in updates.xml(.gz ) for' . $version_name . " "; + } + displayActiveHtaccessLine($version_name); +} + +if (false === $json) { + echo "$json something is wrong with json"; +} else { + echo $json; + $data = array_reverse(json_decode($json, true)); + $master = array_shift($data); // remove master from array + + foreach (array_keys($data) as $branch_name) { + readInformationforBranch($branch_name, $data); + } + echo "\n"; +} +?> + diff --git a/release-helpers/testpmcrm.sh b/release-helpers/testpmcrm.sh new file mode 100755 index 0000000..02b8ed9 --- /dev/null +++ b/release-helpers/testpmcrm.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +/usr/bin/php ./pmcrm.php +