Hi Anders! I know you told me this new target is still experimental, but I went ahead and hooked it up for real usage in r26543... I mean, what better way to test something than by actually using it? ;-) Could you please provide some documentation for it both in the ChangeLog (base/ChangeLog) and in the port(1) man page (base/src/port/ port.1)? Keep up the effort and good work! Regards,... -jmpp On Jun 27, 2007, at 7:45 PM, source_changes@macosforge.org wrote:
Revision 26536 Author afb@macports.org Date 2007-06-27 16:45:18 -0700 (Wed, 27 Jun 2007) Log Message
experimental target to build SRPM (source RPM) Modified Paths
trunk/base/src/package1.0/package.tcl trunk/base/src/port1.0/portutil.tcl Added Paths
trunk/base/src/package1.0/portsrpm.tcl Diff
Modified: trunk/base/src/package1.0/package.tcl (26535 => 26536) --- trunk/base/src/package1.0/package.tcl 2007-06-27 23:27:21 UTC (rev 26535) +++ trunk/base/src/package1.0/package.tcl 2007-06-27 23:45:18 UTC (rev 26536) @@ -33,6 +33,7 @@ package provide mp_package 1.0
package require portrpm 1.0 +package require portsrpm 1.0 package require portpkg 1.0 package require portmpkg 1.0 package require portdmg 1.0 Added: trunk/base/src/package1.0/portsrpm.tcl (0 => 26536) --- trunk/base/src/package1.0/portsrpm.tcl (rev 0) +++ trunk/base/src/package1.0/portsrpm.tcl 2007-06-27 23:45:18 UTC (rev 26536) @@ -0,0 +1,234 @@ +# et:ts=4 +# portsrpm.tcl +# $Id: portsrpm.tcl $ +# +# Copyright (c) 2002 - 2003 Apple Computer, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +package provide portsrpm 1.0 +package require portutil 1.0 +package require portfetch 1.0 + +set org.macports.srpm [target_new org.macports.srpm srpm_main] +target_runtype ${org.macports.srpm} always +target_provides ${org.macports.srpm} srpm +target_requires ${org.macports.srpm} checksum + +options package.destpath + +set_ui_prefix + +proc srpm_main {args} { + global portname portversion portrevision UI_PREFIX + + ui_msg "$UI_PREFIX [format [msgcat::mc "Creating SRPM package for %s-%s"] ${portname} ${portversion}]" + + return [srpm_pkg $portname $portversion $portrevision] +} + +proc srpm_pkg {portname portversion portrevision} { + global UI_PREFIX package.destpath portdbpath destpath workpath distpath prefix portresourcepath categories maintainers description long_description homepage epoch portpath distfiles fetch_urls + global os.platform os.arch os.version + + set rpmdestpath "" + if {![string equal ${package.destpath} ${workpath}] && ![string equal ${package.destpath} ""]} { + set pkgpath ${package.destpath} + system "mkdir -p ${pkgpath}/BUILD" + system "mkdir -p ${pkgpath}/RPMS" + system "mkdir -p ${pkgpath}/SOURCES" + system "mkdir -p ${pkgpath}/SPECS" + system "mkdir -p ${pkgpath}/SRPMS" + set rpmdestpath "--define '_topdir ${pkgpath}'" + } + + foreach dir [list "${prefix}/src/macports/SRPMS" "${prefix}/src/ apple/SRPMS" "/usr/src/apple/SRPMS" "/macports/rpms/SRPMS"] { + foreach arch {"src" "nosrc"} { + set rpmpath "$dir/${portname}-${portversion}-$ {portrevision}.${arch}.rpm" + if {[file readable $rpmpath] && ([file mtime ${rpmpath}] >= [file mtime ${portpath}/Portfile])} { + ui_debug "$rpmpath" + ui_msg "$UI_PREFIX [format [msgcat::mc "SRPM package for %s-%s is up-to-date"] ${portname} ${portversion}]" + return 0 + } + } + } + + set specpath ${workpath}/${portname}-port.spec + # long_description, description, or homepage may not exist + foreach variable {long_description description homepage categories maintainers} { + if {![info exists $variable]} { + set pkg_$variable "" + } else { + set pkg_$variable [set $variable] + } + } + set category [lindex [split $categories " "] 0] + set license "Unknown" + set maintainer $maintainers + + set dependencies {} + # get deplist + set deps [make_dependency_list $portname] + set deps [lsort -unique $deps] + foreach dep $deps { + set name [lindex [split $dep /] 0] + set vers [lindex [split $dep /] 1] + # don't re-package ourself + if {$name != $portname} { + lappend dependencies "${name} >= ${vers}" + } + } + + # true = .src.rpm (with distfiles), false = .nosrc.rpm (without distfiles) + set src false + + #set sourcespath ${prefix}/src/macports/SOURCES + set sourcespath "`rpm --eval %{_sourcedir}`" + + system "cp -p ${portpath}/Portfile ${sourcespath}/$portname- Portfile" + system "cd ${portpath} && zip -r -q ${sourcespath}/$portname- files.zip files -x \\*.DS_Store -x files/.svn\\*" + foreach dist $distfiles { + system "cp -p ${distpath}/${dist} ${sourcespath}/${dist}" + } + + write_port_spec ${specpath} $portname $portversion $portrevision $pkg_description $pkg_long_description $pkg_homepage $category $license $maintainer $distfiles $fetch_urls $dependencies $epoch $src + system "rpmbuild -bs -v --nodeps ${rpmdestpath} ${specpath}" + + return 0 +} + +proc make_dependency_list {portname} { + set result {} + if {[catch {set res [mport_search "^$portname\$"]} error]} { + global errorInfo + ui_debug "$errorInfo" + ui_error "port search failed: $error" + return 1 + } + foreach {name array} $res { + array set portinfo $array + + if {[info exists portinfo(depends_build)] || [info exists portinfo(depends_lib)]} { + # get the union of depends_build and depends_lib + # xxx: only examines the portfile component of the depspec + set depends {} + if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" } + if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" } + + foreach depspec $depends { + set dep [lindex [split $depspec :] end] + + # xxx: nasty hack + if {$dep != "XFree86"} { + eval "lappend result [make_dependency_list $dep]" + } + } + } + lappend result $portinfo(name)/$portinfo(version) + unset portinfo + } + ui_debug "dependencies for ${portname}: $result" + return $result +} + +proc write_port_spec {specfile portname portversion portrevision description long_description homepage category license maintainer distfiles fetch_urls dependencies epoch src} { + set specfd [open ${specfile} w+] + set origportname ${portname} + regsub -all -- "\-" $portversion "_" portversion + regsub -all -- "\-" $portname "_" portname + puts $specfd "\#Spec file generated by MacPorts +%define distribution MacPorts +%define vendor MacPorts +%define packager ${maintainer} + +Summary: ${description} +Name: ${portname} +Version: ${portversion} +Release: ${portrevision} +Group: ${category} +License: ${license} +URL: ${homepage} +BuildRoot: %{_tmppath}/%{name}-%{version}-root +Epoch: ${epoch} +Source0: ${portname}-Portfile +Source1: ${portname}-files.zip" + set first 2 + set count $first + puts $specfd "#distfiles" + foreach file ${distfiles} { + + puts -nonewline $specfd "Source${count}: " + if {![info exists $fetch_urls]} { + foreach {url_var distfile} ${fetch_urls} { + if {[string equal $distfile $file]} { + global portfetch::$url_var + set site [lindex [set $url_var] 0] + set file [portfetch::assemble_url $site $distfile] + break + } + } + } + puts $specfd $file + if (!$src) { + puts $specfd "NoSource: $count" + } + incr count + } + puts $specfd "" + puts $specfd "AutoReqProv: no" + if {[llength ${dependencies}] != 0} { + foreach require ${dependencies} { + puts $specfd "BuildRequires: [regsub -all -- "\-" $require "_"]" + } + } + puts $specfd " +%description +${long_description} + +%prep +%setup -c -a 1 -T +cp -p %{SOURCE0} Portfile +#prepare work area +port fetch +port checksum +port extract +port patch + +%build +port configure +port build + +%install +rm -rf \$RPM_BUILD_ROOT +mkdir -p \$RPM_BUILD_ROOT +port destroot +port rpm + +%clean +port clean" + close $specfd +} Modified: trunk/base/src/port1.0/portutil.tcl (26535 => 26536) --- trunk/base/src/port1.0/portutil.tcl 2007-06-27 23:27:21 UTC (rev 26535) +++ trunk/base/src/port1.0/portutil.tcl 2007-06-27 23:45:18 UTC (rev 26536) @@ -1166,7 +1166,8 @@ archive - pkg - mpkg - - rpm - + rpm - + srpm - dpkg - activate - "" { set deptypes "depends_lib depends_build depends_run" } _______________________________________________ macports-changes mailing list macports-changes@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/macports-changes
participants (1)
-
Juan Manuel Palacios