On 10/23/2012 04:54 PM, Thorsten Leemhuis wrote: > Lo! > > On 23.10.2012 17:23, Tom Callaway wrote: >> On 10/22/2012 10:37 PM, Ralf Corsepius wrote: >>> On 10/22/2012 10:43 PM, Tom Callaway wrote: >>>> On 10/22/2012 12:09 PM, Ralf Corsepius wrote: >>>>>> There is currently no way to "undefine" a macro at the rpm >>>>>> commandline, >>>>> >>>>> rpmbuild --define "xxxx %{nil}" ? >>>> >>>> Huh, I swear I knew that once. :) Attached is a patch to use the %{nil} >>>> behavior instead of setting the unused dist macro to 0. I smoke tested >>>> and confirmed that the %{rhel} macro is unset on Fedora with this patch >>>> applied. >>> >>> I haven't tried your patch, but don't you have to unset/define %{nil} >>> all build-host related rpm macros from /etc/rpm/macros.dist? >>> >>> It's at least what I can not avoid doing in my before-mentioned >>> build-scripts. >>> >>> I.e. when running my script on Fedora 17, I invoke rpmbuild this way: >>> >>> rpmbuild ... \ >>> --define "fedora %{nil}" --define "fc17 %{nil}" >>> --define "dist .el6" --define "rhel 6" --define "el6 1" >>> ... >>> >>> Otherwise constructs such as >>> %{?fc17:xxxx} >>> %{?el6:yyyy} >>> also won't work correctly in rpm.specs. >>> >>> IIUC, fedpkg with your patch sets %dist and unsets %fedora, but it >>> doesn't seem to catch "fc17". >> >> Yeah, thats a valid corner case. It wasn't in the original issue, so I >> didn't think about it. I'll work on a fix that covers that as well. > > Spot: Thanks for working on this and finding a solution that removes the > inconsistency I was running into with someone else package. Okay, so here are two patches: fedpkg-1.10-use-nil-to-unset-distunset.patch (this one uses %nil instead of 0 in my previous fix) fedpkg-1.10-unset-runtime-disttag.patch (this patch detects the runtime environment and unsets the version specific tag (e.g. %{fc17} or %{el6}), except in the case where the runtime env matches the build target exactly) Jesse, please review and apply these upstream and make a new update. ~tom == Fedora Project
diff -up fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py.unset-runtime-disttag fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py --- fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py.unset-runtime-disttag 2012-11-06 13:46:22.767693545 -0500 +++ fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py 2012-11-06 13:54:08.767907308 -0500 @@ -17,6 +17,7 @@ import git import re import pycurl import fedora_cert +import platform # This check (decorator) can go away after a few months def _check_newstyle_branches(func): @@ -153,6 +154,9 @@ class Commands(pyrpkg.Commands): def load_rpmdefines(self): """Populate rpmdefines based on branch data""" + """ Determine runtime environment""" + self._runtime_disttag = self._determine_runtime_env() + # We only match the top level branch name exactly. # Anything else is too dangerous and --dist should be used # This regex works until after Fedora 99. @@ -199,6 +203,11 @@ class Commands(pyrpkg.Commands): "--define '%s %s'" % (self._distvar, self._distval), "--define '%s %%{nil}'" % self._distunset, "--define '%s 1'" % self.dist] + if self._runtime_disttag: + if self.dist != self._runtime_disttag: + """ This means that the runtime is known, and is different from the target, """ + """ so we need to unset the _runtime_disttag """ + self._rpmdefines.append("--define '%s %%{nil}'" % self._runtime_disttag) def load_target(self): """This creates the target attribute based on branch merge""" @@ -313,6 +322,33 @@ class Commands(pyrpkg.Commands): desttag = rawhidetarget['dest_tag_name'] return desttag.replace('f', '') + def _determine_runtime_env(self): + """Need to know what the runtime env is, so we can unset anything conflicting""" + try: + mydist = platform.linux_distribution() + except: + """ This is marked as eventually being deprecated. """ + try: + mydist = platform.dist() + except: + runtime_os = 'unknown' + runtime_version = '0' + + if mydist: + runtime_os = mydist[0] + runtime_version = mydist[1] + else: + runtime_os = 'unknown' + runtime_version = '0' + + if runtime_os == 'redhat' or runtime_os == 'centos': + return 'el%s' % runtime_version + if runtime_os == 'Fedora': + return 'fc%s' % runtime_version + + """ fall through, return None """ + return None + def new_ticket(self, passwd, desc, build=None): """Open a new ticket on Rel-Eng trac instance.
diff -up fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py.nil fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py --- fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py.nil 2012-10-22 13:51:28.706781587 -0400 +++ fedpkg-1.10/src/pyrpkg/fedpkg/__init__.py 2012-10-22 13:54:23.750857940 -0400 @@ -197,7 +197,7 @@ class Commands(pyrpkg.Commands): "--define '_rpmdir %s'" % self.path, "--define 'dist .%s'" % self.dist, "--define '%s %s'" % (self._distvar, self._distval), - "--define '%s 0'" % self._distunset, + "--define '%s %%{nil}'" % self._distunset, "--define '%s 1'" % self.dist] def load_target(self):
-- devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/devel