1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
#
# Utility makefile for people working with xen-tools.
#
# The targets are intended to be useful for people who are using
# the source repository - but it also contains other useful targets.
#
# Steve
# --
# http://www.steve.org.uk/
#
#
# Only used to build distribution tarballs.
#
TMP ?= /tmp
DIST_PREFIX = ${TMP}
VERSION = 4.2
DEBVERSION = $(shell echo $(VERSION)|sed 's/\(rc\|pre\|beta\|alpha\)/~\1/')
BASE = xen-tools
VCS = $(shell if git ls-files > /dev/null; then echo git; \
elif hg st > /dev/null; then echo hg; \
else echo cannot-determine-used-vcs; fi)
#
# Installation prefix, useful for the Debian package.
#
prefix=
nop:
@echo "Valid targets are (alphabetically) :"
@echo " "
@echo " clean = Remove bogus files."
@echo " commit = Commit changes, after running check."
@echo " diff = See local changes."
@echo " install = Install the software"
@echo " manpages = Make manpages beneath man/"
@echo " release = Make a release tarball"
@echo " uninstall = Remove the software"
@echo " update = Update from the source repository."
@echo " "
#
# Extract the revision history and make a ChangeLog file
# with those details.
#
changelog:
$(VCS) log -v > ChangeLog
#
# Delete all temporary files, recursively.
#
clean:
@find . \
-path ./.git -prune -o \
\( \
-name '*~' -o \
-name '.#*' -o \
-name '*.bak' -o \
-name '*.tmp' -o \
-name 'tags' -o \
-name '*.8.gz' -o \
-name '*.tdy' \
\) -exec rm "{}" +
@if [ -d man ]; then rm -rf man ; fi
@if [ -e build-stamp ]; then rm -f build-stamp ; fi
@if [ -e configure-stamp ]; then rm -f configure-stamp ; fi
@if [ -d debian/xen-tools ]; then rm -rf ./debian/xen-tools; fi
@if [ -e $(BASE)-$(VERSION).tar.gz ]; then rm $(BASE)-$(VERSION).tar.gz ; fi
@if [ -e $(BASE)-$(VERSION).tar.gz.asc ]; then rm $(BASE)-$(VERSION).tar.gz.asc ; fi
#
# If the testsuite runs correctly then commit any pending changes.
#
commit: test
$(VCS) commit
#
# Show what has been changed in the local copy vs. the remote repository.
#
diff:
$(VCS) diff 2>/dev/null
#
# Fix hooks and configuration files permissions
#
fixup-perms:
for i in hooks/*/*-*; do chmod 755 $$i; done
chmod 755 hooks/common.sh
chmod 644 etc/xen-tools.conf
chmod 644 etc/xm.tmpl
chmod 644 etc/xm-nfs.tmpl
chmod 644 misc/xen-tools misc/README
#
# Install files to /etc/
#
install-etc:
-mkdir -p ${prefix}/etc/xen-tools
-if [ -d ${prefix}/etc/xen-tools/hook.d ]; then mv ${prefix}/etc/xen-tools/hook.d/ ${prefix}/etc/xen-tools/hook.d.obsolete ; fi
-mkdir -p ${prefix}/etc/xen-tools/skel/
-mkdir -p ${prefix}/etc/xen-tools/role.d/
-mkdir -p ${prefix}/etc/xen-tools/partitions.d/
cp etc/xen-tools.conf ${prefix}/etc/xen-tools/
cp etc/xm.tmpl ${prefix}/etc/xen-tools/
cp etc/xm-nfs.tmpl ${prefix}/etc/xen-tools/
cp partitions/*-* ${prefix}/etc/xen-tools/partitions.d/
-mkdir -p ${prefix}/etc/bash_completion.d
cp misc/xen-tools ${prefix}/etc/bash_completion.d/
#
# Install binary files.
#
install-bin:
mkdir -p ${prefix}/usr/bin
cp bin/xen-create-image ${prefix}/usr/bin
cp bin/xen-create-nfs ${prefix}/usr/bin
cp bin/xt-customize-image ${prefix}/usr/bin
cp bin/xt-install-image ${prefix}/usr/bin
cp bin/xt-create-xen-config ${prefix}/usr/bin
cp bin/xen-delete-image ${prefix}/usr/bin
cp bin/xen-list-images ${prefix}/usr/bin
cp bin/xen-update-image ${prefix}/usr/bin
cp bin/xt-guess-suite-and-mirror ${prefix}/usr/bin
chmod 755 ${prefix}/usr/bin/xen-create-image
chmod 755 ${prefix}/usr/bin/xen-create-nfs
chmod 755 ${prefix}/usr/bin/xt-customize-image
chmod 755 ${prefix}/usr/bin/xt-install-image
chmod 755 ${prefix}/usr/bin/xt-create-xen-config
chmod 755 ${prefix}/usr/bin/xen-delete-image
chmod 755 ${prefix}/usr/bin/xen-list-images
chmod 755 ${prefix}/usr/bin/xen-update-image
chmod 755 ${prefix}/usr/bin/xt-guess-suite-and-mirror
#
# Install hooks
#
install-hooks:
for i in roles/* ; do if [ -f $$i ]; then cp $$i ${prefix}/etc/xen-tools/role.d; fi ; done
for i in ${prefix}/usr/lib/xen-tools/*.d; do if [ -L "$$i" ]; then rm -vf "$$i"; fi; done
mkdir -p ${prefix}/usr/lib/xen-tools/centos-4.d/
mkdir -p ${prefix}/usr/lib/xen-tools/centos-5.d/
mkdir -p ${prefix}/usr/lib/xen-tools/fedora-core-6.d/
cp -R hooks/centos-4/*-* ${prefix}/usr/lib/xen-tools/centos-4.d
cp -R hooks/centos-5/*-* ${prefix}/usr/lib/xen-tools/centos-5.d
cp -R hooks/fedora-core-6/*-* ${prefix}/usr/lib/xen-tools/fedora-core-6.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-4.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-5.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-7.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-8.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-9.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-10.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-11.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-12.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s fedora-core-6.d fedora-core-13.d
mkdir -p ${prefix}/usr/lib/xen-tools/debian.d/
cp -R hooks/debian/*-* ${prefix}/usr/lib/xen-tools/debian.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d sarge.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d etch.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d lenny.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d squeeze.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d wheezy.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d sid.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d testing.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s debian.d stable.d
mkdir -p ${prefix}/usr/lib/xen-tools/gentoo.d/
cp -R hooks/gentoo/*-* ${prefix}/usr/lib/xen-tools/gentoo.d
mkdir -p ${prefix}/usr/lib/xen-tools/dapper.d/
cp -R hooks/dapper/*-* ${prefix}/usr/lib/xen-tools/dapper.d/
mkdir -p ${prefix}/usr/lib/xen-tools/edgy.d/
cp -R hooks/edgy/*-* ${prefix}/usr/lib/xen-tools/edgy.d/
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d feisty.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d gutsy.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d hardy.d
mkdir -p ${prefix}/usr/lib/xen-tools/intrepid.d/
cp -R hooks/intrepid/*-* ${prefix}/usr/lib/xen-tools/intrepid.d/
-cd ${prefix}/usr/lib/xen-tools/ && ln -s intrepid.d jaunty.d
mkdir -p ${prefix}/usr/lib/xen-tools/karmic.d/
cp -R hooks/karmic/*-* ${prefix}/usr/lib/xen-tools/karmic.d/
-cd ${prefix}/usr/lib/xen-tools/ && ln -s karmic.d lucid.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s karmic.d maverick.d
-cd ${prefix}/usr/lib/xen-tools/ && ln -s karmic.d natty.d
cp hooks/common.sh ${prefix}/usr/lib/xen-tools
#
# Install our library files
#
install-libraries:
-mkdir -p ${prefix}/usr/share/perl5/Xen/Tools
cp ./lib/Xen/*.pm ${prefix}/usr/share/perl5/Xen
cp ./lib/Xen/Tools/*.pm ${prefix}/usr/share/perl5/Xen/Tools
#
# Generate and install manpages.
#
install-manpages: manpages
-mkdir -p ${prefix}/usr/share/man/man8/
cp man/*.8.gz ${prefix}/usr/share/man/man8/
#
# Install everything.
#
install: fixup-perms install-bin install-etc install-hooks install-libraries install-manpages
#
# Build our manpages via the `pod2man` command.
#
manpages:
-mkdir -p man
cd bin; for i in *-*[!y]; do pod2man --release=${VERSION} --official --section=8 $$i ../man/$$i.8; done
for i in man/*.8; do gzip --force -9 $$i; done
#
# Make a new release tarball, and make a GPG signature.
#
release: tidy fixup-perms update-version update-modules clean changelog
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)
rm -f $(DIST_PREFIX)/$(BASE)-$(VERSION).tar.gz
cp -R . $(DIST_PREFIX)/$(BASE)-$(VERSION)
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)/debian
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)/.hg*
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)/.git*
cd $(DIST_PREFIX) && tar -cvf $(DIST_PREFIX)/$(BASE)-$(VERSION).tar $(BASE)-$(VERSION)/
gzip $(DIST_PREFIX)/$(BASE)-$(VERSION).tar
mv $(DIST_PREFIX)/$(BASE)-$(VERSION).tar.gz .
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)
gpg --armour --detach-sign $(BASE)-$(VERSION).tar.gz
#
# Make a new orig.tar.gz for the Debian package
#
orig-tar-gz: release
mv $(BASE)-$(VERSION).tar.gz ../$(BASE)_$(DEBVERSION).orig.tar.gz
mv $(BASE)-$(VERSION).tar.gz.asc ../$(BASE)_$(DEBVERSION).orig.tar.gz.asc
#
# Run the test suite.
#
test: update-modules
prove --shuffle t/
#
# Run the test suite verbosely.
#
test-verbose:
prove --shuffle --verbose t/
#
# Run our main script(s) through perltidy
#
tidy:
if [ -x /usr/bin/perltidy ]; then \
for i in bin/*-*[^~]; do \
echo "tidying $$i"; \
perltidy $$i \
; done \
; fi
#
# Uninstall the software, completely.
#
uninstall:
rm -f ${prefix}/usr/bin/xen-create-image
rm -f ${prefix}/usr/bin/xen-delete-image
rm -f ${prefix}/usr/bin/xen-list-images
rm -f ${prefix}/usr/bin/xen-update-image
rm -f ${prefix}/usr/bin/xt-customize-image
rm -f ${prefix}/usr/bin/xt-install-image
rm -f ${prefix}/usr/bin/xt-create-xen-config
rm -f ${prefix}/usr/bin/xen-create-nfs
rm -f ${prefix}/usr/bin/xt-guess-suite-and-mirror
rm -f ${prefix}/etc/xen-tools/xen-tools.conf
rm -f ${prefix}/etc/xen-tools/xm.tmpl
-rm -rf ${prefix}/etc/xen-tools/skel
-rmdir ${prefix}/etc/xen-tools/
-rm -f ${prefix}/etc/bash_completion.d/xen-tools
rm -rf ${prefix}/usr/lib/xen-tools
rm -f ${prefix}/usr/share/man/man8/xen-create-image.8.gz
rm -f ${prefix}/usr/share/man/man8/xen-delete-image.8.gz
rm -f ${prefix}/usr/share/man/man8/xen-list-images.8.gz
rm -f ${prefix}/usr/share/man/man8/xen-update-image.8.gz
#
# Update the local copy from the remote repository.
#
# NOTE: Removes empty local directories.
#
update:
$(VCS) pull --update 2>/dev/null
#
# Update the module test - this is designed to automatically write test
# cases to ensure that all required modules are available.
#
update-modules:
@cd t && make modules
#
# Update the release number of each script we have from the variable
# at the top of this file. Steve-Specific?
#
update-version:
perl -pi.bak -e "s/RELEASE = '[0-9]\.[0-9][^']*';/RELEASE = '${VERSION}';/g" bin/*-*[!~]
|