| 1 | ########################################################### |
|---|
| 2 | # |
|---|
| 3 | # optware-bootstrap |
|---|
| 4 | # |
|---|
| 5 | # Creates an ipk for optware-bootstrapping optware. |
|---|
| 6 | # |
|---|
| 7 | ########################################################### |
|---|
| 8 | |
|---|
| 9 | OPTWARE-BOOTSTRAP_VERSION=1.2 |
|---|
| 10 | OPTWARE-BOOTSTRAP_IPK_VERSION=7 |
|---|
| 11 | |
|---|
| 12 | OPTWARE-BOOTSTRAP_DIR=optware-bootstrap-$(OPTWARE-BOOTSTRAP_VERSION) |
|---|
| 13 | OPTWARE-BOOTSTRAP_MAINTAINER=NSLU2 Linux <nslu2-linux@yahoogroups.com> |
|---|
| 14 | OPTWARE-BOOTSTRAP_DESCRIPTION=Optware bootstrap package |
|---|
| 15 | OPTWARE-BOOTSTRAP_SECTION=util |
|---|
| 16 | OPTWARE-BOOTSTRAP_PRIORITY=optional |
|---|
| 17 | OPTWARE-BOOTSTRAP_DEPENDS= |
|---|
| 18 | OPTWARE-BOOTSTRAP_CONFLICTS= |
|---|
| 19 | |
|---|
| 20 | OPTWARE-BOOTSTRAP_SOURCE_DIR=$(SOURCE_DIR)/optware-bootstrap |
|---|
| 21 | |
|---|
| 22 | # This is used when multiple devices shares the same feed, but need different bootstrap.xsh |
|---|
| 23 | # For instance, in the case of mssii |
|---|
| 24 | # OPTWARE_TARGET is set to mssii |
|---|
| 25 | # OPTWARE-BOOTSTRAP_TARGET can be either mssii, lspro, terapro |
|---|
| 26 | OPTWARE-BOOTSTRAP_TARGET ?= $(OPTWARE_TARGET) |
|---|
| 27 | |
|---|
| 28 | # bootstrap target specific options such as |
|---|
| 29 | # OPTWARE-BOOTSTRAP_REAL_OPT_DIR and OPTWARE-BOOTSTRAP_RC |
|---|
| 30 | # will be set in the .mk included below |
|---|
| 31 | include $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/target-specific.mk |
|---|
| 32 | |
|---|
| 33 | ifneq (, $(filter $(OPTWARE-BOOTSTRAP_TARGET), $(OPTWARE-BOOTSTRAP_TARGETS))) |
|---|
| 34 | |
|---|
| 35 | OPTWARE-BOOTSTRAP_CONTAINS ?= ipkg-opt openssl wget-ssl |
|---|
| 36 | OPTWARE-BOOTSTRAP_IPKS_DONE:=$(foreach p, $(OPTWARE-BOOTSTRAP_CONTAINS), $(BUILD_DIR)/$(p)/.ipk) |
|---|
| 37 | |
|---|
| 38 | OPTWARE-BOOTSTRAP_BUILD_DIR=$(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)-optware-bootstrap |
|---|
| 39 | |
|---|
| 40 | OPTWARE-BOOTSTRAP_V=$(OPTWARE-BOOTSTRAP_VERSION)-$(OPTWARE-BOOTSTRAP_IPK_VERSION) |
|---|
| 41 | OPTWARE-BOOTSTRAP_IPK_DIR=$(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)-bootstrap-$(OPTWARE-BOOTSTRAP_VERSION)-ipk |
|---|
| 42 | OPTWARE-BOOTSTRAP_IPK=$(BUILD_DIR)/optware-bootstrap_$(OPTWARE-BOOTSTRAP_V)_$(TARGET_ARCH).ipk |
|---|
| 43 | OPTWARE-BOOTSTRAP_XSH=$(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)-bootstrap_$(OPTWARE-BOOTSTRAP_V)_$(TARGET_ARCH).xsh |
|---|
| 44 | |
|---|
| 45 | $(OPTWARE-BOOTSTRAP_BUILD_DIR)/.configured: $(OPTWARE-BOOTSTRAP_PATCHES) make/optware-bootstrap.mk \ |
|---|
| 46 | $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/target-specific.mk |
|---|
| 47 | rm -rf $(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_DIR) $(@D) |
|---|
| 48 | mkdir -p $(@D) |
|---|
| 49 | touch $@ |
|---|
| 50 | |
|---|
| 51 | optware-bootstrap-unpack: $(OPTWARE-BOOTSTRAP_BUILD_DIR)/.configured |
|---|
| 52 | |
|---|
| 53 | $(OPTWARE-BOOTSTRAP_BUILD_DIR)/.built: $(OPTWARE-BOOTSTRAP_BUILD_DIR)/.configured |
|---|
| 54 | rm -f $@ |
|---|
| 55 | # cp -a $(TARGET_LIBDIR)/* $(OPTWARE-BOOTSTRAP_BUILD_DIR)/ |
|---|
| 56 | # find $(OPTWARE-BOOTSTRAP_BUILD_DIR)/ -type l | xargs rm -f |
|---|
| 57 | # rm $(OPTWARE-BOOTSTRAP_BUILD_DIR)/libc.so* |
|---|
| 58 | touch $@ |
|---|
| 59 | |
|---|
| 60 | optware-bootstrap: $(OPTWARE-BOOTSTRAP_BUILD_DIR)/.built |
|---|
| 61 | |
|---|
| 62 | optware-bootstrap-stage: |
|---|
| 63 | |
|---|
| 64 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/CONTROL/control: |
|---|
| 65 | @install -d $(@D) |
|---|
| 66 | @rm -f $@ |
|---|
| 67 | @echo "Package: optware-bootstrap" >>$@ |
|---|
| 68 | @echo "Architecture: $(TARGET_ARCH)" >>$@ |
|---|
| 69 | @echo "Priority: $(OPTWARE-BOOTSTRAP_PRIORITY)" >>$@ |
|---|
| 70 | @echo "Section: $(OPTWARE-BOOTSTRAP_SECTION)" >>$@ |
|---|
| 71 | @echo "Version: $(OPTWARE-BOOTSTRAP_V)" >>$@ |
|---|
| 72 | @echo "Maintainer: $(OPTWARE-BOOTSTRAP_MAINTAINER)" >>$@ |
|---|
| 73 | @echo "Source: $(OPTWARE-BOOTSTRAP_SITE)/$(OPTWARE-BOOTSTRAP_SOURCE)" >>$@ |
|---|
| 74 | @echo "Description: $(OPTWARE-BOOTSTRAP_DESCRIPTION) for $(OPTWARE-BOOTSTRAP_TARGET)" >>$@ |
|---|
| 75 | @echo "Depends: $(OPTWARE-BOOTSTRAP_DEPENDS)" >>$@ |
|---|
| 76 | @echo "Conflicts: $(OPTWARE-BOOTSTRAP_CONFLICTS)" >>$@ |
|---|
| 77 | |
|---|
| 78 | $(OPTWARE-BOOTSTRAP_XSH): $(OPTWARE-BOOTSTRAP_BUILD_DIR)/.built $(OPTWARE-BOOTSTRAP_IPKS_DONE) |
|---|
| 79 | # build optware-bootstrap.ipk first |
|---|
| 80 | rm -rf $(OPTWARE-BOOTSTRAP_IPK_DIR) $(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)-bootstrap_*_$(TARGET_ARCH).ipk |
|---|
| 81 | install -d -m 755 \ |
|---|
| 82 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/etc \ |
|---|
| 83 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/lib \ |
|---|
| 84 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/var |
|---|
| 85 | ifneq ($(OPTWARE-BOOTSTRAP_LIBS),) |
|---|
| 86 | cp -rip $(OPTWARE-BOOTSTRAP_LIBS) $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/lib |
|---|
| 87 | endif |
|---|
| 88 | install -d $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/var/lib |
|---|
| 89 | install -d $(OPTWARE-BOOTSTRAP_IPK_DIR)/etc/init.d |
|---|
| 90 | install -d -m 1755 $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/tmp |
|---|
| 91 | install -m 755 $(IPKG-OPT_SOURCE_DIR)/rc.optware $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/etc/ |
|---|
| 92 | ifneq (, $(filter fsg3 fsg3v4, $(OPTWARE_TARGET))) |
|---|
| 93 | install -m 755 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/$(OPTWARE_TARGET)/optware \ |
|---|
| 94 | $(OPTWARE-BOOTSTRAP_IPK_DIR)$(OPTWARE-BOOTSTRAP_RC) |
|---|
| 95 | else |
|---|
| 96 | install -m 755 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/optware $(OPTWARE-BOOTSTRAP_IPK_DIR)$(OPTWARE-BOOTSTRAP_RC) |
|---|
| 97 | endif |
|---|
| 98 | install -d $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/etc/init.d |
|---|
| 99 | if [ -e $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/$(OPTWARE_TARGET)/S00optware ] ; then \ |
|---|
| 100 | install -m 755 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/$(OPTWARE_TARGET)/S00optware \ |
|---|
| 101 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/opt/etc/init.d/ ; \ |
|---|
| 102 | fi |
|---|
| 103 | ifneq (, $(filter yes, $(OPTWARE-BOOTSTRAP_UPDATE_ALTERNATIVES))) |
|---|
| 104 | install -d $(OPTWARE-BOOTSTRAP_IPK_DIR)$(UPD-ALT_PREFIX)/bin |
|---|
| 105 | install -m 755 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/update-alternatives \ |
|---|
| 106 | $(OPTWARE-BOOTSTRAP_IPK_DIR)$(UPD-ALT_PREFIX)/bin/ |
|---|
| 107 | endif |
|---|
| 108 | $(MAKE) $(OPTWARE-BOOTSTRAP_IPK_DIR)/CONTROL/control |
|---|
| 109 | install -m 644 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/preinst $(OPTWARE-BOOTSTRAP_IPK_DIR)/CONTROL/ |
|---|
| 110 | ifneq ($(OPTWARE-BOOTSTRAP_REAL_OPT_DIR),) |
|---|
| 111 | sed -i -e '/^[ ]*REAL_OPT_DIR=$$/s|=.*|=$(OPTWARE-BOOTSTRAP_REAL_OPT_DIR)|' \ |
|---|
| 112 | $(OPTWARE-BOOTSTRAP_IPK_DIR)$(OPTWARE-BOOTSTRAP_RC) \ |
|---|
| 113 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/CONTROL/preinst |
|---|
| 114 | endif |
|---|
| 115 | install -m 644 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)/postinst \ |
|---|
| 116 | $(OPTWARE-BOOTSTRAP_IPK_DIR)/CONTROL/ |
|---|
| 117 | cd $(BUILD_DIR); $(IPKG_BUILD) $(OPTWARE-BOOTSTRAP_IPK_DIR) |
|---|
| 118 | # build optware-bootstrap.xsh next |
|---|
| 119 | rm -rf $(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)-bootstrap_*_$(TARGET_ARCH).xsh |
|---|
| 120 | rm -rf $(OPTWARE-BOOTSTRAP_BUILD_DIR)/bootstrap |
|---|
| 121 | install -d $(OPTWARE-BOOTSTRAP_BUILD_DIR)/bootstrap |
|---|
| 122 | # move the ipk, so it will not be in the feed |
|---|
| 123 | mv $(OPTWARE-BOOTSTRAP_IPK) $(OPTWARE-BOOTSTRAP_BUILD_DIR)/bootstrap/optware-bootstrap.ipk |
|---|
| 124 | # additional ipk's we require |
|---|
| 125 | for i in $(OPTWARE-BOOTSTRAP_CONTAINS); do \ |
|---|
| 126 | I_IPK=`grep -i ^$${i}_IPK= make/*.mk | sed 's/^.*://;s/=.*//'`; \ |
|---|
| 127 | ipkfile=`MAKEFLAGS=-s $(MAKE) query-$${I_IPK}`; \ |
|---|
| 128 | cp $$ipkfile $(OPTWARE-BOOTSTRAP_BUILD_DIR)/bootstrap/$${i}.ipk; \ |
|---|
| 129 | done |
|---|
| 130 | # bootstrap scripts |
|---|
| 131 | install -m 755 $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/$(OPTWARE-BOOTSTRAP_TARGET)/bootstrap.sh \ |
|---|
| 132 | $(OPTWARE-BOOTSTRAP_SOURCE_DIR)/ipkg.sh \ |
|---|
| 133 | $(OPTWARE-BOOTSTRAP_BUILD_DIR)/bootstrap/ |
|---|
| 134 | ifneq (OPTWARE-BOOTSTRAP_REAL_OPT_DIR,) |
|---|
| 135 | sed -i -e '/^[ ]*REAL_OPT_DIR=.*/s|=.*|=$(OPTWARE-BOOTSTRAP_REAL_OPT_DIR)|' \ |
|---|
| 136 | -e 's/$${OPTWARE_TARGET}/$(OPTWARE_TARGET)/g' \ |
|---|
| 137 | $(OPTWARE-BOOTSTRAP_BUILD_DIR)/bootstrap/bootstrap.sh |
|---|
| 138 | endif |
|---|
| 139 | # NNN is the number of bytes to skip, adjust if not 3 digits |
|---|
| 140 | echo "#!/bin/sh" >$@ |
|---|
| 141 | echo 'echo "Optware Bootstrap for $(OPTWARE-BOOTSTRAP_TARGET)."' >>$@ |
|---|
| 142 | echo 'echo "Extracting archive... please wait"' >>$@ |
|---|
| 143 | echo 'dd if=$$0 bs=NNN skip=1 | tar xzv' >>$@ |
|---|
| 144 | echo "cd bootstrap && sh bootstrap.sh && cd .. && rm -r bootstrap" >>$@ |
|---|
| 145 | echo 'exec /bin/sh --login' >>$@ |
|---|
| 146 | sed -i -e "s/NNN/`wc -c $@ | awk '{print $$1}'`/" $@ |
|---|
| 147 | tar -C $(OPTWARE-BOOTSTRAP_BUILD_DIR) -czf - bootstrap >>$@ |
|---|
| 148 | chmod 755 $@ |
|---|
| 149 | |
|---|
| 150 | optware-bootstrap-ipk: $(OPTWARE-BOOTSTRAP_XSH) |
|---|
| 151 | optware-bootstrap-xsh: $(OPTWARE-BOOTSTRAP_XSH) |
|---|
| 152 | |
|---|
| 153 | optware-bootstrap-clean: |
|---|
| 154 | rm -rf $(OPTWARE-BOOTSTRAP_BUILD_DIR)/* |
|---|
| 155 | |
|---|
| 156 | optware-bootstrap-dirclean: |
|---|
| 157 | rm -rf $(BUILD_DIR)/$(OPTWARE-BOOTSTRAP_DIR) $(OPTWARE-BOOTSTRAP_BUILD_DIR) $(OPTWARE-BOOTSTRAP_IPK_DIR) $(OPTWARE-BOOTSTRAP_IPK) |
|---|
| 158 | rm -rf $(OPTWARE-BOOTSTRAP_XSH) |
|---|
| 159 | |
|---|
| 160 | endif |
|---|