Each line in Make is started in a new shell. Your added lines are
executed as (simplified):
bash -c 'if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then'
bash -c '$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n'
bash -c '$(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo
$(1)/usr/lib/lua/luci/i18n'
bash -c 'fi'
The first "if" command is invalid because it is not terminated
("unexpected end of file") and the single "fi" command in the end is
invalid syntax as well (preceding if ... then missing).
You need to join your four lines into a single statement by escaping
the newline with a backslash and by terminating statements with a
semicolon:
> if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then \
> $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n; \
> $(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo
> $(1)/usr/lib/lua/luci/i18n; \
> fi
Which will result in (simplified)
bash -c 'if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then $(INSTALL_DIR)
$(1)/usr/lib/lua/luci/i18n; $(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo
$(1)/usr/lib/lua/luci/i18n; fi'
~ Jow
On 01/05/2016 10:41 AM, Andy Wong wrote:
> Hi.I not quite understand.I've change the install part as below:
>
> define Package/openwrt-dist-luci/install
> #!/bin/sh
> $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
> $(INSTALL_DATA) ./files/luci/controller/$(2).lua
> $(1)/usr/lib/lua/luci/controller/$(2).lua
> $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
> $(INSTALL_DATA) ./files/luci/model/cbi/$(2).lua
> $(1)/usr/lib/lua/luci/model/cbi/$(2).lua
> $(INSTALL_DIR) $(1)/etc/uci-defaults
> $(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-$(2)
> $(1)/etc/uci-defaults/luci-$(2)
> *if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then*
> *$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n*
> *$(INSTALL_DATA) ./files/luci/i18n/$(2).zh-cn.lmo
> $(1)/usr/lib/lua/luci/i18n*
> *fi*
> exit 0
> endef
>
> Notice the if then course.
>
> Here is the error now.
>
> if [ -f "./files/luci/i18n/chinadns.zh-cn.lmo" ]; then install -d -m0755
> /home/Openwrt/witi-openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openwrt-dist-luci/ipkg-all/luci-app-chinadns/usr/lib/lua/luci/i18n
> install -m0644 ./files/luci/i18n/chinadns.zh-cn.lmo
> /home/Openwrt/witi-openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openwrt-dist-luci/ipkg-all/luci-app-chinadns/usr/lib/lua/luci/i18n
> fi
> bash: -c: line 1: syntax error: unexpected end of file
> make[2]: ***
> [/home/Openwrt/witi-openwrt/bin/ramips/packages/base/luci-app-chinadns_1.3.8-1_all.ipk]
> Error 1
> make[2]: Leaving directory
> `/home/Openwrt/witi-openwrt/package/my_package/openwrt-dist-luci'
> make[1]: *** [package/my_package/openwrt-dist-luci/compile] Error 2
> make[1]: Leaving directory `/homeOpenwrt/witi-openwrt'
> make: *** [package/openwrt-dist-luci/compile] 错误 2
>
>
>
>
> At 2016-01-04 22:28:36, "Luiz Angelo Daros de Luca" <[email protected]>
> wrote:
>
> Andy,
>
> Make runs one line per time. Make the "if" inline or backslash each
> newline (adding semicolon when needed)
>
> Regards
>
>
> Em seg, 4 de jan de 2016 11:56, Andy Wong <[email protected]
> <mailto:[email protected]>> escreveu:
>
>
> For no misunderstanding.Here is the error now
> http://pastebin.com/t4Rb08kA
>
>
>
>
>
>
> 在 2016-01-04 21:18:14,"Andy Wong" <[email protected]
> <mailto:[email protected]>> 写道:
> >Thanks.I have indented like this:<br/>define
> Package/openwrt-dist-luci/install<br/>#!/bin/sh<br/> $(INSTALL_DIR)
> $(1)/usr/lib/lua/luci/controller<br/> $(INSTALL_DATA)
> ./files/luci/controller/$(2).lua
> $(1)/usr/lib/lua/luci/controller/$(2).lua<br/> $(INSTALL_DIR)
> $(1)/usr/lib/lua/luci/model/cbi<br/> $(INSTALL_DATA)
> ./files/luci/model/cbi/$(2).lua $(1)/usr/lib/lua/luci/model/cbi/$(2).lua<br/>
> $(INSTALL_DIR) $(1)/etc/uci-defaults<br/> $(INSTALL_BIN)
> ./files/root/etc/uci-defaults/luci-$(2) $(1)/etc/uci-defaults/luci-$(2)<br/>
> if [ -f "./files/luci/i18n/$(2).zh-cn.lmo" ]; then<br/> $(INSTALL_DIR)
> $(1)/usr/lib/lua/luci/i18n<br/> $(INSTALL_DATA)
> ./files/luci/i18n/$(2).zh-cn.lmo $(1)/usr/lib/lua/luci/i18n<br/>
> fi<br/>endef<br/><br/>But another error
> appears:<br/>enwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/openwrt-dist-luci/ipkg-all/luci-app-chinadns/etc/uci-defaults/luci-chinadns<br/>if
> [ -f "./files/luci/i18n/chinadns.zh-cn.lmo" ]; then<br/>bash: -c: line 1:
> syntax e
r
ror: unexpected end of file<br/>make[2]: ***
[/home/Openwrt/witi-openwrt/bin/ramips/packages/base/luci-app-chinadns_1.3.8-1_all.ipk]
Error 1<br/>make[2]: Leaving directory
`/home/Openwrt/witi-openwrt/package/my_package/openwrt-dist-luci'<br/>make[1]:
*** [package/my_package/openwrt-dist-luci/compile] Error 2<br/>make[1]: Leaving
directory `/home/Openwrt/witi-openwrt'<br/>make: ***
[package/openwrt-dist-luci/compile] 错误 2<br/><br/>My if,then course is
intending to find out if *.zh-cn.lmo exist,then install it.
> >At 2016-01-04 20:20:00, "Jo-Philipp Wich" <[email protected]
> <mailto:[email protected]>> wrote:
> >>Hi.
> >>
> >>Lines in the isntall section must be indented with at least one tab
> >>since they're shell instructions.
> >>
> >>~ Jow
> >>_______________________________________________
> >>openwrt-devel mailing list
> >>[email protected]
> <mailto:[email protected]>
> >>https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> >_______________________________________________
> >openwrt-devel mailing list
> >[email protected]
> <mailto:[email protected]>
> >https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
>
>
>
>
> _______________________________________________
> openwrt-devel mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
> --
>
> Luiz Angelo Daros de Luca
> [email protected] <mailto:[email protected]>
>
>
>
>
>
>
>
> _______________________________________________
> openwrt-devel mailing list
> [email protected]
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel