Makefile: simplify "make rpm"
parent
cae57c60a1
commit
0e6a94b329
34
Makefile
34
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION=011
|
VERSION=010
|
||||||
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
|
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
|
||||||
|
|
||||||
prefix ?= /usr
|
prefix ?= /usr
|
||||||
|
|
@ -10,9 +10,10 @@ mandir ?= ${prefix}/share/man
|
||||||
|
|
||||||
manpages = dracut.8 dracut.kernel.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
|
manpages = dracut.8 dracut.kernel.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
|
||||||
|
|
||||||
.PHONY: install clean archive rpm testimage test all check AUTHORS
|
.PHONY: install clean archive rpm testimage test all check AUTHORS doc
|
||||||
|
|
||||||
all: syncheck $(manpages) dracut.html
|
doc: $(manpages) dracut.html
|
||||||
|
all: syncheck
|
||||||
|
|
||||||
%: %.xml
|
%: %.xml
|
||||||
xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
|
xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
|
||||||
|
|
@ -23,7 +24,7 @@ dracut.html: dracut.xml $(manpages)
|
||||||
--stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \
|
--stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \
|
||||||
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
|
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
|
||||||
|
|
||||||
install:
|
install: doc
|
||||||
mkdir -p $(DESTDIR)$(pkglibdir)
|
mkdir -p $(DESTDIR)$(pkglibdir)
|
||||||
mkdir -p $(DESTDIR)$(sbindir)
|
mkdir -p $(DESTDIR)$(sbindir)
|
||||||
mkdir -p $(DESTDIR)$(sysconfdir)
|
mkdir -p $(DESTDIR)$(sysconfdir)
|
||||||
|
|
@ -64,22 +65,15 @@ dracut-$(VERSION).tar.bz2:
|
||||||
dracut-$(VERSION).tar.gz:
|
dracut-$(VERSION).tar.gz:
|
||||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
|
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
|
||||||
|
|
||||||
dracut-$(VERSION)-$(GITVERSION).tar.bz2:
|
rpm: dracut-$(VERSION).tar.bz2
|
||||||
git archive --format=tar HEAD --prefix=dracut-$(VERSION)-$(GITVERSION)/ |bzip2 > dracut-$(VERSION)-$(GITVERSION).tar.bz2
|
mkdir -p rpmbuild
|
||||||
|
cp dracut-$(VERSION).tar.bz2 rpmbuild
|
||||||
|
cd rpmbuild; ../git2spec.pl $(VERSION) < ../dracut.spec > dracut.spec; \
|
||||||
rpm: clean dracut-$(VERSION).tar.bz2
|
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
|
||||||
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" -ba dracut.spec
|
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
|
||||||
rm -fr BUILD BUILDROOT
|
--define "_rpmdir $$PWD" -ba dracut.spec || :; \
|
||||||
|
cd ..;
|
||||||
gitrpm: dracut-$(VERSION)-$(GITVERSION).tar.bz2
|
rm -fr rpmbuild
|
||||||
echo "%define gittag $(GITVERSION)" > dracut.spec.git
|
|
||||||
cat dracut.spec >> dracut.spec.git
|
|
||||||
mv dracut.spec dracut.spec.bak
|
|
||||||
mv dracut.spec.git dracut.spec
|
|
||||||
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec || :
|
|
||||||
mv dracut.spec.bak dracut.spec
|
|
||||||
rm -fr BUILD BUILDROOT
|
|
||||||
|
|
||||||
syncheck:
|
syncheck:
|
||||||
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \
|
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \
|
||||||
|
|
|
||||||
18
dracut.spec
18
dracut.spec
|
|
@ -6,17 +6,9 @@
|
||||||
%define with_nbd 0
|
%define with_nbd 0
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{defined gittag}
|
|
||||||
%define rdist .git%{gittag}%{?dist}
|
|
||||||
%define dashgittag -%{gittag}
|
|
||||||
%else
|
|
||||||
%define rdist %{?dist}
|
|
||||||
%endif
|
|
||||||
|
|
||||||
Name: dracut
|
Name: dracut
|
||||||
Version: 011
|
Version: xxx
|
||||||
%define release_prefix 0%{?rdist}
|
Release: xxx
|
||||||
Release: %{release_prefix}
|
|
||||||
|
|
||||||
Summary: Initramfs generator using udev
|
Summary: Initramfs generator using udev
|
||||||
%if 0%{?fedora}
|
%if 0%{?fedora}
|
||||||
|
|
@ -28,8 +20,8 @@ Group: System/Base
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: https://dracut.wiki.kernel.org/
|
URL: https://dracut.wiki.kernel.org/
|
||||||
# Source can be generated by
|
# Source can be generated by
|
||||||
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{?dashgittag};sf=tgz
|
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
|
||||||
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}%{?dashgittag}.tar.bz2
|
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: dash bash
|
BuildRequires: dash bash
|
||||||
|
|
@ -162,7 +154,7 @@ Requires: %{name} = %{version}-%{release}
|
||||||
This package contains tools to assemble the local initrd and host configuration.
|
This package contains tools to assemble the local initrd and host configuration.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}%{?dashgittag}
|
%setup -q -n %{name}-%{version}
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make
|
make
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
sub last_tag {
|
||||||
|
open( GIT, 'git log --pretty=format:%H |');
|
||||||
|
LINE: while( <GIT> ) {
|
||||||
|
open( GIT2, "git tag --contains $_ |");
|
||||||
|
while( <GIT2> ) {
|
||||||
|
chomp;
|
||||||
|
last LINE if /..*/;
|
||||||
|
}
|
||||||
|
close GIT2;
|
||||||
|
}
|
||||||
|
$tag=$_;
|
||||||
|
close GIT2;
|
||||||
|
close GIT; # be done
|
||||||
|
return $tag;
|
||||||
|
};
|
||||||
|
|
||||||
|
sub create_patches {
|
||||||
|
my $tag=shift;
|
||||||
|
my $num=0;
|
||||||
|
open( GIT, 'git format-patch -M -N --no-signature '.$tag.' |');
|
||||||
|
@lines=<GIT>;
|
||||||
|
close GIT; # be done
|
||||||
|
return @lines;
|
||||||
|
};
|
||||||
|
use POSIX qw(strftime);
|
||||||
|
my $datestr = strftime "%Y%m%d", gmtime;
|
||||||
|
|
||||||
|
my $tag=shift;
|
||||||
|
$tag=&last_tag if not defined $tag;
|
||||||
|
my @patches=&create_patches($tag);
|
||||||
|
my $num=$#patches + 2;
|
||||||
|
$tag=~s/[^0-9]+?([0-9]+)/$1/;
|
||||||
|
my $release="$num.git$datestr";
|
||||||
|
$release="1" if $num == 1;
|
||||||
|
|
||||||
|
while(<>) {
|
||||||
|
if (/^Version:/) {
|
||||||
|
print "Version: $tag\n";
|
||||||
|
}
|
||||||
|
elsif (/^Release:/) {
|
||||||
|
print "Release: $release\n";
|
||||||
|
}
|
||||||
|
elsif ((/^Source0:/) || (/^Source:/)) {
|
||||||
|
print $_;
|
||||||
|
$num=1;
|
||||||
|
for(@patches) {
|
||||||
|
print "Patch$num: $_";
|
||||||
|
$num++;
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
elsif (/^%setup/) {
|
||||||
|
print $_;
|
||||||
|
$num=1;
|
||||||
|
for(@patches) {
|
||||||
|
print "%patch$num -p1\n";
|
||||||
|
$num++;
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue