| 1 |
# -*- Makefile -*-
|
| 2 |
#
|
| 3 |
# Common Makefile for building RPMs
|
| 4 |
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
|
| 5 |
# Copyright (C) 2004-2009 Red Hat, Inc.
|
| 6 |
# Copyright (C) 2005 Fedora Foundation
|
| 7 |
#
|
| 8 |
# $Id: Makefile.common,v 1.138 2009/09/29 07:33:28 jkeating Exp $
|
| 9 |
|
| 10 |
# Define the common dir.
|
| 11 |
# This needs to happen first.
|
| 12 |
define find-common-dir
|
| 13 |
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then echo "$$d"; break ; fi ; done
|
| 14 |
endef
|
| 15 |
COMMON_DIR := $(shell $(find-common-dir))
|
| 16 |
|
| 17 |
# Branch and disttag definitions
|
| 18 |
# These need to happen second.
|
| 19 |
ifndef HEAD_BRANCH
|
| 20 |
HEAD_BRANCH := devel
|
| 21 |
endif
|
| 22 |
BRANCH:=$(shell pwd | awk -F '/' '{ print $$NF }' )
|
| 23 |
# check to see if this is an early branched package; we should make this more
|
| 24 |
# generic in the future
|
| 25 |
#ifeq ($(BRANCH),devel)
|
| 26 |
#BRANCH:=$(shell cvs rlog rpms/$(NAME)/F-12/$(SPECFILE) >/dev/null 2>&1 && echo "F-13" || echo "devel")
|
| 27 |
#endif
|
| 28 |
BRANCHINFO = $(shell grep ^$(BRANCH): $(COMMON_DIR)/branches | cut -d: --output-delimiter=" " -f2-)
|
| 29 |
TARGET := $(word 1, $(BRANCHINFO))
|
| 30 |
DIST = $(word 2, $(BRANCHINFO))
|
| 31 |
DISTVAR = $(word 3, $(BRANCHINFO))
|
| 32 |
DISTVAL = $(word 4, $(BRANCHINFO))
|
| 33 |
DISTDEF = $(shell echo $(DIST) | sed -e s/^\\\.// )
|
| 34 |
DIST_DEFINES = --define "dist $(DIST)" --define "$(DISTVAR) $(DISTVAL)" --define "$(DISTDEF) 1"
|
| 35 |
|
| 36 |
BUILD_FLAGS ?= $(KOJI_FLAGS)
|
| 37 |
|
| 38 |
LOCALARCH := $(shell rpm --eval %{_arch})
|
| 39 |
|
| 40 |
## a base directory where we'll put as much temporary working stuff as we can
|
| 41 |
ifndef WORKDIR
|
| 42 |
WORKDIR := $(shell pwd)
|
| 43 |
endif
|
| 44 |
## of course all this can also be overridden in your RPM macros file,
|
| 45 |
## but this way you can separate your normal RPM setup from your CVS
|
| 46 |
## setup. Override RPM_WITH_DIRS in ~/.cvspkgsrc to avoid the usage of
|
| 47 |
## these variables.
|
| 48 |
SRCRPMDIR ?= $(WORKDIR)
|
| 49 |
BUILDDIR ?= $(WORKDIR)
|
| 50 |
RPMDIR ?= $(WORKDIR)
|
| 51 |
MOCKDIR ?= $(WORKDIR)
|
| 52 |
ifeq ($(DISTVAR),epel)
|
| 53 |
DISTVAR := rhel
|
| 54 |
MOCKCFG ?= fedora-$(DISTVAL)-$(BUILDARCH)-epel
|
| 55 |
else
|
| 56 |
MOCKCFG ?= fedora-$(DISTVAL)-$(BUILDARCH)
|
| 57 |
## 4, 5, 6 need -core
|
| 58 |
ifeq ($(DISTVAL),4)
|
| 59 |
MOCKCFG = fedora-$(DISTVAL)-$(BUILDARCH)-core
|
| 60 |
endif
|
| 61 |
ifeq ($(DISTVAL),5)
|
| 62 |
MOCKCFG = fedora-$(DISTVAL)-$(BUILDARCH)-core
|
| 63 |
endif
|
| 64 |
ifeq ($(DISTVAL),6)
|
| 65 |
MOCKCFG = fedora-$(DISTVAL)-$(BUILDARCH)-core
|
| 66 |
endif
|
| 67 |
## Devel builds use -devel mock config
|
| 68 |
ifeq ($(BRANCH),devel)
|
| 69 |
MOCKCFG = fedora-devel-$(BUILDARCH)
|
| 70 |
endif
|
| 71 |
endif
|
| 72 |
|
| 73 |
## SOURCEDIR is special; it has to match the CVS checkout directory,
|
| 74 |
## because the CVS checkout directory contains the patch files. So it basically
|
| 75 |
## can't be overridden without breaking things. But we leave it a variable
|
| 76 |
## for consistency, and in hopes of convincing it to work sometime.
|
| 77 |
ifndef SOURCEDIR
|
| 78 |
SOURCEDIR := $(shell pwd)
|
| 79 |
endif
|
| 80 |
ifndef SPECDIR
|
| 81 |
SPECDIR := $(shell pwd)
|
| 82 |
endif
|
| 83 |
|
| 84 |
ifndef RPM_DEFINES
|
| 85 |
RPM_DEFINES := --define "_sourcedir $(SOURCEDIR)" \
|
| 86 |
--define "_specdir $(SPECDIR)" \
|
| 87 |
--define "_builddir $(BUILDDIR)" \
|
| 88 |
--define "_srcrpmdir $(SRCRPMDIR)" \
|
| 89 |
--define "_rpmdir $(RPMDIR)" \
|
| 90 |
$(DIST_DEFINES)
|
| 91 |
endif
|
| 92 |
|
| 93 |
# to make srpms on F-11 and newer for older releases use old hashes
|
| 94 |
# F-10's rpm supports both styles F-9 is the only current release
|
| 95 |
# outside of rhel that needs old hasnes
|
| 96 |
ifeq ($(DISTVAR),rhel)
|
| 97 |
RPM_DEFINES := $(RPM_DEFINES) \
|
| 98 |
--define "_source_filedigest_algorithm md5" \
|
| 99 |
--define "_binary_filedigest_algorithm md5"
|
| 100 |
endif
|
| 101 |
ifeq ($(DISTVAL),9)
|
| 102 |
RPM_DEFINES := $(RPM_DEFINES) \
|
| 103 |
--define "_source_filedigest_algorithm md5" \
|
| 104 |
--define "_binary_filedigest_algorithm md5"
|
| 105 |
endif
|
| 106 |
|
| 107 |
# Initialize the variables that we need, but are not defined
|
| 108 |
# the version of the package
|
| 109 |
|
| 110 |
VER_REL := $(shell rpm $(RPM_DEFINES) -q --qf "%{VERSION} %{RELEASE}\n" --specfile $(SPECFILE)| head -1)
|
| 111 |
|
| 112 |
ifndef NAME
|
| 113 |
$(error "You can not run this Makefile without having NAME defined")
|
| 114 |
endif
|
| 115 |
ifndef VERSION
|
| 116 |
VERSION := $(word 1, $(VER_REL))
|
| 117 |
endif
|
| 118 |
# the release of the package
|
| 119 |
ifndef RELEASE
|
| 120 |
RELEASE := $(word 2, $(VER_REL))
|
| 121 |
endif
|
| 122 |
|
| 123 |
# this is used in make patch, maybe make clean eventually.
|
| 124 |
# would be nicer to autodetermine from the spec file...
|
| 125 |
RPM_BUILD_DIR ?= $(BUILDDIR)/$(NAME)-$(VERSION)
|
| 126 |
|
| 127 |
## for secondary arch only packages we cant build on the primary hub
|
| 128 |
## we need to go direct to the secondary arch hub
|
| 129 |
define secondary-arch
|
| 130 |
for name in silo prtconf lssbus afbinit piggyback xorg-x11-drv-sunbw2 xorg-x11-drv-suncg14 xorg-x11-drv-suncg3 xorg-x11-drv-suncg6 xorg-x11-drv-sunffb xorg-x11-drv-sunleo xorg-x11-drv-suntcx ; \
|
| 131 |
do if [ "$$name" = "$(NAME)" ]; then echo "-c ~/.koji/sparc-config"; fi \
|
| 132 |
done
|
| 133 |
endef
|
| 134 |
# if we have defineded SECONDARY_CONFIG trust the user is doing it for a reason
|
| 135 |
ifndef SECONDARY_CONFIG
|
| 136 |
SECONDARY_CONFIG := $(shell $(secondary-arch))
|
| 137 |
endif
|
| 138 |
|
| 139 |
# default target: just make sure we've got the sources
|
| 140 |
all: sources
|
| 141 |
|
| 142 |
# user specific configuration
|
| 143 |
CVS_EXTRAS_RC := $(shell if test -f $(HOME)/.cvspkgsrc ; then echo $(HOME)/.cvspkgsrc ; fi)
|
| 144 |
ifdef CVS_EXTRAS_RC
|
| 145 |
include $(CVS_EXTRAS_RC)
|
| 146 |
endif
|
| 147 |
|
| 148 |
# The repository and the clients we use for the files
|
| 149 |
REPOSITORY ?= http://cvs.fedoraproject.org/repo/pkgs
|
| 150 |
UPLOAD_REPOSITORY ?= https://cvs.fedoraproject.org/repo/pkgs/upload.cgi
|
| 151 |
|
| 152 |
# We define CURL and WGET in a way that makes if possible to have them
|
| 153 |
# overwritten from the module's Makefiles. Then CLIENT picks CURL, otherwise WGET
|
| 154 |
CURL ?= $(shell if test -f /usr/bin/curl ; then echo "curl -H Pragma: -O -R -S --fail --show-error" ; fi)
|
| 155 |
WGET ?= $(shell if test -f /usr/bin/wget ; then echo "wget -nd -m" ; fi)
|
| 156 |
CLIENT ?= $(if $(CURL),$(CURL),$(if $(WGET),$(WGET)))
|
| 157 |
BUILD_CLIENT ?= $(shell which koji 2>/dev/null)
|
| 158 |
BODHI_CLIENT ?= $(shell which bodhi 2>/dev/null)
|
| 159 |
FEDORAHOSTED ?= $(shell which fedora-hosted 2>/dev/null)
|
| 160 |
|
| 161 |
# RPM with all the overrides in place; you can override this in your
|
| 162 |
# .cvspkgsrc also, to use a default rpm setup
|
| 163 |
# the rpm build command line
|
| 164 |
ifndef RPM
|
| 165 |
RPM := rpmbuild
|
| 166 |
endif
|
| 167 |
ifndef RPM_WITH_DIRS
|
| 168 |
RPM_WITH_DIRS = $(RPM) $(RPM_DEFINES)
|
| 169 |
endif
|
| 170 |
|
| 171 |
# CVS-safe version/release -- a package name like 4Suite screws things
|
| 172 |
# up, so we have to remove the leaving digits from the name
|
| 173 |
TAG_NAME := $(shell echo $(NAME) | sed -e s/\\\./_/g -e s/^389/three89/g -e s/^[0-9]\\\+//g)
|
| 174 |
TAG_VERSION := $(shell echo $(VERSION) | sed s/\\\./_/g)
|
| 175 |
TAG_RELEASE := $(shell echo $(RELEASE) | sed s/\\\./_/g)
|
| 176 |
|
| 177 |
# tag to export, defaulting to current tag in the spec file
|
| 178 |
TAG?=$(TAG_NAME)-$(TAG_VERSION)-$(TAG_RELEASE)
|
| 179 |
|
| 180 |
# where to cvs export temporarily
|
| 181 |
TMPCVS := $(WORKDIR)/cvs-$(TAG)
|
| 182 |
|
| 183 |
# source file basenames
|
| 184 |
SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print $$2 }')
|
| 185 |
# full path to source files
|
| 186 |
FULLSOURCEFILES := $(addprefix $(SOURCEDIR)/,$(SOURCEFILES))
|
| 187 |
|
| 188 |
# retrieve the stored md5 sum for a source download
|
| 189 |
define get_sources_md5
|
| 190 |
$(shell cat sources 2>/dev/null | while read m f ; do if test "$$f" = "$@" ; then echo $$m ; break ; fi ; done)
|
| 191 |
endef
|
| 192 |
|
| 193 |
# list the possible targets for valid arches
|
| 194 |
ARCHES = noarch i386 i586 i686 x86_64 ia64 s390 s390x ppc ppc64 pseries ppc64pseries iseries ppc64iseries athlon alpha alphaev6 sparc sparc64 sparcv9 sparcv9v sparc64v i164 mac sh mips geode armv5tel armv6tel armv7tel
|
| 195 |
|
| 196 |
# for the modules that do different "make prep" depending on what arch we build for
|
| 197 |
PREP_ARCHES = $(addprefix prep-,$(ARCHES))
|
| 198 |
|
| 199 |
## list all our bogus targets
|
| 200 |
.PHONY :: $(ARCHES) sources uploadsource upload export check build-check build cvsurl chain-build test-srpm srpm tag verrel new clean patch prep compile install install-short compile-short FORCE local scratch-build scratch-build-% srpm-scratch-build srpm-scratch-build-%
|
| 201 |
|
| 202 |
# The TARGETS define is meant for local module targets that should be
|
| 203 |
# made in addition to the SOURCEFILES whenever needed
|
| 204 |
TARGETS ?=
|
| 205 |
|
| 206 |
# default target - retrieve the sources and make the module specific targets
|
| 207 |
sources: $(SOURCEFILES) $(TARGETS)
|
| 208 |
|
| 209 |
# Retrieve the sources we do not have in CVS
|
| 210 |
$(SOURCEFILES): #FORCE
|
| 211 |
@mkdir -p $(SOURCEDIR)
|
| 212 |
@echo "Downloading $@..."
|
| 213 |
@for i in `find ../ -maxdepth 2 -name "$@"`; do \
|
| 214 |
if test "$$(md5sum $$i | awk '{print $$1}')" = "$(get_sources_md5)" ; then \
|
| 215 |
echo "Copying from $$i" ; \
|
| 216 |
ln $$i $@ ; \
|
| 217 |
break ; \
|
| 218 |
fi ; \
|
| 219 |
done
|
| 220 |
@if [ -z "$(CLIENT)" ]; then echo "Can't download, need curl or wget installed." ; exit 1; fi
|
| 221 |
@if [ ! -e "$@" ] ; then $(CLIENT) $(REPOSITORY)/$(NAME)/$@/$(get_sources_md5)/$@ ; fi
|
| 222 |
@if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
|
| 223 |
@if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \
|
| 224 |
echo "md5sum of the downloaded $@ does not match the one from 'sources' file" ; \
|
| 225 |
echo "Local copy: $$(md5sum $@)" ; \
|
| 226 |
echo "In sources: $$(grep $@ sources)" ; \
|
| 227 |
exit 1 ; \
|
| 228 |
else \
|
| 229 |
ls -l $@ ; \
|
| 230 |
fi
|
| 231 |
|
| 232 |
# Support for uploading stuff into the repository. Since this is
|
| 233 |
# pretty specific to the upload.cgi we use, we hardwire the assumption
|
| 234 |
# that we're always using upload.cgi
|
| 235 |
ifdef FILES
|
| 236 |
|
| 237 |
# we hardwire curl in here because the upload rules are very dependent
|
| 238 |
# on curl's behavior on missing pages, ISEs, etc.
|
| 239 |
UPLOAD_CERT = $(shell if test -f $(HOME)/.fedora.cert ; then echo " --cert $(HOME)/.fedora.cert" ; fi)
|
| 240 |
UPLOAD_CHECK = curl -k $(UPLOAD_CERT) --fail --silent
|
| 241 |
UPLOAD_CLIENT = curl -k $(UPLOAD_CERT) --fail -o /dev/null --show-error --progress-bar
|
| 242 |
|
| 243 |
upload-check = $(UPLOAD_CHECK) -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "filename=$$f" $(UPLOAD_REPOSITORY)
|
| 244 |
upload-file = $(UPLOAD_CLIENT) -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "file=@$$f" $(UPLOAD_REPOSITORY)
|
| 245 |
|
| 246 |
define upload-request
|
| 247 |
echo "Checking : $$b on $(UPLOAD_REPOSITORY)..." ; \
|
| 248 |
check=$$($(upload-check)) ; retc=$$? ; \
|
| 249 |
if test $$retc -ne 0 ; then \
|
| 250 |
echo "ERROR: could not check remote file status" ; \
|
| 251 |
exit -1 ; \
|
| 252 |
elif test "$$check" = "Available" ; then \
|
| 253 |
echo "This file ($$m) is already uploaded" ; \
|
| 254 |
elif test "$$check" = "Missing" ; then \
|
| 255 |
echo "Uploading: $$b to $(UPLOAD_REPOSITORY)..." ; \
|
| 256 |
$(upload-file) || exit 1 ; \
|
| 257 |
else \
|
| 258 |
echo "$$check" ; \
|
| 259 |
exit 1 ; \
|
| 260 |
fi
|
| 261 |
endef
|
| 262 |
|
| 263 |
OPENSSL=$(shell which openssl 2>/dev/null)
|
| 264 |
define check-cert
|
| 265 |
@if ! test -f $(HOME)/.fedora.cert ; then echo "ERROR: You need to download your Fedora client certificate" >&2 ; echo " from https://admin.fedoraproject.org/accounts/" >&2; echo " and save it in a file named ~/.fedora.cert" >&2; exit 1 ; fi
|
| 266 |
@if [ -x ${OPENSSL} ]; then \
|
| 267 |
${OPENSSL} x509 -checkend 6000 -noout -in ${HOME}/.fedora.cert ; \
|
| 268 |
if [ $$? -ne 0 ]; then \
|
| 269 |
echo "ERROR: Your Fedora client-side certificate expired." >&2 ; \
|
| 270 |
echo " You need to download a new client-side certificate" >&2 ; \
|
| 271 |
echo " from https://admin.fedoraproject.org/accounts/" >&2 ; \
|
| 272 |
echo " and save it in a file named ~/.fedora.cert" >&2 ; \
|
| 273 |
exit 1 ; \
|
| 274 |
fi ; \
|
| 275 |
fi
|
| 276 |
endef
|
| 277 |
|
| 278 |
# Upload the FILES, adding to the ./sources manifest
|
| 279 |
upload: $(FILES)
|
| 280 |
$(check-cert)
|
| 281 |
@if ! test -f ./sources ; then touch ./sources ; fi
|
| 282 |
@if ! test -f ./.cvsignore ; then touch ./.cvsignore ; fi
|
| 283 |
@for f in $(FILES); do \
|
| 284 |
if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
|
| 285 |
b="$$(basename $$f)" ; \
|
| 286 |
m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
|
| 287 |
if test "$$m" = "$$(grep $$b sources)" ; then \
|
| 288 |
echo "ERROR: file $$f is already listed in the sources file..." ; \
|
| 289 |
exit 1 ; \
|
| 290 |
fi ; \
|
| 291 |
chmod +r $$f ; \
|
| 292 |
echo ; $(upload-request) ; echo ; \
|
| 293 |
if test -z "$$(egrep ""[[:space:]]$$b$$"" sources)" ; then \
|
| 294 |
echo "$$m" >> sources ; \
|
| 295 |
else \
|
| 296 |
egrep -v "[[:space:]]$$b$$" sources > sources.new ; \
|
| 297 |
echo "$$m" >> sources.new ; \
|
| 298 |
mv sources.new sources ; \
|
| 299 |
fi ; \
|
| 300 |
if test -z "$$(egrep ""^$$b$$"" .cvsignore)" ; then \
|
| 301 |
echo $$b >> .cvsignore ; \
|
| 302 |
fi \
|
| 303 |
done
|
| 304 |
@if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
|
| 305 |
@echo "Source upload succeeded. Don't forget to commit the new ./sources file"
|
| 306 |
@cvs update sources .cvsignore
|
| 307 |
|
| 308 |
# Upload FILES and recreate the ./sources file to include only these FILES
|
| 309 |
new-source new-sources: $(FILES)
|
| 310 |
$(check-cert)
|
| 311 |
@rm -f sources && touch sources
|
| 312 |
@rm -f .cvsignore && touch .cvsignore
|
| 313 |
@for f in $(FILES); do \
|
| 314 |
if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
|
| 315 |
b="$$(basename $$f)" ; \
|
| 316 |
m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
|
| 317 |
chmod +r $$f ; \
|
| 318 |
echo ; $(upload-request) ; echo ; \
|
| 319 |
echo "$$m" >> sources ; \
|
| 320 |
echo "$$b" >> .cvsignore ; \
|
| 321 |
done
|
| 322 |
@if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
|
| 323 |
@echo "Source upload succeeded. Don't forget to commit the new ./sources file"
|
| 324 |
@cvs update sources .cvsignore
|
| 325 |
else
|
| 326 |
upload new-source new-sources:
|
| 327 |
@echo "FILES variable not set!"
|
| 328 |
endif
|
| 329 |
|
| 330 |
# allow overriding buildarch so you can do, say, an i386 build on x86_64
|
| 331 |
ifndef BUILDARCH
|
| 332 |
BUILDARCH := $(shell rpm --eval "%{_arch}")
|
| 333 |
endif
|
| 334 |
|
| 335 |
# test build in mock
|
| 336 |
mockbuild : srpm
|
| 337 |
mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) rebuild $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
|
| 338 |
|
| 339 |
# check the build with rpmlint
|
| 340 |
lint:
|
| 341 |
@test -e $(NAME)-$(VERSION)-$(RELEASE).src.rpm || (echo "run 'make local' first" ; exit 1 )
|
| 342 |
rpmlint $(NAME)-$(VERSION)-$(RELEASE).src.rpm $(LOCALARCH)/*-$(VERSION)-$(RELEASE).$(LOCALARCH).rpm
|
| 343 |
|
| 344 |
# build for a particular arch
|
| 345 |
$(ARCHES) : sources $(TARGETS)
|
| 346 |
$(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log ; exit $${PIPESTATUS[0]}
|
| 347 |
|
| 348 |
# empty target to force checking of md5sums in FULLSOURCEFILES
|
| 349 |
FORCE:
|
| 350 |
|
| 351 |
# build whatever's appropriate for the local architecture
|
| 352 |
local: $(LOCALARCH)
|
| 353 |
|
| 354 |
# attempt to apply all the patches, optionally only for a particular arch
|
| 355 |
ifdef PREPARCH
|
| 356 |
prep: sources $(TARGETS)
|
| 357 |
$(RPM_WITH_DIRS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
|
| 358 |
else
|
| 359 |
prep: sources $(TARGETS)
|
| 360 |
$(RPM_WITH_DIRS) --nodeps -bp $(SPECFILE)
|
| 361 |
endif
|
| 362 |
|
| 363 |
# this allows for make prep-i686, make prep-ppc64, etc
|
| 364 |
prep-% : Makefile
|
| 365 |
$(MAKE) prep PREPARCH=$*
|
| 366 |
|
| 367 |
compile: sources $(TARGETS)
|
| 368 |
$(RPM_WITH_DIRS) -bc $(SPECFILE)
|
| 369 |
|
| 370 |
install: sources $(TARGETS)
|
| 371 |
$(RPM_WITH_DIRS) -bi $(SPECFILE)
|
| 372 |
|
| 373 |
compile-short: sources $(TARGETS)
|
| 374 |
$(RPM_WITH_DIRS) --nodeps --short-circuit -bc $(SPECFILE)
|
| 375 |
|
| 376 |
install-short: sources $(TARGETS)
|
| 377 |
$(RPM_WITH_DIRS) --nodeps --short-circuit -bi $(SPECFILE)
|
| 378 |
|
| 379 |
CVS_ROOT := $(shell if [ -f CVS/Root ] ; then cat CVS/Root ; fi)
|
| 380 |
CVS_REPOSITORY := $(shell if [ -f CVS/Repository ] ; then cat CVS/Repository ; fi)
|
| 381 |
CVS_URL := cvs://cvs.fedoraproject.org/cvs/pkgs?$(CVS_REPOSITORY)\#$(TAG)
|
| 382 |
|
| 383 |
## create a clean exported copy in $(TMPCVS)
|
| 384 |
export:: sources
|
| 385 |
@mkdir -p $(WORKDIR)
|
| 386 |
/bin/rm -rf $(TMPCVS)
|
| 387 |
@if test -z "$(TAG)" ; then echo "Must specify a tag to check out" ; exit 1; fi
|
| 388 |
@mkdir -p $(TMPCVS)
|
| 389 |
@cd $(TMPCVS) && \
|
| 390 |
cvs -Q -d $(CVS_ROOT) export -r$(TAG) -d $(NAME) $(CVS_REPOSITORY) && \
|
| 391 |
cvs -Q -d $(CVS_ROOT) export -rHEAD common
|
| 392 |
@if [ -n "$(FULLSOURCEFILES)" ]; then ln -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) 2> /dev/null || cp -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) ; fi
|
| 393 |
@echo "Exported $(TMPCVS)/$(NAME)"
|
| 394 |
|
| 395 |
## build a test-srpm and see if it will -bp on all arches
|
| 396 |
# XXX: I am not sure exactly what this is supposed to really do, since the
|
| 397 |
# query format returns (none) most of the time, and that is not
|
| 398 |
# handled --gafton
|
| 399 |
check: test-srpm
|
| 400 |
@archs=`rpm -qp $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm --qf "[%{EXCLUSIVEARCH}\n]" | egrep -v "(i586)|(i686)|(athlon)"` ;\
|
| 401 |
if test -z "$$archs"; then archs=noarch; fi ; \
|
| 402 |
echo "Checking arches: $$archs" ; \
|
| 403 |
for arch in $$archs; do \
|
| 404 |
echo "Checking $$arch..."; \
|
| 405 |
if ! $(RPM_WITH_DIRS) -bp --target $$arch $(SPECFILE); then \
|
| 406 |
echo "*** make prep failed for $$arch"; \
|
| 407 |
exit 1; \
|
| 408 |
fi; \
|
| 409 |
done;
|
| 410 |
|
| 411 |
## use this to build an srpm locally
|
| 412 |
srpm: sources $(TARGETS)
|
| 413 |
$(RPM_WITH_DIRS) --nodeps -bs $(SPECFILE)
|
| 414 |
|
| 415 |
test-srpm: srpm
|
| 416 |
|
| 417 |
verrel:
|
| 418 |
@echo $(NAME)-$(VERSION)-$(RELEASE)
|
| 419 |
|
| 420 |
# If you build a new version into the tree, first do "make tag",
|
| 421 |
# then "make srpm", then build the package.
|
| 422 |
tag:: $(SPECFILE) $(COMMON_DIR)/branches
|
| 423 |
cvs tag $(TAG_OPTS) -c $(TAG)
|
| 424 |
@echo "Tagged with: $(TAG)"
|
| 425 |
@echo
|
| 426 |
|
| 427 |
define find-user
|
| 428 |
if [ `cat CVS/Root |grep -c [^:]@` -ne 0 ]; then cat CVS/Root |cut -d @ -f 1 | sed 's/:.*://' ; else echo $(USER); fi
|
| 429 |
endef
|
| 430 |
USER := $(shell $(find-user))
|
| 431 |
|
| 432 |
oldbuild: $(COMMON_DIR)/branches
|
| 433 |
@if [ -z "$(TARGET)" -a ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
|
| 434 |
|
| 435 |
@cvs status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
|
| 436 |
if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
|
| 437 |
|
| 438 |
@(pushd $(COMMON_DIR) >/dev/null ;\
|
| 439 |
rm -f tobuild ;\
|
| 440 |
cvs -Q update -C tobuild ;\
|
| 441 |
echo -e "$(USER)\t$(CVS_REPOSITORY)\t$(TAG)\t$(TARGET)" >> tobuild ;\
|
| 442 |
cvs commit -m "request build of $(CVS_REPOSITORY) $(TAG) for $(TARGET)" tobuild ;\
|
| 443 |
popd >/dev/null)
|
| 444 |
|
| 445 |
build-check: $(SPECFILE)
|
| 446 |
@if [ -z "$(TARGET)" -o ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
|
| 447 |
@cvs -f status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
|
| 448 |
if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
|
| 449 |
|
| 450 |
|
| 451 |
build: build-check $(COMMON_DIR)/branches
|
| 452 |
@if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
|
| 453 |
$(BUILD_CLIENT) $(SECONDARY_CONFIG) build $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
|
| 454 |
|
| 455 |
|
| 456 |
scratch-build: build-check
|
| 457 |
@if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
|
| 458 |
$(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
|
| 459 |
|
| 460 |
srpm-scratch-build: srpm
|
| 461 |
@if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
|
| 462 |
$(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch $(BUILD_FLAGS) $(TARGET) $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
|
| 463 |
|
| 464 |
scratch-build-%: build-check
|
| 465 |
@if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
|
| 466 |
$(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch --arch-override=$* $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
|
| 467 |
|
| 468 |
srpm-scratch-build-%: srpm
|
| 469 |
@if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
|
| 470 |
$(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch --arch-override=$* $(BUILD_FLAGS) $(TARGET) $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
|
| 471 |
|
| 472 |
|
| 473 |
bodhi: build-check $(COMMON_DIR)/branches clog
|
| 474 |
@if [ ! -x "$(BODHI_CLIENT)" ]; then echo "Must have bodhi-client installed"; exit 1; fi
|
| 475 |
@echo -e "\
|
| 476 |
[ $(NAME)-$(VERSION)-$(RELEASE) ]\n\n\
|
| 477 |
# bugfix, security, enhancement, newpackage (required)\n\
|
| 478 |
type=\n\n\
|
| 479 |
# testing, stable\n\
|
| 480 |
request=testing\n\n\
|
| 481 |
# Bug numbers: 1234,9876\n\
|
| 482 |
bugs=\n\n\
|
| 483 |
# Description of your update\n\
|
| 484 |
notes=Here is where you\n\
|
| 485 |
\tgive an explanation of\n\
|
| 486 |
\tyour update.\n\n\
|
| 487 |
# Enable request automation based on the stable/unstable karma thresholds\n\
|
| 488 |
autokarma=True\n\
|
| 489 |
stable_karma=3\n\
|
| 490 |
unstable_karma=-3\n\n\
|
| 491 |
# Automatically close bugs when this marked as stable\n\
|
| 492 |
close_bugs=True\n\n\
|
| 493 |
# Suggest that users restart after update\n\
|
| 494 |
suggest_reboot=False\n\
|
| 495 |
" > bodhi.template
|
| 496 |
@grep -Z '#' clog | xargs -0n1 | sed -n -e 's,^#\([0-9]*\)$$,\1,p' | xargs | tr ' ' ',' > $(NAME).bugs
|
| 497 |
@if [ `cat $(NAME).bugs` ]; then echo "bug=`cat $(NAME).bugs`" >> bodhi.template; fi
|
| 498 |
@sed -e '/^#/d' < bodhi.template > bodhi.template.orig
|
| 499 |
@if [ -z "$$EDITOR" ]; then vi bodhi.template; else $$EDITOR bodhi.template; fi
|
| 500 |
@if [ -n "`sed -e '/^#/d' < bodhi.template | diff bodhi.template.orig -`" ]; then \
|
| 501 |
$(BODHI_CLIENT) --new --release $(subst -,,$(BRANCH)) \
|
| 502 |
--file bodhi.template $(NAME)-$(VERSION)-$(RELEASE) -u $(BODHI_USER); \
|
| 503 |
else \
|
| 504 |
echo "Bodhi update aborted!"; \
|
| 505 |
fi
|
| 506 |
@rm -f bodhi.template{,.orig} $(NAME).bugs clog
|
| 507 |
|
| 508 |
ifndef $(BODHI_USER)
|
| 509 |
BODHI_USER=$(USER)
|
| 510 |
endif
|
| 511 |
|
| 512 |
update: bodhi
|
| 513 |
|
| 514 |
tag-request: build-check $(COMMON_DIR)/branches
|
| 515 |
@if [ ! -x "$(FEDORAHOSTED)" ]; then echo "Must have fedora-packager > 0.3.8 installed"; exit 1; fi
|
| 516 |
@echo -e "\
|
| 517 |
# Tag target (default is target of the CVS branch)\n\
|
| 518 |
target=$(TARGET)\n\n\
|
| 519 |
# Description of your tag request\n\
|
| 520 |
notes=Here is where you give a description of what you want to change,\n\
|
| 521 |
rational for why the change is important enough to break the freeze,\n\
|
| 522 |
impact of not accepting the change, and what testing has been done.\n\
|
| 523 |
Or if this is a tag request for updates, just the info about the updates.\
|
| 524 |
" > fedora-hosted.template
|
| 525 |
@sed -e '/^#/d' < fedora-hosted.template > fedora-hosted.template.orig
|
| 526 |
@if [ -z "$$EDITOR" ]; then vi fedora-hosted.template; else $$EDITOR fedora-hosted.template; fi
|
| 527 |
@if [ -n "`sed -e '/^#/d' < fedora-hosted.template | diff fedora-hosted.template.orig -`" ]; then \
|
| 528 |
target=`grep '^target=' fedora-hosted.template | sed -e 's/target=//'` \
|
| 529 |
component=`echo $(TARGET) |grep -q epel && echo "epel" || echo "koji"`\
|
| 530 |
descript="{{{\
|
| 531 |
`grep -v -e '^target=' -e '^#' fedora-hosted.template | sed -e 's/notes=//'`"; \
|
| 532 |
$(FEDORAHOSTED) -u $(USER) -P rel-eng new-ticket -s \
|
| 533 |
"Tag request $(NAME)-$(VERSION)-$(RELEASE) for $$target" \
|
| 534 |
-C $$component -d "$$descript"; \
|
| 535 |
else \
|
| 536 |
echo "Tag request aborted!"; \
|
| 537 |
fi
|
| 538 |
@rm -f fedora-hosted.template{,.orig}
|
| 539 |
|
| 540 |
|
| 541 |
cvsurl:
|
| 542 |
@echo '$(CVS_URL)'
|
| 543 |
|
| 544 |
target:
|
| 545 |
@echo '$(TARGET)'
|
| 546 |
|
| 547 |
chain-build: build-check
|
| 548 |
@if [ -z "$(CHAIN)" ]; then \
|
| 549 |
echo "Missing CHAIN variable, please specify the order of packages to" ; \
|
| 550 |
echo "chain build. For example: make chain-build CHAIN='foo bar'" ; \
|
| 551 |
exit 1 ; \
|
| 552 |
fi ; \
|
| 553 |
set -e ; \
|
| 554 |
subdir=`basename $$(pwd)` ; \
|
| 555 |
urls="" ; \
|
| 556 |
for component in $(CHAIN) ; do \
|
| 557 |
if [ "$$component" = "$(NAME)" ]; then \
|
| 558 |
echo "$(NAME) must not appear in CHAIN" ; \
|
| 559 |
exit 1 ; \
|
| 560 |
fi ; \
|
| 561 |
if [ "$$component" = ":" ]; then \
|
| 562 |
urls="$$urls :" ; \
|
| 563 |
continue ; \
|
| 564 |
elif [ -n "$$urls" -a -z "$(findstring :,$(CHAIN))" ]; then \
|
| 565 |
urls="$$urls :" ; \
|
| 566 |
fi ; \
|
| 567 |
rm -rf .tmp-$$$$ ; \
|
| 568 |
mkdir -p .tmp-$$$$ ; \
|
| 569 |
pushd .tmp-$$$$ > /dev/null ; \
|
| 570 |
cvs -f -Q -z 3 -d $(CVS_ROOT) co $$component ; \
|
| 571 |
urls="$$urls `make -s -C $$component/$$subdir cvsurl`" ; \
|
| 572 |
popd > /dev/null ; \
|
| 573 |
rm -rf .tmp-$$$$ ; \
|
| 574 |
done ; \
|
| 575 |
if [ -z "$(findstring :,$(CHAIN))" ]; then \
|
| 576 |
urls="$$urls :" ; \
|
| 577 |
fi ; \
|
| 578 |
urls="$$urls `make -s cvsurl`" ; \
|
| 579 |
$(BUILD_CLIENT) chain-build $(BUILD_FLAGS) $(TARGET) $$urls
|
| 580 |
|
| 581 |
# "make new | less" to see what has changed since the last tag was assigned
|
| 582 |
new:
|
| 583 |
-@cvs diff -u -r$$(cvs log Makefile 2>/dev/null | awk '/^symbolic names:$$/ {getline; sub(/^[ \t]*/, "") ; sub (/:.*$$/, ""); print; exit 0}')
|
| 584 |
|
| 585 |
# mop up, printing out exactly what was mopped.
|
| 586 |
clean ::
|
| 587 |
@echo "Running the %clean script of the rpmbuild..."
|
| 588 |
-@$(RPM_WITH_DIRS) --clean --nodeps $(SPECFILE)
|
| 589 |
@for F in $(FULLSOURCEFILES); do \
|
| 590 |
if test -e $$F ; then \
|
| 591 |
echo "Deleting $$F" ; /bin/rm -f $$F ; \
|
| 592 |
fi; \
|
| 593 |
done
|
| 594 |
@if test -d $(TMPCVS); then \
|
| 595 |
echo "Deleting CVS dir $(TMPCVS)" ; \
|
| 596 |
/bin/rm -rf $(TMPCVS); \
|
| 597 |
fi
|
| 598 |
@if test -e $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; then \
|
| 599 |
echo "Deleting $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm" ; \
|
| 600 |
/bin/rm -f $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; \
|
| 601 |
fi
|
| 602 |
@rm -fv *~ clog
|
| 603 |
@echo "Fully clean!"
|
| 604 |
|
| 605 |
# To prevent CVS noise due to changing file timestamps, upgrade
|
| 606 |
# to patchutils-0.2.23-3 or later, and add to ~/.cvspkgsrc:
|
| 607 |
# FILTERDIFF := filterdiff --remove-timestamps
|
| 608 |
ifndef FILTERDIFF
|
| 609 |
FILTERDIFF := cat
|
| 610 |
endif
|
| 611 |
|
| 612 |
ifdef CVE
|
| 613 |
PATCHFILE := $(NAME)-$(VERSION)-CVE-$(CVE).patch
|
| 614 |
SUFFIX := cve$(shell echo $(CVE) | sed s/.*-//)
|
| 615 |
else
|
| 616 |
PATCHFILE := $(NAME)-$(VERSION)-$(SUFFIX).patch
|
| 617 |
endif
|
| 618 |
|
| 619 |
patch:
|
| 620 |
@if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
|
| 621 |
(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) > $(PATCHFILE) || true
|
| 622 |
@if ! test -s $(PATCHFILE); then echo "Patch is empty!"; exit 1; fi
|
| 623 |
@echo "Created $(PATCHFILE)"
|
| 624 |
@grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
|
| 625 |
|
| 626 |
# Recreates the patch file of specified suffix from the current working sources
|
| 627 |
# but keeping any comments at the top of file intact, and backing up the old copy
|
| 628 |
# with a '~' suffix.
|
| 629 |
rediff:
|
| 630 |
@if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
|
| 631 |
@if ! test -f "$(PATCHFILE)"; then echo "$(PATCHFILE) not found"; exit 1; fi
|
| 632 |
@mv -f $(PATCHFILE) $(PATCHFILE)\~
|
| 633 |
@sed '/^--- /,$$d' < $(PATCHFILE)\~ > $(PATCHFILE)
|
| 634 |
@(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) >> $(PATCHFILE) || true
|
| 635 |
|
| 636 |
clog: $(SPECFILE)
|
| 637 |
@sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $(SPECFILE) | tee $@
|
| 638 |
|
| 639 |
help:
|
| 640 |
@echo "Usage: make <target>"
|
| 641 |
@echo "Available targets are:"
|
| 642 |
@echo " help Show this text"
|
| 643 |
@echo " sources Download source files [default]"
|
| 644 |
@echo " upload FILES=<files> Add <files> to CVS"
|
| 645 |
@echo " new-sources FILES=<files> Replace sources in CVS with <files>"
|
| 646 |
@echo " <arch> Local test rpmbuild binary"
|
| 647 |
@echo " local Local test rpmbuild binary"
|
| 648 |
@echo " prep Local test rpmbuild prep"
|
| 649 |
@echo " compile Local test rpmbuild compile"
|
| 650 |
@echo " install Local test rpmbuild install"
|
| 651 |
@echo " compile-short Local test rpmbuild short-circuit compile"
|
| 652 |
@echo " install-short Local test rpmbuild short-circuit install"
|
| 653 |
@echo " lint Run rpmlint against local build output"
|
| 654 |
@echo " export Create clean export in \"cvs-$(TAG)\""
|
| 655 |
@echo " check Check test srpm preps on all archs"
|
| 656 |
@echo " srpm Create a srpm"
|
| 657 |
@echo " tag Tag sources as \"$(TAG)\""
|
| 658 |
@echo " build Request build of \"$(TAG)\" for $(TARGET)"
|
| 659 |
@echo " chain-build Build current package in order with other packages"
|
| 660 |
@echo " example: make chain-build CHAIN='libwidget libgizmo'"
|
| 661 |
@echo " The current package is added to the end of the CHAIN list."
|
| 662 |
@echo " Colons (:) can be used in the CHAIN parameter to define"
|
| 663 |
@echo " groups of packages. Packages in any single group will be"
|
| 664 |
@echo " built in parallel and all packages in a group must build"
|
| 665 |
@echo " successfully and populate the repository before the next"
|
| 666 |
@echo " group will begin building. For example:"
|
| 667 |
@echo " make chain-build CHAIN='libwidget libaselib : libgizmo :'"
|
| 668 |
@echo " will cause libwidget and libaselib to be built in parallel,"
|
| 669 |
@echo " followed by libgizmo and then the currect directory package."
|
| 670 |
@echo " If no groups are defined, packages will be built sequentially."
|
| 671 |
@echo " scratch-build Request scratch build of \"$(TAG)\" for $(TARGET)"
|
| 672 |
@echo " srpm-scratch-build Request scratch build of srpm"
|
| 673 |
@echo " scratch-build-<archs> Request scratch build of \"$(TAG)\" for $(TARGET) and archs <archs>"
|
| 674 |
@echo " srpm-scratch-build-<archs> Request scratch build of srpm and archs <archs>"
|
| 675 |
@echo " examples: make scratch-build-i386,ppc64"
|
| 676 |
@echo " make scratch-build-x86_64"
|
| 677 |
@echo " mockbuild Local test build using mock"
|
| 678 |
@echo " verrel Echo \"$(NAME)-$(VERSION)-$(RELEASE)\""
|
| 679 |
@echo " new Diff against last tag"
|
| 680 |
@echo " clog Make a clog file containing top changelog entry"
|
| 681 |
@echo " clean Remove srcs ($(SOURCEFILES)), export dir (cvs-$(TAG)) and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
|
| 682 |
@echo " patch SUFFIX=<suff> Create and add a gendiff patch file"
|
| 683 |
@echo " rediff SUFFIX=<suff> Recreates a gendiff patch file, retaining comments"
|
| 684 |
@echo " unused-patches Print list of patches not referenced by name in specfile"
|
| 685 |
@echo " unused-fedora-patches Print Fedora patches not used by Patch and/or ApplyPatch directives"
|
| 686 |
@echo " gimmespec Print the name of the specfile"
|
| 687 |
@echo " update Submit $(NAME)-$(VERSION)-$(RELEASE) as an update for $(BRANCH)"
|
| 688 |
@echo " tag-request Submit $(NAME)-$(VERSION)-$(RELEASE) as an tag-request for $(BRANCH)"
|
| 689 |
@echo
|
| 690 |
@echo "For bug reports or patch submissions, please use the issue tracker at:"
|
| 691 |
@echo "https://fedorahosted.org/fedora-infrastructure"
|
| 692 |
@echo "Hint: You need to login with your FAS credentials to see the 'new ticket' link."
|
| 693 |
|
| 694 |
gimmespec:
|
| 695 |
@echo "$(SPECFILE)"
|
| 696 |
|
| 697 |
unused-patches:
|
| 698 |
@for f in *.patch; do if [ -e $$f ]; then grep -q $$f $(SPECFILE) || echo $$f; fi; done
|
| 699 |
|
| 700 |
unused-fedora-patches:
|
| 701 |
@for f in *.patch; do if [ -e $$f ]; then (egrep -q "^Patch[[:digit:]]+:[[:space:]]+$$f" $(SPECFILE) || echo "Unused: $$f") && egrep -q "^ApplyPatch[[:space:]]+$$f" $(SPECFILE) || echo "Unapplied: $$f"; fi; done
|
| 702 |
|
| 703 |
##################### EXPERIMENTAL ##########################
|
| 704 |
# this stuff is very experimental in nature and should not be
|
| 705 |
# relied upon until these targets are moved above this line
|
| 706 |
|
| 707 |
# This section contains some hacks that instrument
|
| 708 |
# download-from-upstream support. You'll have to talk to gafton, he
|
| 709 |
# knows how this shit works.
|
| 710 |
|
| 711 |
# Add to the list of hardcoded upstream files the contents of the
|
| 712 |
# ./upstream file
|
| 713 |
UPSTREAM_FILES += $(shell if test -f ./upstream ; then cat ./upstream ; fi)
|
| 714 |
# extensions for signature files we need to retrieve for verification
|
| 715 |
# Warning: if you update the set of defaults, please make sure to
|
| 716 |
# update/add to the checking rules further down
|
| 717 |
UPSTREAM_CHECKS ?= sign asc sig md5
|
| 718 |
|
| 719 |
# check the signatures for the downloaded upstream stuff
|
| 720 |
UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
|
| 721 |
|
| 722 |
# Download a file from a particular host.
|
| 723 |
# First argument contains the url base, the second the filename,
|
| 724 |
# third extra curl options
|
| 725 |
define download-host-file
|
| 726 |
if test ! -e "$(2)" ; then \
|
| 727 |
echo -n "URL: $(1)/$(2) ..." ; \
|
| 728 |
$(CURL) --silent --head $(1)/$(2) && \
|
| 729 |
{ \
|
| 730 |
echo "OK, downloading..." ; \
|
| 731 |
$(CURL) $(3) $(1)/$(2) ; \
|
| 732 |
} || \
|
| 733 |
echo "not found" ; \
|
| 734 |
fi
|
| 735 |
endef
|
| 736 |
|
| 737 |
# Download a file, trying each mirror in sequence. Also check for
|
| 738 |
# signatures, if available
|
| 739 |
# First argument contains the file name. We read the list of mirrors
|
| 740 |
# from the ./mirrors file
|
| 741 |
define download-file
|
| 742 |
$(foreach h, $(shell cat mirrors),
|
| 743 |
$(call download-host-file,$(h),$(1))
|
| 744 |
if test -e $(1) ; then \
|
| 745 |
$(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
|
| 746 |
fi
|
| 747 |
)
|
| 748 |
if test ! -e $(1) ; then \
|
| 749 |
echo "ERROR: Could not download file: $(1)" ; \
|
| 750 |
exit -1 ; \
|
| 751 |
else \
|
| 752 |
echo "File $(1) available for local use" ; \
|
| 753 |
fi
|
| 754 |
endef
|
| 755 |
|
| 756 |
# Download all the UPSTREAM files
|
| 757 |
define download-files
|
| 758 |
$(foreach f, $(UPSTREAM_FILES),
|
| 759 |
$(call download-file,$(f))
|
| 760 |
echo
|
| 761 |
)
|
| 762 |
endef
|
| 763 |
|
| 764 |
# Make sure the signature files we download are properly added
|
| 765 |
define cvs-add-upstream-sigs
|
| 766 |
for s in $(UPSTREAM_CHECK_FILES) ; do \
|
| 767 |
if test -f "$$s" ; then \
|
| 768 |
if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
|
| 769 |
cvs -Q add "$$s" ; \
|
| 770 |
fi ; \
|
| 771 |
fi ; \
|
| 772 |
done
|
| 773 |
endef
|
| 774 |
|
| 775 |
download : upstream mirrors
|
| 776 |
@$(download-files)
|
| 777 |
$(MAKE) download-checks
|
| 778 |
|
| 779 |
download-checks :: import-upstream-gpg
|
| 780 |
download-checks :: $(UPSTREAM_CHECK_FILES)
|
| 781 |
|
| 782 |
# how to check for a gpg signature, given a separate signature file
|
| 783 |
define check-upstream-gpg-sig
|
| 784 |
echo -n "Checking GPG signature on $* from $@ : "
|
| 785 |
if ! test -f $@ ; then \
|
| 786 |
echo "ERROR" ; echo "GPG signature file $@ not found" ; \
|
| 787 |
exit 1 ; \
|
| 788 |
fi
|
| 789 |
if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
|
| 790 |
echo "FAILED" ; \
|
| 791 |
exit 1 ; \
|
| 792 |
else \
|
| 793 |
echo "OK" ; \
|
| 794 |
fi
|
| 795 |
endef
|
| 796 |
|
| 797 |
# how to check for a md5sum, given a separate .md5 file
|
| 798 |
define check-upstream-md5sum
|
| 799 |
echo -n "Checking md5sum on $* from $@ : "
|
| 800 |
if ! test -f $@ ; then \
|
| 801 |
echo "ERROR" ; echo "md5sum file $@ not found" ; \
|
| 802 |
exit 1 ; \
|
| 803 |
fi
|
| 804 |
if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
|
| 805 |
echo "FAILED" ; \
|
| 806 |
exit 1 ; \
|
| 807 |
else \
|
| 808 |
echo "OK" ; \
|
| 809 |
fi
|
| 810 |
endef
|
| 811 |
|
| 812 |
# and now the rules, specific to each extension
|
| 813 |
$(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
|
| 814 |
@$(check-upstream-gpg-sig)
|
| 815 |
$(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
|
| 816 |
@$(check-upstream-gpg-sig)
|
| 817 |
$(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
|
| 818 |
@$(check-upstream-gpg-sig)
|
| 819 |
$(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
|
| 820 |
@$(check-upstream-md5sum)
|
| 821 |
|
| 822 |
# We keep all the relevant GPG keys in the upstream-key.gpg so we can
|
| 823 |
# check the signatures...
|
| 824 |
import-upstream-gpg : upstream-key.gpg FORCE
|
| 825 |
mkdir -p $(HOME)/.gnupg
|
| 826 |
gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
|
| 827 |
|
| 828 |
# A handy target to download the latest and greatest from upstream and
|
| 829 |
# check it into the lookaside cache.
|
| 830 |
# new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
|
| 831 |
# rebase uses the standard "make upload"
|
| 832 |
new-base : clean download
|
| 833 |
$(MAKE) new-source FILES="$(UPSTREAM_FILES)"
|
| 834 |
@$(cvs-add-upstream-sigs)
|
| 835 |
@echo "Don't forget to do a 'cvs commit' for your new sources file."
|
| 836 |
|
| 837 |
rebase : clean download
|
| 838 |
$(MAKE) upload FILES="$(UPSTREAM_FILES)"
|
| 839 |
@$(cvs-add-upstream-sigs)
|
| 840 |
@echo "Don't forget to do a 'cvs commit' for your new sources file."
|
| 841 |
|
| 842 |
# there is more stuff to clean, now that we have upstream files
|
| 843 |
clean ::
|
| 844 |
@rm -fv $(UPSTREAM_FILES)
|