[PATCH] Makefile.common autodetermine RPM_BUILD_DIR from spec file

2008-09-30 Thread Petr Lautrbach

Hello.

make patch and make rediff don't work if %setup macro defines with -n  other
directory than $(NAME)-$(VERSION).



Petr






--
Fedora-buildsys-list mailing list
Fedora-buildsys-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-buildsys-list


Re: [PATCH] Makefile.common autodetermine RPM_BUILD_DIR from spec file

2008-09-30 Thread Petr Lautrbach

Petr Lautrbach wrote:

Hello.

make patch and make rediff don't work if %setup macro defines with -n  
other

directory than $(NAME)-$(VERSION).




patch in attachment

Petr
diff -up common/Makefile.common.patch-rediff common/Makefile.common
--- common/Makefile.common.patch-rediff 2008-09-30 14:19:22.0 +0200
+++ common/Makefile.common  2008-09-30 16:59:59.0 +0200
@@ -108,7 +108,12 @@ endif
 
 # this is used in make patch, maybe make clean eventually.
 # would be nicer to autodetermine from the spec file...
-RPM_BUILD_DIR ?= $(BUILDDIR)/$(NAME)-$(VERSION)
+# look for %setup -n SOURCE_DIR in .spec and use it instead of default if 
exists
+NAME_VER_DIR := $(shell sed -ne '/^%setup .*-n/{s/.*-n \([^ 
]*\)/\1/;s/%{name}/$(NAME)/;s/%{version}/$(VERSION)/;p}' $(SPECFILE))
+ifndef NAME_VER_DIR
+NAME_VER_DIR := $(NAME)-$(VERSION)
+endif
+RPM_BUILD_DIR ?= $(BUILDDIR)/$(NAME_VER_DIR)
 
 ## for secondary arch only packages we cant build on the primary hub
 ## we need to go direct to the secondary arch hub
@@ -581,7 +586,7 @@ endif
 
 patch:
@if test -z $(SUFFIX); then echo Must specify SUFFIX=whatever ; 
exit 1; fi
-   (cd $(RPM_BUILD_DIR)/..  gendiff $(NAME)-$(VERSION) .$(SUFFIX) | 
$(FILTERDIFF))  $(PATCHFILE) || true
+   (cd $(RPM_BUILD_DIR)/..  gendiff $(NAME_VER_DIR) .$(SUFFIX) | 
$(FILTERDIFF))  $(PATCHFILE) || true
@if ! test -s $(PATCHFILE); then echo Patch is empty!; exit 1; fi
@echo Created $(PATCHFILE)
@grep $(PATCHFILE) CVS/Entries /dev/null || cvs add -ko 
$(PATCHFILE) || true
@@ -594,7 +599,7 @@ rediff:
@if ! test -f $(PATCHFILE); then echo $(PATCHFILE) not found; exit 
1; fi
@mv -f $(PATCHFILE) $(PATCHFILE)\~
@sed '/^--- /,$$d'  $(PATCHFILE)\~  $(PATCHFILE)
-   @(cd $(RPM_BUILD_DIR)/..  gendiff $(NAME)-$(VERSION) .$(SUFFIX) | 
$(FILTERDIFF))  $(PATCHFILE) || true
+   @(cd $(RPM_BUILD_DIR)/..  gendiff $(NAME_VER_DIR) .$(SUFFIX) | 
$(FILTERDIFF))  $(PATCHFILE) || true
 
 clog: $(SPECFILE)
@sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $(SPECFILE) | 
tee $@
--
Fedora-buildsys-list mailing list
Fedora-buildsys-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-buildsys-list