Ticket #1068: dports.patch

File dports.patch, 2.5 KB (added by jdputsch@…, 21 years ago)

Sample implementation patch to base/...

  • ./base/src/port1.0/portinstall.tcl

    old new  
    111111    cd $pwd
    112112}
    113113
     114proc run_inst_helper_script {script} {
     115    global workdir
     116
     117    set script_src [file join [option filespath] [option $script]]
     118    set script_exe [file join $workdir [option $script]]
     119
     120    if {[file exists $script_src]} {
     121        system "cp $script_src $script_exe"
     122        reinplace "s|@PREFIX@|$prefix|g" $script_exe
     123        system $script_exe
     124    }
     125}
     126
     127
    114128proc install_main {args} {
    115129    global portname portversion portpath categories description long_description homepage depends_run installPlist package-install uninstall workdir worksrcdir prefix UI_PREFIX destroot
    116130
     131    # Run preinstall script if it exists
     132    run_inst_helper_script [option preinstall]
     133
    117134    # Install ${destroot} contents into /
    118135    directory_dig ${destroot} ${destroot}
     136
     137    # Run postinstall script if it exists
     138    run_inst_helper_script [option postinstall]
    119139
    120140    # Package installed successfully, so now we must register it
    121141    set rhandle [registry_new $portname $portversion]
  • ./base/src/port1.0/portmain.tcl

    old new  
    6868default filesdir {files}
    6969default filespath {[file join $portpath $filesdir]}
    7070default worksrcpath {[file join $workpath $worksrcdir]}
     71default preinstall {preinstall}
     72default postinstall {postinstall}
     73default postremove {postremove}
    7174
    7275# Compatibility namespace
    7376default portname {$name}
  • ./base/src/port1.0/portpackage.tcl

    old new  
    7777            set pkg_$variable [set $variable]
    7878        }
    7979    }
     80    # Add pre/post install scripts if they exist
     81
     82    foreach script {preinstall postinstall postremove} {
     83        set script_src [file join [option filespath] [option $script]]
     84        set script_dst "${pkgpath}/Contents/Resources/$script"
     85
     86        if {[file exists $script_src]} {
     87            system "cp ${script_src} ${script_dst}"
     88            reinplace "s|@PREFIX@|$prefix|g" $script_dst
     89            system "chmod a+rx ${script_dst}"
     90        }
     91    }
     92
    8093    write_welcome_html ${pkgpath}/Contents/Resources/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
    8194    file copy -force -- ${portresourcepath}/package/background.tiff ${pkgpath}/Contents/Resources/background.tiff
    8295    system "mkbom ${destpath} ${pkgpath}/Contents/Archive.bom"