]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - lfs/stage2
suricata: Change midstream policy to "pass-flow"
[people/pmueller/ipfire-2.x.git] / lfs / stage2
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2020 IPFire Team <info@ipfire.org> #
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/firmware/brcm,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,xt_geoip,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 ifeq "$(IS_64BIT)" "1"
68 ln -svf lib /lib64
69 ln -svf lib /usr/lib64
70 endif
71
72 ifeq "$(BUILD_ARCH)" "riscv64"
73 ln -svf . /lib/lp64d
74 ln -svf . /usr/lib/lp64d
75 endif
76
77 # Symlinks
78 # for this reason, stage2 rebuild will broke the iso:perl, grubbatch
79 -ln -sv $(TOOLS_DIR)/bin/{bash,cat,echo,pwd,stty} /bin
80 -ln -sv $(TOOLS_DIR)/bin/perl /usr/bin
81 -ln -sv $(TOOLS_DIR)/lib/libgcc_s.so{,.1} /usr/lib
82 -ln -sv $(TOOLS_DIR)/lib/libstdc++.so{,.6} /usr/lib
83 sed 's@$(TOOLS_DIR)@/usr@' $(TOOLS_DIR)/lib/libstdc++.la > /usr/lib/libstdc++.la
84 -ln -sv bash /bin/sh
85
86 # Config files
87 cp -rvf $(DIR_SRC)/config/etc/* /etc;
88 [ ! -d "$(DIR_SRC)/config/etc-$(BUILD_ARCH)" ] || cp -rvf $(DIR_SRC)/config/etc-$(BUILD_ARCH)/* /etc
89 cp -rvf $(DIR_SRC)/config/lib/* /lib;
90 touch /etc/{fs,m}tab
91 echo "$(NAME) v$(VERSION) - $(SLOGAN)" > /etc/issue
92 echo "===============================" >> /etc/issue
93 echo "\n running on \s \r \m" >> /etc/issue
94
95 # Bash startup files
96 install --directory --mode=0755 --owner=root --group=root /etc/profile.d
97 for i in $(DIR_SRC)/config/profile.d/*; do \
98 [ -f $$i ] && cp $$i /etc/profile.d; \
99 done
100 chmod 755 /etc/bashrc
101
102 # Install root's bash files.
103 for i in $(DIR_SRC)/config/bash/dot_*; do \
104 [ -f $$i ] && cp $$i /root/$$(basename $${i/dot_/\.}); \
105 done
106
107 # Scripts
108 for i in `find $(DIR_SRC)/src/scripts -maxdepth 1 -type f`; do \
109 sed "s+CONFIG_ROOT+$(CONFIG_ROOT)+g" $$i > /usr/local/bin/`basename $$i`; \
110 chmod 755 /usr/local/bin/`basename $$i`; \
111 done
112
113 # Move script to correct place.
114 mv -vf /usr/local/bin/openvpn-metrics /usr/sbin/
115 mv -vf /usr/local/bin/ovpn-ccd-convert /usr/sbin/
116 mv -vf /usr/local/bin/ovpn-collectd-convert /usr/sbin/
117 mv -vf /usr/local/bin/captive-cleanup /usr/bin/
118
119 # Install firewall scripts.
120 mkdir -pv /usr/lib/firewall
121 install -m 755 $(DIR_SRC)/config/firewall/rules.pl \
122 /usr/lib/firewall/rules.pl
123 install -m 644 $(DIR_SRC)/config/firewall/firewall-lib.pl \
124 /usr/lib/firewall/firewall-lib.pl
125 install -m 755 $(DIR_SRC)/config/firewall/ipsec-policy \
126 /usr/lib/firewall/ipsec-policy
127
128 # Nobody user
129 -mkdir -p /home/nobody
130 chown -R nobody:nobody /home/nobody
131
132 # Create /var dirs and files
133 -mkdir -v /var/{lock,log,mail,spool,empty}
134 -mkdir -pv /var/{opt,cache,lib/{misc,locate},local}
135 -mkdir -pv /var/log/{counter,calamaris}
136 chown nobody.nobody /var/log/calamaris
137 touch /var/log/{btmp,lastlog,wtmp}
138 chmod -v 600 /var/log/btmp
139 chgrp -v utmp /var/log/lastlog
140 chmod -v 664 /var/log/lastlog
141
142 # Permissions
143 chmod 0711 /var/empty
144
145 # A small hack to include /root to the iso but not all of it's files.
146 touch /root/ipfire
147
148 # License agreement
149 -mkdir -pv /usr/share/doc/licenses/
150 cp -vf $(DIR_SRC)/doc/COPYING /usr/share/doc/licenses/GPLv3
151
152 # System release
153 echo "$(SYSTEM_RELEASE)" > /etc/system-release
154
155 # OS release
156 : >/etc/os-release
157 echo "NAME=\"$(NAME)\"" >> /etc/os-release
158 echo "VERSION=\"$(VERSION)\"" >> /etc/os-release
159 echo "ID=$(SNAME)" >> /etc/os-release
160 echo "VERSION_ID=2" >> /etc/os-release
161 echo "PRETTY_NAME=\"$(SYSTEM_RELEASE)\"" >> /etc/os-release
162 echo "ANSI_COLOR=\"0:31\"" >> /etc/os-release
163
164 # Pakfire
165 -mkdir -pv /opt/pakfire/db/core
166 echo "$(CORE)" > /opt/pakfire/db/core/mine
167
168 @$(POSTBUILD)