| 1 |
uberlord |
2085 |
# baselayout Makefile
|
| 2 |
|
|
# Copyright (c) 2006 Gentoo Foundation
|
| 3 |
|
|
# Distributed under the terms of the GNU General Public License v2
|
| 4 |
|
|
# Contributed by Roy Marples (uberlord@gentoo.org)
|
| 5 |
|
|
#
|
| 6 |
|
|
# We've moved the installation logic from Gentoo ebuild into a generic
|
| 7 |
|
|
# Makefile so that the ebuild is much smaller and more simple.
|
| 8 |
|
|
# It also has the added bonus of being easier to install on systems
|
| 9 |
|
|
# without an ebuild style package manager.
|
| 10 |
|
|
|
| 11 |
|
|
NAME = baselayout
|
| 12 |
|
|
VERSION = 1.12.2
|
| 13 |
|
|
PKG = $(NAME)-$(VERSION)
|
| 14 |
|
|
|
| 15 |
|
|
ARCH = x86
|
| 16 |
|
|
KERNEL = linux
|
| 17 |
|
|
DESTDIR =
|
| 18 |
|
|
ROOT = /
|
| 19 |
|
|
LIB = lib
|
| 20 |
|
|
|
| 21 |
|
|
DEVDIR = $(DESTDIR)/dev
|
| 22 |
|
|
BINDIR = $(DESTDIR)/bin
|
| 23 |
|
|
SBINDIR = $(DESTDIR)/sbin
|
| 24 |
|
|
LIBDIR = $(DESTDIR)/$(LIB)
|
| 25 |
|
|
INITDIR = $(DESTDIR)/etc/init.d
|
| 26 |
|
|
MANDIR = $(DESTDIR)/usr/share/man
|
| 27 |
|
|
LOGDIR = $(DESTDIR)/var/log
|
| 28 |
|
|
RUNDIR = $(DESTDIR)/var/run
|
| 29 |
|
|
|
| 30 |
|
|
RCDIR = $(LIBDIR)/rcscripts
|
| 31 |
|
|
SHDIR = $(RCDIR)/sh
|
| 32 |
|
|
NETDIR= $(RCDIR)/net
|
| 33 |
|
|
AWKDIR = $(RCDIR)/awk
|
| 34 |
|
|
LVLDIR = $(DESTDIR)/etc/runlevels
|
| 35 |
|
|
|
| 36 |
|
|
# Default init scripts for the boot runlevel
|
| 37 |
|
|
BOOT_LEVEL = bootmisc checkroot checkfs clock consolefont hostname keymaps \
|
| 38 |
|
|
localmount modules net.lo rmnologin urandom
|
| 39 |
|
|
|
| 40 |
|
|
# Default init scripts for the default runlevel
|
| 41 |
|
|
DEFAULT_LEVEL = hdparm local netmount
|
| 42 |
|
|
|
| 43 |
|
|
# Don't install these files if they already exist in ROOT
|
| 44 |
|
|
# Basically, don't hit the users key config files
|
| 45 |
|
|
ETC_SKIP = hosts passwd shadow group fstab
|
| 46 |
|
|
|
| 47 |
|
|
KEEP_DIRS = boot proc home sys \
|
| 48 |
|
|
mnt/cdrom mnt/floppy \
|
| 49 |
|
|
usr/local/bin usr/local/sbin usr/local/share/doc usr/local/share/man \
|
| 50 |
|
|
var/lib/init.d var/run
|
| 51 |
|
|
|
| 52 |
|
|
SUBDIRS = src
|
| 53 |
|
|
|
| 54 |
|
|
SBINTOLIB = rc-daemon.sh rc-help.sh rc-services.sh
|
| 55 |
|
|
# init.$(KERNEL).sh init-common-pre.sh init-common-post.sh
|
| 56 |
|
|
|
| 57 |
|
|
default:
|
| 58 |
|
|
for x in $(SUBDIRS) ; do \
|
| 59 |
|
|
cd $$x ; \
|
| 60 |
|
|
$(MAKE) $(AM_MAKEFLAGS) ; \
|
| 61 |
|
|
done
|
| 62 |
|
|
|
| 63 |
|
|
clean:
|
| 64 |
|
|
for x in $(SUBDIRS) ; do \
|
| 65 |
|
|
cd $$x ; \
|
| 66 |
|
|
$(MAKE) clean ; \
|
| 67 |
|
|
done
|
| 68 |
|
|
|
| 69 |
|
|
basedev-linux:
|
| 70 |
|
|
if ! test -d $(DEVDIR) ; then \
|
| 71 |
|
|
install -m 0755 -d $(DEVDIR) ; \
|
| 72 |
|
|
fi
|
| 73 |
|
|
if ! test -e $(DEVDIR)/null ; then \
|
| 74 |
|
|
mknod -m 0660 $(DEVDIR)/null c 1 3 ; \
|
| 75 |
|
|
fi
|
| 76 |
|
|
if ! test -e $(DEVDIR)/console ; then \
|
| 77 |
|
|
mknod -m 0660 $(DEVDIR)/console c 5 1 ; \
|
| 78 |
|
|
fi
|
| 79 |
|
|
# tty1 is used by splashutils for silent mode
|
| 80 |
|
|
if ! test -e $(DEVDIR)/tty1 ; then \
|
| 81 |
|
|
mknod -m 0660 $(DEVDIR)/tty1 c 4 1 ; \
|
| 82 |
|
|
fi
|
| 83 |
|
|
|
| 84 |
|
|
dev-linux:
|
| 85 |
|
|
install -m 0755 -d $(DEVDIR)
|
| 86 |
|
|
( curdir=`pwd` ; cd $(DEVDIR) ; \
|
| 87 |
|
|
suffix= ; \
|
| 88 |
|
|
case $(ARCH) in \
|
| 89 |
|
|
arm*) suffix=-arm ;; \
|
| 90 |
|
|
alpha) suffix=-alpha ;; \
|
| 91 |
|
|
amd64) suffix=-i386 ;; \
|
| 92 |
|
|
hppa) suffix=-hppa ;; \
|
| 93 |
|
|
ia64) suffix=-ia64 ;; \
|
| 94 |
|
|
m68k) suffix=-m68k ;; \
|
| 95 |
|
|
mips*) suffix=-mips ;; \
|
| 96 |
|
|
ppc*) suffix=-powerpc ;; \
|
| 97 |
|
|
s390*) suffix=-s390 ;; \
|
| 98 |
|
|
sh*) suffix=-sh ;; \
|
| 99 |
|
|
sparc*) suffix=-sparc ;; \
|
| 100 |
|
|
x86) suffix=-i386 ;; \
|
| 101 |
|
|
esac ; \
|
| 102 |
|
|
$$curdir/sbin/MAKEDEV generic$$suffix ; \
|
| 103 |
|
|
$$curdir/sbin/MAKEDEV sg scd rtc hde hdf hdg hdh ; \
|
| 104 |
|
|
$$curdir/sbin/MAKEDEV input audio video ; \
|
| 105 |
|
|
)
|
| 106 |
|
|
|
| 107 |
|
|
basedev: basedev-$(KERNEL)
|
| 108 |
|
|
|
| 109 |
|
|
dev: dev-$(KERNEL)
|
| 110 |
|
|
ln -snf ../sbin/MAKEDEV $(DEVDIR)/MAKEDEV
|
| 111 |
|
|
|
| 112 |
|
|
layout:
|
| 113 |
|
|
# Create base filesytem layout
|
| 114 |
|
|
for x in $(KEEP_DIRS) ; do \
|
| 115 |
|
|
install -m 0755 -d $(DESTDIR)/$$x ; \
|
| 116 |
|
|
touch $(DESTDIR)/$$x/.keep ; \
|
| 117 |
|
|
done
|
| 118 |
|
|
# Special dirs
|
| 119 |
|
|
install -m 0700 -d $(DESTDIR)/root
|
| 120 |
|
|
touch $(DESTDIR)/root/.keep
|
| 121 |
|
|
install -m 1777 -d $(DESTDIR)/var/tmp
|
| 122 |
|
|
touch $(DESTDIR)/var/tmp/.keep
|
| 123 |
|
|
install -m 1777 -d $(DESTDIR)/tmp
|
| 124 |
|
|
touch $(DESTDIR)/tmp/.keep
|
| 125 |
|
|
# Needed log files
|
| 126 |
|
|
install -m 0755 -d $(LOGDIR)
|
| 127 |
|
|
touch $(LOGDIR)/lastlog
|
| 128 |
|
|
install -m 0644 -g utmp /dev/null $(LOGDIR)/wtmp
|
| 129 |
|
|
install -m 0755 -d $(RUNDIR)
|
| 130 |
|
|
install -m 0664 -g utmp /dev/null $(RUNDIR)/utmp
|
| 131 |
|
|
# FHS compatibility symlinks stuff
|
| 132 |
|
|
ln -snf /var/tmp $(DESTDIR)/usr/tmp
|
| 133 |
|
|
ln -snf share/man $(DESTDIR)/usr/local/man
|
| 134 |
|
|
|
| 135 |
|
|
install:
|
| 136 |
|
|
# bin
|
| 137 |
|
|
install -m 0755 -d $(BINDIR)
|
| 138 |
|
|
for x in `ls bin` ; do \
|
| 139 |
|
|
install -m 0755 "bin/$$x" $(BINDIR) ; \
|
| 140 |
|
|
done
|
| 141 |
|
|
# sbin
|
| 142 |
|
|
install -m 0755 -d $(SBINDIR)
|
| 143 |
|
|
install -m 0644 sbin/functions.sh $(SBINDIR)
|
| 144 |
|
|
for x in depscan.sh env-update.sh runscript.sh rc rc-update \
|
| 145 |
|
|
modules-update MAKEDEV ; do \
|
| 146 |
|
|
install -m 0755 "sbin/$$x" $(SBINDIR) ; \
|
| 147 |
|
|
done
|
| 148 |
|
|
# lib
|
| 149 |
|
|
install -m 0755 -d $(SHDIR)
|
| 150 |
|
|
for x in $(SBINTOLIB) ; do \
|
| 151 |
|
|
n=`echo $$x | sed -e 's/\.$(KERNEL)//'` ; \
|
| 152 |
|
|
install -m 0644 "sbin/$$x" $(SHDIR)/$$n ; \
|
| 153 |
|
|
done
|
| 154 |
|
|
# awk
|
| 155 |
|
|
install -m 0755 -d $(AWKDIR)
|
| 156 |
|
|
for x in `ls src/awk` ; do \
|
| 157 |
|
|
install -m 0644 "src/awk/$$x" $(AWKDIR) ; \
|
| 158 |
|
|
if test $(LIB) != "lib" ; then \
|
| 159 |
|
|
sed -i -e 's:/lib/rcscripts:/$(LIB)/rcscripts:' $(AWKDIR)/$$x ; \
|
| 160 |
|
|
fi ; \
|
| 161 |
|
|
done
|
| 162 |
|
|
# init.d
|
| 163 |
|
|
install -m 0755 -d $(INITDIR)
|
| 164 |
|
|
for x in `ls init.d` ; do \
|
| 165 |
|
|
install -m 0755 "init.d/$$x" $(INITDIR) ; \
|
| 166 |
|
|
done
|
| 167 |
|
|
# Create our symlinks
|
| 168 |
|
|
for x in depscan.sh functions.sh runscript.sh ; do \
|
| 169 |
|
|
ln -snf ../../sbin/"$$x" $(INITDIR)/"$$x" ; \
|
| 170 |
|
|
done
|
| 171 |
|
|
# etc
|
| 172 |
|
|
# Assume that everything is a flat layout
|
| 173 |
|
|
for x in `ls -R etc` ; do \
|
| 174 |
|
|
if test `echo "$$x" | sed -e 's/.*\(.\)$$/\1/'` = ":" ; then \
|
| 175 |
|
|
d=`echo "$$x" | sed -e 's/\(.*\).$$/\1/'` ; \
|
| 176 |
|
|
install -m 0755 -d $(DESTDIR)/"$$d" ; \
|
| 177 |
|
|
elif test -f "$$d/$$x" ; then \
|
| 178 |
|
|
skip=0 ; \
|
| 179 |
|
|
for y in $(ETC_SKIP) ; do \
|
| 180 |
|
|
if test "$$d/$$x" = "etc/$$y" ; then \
|
| 181 |
|
|
if test -f $(ROOT)/$$d/$$x ; then \
|
| 182 |
|
|
skip=1 ; \
|
| 183 |
|
|
break ; \
|
| 184 |
|
|
fi ; \
|
| 185 |
|
|
fi ; \
|
| 186 |
|
|
done ; \
|
| 187 |
|
|
if test $$skip -eq 0 ; then \
|
| 188 |
|
|
m=0644 ; \
|
| 189 |
|
|
if test "$$d/$$x" = "etc/shadow" ; then \
|
| 190 |
|
|
m=0600 ; \
|
| 191 |
|
|
elif test "$$d/$$x" = "/etc/sysctl.conf" ; then \
|
| 192 |
|
|
m=0640 ; \
|
| 193 |
|
|
fi ; \
|
| 194 |
|
|
install -m $$m "$$d/$$x" $(DESTDIR)/"$$d/$$x" ; \
|
| 195 |
|
|
fi ; \
|
| 196 |
|
|
fi; \
|
| 197 |
|
|
done
|
| 198 |
|
|
# net scripts
|
| 199 |
|
|
install -m 0755 net-scripts/init.d/net.lo $(INITDIR)
|
| 200 |
|
|
ln -snf net.lo $(INITDIR)/net.eth0
|
| 201 |
|
|
for x in `ls net-scripts/conf.d` ; do \
|
| 202 |
|
|
install -m 0644 net-scripts/conf.d/"$$x" $(DESTDIR)/etc/conf.d ; \
|
| 203 |
|
|
done
|
| 204 |
|
|
install -m 0755 -d $(NETDIR)
|
| 205 |
|
|
for x in `ls net-scripts/net` ; do \
|
| 206 |
|
|
install -m 0644 net-scripts/net/"$$x" $(NETDIR) ; \
|
| 207 |
|
|
done
|
| 208 |
|
|
# Wang our man pages in
|
| 209 |
|
|
for x in `ls man` ; do \
|
| 210 |
|
|
d=`echo "$$x" | sed -e 's/.*\.\([0-9]\+\)$$/\1/'` ; \
|
| 211 |
|
|
install -m 0755 -d $(MANDIR)/man"$$d" ; \
|
| 212 |
|
|
install -m 0644 man/"$$x" $(MANDIR)/man"$$d" ; \
|
| 213 |
|
|
done
|
| 214 |
|
|
# Populate our runlevel folders
|
| 215 |
|
|
if ! test -d $(ROOT)/etc/runlevels/boot ; then \
|
| 216 |
|
|
install -m 0755 -d $(LVLDIR)/boot ; \
|
| 217 |
|
|
for x in $(BOOT_LEVEL) ; do \
|
| 218 |
|
|
ln -snf ../../init.d/"$$x" $(LVLDIR)/boot/"$$x" ; \
|
| 219 |
|
|
done ; \
|
| 220 |
|
|
fi
|
| 221 |
|
|
if ! test -d $(ROOT)/etc/runlevels/default ; then \
|
| 222 |
|
|
install -m 0755 -d $(LVLDIR)/default ; \
|
| 223 |
|
|
for x in $(DEFAULT_LEVEL) ; do \
|
| 224 |
|
|
ln -snf ../../init.d/"$$x" $(LVLDIR)/default/"$$x" ; \
|
| 225 |
|
|
done ; \
|
| 226 |
|
|
fi
|
| 227 |
|
|
# SPARC fixes
|
| 228 |
|
|
# SPAC does not like stty, so we disable RC_INTERACTIVE which requires it
|
| 229 |
|
|
# see Gentoo bug #104067.
|
| 230 |
|
|
if test $(ARCH) = "sparc" ; then \
|
| 231 |
|
|
sed -i -e '/^KEYMAP=/s:us:sunkeymap:' $(DESTDIR)/etc/conf.d/keymaps ; \
|
| 232 |
|
|
sed -i -e '/^RC_INTERACTIVE=/s:yes:no:' $(DESTDIR)/etc/conf.d/rc ; \
|
| 233 |
|
|
fi
|
| 234 |
|
|
# Now install our supporting utilities
|
| 235 |
|
|
for x in $(SUBDIRS) ; do \
|
| 236 |
|
|
cd $$x ; \
|
| 237 |
|
|
$(MAKE) install ; \
|
| 238 |
|
|
done
|
| 239 |
|
|
|
| 240 |
|
|
distcheck:
|
| 241 |
|
|
svnfiles=`svn status 2>&1 | egrep -v '^(U|P)'` ; \
|
| 242 |
|
|
if test "x$$svnfiles" != "x" ; then \
|
| 243 |
|
|
echo "Refusing to package tarball until svn is in sync:" ; \
|
| 244 |
|
|
echo "$$svnfiles" ; \
|
| 245 |
|
|
echo "make distforce to force packaging" ; \
|
| 246 |
|
|
exit 1 ; \
|
| 247 |
|
|
fi
|
| 248 |
|
|
|
| 249 |
|
|
distforce:
|
| 250 |
|
|
install -d /tmp/$(PKG)
|
| 251 |
|
|
cp -axr . /tmp/$(PKG)
|
| 252 |
|
|
cd /tmp/$(PKG) ; \
|
| 253 |
|
|
rm -rf *.sh rc-lists `find . -iname .svn` sbin/MAKEDEV-gentoo.patch ; \
|
| 254 |
|
|
cd .. ; \
|
| 255 |
|
|
tar -cvjpf $(PKG).tar.bz2 $(PKG)
|
| 256 |
|
|
rm -rf /tmp/$(PKG)
|
| 257 |
|
|
du /tmp/$(PKG).tar.bz2
|
| 258 |
|
|
|
| 259 |
|
|
dist: distcheck distforce
|
| 260 |
|
|
|
| 261 |
|
|
# vim: set ts=4 :
|