3d64f6839970ac82b223f5fbdc34ca16927afe64
[people/teissler/ipfire-2.x.git] / lfs / stage2
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 ###############################################################################
20
21 ###############################################################################
22 # Definitions
23 ###############################################################################
24
25 include Config
26
27 VER = ipfire
28
29 THISAPP = stage2
30 TARGET = $(DIR_INFO)/$(THISAPP)
31
32 ###############################################################################
33 # Top-level Rules
34 ###############################################################################
35
36 install : $(TARGET)
37
38 check :
39
40 download :
41
42 md5 :
43
44 ###############################################################################
45 # Installation Details
46 ###############################################################################
47
48 $(TARGET) :
49 @$(PREBUILD)
50
51 # Create directories
52 -mkdir -pv /{bin,boot,etc/opt,etc/modprobe.d,home,lib,mnt,opt,run}
53 -mkdir -pv /{media/{floppy,cdrom,usbkey},sbin,srv,var}
54 -install -dv -m 0750 /root
55 -install -dv -m 1777 /tmp /var/tmp
56 -mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
57 -mkdir -pv /usr/{,local/}share/{doc,info,locale,man}
58 -mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
59 -mkdir -pv /usr/{,local/}share/man/man{1..8}
60 #-for dir in /usr /usr/local; do \
61 # ln -sv share/{man,doc,info} $$dir; \
62 #done
63
64 # Symlink /var/run -> /run.
65 ln -svf ../run /var/run
66
67 # Symlinks
68 # for this reason, stage2 rebuild will broke the iso:perl, grubbatch
69 -ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
70 -ln -sv /tools/bin/perl /usr/bin
71 -ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
72 -ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
73 sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
74 -ln -sv bash /bin/sh
75
76 # Config files
77 cp -rvf $(DIR_SRC)/config/etc/* /etc;
78 touch /etc/mtab
79 echo "$(NAME) v$(VERSION) - $(SLOGAN)" > /etc/issue
80 echo "===============================" >> /etc/issue
81 echo "\n running on \s \r \m" >> /etc/issue
82
83 # Bash startup files
84 install --directory --mode=0755 --owner=root --group=root /etc/profile.d
85 for i in $(DIR_SRC)/config/profile.d/*; do \
86 [ -f $$i ] && cp $$i /etc/profile.d; \
87 done
88 chmod 755 /etc/bashrc
89
90 # Install root's bash files.
91 for i in $(DIR_SRC)/config/bash/dot_*; do \
92 [ -f $$i ] && cp $$i /root/$$(basename $${i/dot_/\.}); \
93 done
94
95 # Scripts
96 for i in `find $(DIR_SRC)/src/scripts -maxdepth 1 -type f`; do \
97 sed "s+CONFIG_ROOT+$(CONFIG_ROOT)+g" $$i > /usr/local/bin/`basename $$i`; \
98 chmod 755 /usr/local/bin/`basename $$i`; \
99 done
100
101 # Move script to correct place.
102 mv -vf /usr/local/bin/ovpn-ccd-convert /usr/sbin/
103
104 # Nobody user
105 -mkdir -p /home/nobody
106 chown -R nobody:nobody /home/nobody
107
108 # Create /var dirs and files
109 -mkdir -v /var/{lock,log,mail,spool,empty}
110 -mkdir -pv /var/{opt,cache,lib/{misc,locate},local}
111 -mkdir -pv /var/log/{counter,calamaris}
112 chown nobody.nobody /var/log/calamaris
113 touch /var/log/{btmp,lastlog,wtmp,net-traffic.log}
114 chgrp -v utmp /var/log/lastlog
115 chmod -v 664 /var/log/lastlog
116
117 # Permissions
118 chmod 0711 /var/empty
119
120 # A small hack to include /root to the iso but not all of it's files.
121 touch /root/ipfire
122
123 # License agreement
124 -mkdir -pv /usr/share/doc/licenses/
125 cp -vf $(DIR_SRC)/doc/COPYING /usr/share/doc/licenses/GPLv3
126
127 # System release
128 echo "$(SYSTEM_RELEASE)" > /etc/system-release
129
130 # Pakfire
131 -mkdir -pv /opt/pakfire/db/core
132 echo "$(PAKFIRE_CORE)" > /opt/pakfire/db/core/mine
133
134 @$(POSTBUILD)