[TikiWiki-commits] [Git][tikiwiki/tiki][24.x] [BP][REF] Fix .tar.* build package script and Improve directory scanning

"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69d82f6067dae_3b1a592825056@gitlab-sidekiq-low-urgency-cpu-bound-v2-d5f7cf479-ll7rq.mail>

ushindi bienvenu pushed to branch 24.x at Tiki Wiki CMS Groupware / Tiki


Commits:
e25c8b22 by ushindi bienvenu at 2026-04-09T22:53:09+00:00
[BP][REF] Fix .tar.* build package script and Improve directory scanning
---
* [BP][REF] Fix .tar.* build package script and Improve directory scanning
---
* [BP][REF] Fix .tar.* build package script and Improve directory scanning
---
* [BP][REF] Fix .tar.* build package script and Improve directory scanning
---
* [REF] Fix .tar.* build package script and Improve directory scanning
---
* [REF] Fix .tar.* build package script and Improve directory scanning

See merge request tikiwiki/tiki!9752

See merge request tikiwiki/tiki!9975

See merge request tikiwiki/tiki!9977

See merge request tikiwiki/tiki!9980

See merge request tikiwiki/tiki!9985

- - - - -


1 changed file:

- doc/devtools/release.php


Changes:

=====================================
doc/devtools/release.php
=====================================
@@ -310,23 +310,23 @@ function updateSecdb($version)
 
         $insertString = 'INSERT INTO `tiki_secdb` (`filename`, `md5_value`, `tiki_version`) VALUES ';
 
-        $extendedInsertSize=0;
-        $extendedInsertMaxSize=1*1024*1024 - 100; // 1MB with 100 bytes safety limit, some old versions of Mysql had max_allowed_packet=1MB
+        $extendedInsertSize = 0;
+        $extendedInsertMaxSize = 1 * 1024 * 1024 - 100; // 1MB with 100 bytes safety limit, some old versions of Mysql had max_allowed_packet=1MB
 
         foreach ($queries as $q) {
-            if (($extendedInsertSize + strlen($q) + 2) > $extendedInsertMaxSize ) {
-                fwrite($fp,";\n");
-                $extendedInsertSize=0;
+            if (($extendedInsertSize + strlen($q) + 2) > $extendedInsertMaxSize) {
+                fwrite($fp, ";\n");
+                $extendedInsertSize = 0;
             }
             if ($extendedInsertSize === 0) {
-                fwrite($fp, $insertString ."\n");
+                fwrite($fp, $insertString . "\n");
                 $extendedInsertSize = strlen($insertString) + 1;
             } else {
                 fwrite($fp, ",\n");
-                $extendedInsertSize+=2;
+                $extendedInsertSize += 2;
             }
             fwrite($fp, $q);
-            $extendedInsertSize+=strlen($q);
+            $extendedInsertSize += strlen($q);
         }
         fwrite($fp, ";\n");
 
@@ -447,35 +447,29 @@ function rrmdir($dir)
 
 function removeFiles($src, $files)
 {
-    $dir = opendir($src);
-    while (false !== ($file = readdir($dir))) {
-        if (($file != '.') && ($file != '..')) {
-            $full = $src . '/' . $file;
-            if (is_dir($full)) {
-                $flag = false;
-
-                foreach ($files as $delfile) {
-                    if (basename($full) === $delfile) {
-                        rrmdir($full);
-                        $flag = true;
-                        break;
-                    }
-                }
-                if (! $flag) {
-                    removeFiles($full, $files);
-                }
-            } else {
-                foreach ($files as $delfile) {
-                    if (basename($full) === $delfile) {
-                        @chmod($full, 0777);
-                        unlink($full);
-                        break;
-                    }
-                }
+    $lookup = array_flip($files);
+
+    $iterator = new RecursiveIteratorIterator(
+        new RecursiveDirectoryIterator($src, FilesystemIterator::SKIP_DOTS),
+        RecursiveIteratorIterator::SELF_FIRST
+    );
+
+    foreach ($iterator as $path => $info) {
+        $name = $info->getFilename();
+
+        if (! isset($lookup[$name])) {
+            continue;
+        }
+
+        if ($info->isDir()) {
+            rrmdir($path);
+        } else {
+            if (! is_writable($path)) {
+                chmod($path, 0777);
             }
+            unlink($path);
         }
     }
-    closedir($dir);
 }
 
 
@@ -486,24 +480,24 @@ function removeFiles($src, $files)
  * @param string $src The directory to set permissions for
  */
 
-function setPermissions($src)
+function setPermissions(string $src): void
 {
-    $dir = opendir($src);
-    while (false !== ($file = readdir($dir))) {
-        if (($file != '.') && ($file != '..')) {
-            $full = $src . '/' . $file;
-            if (is_dir($full)) {
-                setPermissions($full);
-                chmod($full, 0755);
-            } else {
-                if (is_link($full)) {
-                    continue;
-                }
-                chmod($full, 0664);
-            }
+    $iterator = new RecursiveIteratorIterator(
+        new RecursiveDirectoryIterator($src, FilesystemIterator::SKIP_DOTS),
+        RecursiveIteratorIterator::SELF_FIRST
+    );
+
+    foreach ($iterator as $path => $info) {
+        if ($info->isLink()) {
+            continue;
+        }
+
+        if ($info->isDir()) {
+            chmod($path, 0755);
+        } else {
+            chmod($path, 0664);
         }
     }
-    closedir($dir);
 }
 
 
@@ -567,7 +561,7 @@ function build_packages($releaseVersion)
     echo "Downloading composer.phar" . "\n";
     $checksum = file_get_contents('https://composer.github.io/installer.sig');
     $composerInstaller = $workDir . '/composer-setup.php';
-    if (! file_put_contents($composerInstaller, file_get_contents('http://getcomposer.org/installer'))) {
+    if (! file_put_contents($composerInstaller, file_get_contents('https://getcomposer.org/installer'))) {
         echo "Can't create tikipack/composer-setup.php. Aborting." . "\n";
         die();
     }
@@ -646,38 +640,36 @@ function build_packages($releaseVersion)
     setPermissions($sourceDir);
 
     $relDir = escapeshellarg($relDir);
+    $isMac = (PHP_OS_FAMILY === 'Darwin');
+    $macPrefix = $isMac ? 'COPYFILE_DISABLE=1 ' : '';
+    // exclude the .DS_Store files which are macOS generated files
+    $archives = [
+        'tar.gz'  => "{$macPrefix}tar -czp --exclude='*.DS_Store' -f {archive} {source}",
+        'tar.bz2' => "{$macPrefix}tar -cjp --exclude='*.DS_Store' -f {archive} {source}",
+        'tar.xz'  => "{$macPrefix}tar -cJp --exclude='*.DS_Store' -f {archive} {source}",
+        'zip'     => "zip -ry {archive} {source} -x '*.DS_Store' -9",
+        '7z'      => "7za a {archive} {source} -xr!*.DS_Store -mx=9",
+    ];
+//    'zip' => "zip -r9X {archive} {source} -x '*.DS_Store'",
+    foreach ($archives as $ext => $cmdTemplate) {
+        $archive = escapeshellarg("$fileName.$ext");
+        $source  = escapeshellarg($fileName);
+
+        $command = str_replace(
+            ['{archive}', '{source}'],
+            [$archive, $source],
+            $cmdTemplate
+        );
 
-    echo "Creating $fileName.tar.gz\n";
-    $shellout = shell_exec("cd $relDir; tar -pczf " . escapeshellarg($fileName . ".tar.gz") . ' ' . escapeshellarg($fileName) . " --exclude '*.DS_Store' 2>&1");
-    if ($options['debug-packaging']) {
-        echo $shellout . "\n";
-    }
-
-    echo "Creating $fileName.tar.bz2\n";
-    $shellout = shell_exec("cd $relDir; tar -pcjf " . escapeshellarg($fileName . ".tar.bz2") . ' ' . escapeshellarg($fileName) . " --exclude '*.DS_Store' 2>&1");
-    if ($options['debug-packaging']) {
-        echo $shellout . "\n";
-    }
-
-    echo "Creating $fileName.tar.xz\n";
-    $shellout = shell_exec("cd $relDir; tar -pcJf " . escapeshellarg($fileName . ".tar.xz") . ' ' . escapeshellarg($fileName) . " --exclude '*.DS_Store' 2>&1");
-    if ($options['debug-packaging']) {
-        echo $shellout . "\n";
-    }
-
-    echo "Creating $fileName.zip\n";
-    $shellout = shell_exec("cd $relDir; zip -ry " . escapeshellarg($fileName . ".zip") . ' ' . escapeshellarg($fileName) . ' -x "*.DS_Store" -9 2>&1');
-    if ($options['debug-packaging']) {
-        echo $shellout . "\n";
-    }
+        echo "Creating $fileName.$ext \n";
+        $shellout = shell_exec("cd $relDir; $command 2>&1");
+        if (! empty($options['debug-packaging'])) {
+            echo $shellout . "\n";
+        }
 
-    echo "Creating $fileName.7z\n";
-    $shellout = shell_exec("cd $relDir; 7za a " . escapeshellarg($fileName . ".7z") . ' ' . escapeshellarg($fileName) . ' -xr!*.DS_Store -mx=9 2>&1');
-    if (strpos($shellout, 'command not found')) {
-        error("7za not installed. Archive creation failed.\n");
-    }
-    if ($options['debug-packaging']) {
-        echo $shellout . "\n";
+        if ($ext === '7z' && strpos($shellout, 'command not found') !== false) {
+            error("7za not installed. Archive creation failed.\n");
+        }
     }
 
     echo color("\nTo upload the 'tarballs', copy-paste and execute the following line (and change '\$SF_LOGIN' by your SF.net login):\n", 'yellow');



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e25c8b22eece530e1b40677d058470e6a9d08530

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e25c8b22eece530e1b40677d058470e6a9d08530
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.