From 34f42daaaab18e26d7d620cf9969cdf381e727e0 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Sat, 3 May 2025 00:25:11 +0800
Subject: [PATCH 13/16] Avoid flat packages on 10.6, they do not work

---
 src/package1.0/portmpkg.tcl | 8 ++++----
 src/package1.0/portpkg.tcl  | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/package1.0/portmpkg.tcl b/src/package1.0/portmpkg.tcl
index 4d75fdf87..32a1bbd2e 100644
--- a/src/package1.0/portmpkg.tcl
+++ b/src/package1.0/portmpkg.tcl
@@ -48,7 +48,7 @@ set_ui_prefix
 
 proc portmpkg::mpkg_main {args} {
     global package.flat os.major package.destpath subport epoch version revision
-    if {!${package.flat} || ${os.major} < 10} {
+    if {!${package.flat} || ${os.major} < 11} {
         # Make sure the destination path exists.
         file mkdir ${package.destpath}
     }
@@ -184,7 +184,7 @@ proc portmpkg::mpkg_path {portname portversion portrevision} {
 }
 
 proc portmpkg::package_mpkg {portname portepoch portversion portrevision} {
-    global os.major workpath porturl description long_description homepage \
+    global os.major os.arch workpath porturl description long_description homepage \
            package.flat package.destpath
 
     set mpkgpath [portmpkg::mpkg_path $portname $portversion $portrevision]
@@ -221,7 +221,7 @@ proc portmpkg::package_mpkg {portname portepoch portversion portrevision} {
     # copy our own pkg into the mpkg
     system "cp -PR [shellescape ${pkgpath}] [shellescape ${packages_path}]"
 
-    if {!${package.flat} || ${os.major} < 10} {
+    if {!${package.flat} || ${os.major} < 11} {
         global prefix
         portpkg::write_PkgInfo ${mpkgpath}/Contents/PkgInfo
         mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $portrevision $prefix $dependencies
@@ -239,7 +239,7 @@ proc portmpkg::package_mpkg {portname portepoch portversion portrevision} {
     portpkg::write_welcome_html ${resources_path}/Welcome.html $portname $portversion $portrevision $pkg_long_description $pkg_description $pkg_homepage
     file copy -force -- [getportresourcepath $porturl "port1.0/package/background.tiff"] ${resources_path}/background.tiff
 
-    if {${package.flat} && ${os.major} >= 10} {
+    if {${package.flat} && ${os.major} >= 10 && ${os.arch} ne "powerpc"} {
         write_distribution ${workpath}/Distribution $portname $dependencies
         set productbuild [findBinary productbuild]
         set v [portpkg::mp_version_to_apple_version $portepoch $portversion $portrevision]
diff --git a/src/package1.0/portpkg.tcl b/src/package1.0/portpkg.tcl
index 824cc8c7c..e7c2c1baf 100644
--- a/src/package1.0/portpkg.tcl
+++ b/src/package1.0/portpkg.tcl
@@ -51,7 +51,7 @@ default package.destpath {${workpath}}
 default package.resources {${workpath}/pkg_resources}
 default package.scripts  {${workpath}/pkg_scripts}
 # Need productbuild to make flat packages really work
-default package.flat     {[expr {[vercmp $macosx_deployment_target 10.6] >= 0}]}
+default package.flat     {[expr {[vercmp $macosx_deployment_target 10.7] >= 0}]}
 default pkg.asroot no
 
 set_ui_prefix
@@ -65,7 +65,7 @@ proc portpkg::pkg_start {args} {
     variable pkgbuild
     variable language
 
-    if {[catch {findBinary pkgbuild /usr/bin/pkgbuild} pkgbuild]} {
+    if {(${os.arch} eq "powerpc") || [catch {findBinary pkgbuild /usr/bin/pkgbuild} pkgbuild]} {
         set pkgbuild ""
     }
     if {$pkgbuild eq "" || !${package.flat}} {
@@ -118,7 +118,7 @@ proc portpkg::pkg_main {args} {
 
 proc portpkg::package_pkg {portname portepoch portversion portrevision} {
     global UI_PREFIX destpath workpath prefix description \
-        package.flat package.destpath portpath os.major \
+        package.flat package.destpath portpath os.arch os.major \
         package.resources package.scripts \
         pkg_post_unarchive_deletions
     variable packagemaker
@@ -185,7 +185,7 @@ proc portpkg::package_pkg {portname portepoch portversion portrevision} {
         ui_debug "Running command line: $cmdline"
         system $cmdline
 
-        if {${package.flat} && ${os.major} >= 10} {
+        if {${package.flat} && ${os.major} >= 10 && ${os.arch} ne "powerpc"} {
             # the package we just built is just a component
             set componentpath "[file rootname ${pkgpath}]-component.pkg"
             file rename -force ${pkgpath} ${componentpath}
-- 
2.49.0

