source: debwrt/trunk/debian/rootfs/debian.mk @ 250

Last change on this file since 250 was 250, checked in by stappers, 8 years ago

Reverting r243

File size: 4.9 KB
Line 
1# DebWrt - Debian on Embedded devices
2#
3# Copyright (C) 2010 Johan van Zoomeren <amain@debwrt.net>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18DEBIAN_ROOTFS_INCLUDE_PACKAGES:=$(call qstrip,$(CONFIG_DEBIAN_ROOTFS_INCLUDE_PACKAGES))
19DEBWRT_EXTRA_ROOTFS_FILES_DIR:=$(TOPDIR)/debian/rootfs/files
20DEBWRT_MODULES_ARCHIVE=$(shell ls $(INSTALL_DIR)/debwrt-modules-*.tar.gz 2>/dev/null)
21MODULES_VERSION=$(shell echo `basename $(DEBWRT_MODULES_ARCHIVE) 2>/dev/null` | awk -F '-' '{print $$6}')
22
23debian/rootfs: debian/rootfs/bootstrap debian/rootfs/unpack debian/rootfs/files-install debian/rootfs/debwrt-packages debian/rootfs/modules-install debian/rootfs/post-setup
24        touch $@
25
26debian/rootfs/install: debian/rootfs
27        if [ -d /media/DEBWRT_ROOT ]; then \
28                sudo rm -rf /media/DEBWRT_ROOT/*; \
29                sudo bash -c "tar cf - -C $(ROOTFS_BUILD_DIR) . | tar xf - -C /media/DEBWRT_ROOT"; \
30        fi
31        #touch $@
32
33debian/rootfs/save:
34        if [ -d /media/DEBWRT_ROOT ]; then \
35                sudo bash -c "tar cjf debwrt-rootfs-$(TARGET_ARCH)-$(VERSION).tar.bz2 -C /media/DEBWRT_ROOT ."; \
36        fi
37
38debian/rootfs/files-install: debian/rootfs/bootstrap
39        if [ ! -f $(ROOTFS_BUILD_DIR)/etc/init.d/rcS.debian -a -e $(ROOTFS_BUILD_DIR)/etc/init.d/rcS ]; then \
40                sudo mv -v $(ROOTFS_BUILD_DIR)/etc/init.d/rcS $(ROOTFS_BUILD_DIR)/etc/init.d/rcS.debian; \
41        fi
42        if [ ! -p $(ROOTFS_BUILD_DIR)/dev/initctl ]; then  \
43                sudo mkdir -p $(ROOTFS_BUILD_DIR)/dev;         \
44                sudo mkfifo   $(ROOTFS_BUILD_DIR)/dev/initctl; \
45        fi
46        chmod 600 $(DEBWRT_EXTRA_ROOTFS_FILES_DIR)/etc/ssh/ssh_host_rsa_key
47        chmod 600 $(DEBWRT_EXTRA_ROOTFS_FILES_DIR)/etc/ssh/ssh_host_dsa_key
48        sudo bash -c "tar cf - --exclude=".svn" -C $(DEBWRT_EXTRA_ROOTFS_FILES_DIR) . | tar -xovf - -C $(ROOTFS_BUILD_DIR)"
49        sudo cat $(ROOTFS_BUILD_DIR)/etc/securetty \
50                $(TOPDIR)/debian/rootfs/securetty.tail \
51                >> $(TOPDIR)/securetty.temp
52        sudo mv $(TOPDIR)/securetty.temp $(ROOTFS_BUILD_DIR)/etc/securetty
53        touch $@
54
55debian/rootfs/modules-install: debian/rootfs/bootstrap
56ifneq ($(DEBWRT_MODULES_ARCHIVE),)
57        sudo tar xof $(DEBWRT_MODULES_ARCHIVE) -C $(ROOTFS_BUILD_DIR)
58        #sudo depmod -a -b $(ROOTFS_BUILD_DIR) $(MODULES_VERSION)
59endif
60        touch $@
61
62debian/rootfs/bootstrap: debian/rootfs/clean-rootfs-dir
63        sudo debootstrap --arch=$(TARGET_ARCH)\
64                     --foreign \
65                     --include=$(shell grep -v '^#' \
66                       $(DEBIAN_ROOTFS_INCLUDE_PACKAGES) \
67                         | tr '\n' , | sed -e 's/^/"/' -e 's/,$$/"/' ) \
68                     $(DEBIAN_BUILD_VERSION) \
69                     $(ROOTFS_BUILD_DIR) \
70                     $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
71        # complete ROOTFS/dev/ with additional device files
72        sudo bash -c "cd $(ROOTFS_BUILD_DIR)/dev ; /sbin/MAKEDEV -v consoleonly"
73        sudo bash -c "cd $(ROOTFS_BUILD_DIR)/dev ; /sbin/MAKEDEV -v sda"
74        touch $@
75
76debian/rootfs/unpack: debian/rootfs/bootstrap
77        find $(ROOTFS_BUILD_DIR) -name "*.deb" | while read deb; do \
78                n=`basename $$deb`; \
79                echo -n "I: Extracting $${n}..."; \
80                sudo bash -c "dpkg --extract "$$deb" $(ROOTFS_BUILD_DIR)" ; \
81                echo "done"; \
82        done
83        touch $@
84
85# install all available cross-compiled debwrt debian packages, extect for the kernel-headers packages because it is to big
86debian/rootfs/debwrt-packages: debian/rootfs/bootstrap debian/package/rootfs
87        ls ${INSTALL_DIR_DEBIAN_PACKAGES}/*.deb | grep -v "debwrt-kernel-headers" | while read package; do \
88                pfname=`basename $$package`; \
89                pname=`echo $$pfname | sed 's/_.*//'`; \
90                echo "Installing DebWrt package: $$pname"; \
91                sudo cp $$package $(ROOTFS_BUILD_DIR)/var/cache/apt/archives; \
92                sudo dpkg-deb -x $$package $(ROOTFS_BUILD_DIR); \
93                sudo bash -c "echo \"$$pname /var/cache/apt/archives/$$pfname\" >>$(ROOTFS_BUILD_DIR)/debootstrap/debpaths" ;\
94        done
95        touch $@
96       
97debian/rootfs/clean-rootfs-dir:
98        mkdir -p $(BUILD_DIR_BASE)
99        sudo rm -rf $(ROOTFS_BUILD_DIR)
100        touch $@
101
102debian/rootfs/post-setup: debian/rootfs/bootstrap
103        sudo mkdir -p $(ROOTFS_BUILD_DIR)/etc/apt
104        sudo bash -c "echo \"deb $(call qstrip,$(DEBIAN_BUILDENV_REPOSITORY)) $(DEBIAN_BUILD_VERSION) main\" > $(ROOTFS_BUILD_DIR)/etc/apt/sources.list"
105        touch $@
106
107debian/rootfs/clean: 
108        sudo rm -rf $(ROOTFS_BUILD_DIR)
109        rm -f debian/rootfs/debwrt-packages
110        rm -f debian/rootfs/bootstrap
111        rm -f debian/rootfs/install
112        rm -f debian/rootfs/files-install
113        rm -f debian/rootfs/modules-install
114        rm -f debian/package/rootfs
115        rm -f debian/package/*/deliver
116
117# l l
Note: See TracBrowser for help on using the repository browser.