67e17111cf4237599945349ee54cd693a0a3bb54
[oweals/openwrt.git] / package / base-files / Makefile
1 #
2 # Copyright (C) 2007-2012 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/version.mk
12
13 PKG_NAME:=base-files
14 PKG_RELEASE:=111
15
16 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
17 PKG_BUILD_DEPENDS:=opkg/host
18
19 include $(INCLUDE_DIR)/package.mk
20
21 ifneq ($(DUMP),1)
22   TARGET:=-$(BOARD)
23   ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
24     TARGET:=$(TARGET)-$(PROFILE)
25   endif
26   ifneq ($(findstring $(ARCH) , mips64 x86_64 ),)
27     LIB_SUFFIX:=64
28   endif
29 endif
30
31 define Package/base-files
32   SECTION:=base
33   CATEGORY:=Base system
34   DEPENDS:=+netifd +libc
35   TITLE:=Base filesystem for OpenWrt
36   URL:=http://openwrt.org/
37   VERSION:=$(PKG_RELEASE)-$(REVISION)
38 endef
39
40 define Package/base-files/conffiles
41 /etc/hosts
42 /etc/inittab
43 /etc/group
44 /etc/passwd
45 /etc/shadow
46 /etc/profile
47 /etc/shells
48 /etc/sysctl.conf
49 /etc/rc.local
50 /etc/sysupgrade.conf
51 /etc/config/
52 /etc/dropbear/
53 /etc/crontabs/
54 $(call $(TARGET)/conffiles)
55 endef
56
57 define Package/base-files/description
58  This package contains a base filesystem and system scripts for OpenWrt.
59 endef
60
61 ifneq ($(CONFIG_PREINITOPT),)
62 define ImageConfigOptions
63         mkdir -p $(1)/lib/preinit
64         echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
65         echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
66         echo 'pi_init_path=$(if $(CONFIG_TARGET_INIT_PATH),$(CONFIG_TARGET_INIT_PATH),"/bin:/sbin:/usr/bin:/usr/sbin")' >>$(1)/lib/preinit/00_preinit.conf
67         echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
68         echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
69         echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
70         echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
71         echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
72         echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
73         echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
74         echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
75         echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
76 endef
77 endif
78
79 define Build/Prepare
80         mkdir -p $(PKG_BUILD_DIR)
81 endef
82
83 define Build/Compile/Default
84
85 endef
86 Build/Compile = $(Build/Compile/Default)
87
88 define Package/base-files/install
89         $(CP) ./files/* $(1)/
90         if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
91                 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
92         fi
93         if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
94                 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
95         fi
96         if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
97                 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
98         fi
99         if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
100                 $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
101         fi
102         $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
103                 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
104                         $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
105                 fi; \
106                 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
107                         $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
108                 fi; \
109                 if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
110                         $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
111                 fi \
112         )
113
114         $(VERSION_SED) \
115                 $(1)/etc/banner \
116                 $(1)/etc/openwrt_version \
117                 $(1)/etc/openwrt_release
118
119         mkdir -p $(1)/CONTROL
120         mkdir -p $(1)/dev
121         mkdir -p $(1)/etc/crontabs
122         mkdir -p $(1)/etc/rc.d
123         mkdir -p $(1)/overlay
124         mkdir -p $(1)/lib/firmware
125         $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
126         mkdir -p $(1)/mnt
127         mkdir -p $(1)/proc
128         mkdir -p $(1)/tmp
129         mkdir -p $(1)/usr/lib
130         $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
131         mkdir -p $(1)/usr/bin
132         mkdir -p $(1)/sys
133         mkdir -p $(1)/www
134         mkdir -p $(1)/root
135         ln -sf /proc/mounts $(1)/etc/mtab
136         rm -f $(1)/var
137         ln -sf /tmp $(1)/var
138         mkdir -p $(1)/etc
139         ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
140
141         chmod 0600 $(1)/etc/shadow
142         chmod 1777 $(1)/tmp
143
144         $(call ImageConfigOptions,$(1))
145         $(call Package/base-files/install-target,$(1))
146         for conffile in $(1)/etc/config/*; do \
147                 if [ -f "$$$$conffile" ]; then \
148                         grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
149                                 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
150                 fi \
151         done
152 endef
153
154 ifneq ($(DUMP),1)
155   -include $(PLATFORM_DIR)/base-files.mk
156 endif
157
158 $(eval $(call BuildPackage,base-files))