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

Last change on this file since 65 was 65, checked in by amain, 8 years ago

Extend debian rootfs and prepare for second stage install using custom rcS

File size: 3.4 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)
21MODULES_VERSION=$(shell echo `basename $(DEBWRT_MODULES_ARCHIVE)` | awk -F '-' '{print $$6}')
22
23debian/rootfs: debian/rootfs/bootstrap debian/rootfs/debwrt-packages debian/rootfs/unpack debian/rootfs/files-install debian/rootfs/modules-install
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/files-install: debian/rootfs/bootstrap
34        if [ ! -f $(ROOTFS_BUILD_DIR)/etc/init.d/rcS.debian ]; then \
35                sudo mv -v $(ROOTFS_BUILD_DIR)/etc/init.d/rcS $(ROOTFS_BUILD_DIR)/etc/init.d/rcS.debian; \
36        fi
37        sudo bash -c "tar cf - -C $(DEBWRT_EXTRA_ROOTFS_FILES_DIR) . | tar -xovf - -C $(ROOTFS_BUILD_DIR)"
38        touch $@
39
40debian/rootfs/modules-install: debian/rootfs/bootstrap
41ifneq ($(DEBWRT_MODULES_ARCHIVE),)
42        sudo tar xof $(DEBWRT_MODULES_ARCHIVE) -C $(ROOTFS_BUILD_DIR)
43        sudo depmod -a -b $(ROOTFS_BUILD_DIR) $(MODULES_VERSION)
44endif
45        touch $@
46
47debian/rootfs/bootstrap: debian/rootfs/clean-rootfs-dir
48        sudo debootstrap --arch=$(TARGET_ARCH)\
49                     --foreign \
50                         --include="$(DEBIAN_ROOTFS_INCLUDE_PACKAGES)" \
51                     $(DEBIAN_BUILD_VERSION) \
52                     $(ROOTFS_BUILD_DIR) \
53                     $(CONFIG_DEBIAN_BUILDENV_REPOSITORY)
54        touch $@
55
56debian/rootfs/unpack: debian/rootfs/bootstrap
57        find $(ROOTFS_BUILD_DIR) -name "*.deb" | while read deb; do \
58                n=`basename $$deb`; \
59                echo -n "I: Extracting $${n}..."; \
60                sudo bash -c "ar -p "$$deb" data.tar.gz | zcat | tar -C $(ROOTFS_BUILD_DIR) -xf -"; \
61                echo "done"; \
62        done
63        touch $@
64
65debian/rootfs/debwrt-packages: debian/rootfs/bootstrap
66        ls ${INSTALL_DIR_DEBIAN_PACKAGES}/*.deb | grep -v "debwrt-kernel-headers" | while read package; do \
67                pfname=`basename $$package`; \
68                pname=`echo $$pfname | sed 's/_.*//'`; \
69                echo "Installing DebWrt package: $$pname"; \
70                sudo cp $$package $(ROOTFS_BUILD_DIR)/var/cache/apt/archives; \
71                sudo dpkg-deb -x $$package $(ROOTFS_BUILD_DIR); \
72                sudo bash -c "echo \"$$pname /var/cache/apt/archives/$$pfname\" >>$(ROOTFS_BUILD_DIR)/debootstrap/debpaths" ;\
73        done
74        touch $@
75       
76debian/rootfs/clean-rootfs-dir:
77        sudo rm -rf $(ROOTFS_BUILD_DIR)
78        touch $@
79
80debian/rootfs/clean: 
81        sudo rm -rf $(ROOTFS_BUILD_DIR)
82        rm -f debian/rootfs/debwrt-packages
83        rm -f debian/rootfs/bootstrap
84        rm -f debian/rootfs/install
85        rm -f debian/rootfs/files-install
86        rm -g debian/rootfs/modules-install
87
Note: See TracBrowser for help on using the repository browser.