|
1
by Emmet Hikory
Oops: forgot to actually commit the file addition last time |
1 |
#! /usr/bin/make -R
|
2 |
||
3 |
# Note that there is a fair degree of parallelism possible for many of
|
|
4 |
# the targets. Running with make -j is advised, especially when pulling
|
|
5 |
# sources for analysis.
|
|
6 |
||
7 |
# Constants
|
|
|
5
by Emmet Hikory
Redirect to point at Moblin alpha 3 |
8 |
MOBLIN_SITE := http://repo.moblin.org/moblin/releases/test/alpha3/source |
|
1
by Emmet Hikory
Oops: forgot to actually commit the file addition last time |
9 |
FEDORA_SITE := http://kojipkgs.fedoraproject.org/packages |
10 |
RPM_REPO_DIRS := BUILD RPMS SOURCES SPECS SRPMS |
|
11 |
||
12 |
# Shell Functions
|
|
13 |
GET_LINK := ./list_urls.sed | grep -v ^[/?] | sort -n |
|
14 |
GET_MAX_LINK := ${GET_LINK} | tail -1 | sed 's/\///g' |
|
15 |
UNIQUE_THIRD := cut -d: -f3 | sort -u |
|
16 |
WGETQ := wget -q -O- |
|
17 |
RPMRC := rpm -i --rcfile |
|
18 |
||
19 |
# Derivations
|
|
20 |
BASE_MACRO_STRING ?= $(shell rpm --showrc | grep ^macrofiles | cut -d: -f2-) |
|
|
6
by Emmet Hikory
Fix to use getent, which is just nicer all around |
21 |
USER_NAME ?= $(shell getent passwd | awk -F: "/$$USER/ {print \$$5}" | cut -d, -f1) |
|
1
by Emmet Hikory
Oops: forgot to actually commit the file addition last time |
22 |
|
23 |
MOBLIN_SRPMS ?= $(shell ls moblin/repo/*src.rpm) |
|
24 |
FEDORA_SOURCES ?= $(addprefix stamps/, $(notdir ${MOBLIN_SRPMS})) |
|
25 |
MOBLIN_SOURCES ?= $(foreach src, $(notdir ${MOBLIN_SRPMS}), $(call PKG_NAME, ${src})) |
|
26 |
FEDORA_SRPMS ?= $(shell ls fedora/repo/*src.rpm) |
|
27 |
||
28 |
# Functions
|
|
29 |
UPPER = $(shell echo $(1) | tr a-z A-Z) |
|
30 |
PKG_NAME = $(shell echo $(1) | sed 's/\(.*\)-.*-.*/\1/') |
|
31 |
PKG_VERSION = $(shell echo $(1) | sed 's/.*-\(.*\)-.*/\1/') |
|
32 |
PKG_REV = $(shell echo $(1) | sed 's/.*-.*-\(.*\).src.rpm/\1/') |
|
33 |
||
34 |
PKG_URL = ${FEDORA_SITE}/$(call PKG_NAME, $(1)) |
|
35 |
VERSION_URL = $(call PKG_URL, $(1))/$(call PKG_VERSION, $(1)) |
|
36 |
BACKUP_URL = $(call PKG_URL, $(1))/$(shell ${WGETQ} $(call PKG_URL, $(1)) | ${GET_MAX_LINK}) |
|
37 |
||
38 |
# TODO: Improve selection logic for PICK_REV and BACKUP_URL
|
|
39 |
PICK_REV = $(shell ${WGETQ} $(1) | ${GET_MAX_LINK}) |
|
40 |
PICK_FILE = $(shell ${WGETQ} $(call VERSION_URL, $(1))/$(call PICK_REV, $(call VERSION_URL, $(1)))/src/ | ${GET_LINK} || ${WGETQ} $(call BACKUP_URL, $(1))/$(call PICK_REV, $(call BACKUP_URL, $(1)))/src/ | ${GET_LINK}) |
|
41 |
||
42 |
FVER = $(call PKG_VERSION, $(shell ls fedora/repo/$(strip $(1))*)) |
|
43 |
MVER = $(call PKG_VERSION, $(shell ls moblin/repo/$(strip $(1))*)) |
|
44 |
CHECK_VERSION = $(shell [ -z "$(call FVER, $(1))" -o -z "$(call MVER, $(1))" ] || [ "$(call FVER, $(1))" = "$(call MVER, $(1))" ] || echo $(1) is updated from $(call FVER, $(1)) to $(call MVER, $(1)) @) |
|
45 |
||
46 |
# Targets
|
|
47 |
||
48 |
# Need to invoke make three times to ensure correct variable assignments
|
|
49 |
all: |
|
|
4
by Emmet Hikory
Comment out all rule to suggest manual operation |
50 |
# These need to be run manually, unfortunately
|
51 |
#${MAKE} moblin.unpacked
|
|
52 |
#${MAKE} fedora.unpacked
|
|
53 |
#${MAKE} reports
|
|
|
1
by Emmet Hikory
Oops: forgot to actually commit the file addition last time |
54 |
|
55 |
# The available reports, or all of them
|
|
56 |
||
57 |
reports: missing-report update-report patch-report |
|
58 |
echo missing-report contains a list of new sources
|
|
59 |
echo update-report reports any updated packages
|
|
60 |
echo patch-report contains an overview of changes in patches/
|
|
61 |
||
62 |
patch-report: $(addprefix patches/, $(addsuffix .report, ${MOBLIN_SOURCES})) |
|
63 |
cat patches/*.report > $@
|
|
64 |
||
65 |
missing-report: moblin.packages fedora.packages |
|
66 |
comm -23 $+ > $@ |
|
67 |
||
68 |
update-report: moblin/repo-stamp fedora.unpacked |
|
69 |
echo $(foreach pkg, ${MOBLIN_SOURCES}, $(call CHECK_VERSION, ${pkg})) \ |
|
70 |
| tr '@' '\n' > $@ |
|
71 |
||
72 |
# Various degrees of hygine
|
|
73 |
||
74 |
# Remove easily reproduced temporary files
|
|
75 |
clean: |
|
76 |
-rm *.rpmmacros *.rpmrc *.packages |
|
77 |
||
78 |
# Remove the reports and unpacked SRPMS
|
|
79 |
pristine: clean moblin.not-unpacked fedora.not-unpacked |
|
80 |
-rm missing-report patch-report update-report |
|
81 |
-rm -r patches stamps |
|
82 |
||
83 |
# Also remove the fedora download repo
|
|
84 |
uncompared: pristine |
|
85 |
-rm -r fedora |
|
86 |
||
87 |
# Remove everything for distribution or complete recomparison
|
|
88 |
dist-clean: uncompared |
|
89 |
-rm -r moblin |
|
90 |
||
91 |
%.not-unpacked: |
|
92 |
-rm -r $(foreach dir, ${RPM_REPO_DIRS}, $(basename $@)/${dir}) |
|
93 |
-rm $(basename $@).unpacked |
|
94 |
||
95 |
# Necessary utilities
|
|
96 |
list_urls.sed: |
|
97 |
wget http://sed.sourceforge.net/grabbag/scripts/list_urls.sed |
|
98 |
chmod +x list_urls.sed |
|
99 |
||
100 |
# Support rules
|
|
101 |
||
102 |
# Downloading the moblin stuff is easy
|
|
103 |
moblin/repo-stamp: |
|
104 |
mkdir -p moblin/repo |
|
105 |
wget -nd --recursive --level 1 ${MOBLIN_SITE} |
|
106 |
mv *src.rpm moblin/repo |
|
107 |
rm index* |
|
108 |
touch $@
|
|
109 |
||
110 |
# Need to selectively get sources that match moblin
|
|
111 |
fedora.unpacked: moblin/repo-stamp $(FEDORA_SOURCES) |
|
112 |
||
113 |
${FEDORA_SOURCES}: FILE ?= $(call PICK_FILE, $(@F)) |
|
114 |
${FEDORA_SOURCES}: moblin/repo-stamp stamps/stamp list_urls.sed |
|
|
3
by Emmet Hikory
Actually check in the fedora repo before downloading from fedora |
115 |
[ -z "fedora/repo/${FILE}" ] || ${MAKE} fedora/repo/${FILE} |
|
1
by Emmet Hikory
Oops: forgot to actually commit the file addition last time |
116 |
touch $@
|
117 |
||
118 |
fedora/repo-stamp: |
|
119 |
mkdir -p $(@D)/repo |
|
120 |
touch $@
|
|
121 |
||
122 |
# Don't redownload files already present
|
|
123 |
fedora/repo/%: REV ?= $(call PKG_REV, $(@F)) |
|
124 |
fedora/repo/%: fedora/repo-stamp |
|
125 |
[ -s $@ ] || wget -q $(call VERSION_URL, $(@F))/${REV}/src/$(@F) |
|
126 |
-mv $(@F) $(@D) |
|
127 |
||
128 |
stamps/stamp: |
|
129 |
mkdir -p $(@D) |
|
130 |
touch $@
|
|
131 |
||
132 |
# Implicit Rules
|
|
133 |
||
134 |
%.rpmmacros: |
|
135 |
echo "%packager ${USER_NAME}" > $@ |
|
136 |
echo "%vendor Moblin Analysis" >> $@ |
|
137 |
echo "%_topdir $$PWD/$(basename $@)" >> $@ |
|
138 |
||
139 |
%.rpmrc: %.rpmmacros |
|
140 |
echo "macrofiles: ${BASE_MACRO_STRING}:./${basename $@}.rpmmacros" > $@ |
|
141 |
||
|
2
by Emmet Hikory
Fix silly dependency error that forced redownload of source packages |
142 |
%.unpacked: %/repo-stamp %.rpmrc %.rpmmacros |
|
1
by Emmet Hikory
Oops: forgot to actually commit the file addition last time |
143 |
mkdir -p $(foreach dir, ${RPM_REPO_DIRS}, $(basename $@)/${dir}) |
144 |
${RPMRC} $(basename $@).rpmrc $($(call UPPER, $(basename $@))_SRPMS) |
|
145 |
touch $@
|
|
146 |
||
147 |
%.packages: %.unpacked |
|
148 |
echo $(foreach pkg, \ |
|
149 |
$($(call UPPER, $(basename $@))_SRPMS), \ |
|
150 |
$(call PKG_NAME, $(notdir ${pkg}))) | tr ' ' '\n' > $@ |
|
151 |
||
152 |
patches/%.stamp: PKG ?= $(basename $(@F)) |
|
153 |
patches/%.stamp: moblin.unpacked fedora.unpacked |
|
154 |
# Clean up the workspace
|
|
155 |
-rm -r patches/${PKG} |
|
156 |
mkdir -p patches/${PKG} |
|
157 |
||
158 |
# Collect information about sources and patches
|
|
159 |
grep ^Source moblin/SPECS/${PKG}.spec | cut -d\ -f2 | sort -u \ |
|
160 |
> patches/${PKG}/moblin.sources |
|
161 |
-grep ^Source fedora/SPECS/${PKG}.spec | cut -d\ -f2 | sort -u \ |
|
162 |
> patches/${PKG}/fedora.sources |
|
163 |
||
164 |
grep ^Patch moblin/SPECS/${PKG}.spec | cut -d\ -f2 | sort -u \ |
|
165 |
> patches/${PKG}/moblin.patches |
|
166 |
-grep ^Patch fedora/SPECS/${PKG}.spec | cut -d\ -f2 | sort -u \ |
|
167 |
> patches/${PKG}/fedora.patches |
|
168 |
||
169 |
touch $@
|
|
170 |
||
171 |
patches/%.report: PKG ?= $(basename $(@F)) |
|
172 |
patches/%.report: patches/%.stamp |
|
173 |
# Store the individual changes
|
|
174 |
-cp $(addprefix moblin/SOURCES/, $(shell comm -13 patches/${PKG}/fedora.sources patches/${PKG}/moblin.sources | grep -v '://')) patches/${PKG} |
|
175 |
$(foreach src, $(shell comm -12 patches/${PKG}/fedora.sources patches/${PKG}/moblin.sources | grep -v '://'), $(shell diff -u fedora/SOURCES/${src} moblin/SOURCES/${src} > patches/${PKG}/${src}.source.diff)) |
|
176 |
||
177 |
-cp $(addprefix moblin/SOURCES/, $(shell comm -13 patches/${PKG}/fedora.patches patches/${PKG}/moblin.patches | grep -v '://')) patches/${PKG} |
|
178 |
$(foreach src, $(shell comm -12 patches/${PKG}/fedora.patches patches/${PKG}/moblin.patches | grep -v '://'), $(shell diff -u fedora/SOURCES/${src} moblin/SOURCES/${src} > patches/${PKG}/${src}.patch.diff)) |
|
179 |
||
180 |
# Prepare the report
|
|
181 |
echo Package: ${PKG} > $@ |
|
182 |
echo Moblin Version: $(call MVER, ${PKG}) >> $@ |
|
183 |
echo Comparison Version: $(call FVER, ${PKG}) >> $@ |
|
184 |
echo New Sources: $(shell comm -13 patches/${PKG}/fedora.sources patches/${PKG}/moblin.sources) >> $@ |
|
185 |
echo New Patches: $(shell comm -13 patches/${PKG}/fedora.patches patches/${PKG}/moblin.patches) >> $@ |
|
186 |
echo Modified Sources: $(foreach diff, $(shell ls patches/${PKG}/*source.diff), $(shell [ -s ${diff} ] && echo ${diff})) >> $@ |
|
187 |
echo Modified Patches: $(foreach diff, $(shell ls patches/${PKG}/*patch.diff), $(shell [ -s ${diff} ] && echo ${diff})) >> $@ |
|
188 |
echo >> $@ |
|
189 |
||
190 |
# Target Management
|
|
191 |
||
192 |
# Always rerun some targets
|
|
193 |
.PHONY: all reports clean pristine uncompared dist-clean %.not-unpacked |
|
194 |
||
195 |
# Turn off automatic deletion of intermediate files
|
|
196 |
.SECONDARY: |