Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/make -f
- # See copyright notice at end of file
- # Base Version - used to extract the firmware
- VER1=R1.4.5
- # New version to create from the extracted root filesystem and base version
- # kernel and header
- VER2=R1.4.5.M1
- # Directory where you want to extract the root filesystem, from which you want
- # to create it
- ROOTFS=$(BUILDDIR)squashfs-root
- # directory where you want to build files
- BUILDDIR=MAIN/
- # directory where you downloded the original fimware ... where you want to put
- # the firmware you create (TFTP root)
- FIRMDIR=firm/
- # mksquashfs utility
- MKSQUASKFS=$(HOME)/neufbox/mksquashfs
- # network interface
- IFACE=eth0
- LN=ln -s
- CP=cp
- SUDO=
- NB4_UNSQUASH_PY=nb4-unsquash.py
- NB4_UNSQUASH=nb4-unsquash
- NB4_UNSQLZMA=nb4-unsqlzma
- NB4_GETFIRM=nb4-getfirm
- NB4_EXTRACT=nb4-extract
- NB4_CONCAT=nb4-concat
- # Method to extract the root filesystem
- #UNSQUASH_ACTION=$(NB4_UNSQUASH_PY) $< $(ROOTFS)
- #UNSQUASH_ACTION=$(NB4_UNSQUASH) -d $(ROOTFS) $<
- UNSQUASH_ACTION=$(SUDO) $(NB4_UNSQLZMA) -d $(ROOTFS) $<
- ADMIN_USER=
- ADMIN_CRYPTPWD=$1$7L3E4.ch$rrUxKcF0EwU/S9RH0Klo31
- IPADDR=$(shell ip -f inet addr show dev $(IFACE) | grep inet | sed -r 's/.*inet ([0-9\.]*).*/\1/')
- TMPFILE1=tmp1
- #################### HELP ####################
- help:
- @echo "make help - This help"
- @echo "make download - Download the official firmware in $(FIRMDIR)"
- @echo "make extract * - Extract the firmware in $(BUILDDIR)"
- @echo "make svnclean * - remove .svn directories from root filesystem"
- @echo "make admin * - Create an administrative account"
- @echo "make build - Build the new firmware in $(BUILDDIR)"
- @echo "make install - Install the new firmware in $(FIRMDIR)"
- @echo "make tftp-server - Run a TFTP server in $(FIRMDIR)"
- @echo
- @echo "* you may want to run these actions with root privileges"
- @echo " to do so, just run `make SUDO=sudo <target>' (for example)"
- @echo
- @echo "extract, build and install target must be run with correct"
- @echo "firmware version: "
- @echo "Original firmware version (extract, build): VER1=$(VER1)"
- @echo "New firmware version (install): VER2=$(VER2)"
- .PHONY: help
- #################### DOWNLOAD ####################
- download:
- -test ! -d $(FIRMDIR) && mkdir $(FIRMDIR)
- cd $(FIRMDIR); $(NB4_GETFIRM)
- $(CP) $(FIRMDIR)/LOSTVersion.general $(FIRMDIR)/LOSTVersion.general.default
- .PHONY: download
- #################### EXTRACT ####################
- extract: $(BUILDDIR)NB4-$(VER1)-ROOTFS
- $(UNSQUASH_ACTION)
- .PHONY: extract
- $(BUILDDIR)NB4-$(VER1)-HEADER $(BUILDDIR)NB4-$(VER1)-KERNEL $(BUILDDIR)NB4-$(VER1)-ROOTFS: $(BUILDDIR)NB4-$(VER1)-MAIN
- cd $(BUILDDIR) ; $(NB4_EXTRACT) $<
- $(BUILDDIR)NB4-$(VER1)-MAIN: $(FIRMDIR)NB4-$(VER1)-MAIN
- -test ! -d $(BUILDDIR) && mkdir $(BUILDDIR)
- $(LN) $< $@
- #################### SVNCLEAN ####################
- svnclean:
- $(SUDO) find $(ROOTFS) -type d -name '.svn' -exec rm -r {} \; -prune -print
- .PHONY: svnclean
- #################### ADMIN ####################
- admin:
- @user=$(ADMIN_USER) ; \
- pass=$(ADMIN_CRYPTPWD) ; \
- echo "Note: You can change the crypted password by setting the" ;\
- echo " variable ADMIN_CRYPTPWD on the make command line" ;\
- if [ -z "$$pass" ]; then \
- echo "Error: You must specify a username in the Makefile" >&2; \
- echo " by setting the variable ADMIN_CRYPTPWD" >&2; \
- exit 1; \
- fi; \
- if [ -z "$$user" ]; then \
- echo -n "Username: "; \
- read user; \
- fi; \
- $(SUDO) $(CP) $(ROOTFS)/etc/passwd $(ROOTFS)/etc/passwd.bak ; \
- $(SUDO) $(CP) $(ROOTFS)/etc/shadow $(ROOTFS)/etc/shadow.bak ; \
- echo "$$user:x:0:0:root:/:/bin/sh" > $(TMPFILE1) ; \
- $(SUDO) grep -v "^$$user:" $(ROOTFS)/etc/passwd >> $(TMPFILE1) ; \
- $(SUDO) $(CP) $(TMPFILE1) $(ROOTFS)/etc/passwd ; \
- echo "$$user:$$pass:13367:0:99999:7:::" > $(TMPFILE1) ; \
- $(SUDO) grep -v "^$$user:" $(ROOTFS)/etc/shadow >> $(TMPFILE1) ; \
- $(SUDO) $(CP) $(TMPFILE1) $(ROOTFS)/etc/shadow ; \
- echo "Created user $$user."
- .PHONY: admin
- #################### BUILD ####################
- build: $(BUILDDIR)NB4-$(VER2)-MAIN
- .PHONY: build
- $(FIRMDIR)NB4-$(VER2)-MAIN: $(BUILDDIR)NB4-$(VER2)-MAIN
- -test ! -d $(FIRMDIR) && mkdir $(FIRMDIR)
- $(CP) $< $@
- $(BUILDDIR)NB4-$(VER2)-MAIN: $(BUILDDIR)NB4-$(VER2)-HEADER $(BUILDDIR)NB4-$(VER2)-KERNEL $(BUILDDIR)NB4-$(VER2)-ROOTFS
- cd $(BUILDDIR) ; $(NB4_CONCAT) NB4-$(VER2)
- -chmod a+r $@
- $(BUILDDIR)NB4-$(VER2)-HEADER: $(BUILDDIR)NB4-$(VER1)-HEADER
- $(LN) $< $@
- $(BUILDDIR)NB4-$(VER2)-KERNEL: $(BUILDDIR)NB4-$(VER1)-KERNEL
- $(LN) $< $@
- $(BUILDDIR)NB4-$(VER2)-ROOTFS:
- -test ! -d $(BUILDDIR) && mkdir $(BUILDDIR)
- cd $(BUILDDIR) ; $(MKSQUASKFS) $(ROOTFS) $@ -be -lzma -no-fragments -noI -all-root -noappend
- #################### INSTALL ####################
- install: $(FIRMDIR)NB4-$(VER2)-MAIN
- tmp="`cat $(FIRMDIR)/LOSTVersion.general`" ; \
- echo "$$tmp" \
- | sed -r 's/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$$/$(IPADDR)/' \
- | sed -r 's/^.*\-MAIN$$/NB4-$(VER2)-MAIN/'
- .PHONY: install
- #################### TFTP-SERVER ####################
- tftp-server:
- dnsmasq -d -C /dev/null -i $(IFACE) \
- --domain-needed \
- --enable-tftp \
- --tftp-root="$(FIRMDIR)" \
- --dhcp-range=192.168.10.2,192.168.10.150,12h \
- --dhcp-option=1,255.255.255.0 \
- --dhcp-option=6,192.168.10.1 \
- --dhcp-option=3,192.168.10.1 \
- --dhcp-option=17,"192.168.10.1"
- .PHONY: tftp-server
- #######################################################################
- ## Copyright (c) 2008 Mildred <mildred593(at)online.fr>
- ##
- ## Permission is hereby granted, free of charge, to any person
- ## obtaining a copy of this software and associated documentation
- ## files (the "Software"), to deal in the Software without
- ## restriction, including without limitation the rights to use,
- ## copy, modify, merge, publish, distribute, sublicense, and/or sell
- ## copies of the Software, and to permit persons to whom the
- ## Software is furnished to do so, subject to the following
- ## conditions:
- ##
- ## The above copyright notice and this permission notice shall be
- ## included in all copies or substantial portions of the Software.
- ##
- ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- ## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- ## OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- ## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- ## HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- ## WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- ## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- ## OTHER DEALINGS IN THE SOFTWARE.
- #######################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement