Ticket #27485: 0001-Add-support-for-git-managed-portdirs.patch

File 0001-Add-support-for-git-managed-portdirs.patch, 3.1 KB (added by ecronin (Eric Cronin), 12 years ago)
  • base/src/macports1.0/macports.tcl

    From 9fcfe17b049dd25fcc01b34683b593eb0c5e258c Mon Sep 17 00:00:00 2001
    From: Eric Cronin <ecronin@macports.org>
    Date: Sat, 15 Oct 2011 11:54:31 -0400
    Subject: [PATCH] Add support for git managed portdirs
    
    A little fragile on conflicts currently, but shouldn't lose data
    due to git's protections
    ---
     base/src/macports1.0/macports.tcl |   33 +++++++++++++++++++++++++++++++++
     1 files changed, 33 insertions(+), 0 deletions(-)
    
    diff --git a/base/src/macports1.0/macports.tcl b/base/src/macports1.0/macports.tcl
    index 7a157ad..104b11c 100644
    a b proc mportsync {{optionslist {}}} { 
    19741974            {^file$} {
    19751975                set portdir [macports::getportdir $source]
    19761976                set svn_cmd ""
     1977                set git_cmd ""
    19771978                catch {set svn_cmd [macports::findBinary svn]}
     1979                catch {set git_cmd [macports::findBinary git]}
    19781980                if {$svn_cmd != "" && ([file exists $portdir/.svn] || ![catch {exec $svn_cmd info $portdir > /dev/null 2>@1}])} {
    19791981                    set svn_commandline "$svn_cmd update --non-interactive ${portdir}"
    19801982                    ui_debug $svn_commandline
    proc mportsync {{optionslist {}}} { 
    19992001                        incr numfailed
    20002002                        continue
    20012003                    }
     2004                } elseif {$git_cmd != "" && ![catch {exec sh -c "cd ${portdir} && $git_cmd rev-parse --is-inside-work-tree"} result]} {
     2005                    # determine what type of git repository this is
     2006                    if {![catch {exec sh -c "cd ${portdir} && $git_cmd config --local --get svn-remote.svn.url"} result]} {
     2007                        set git_action "svn rebase"
     2008                    } else {
     2009                        set git_action "pull"
     2010                    }
     2011                    set git_commandline "cd ${portdir}; $git_cmd stash save; $git_cmd $git_action; $git_cmd stash pop"
     2012                    ui_debug $git_commandline
     2013                    if {
     2014                        [catch {
     2015                            if {[getuid] == 0} {
     2016                                set euid [geteuid]
     2017                                set egid [getegid]
     2018                                ui_debug "changing euid/egid - current euid: $euid - current egid: $egid"
     2019                                setegid [name_to_gid [file attributes $portdir -group]]
     2020                                seteuid [name_to_uid [file attributes $portdir -owner]]
     2021                            }
     2022                            system $git_commandline
     2023                            if {[getuid] == 0} {
     2024                                seteuid $euid
     2025                                setegid $egid
     2026                            }
     2027                        }]
     2028                    } {
     2029                        ui_debug "$::errorInfo"
     2030                        ui_error "Synchronization of the local ports tree failed doing a git update"
     2031                        incr numfailed
     2032                        continue
     2033                    }
    20022034                }
     2035
    20032036                set needs_portindex 1
    20042037            }
    20052038            {^mports$} {