1 |
# baselayout Makefile |
2 |
# Copyright 2006-2007 Gentoo Foundation |
3 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
# |
5 |
# We've moved the installation logic from Gentoo ebuild into a generic |
6 |
# Makefile so that the ebuild is much smaller and more simple. |
7 |
# It also has the added bonus of being easier to install on systems |
8 |
# without an ebuild style package manager. |
9 |
|
10 |
SUBDIRS = conf.d etc init.d man net sh share src |
11 |
|
12 |
NAME = baselayout |
13 |
VERSION = 2.0.0_alpha1 |
14 |
|
15 |
PKG = $(NAME)-$(VERSION) |
16 |
|
17 |
ARCH = x86 |
18 |
ifeq ($(OS),) |
19 |
OS=$(shell uname -s) |
20 |
ifneq ($(OS),Linux) |
21 |
OS=BSD |
22 |
endif |
23 |
endif |
24 |
|
25 |
BASE_DIRS = /$(LIB)/rcscripts/init.d /$(LIB)/rcscripts/tmp |
26 |
KEEP_DIRS = /boot /home /mnt /root \ |
27 |
/usr/local/bin /usr/local/sbin /usr/local/share/doc /usr/local/share/man \ |
28 |
/var/lock /var/run |
29 |
|
30 |
ifeq ($(OS),Linux) |
31 |
KEEP_DIRS += /dev /sys |
32 |
NET_LO = net.lo |
33 |
endif |
34 |
ifneq ($(OS),Linux) |
35 |
NET_LO = net.lo0 |
36 |
endif |
37 |
|
38 |
TOPDIR = . |
39 |
include $(TOPDIR)/default.mk |
40 |
|
41 |
install:: |
42 |
# These dirs may not exist from prior versions |
43 |
for x in $(BASE_DIRS) ; do \ |
44 |
$(INSTALL_DIR) $(DESTDIR)$$x || exit $$? ; \ |
45 |
touch $(DESTDIR)$$x/.keep || exit $$? ; \ |
46 |
done |
47 |
# Don't install runlevels if they already exist |
48 |
if ! test -d $(DESTDIR)/etc/runlevels ; then \ |
49 |
(cd runlevels; $(MAKE) install) ; \ |
50 |
test -d runlevels.$(OS) && (cd runlevels.$(OS); $(MAKE) install) ; \ |
51 |
$(INSTALL_DIR) $(DESTDIR)/etc/runlevels/single || exit $$? ; \ |
52 |
$(INSTALL_DIR) $(DESTDIR)/etc/runlevels/nonetwork || exit $$? ; \ |
53 |
fi |
54 |
ln -snf ../../$(LIB)/rcscripts/sh/net.sh $(DESTDIR)/etc/init.d/$(NET_LO) || exit $$? |
55 |
ln -snf ../../$(LIB)/rcscripts/sh/functions.sh $(DESTDIR)/etc/init.d || exit $$? |
56 |
# Handle lib correctly |
57 |
if test $(LIB) != "lib" ; then \ |
58 |
sed -i'.bak' -e 's,/lib/,/$(LIB)/,g' $(DESTDIR)/$(LIB)/rcscripts/sh/functions.sh || exit $$? ; \ |
59 |
rm -f $(DESTDIR)/$(LIB)/rcscripts/sh/functions.sh.bak ; \ |
60 |
fi |
61 |
|
62 |
layout: |
63 |
# Create base filesytem layout |
64 |
for x in $(KEEP_DIRS) ; do \ |
65 |
$(INSTALL_DIR) $(DESTDIR)$$x || exit $$? ; \ |
66 |
touch $(DESTDIR)$$x/.keep || exit $$? ; \ |
67 |
done |
68 |
# Special dirs |
69 |
install -m 0700 -d $(DESTDIR)/root || exit $$? |
70 |
touch $(DESTDIR)/root/.keep || exit $$? |
71 |
install -m 1777 -d $(DESTDIR)/var/tmp || exit $$? |
72 |
touch $(DESTDIR)/var/tmp/.keep || exit $$? |
73 |
install -m 1777 -d $(DESTDIR)/tmp || exit $$? |
74 |
touch $(DESTDIR)/tmp/.keep || exit $$? |
75 |
# FHS compatibility symlinks stuff |
76 |
ln -snf /var/tmp $(DESTDIR)/usr/tmp || exit $$? |
77 |
ln -snf share/man $(DESTDIR)/usr/local/man || exit $$? |
78 |
|
79 |
diststatus: |
80 |
if test -d .svn ; then \ |
81 |
svnfiles=`svn status 2>&1 | egrep -v '^(U|P)'` ; \ |
82 |
if test "x$$svnfiles" != "x" ; then \ |
83 |
echo "Refusing to package tarball until svn is in sync:" ; \ |
84 |
echo "$$svnfiles" ; \ |
85 |
echo "make distforce to force packaging" ; \ |
86 |
exit 1 ; \ |
87 |
fi \ |
88 |
fi |
89 |
|
90 |
distforce: |
91 |
rm -rf /tmp/$(PKG) |
92 |
cp -pPR . /tmp/$(PKG) |
93 |
$(MAKE) -C /tmp/$(PKG) clean |
94 |
(find /tmp/$(PKG) -type d -name .svn -exec rm -rf {} \; 2>/dev/null; exit 0) |
95 |
tar -C /tmp -cvjpf /tmp/$(PKG).tar.bz2 $(PKG) |
96 |
rm -rf /tmp/$(PKG) |
97 |
ls -l /tmp/$(PKG).tar.bz2 |
98 |
|
99 |
distit: |
100 |
rm -rf /tmp/$(PKG) |
101 |
svn export . /tmp/$(PKG) |
102 |
$(MAKE) -C /tmp/$(PKG) clean |
103 |
tar -C /tmp -cvjpf /tmp/$(PKG).tar.bz2 $(PKG) |
104 |
rm -rf /tmp/$(PKG) |
105 |
ls -l /tmp/$(PKG).tar.bz2 |
106 |
|
107 |
dist: diststatus distit |
108 |
|
109 |
.PHONY: layout dist distforce distit diststatus |
110 |
|
111 |
# vim: set ts=4 : |