OpenWrt SDK to build your own IPK installation package using the SDK

Source: Internet
Author: User
Tags bool eval lua mkdir openssl prepare
The Openwrt SDK is a relocatable, pre-compiled Openwrt toolchain for cross-compiling individual user-space packages for a specific platform without having to compile the entire system from scratch. Reasons for using the SDK: to compile the updated version of the specified package file for a specific release version of the custom software to ensure binary and feature compatibility

Use a custom patch or different features to recompile a package that already exists


#-----Official documents are as followsThis is the OpenWrt SDK. It contains a stripped-down version of the BuildRoot. You can use it to test/develop packages without have to compile your own toolchain or any of the libraries included with OpenWrt. To use it, just put your buildroot-compatible package directory of the SubDir ' package/' and run ' make ' from this director Y.
#------OpenWrt Makefile rules for the integration of unofficial packagesInclude $ (topdir)/rules.mk
Pkg_name:=[Package name and folder name] pkg_version:=[Package version write yourself a] pkg_release:=1
Pkg_build_dir: = $ (Build_dir)/$ (pkg_name)
Include $ (include_dir)/package.mk
Define package/$ (Pkg_name) section:=utils category:=[package in Menuconfig location such as base system] depends:=[         Two between the package by a space separated by the front Plus + + for the default display selected the package automatically select the packages do not add + to default does not show the selected dependent package display] title:=[title] pkgarch:=[platform such as ar71xx all write all] maintainer:=[Author] Endef
Define package/$ (Pkg_name)/description [Package introduction] Endef


#非本目录下的源码文件, copy it to the appropriate directory.

# like. /.. /XUCOMMON/XUCOMMON.C, copy the XUCOMMON.C to the source code in this directory. /.. /

Define Build/prepare

Mkdir-p $ (Pkg_build_dir)
$ (CP)./src/* $ (pkg_build_dir)/Endef
Define Build/configure Endef
Define Build/compile Endef
Define package/$ (Pkg_name)/conffiles [Preserve files on upgrade/backup file one line when backing up files] Endef
Define package/$ (Pkg_name)/install $ (CP)./files/* $ (1)/Endef
Define package/$ (Pkg_name)/preinst [pre-installation script Remember to add #!/bin/sh not empty] #!/bin/sh uci-q batch <<-eof >/dev/nul     L Delete ucitrack. @aria2 [-1] Add Ucitrack aria2 set ucitrack. @aria2 [ -1].init=aria2 Commit Ucitrack EOF Exit 0 Endef
Define package/$ (Pkg_name)/postinst [script executed after installation Remember to add #!/bin/sh not empty] #!/bin/sh rm-f/tmp/luci-indexcache exit 0 Endef
package/$ (pkg_name)/prerm [Delete pre-executed script remember to add #!/bin/sh not empty] endef
package/$ (pkg_name)/POSTRM [delete executed after script remember add #!/bin/sh not empty] endef
$ (eval $ (call buildpackage,$ (Pkg_name)))---------------------------------------------------------------------
#---Own routines: Makefile under the HttpClient directory

Include $ (topdir)/rules.mk

pkg_name:=httpclient
pkg_release:=1
pkg_build_dir: = $ (Build_dir)/$ (pkg_ NAME)

include $ (include_dir)/package.mk

define package/httpclient
  section:=utils
  category:= Utilities
  title:=http Client demo
endef

define package/httpclient/description
 HTTP Client Demo
endef

define Build/prepare
 mkdir-p $ (pkg_build_dir)
 $ (CP)./src/* $ (pkg_build_dir)/
Endef

define Package/httpclient/install
 $ (install_dir) $ (1)/usr/sbin
 $ (install_bin) $ (pkg_build_ DIR)/httptest $ (1)/usr/sbin/ 
 $ (install_dir) $ (1)/etc/config
 $ (install_conf)./files/test.lua $ (1)/etc/ Config/test.lua
endef

$ (eval $ (call buildpackage,$ (Pkg_name)))

#---The Makefile of ser2net
Include $ (topdir)/rules.mk pkg_name:=ser2net pkg_version:=2.7 pkg_release:=2 pkg_source:=$ (PKG_NAME)-$ (PKG_VERSION)

. tar.gz pkg_source_url:= @SF/ser2net pkg_md5sum:=22977477789868923a5de09a85e847dd pkg_fixup:=libtool PKG_INSTALL:=1 Include $ (include_dir)/package.mk define package/ser2net section:=net category:=network title:=serial Port TCP/IP R Edirector Url:=http://sourceforge.net/projects/ser2net/endef define Package/ser2net/description This is ser2net, a P
  Rogram for allowing network connections to serial ports. See the Mans page for information about using the program.
Note that Ser2net supports RFC 2217 (remote control of the serial port parameters), but you must has a complient client. Endef define package/ser2net/conffiles/etc/ser2net.conf endef # uses GNU Configure define Package/ser2net/install $ (I Nstall_dir) $ (1)/usr/sbin $ (install_bin) $ (pkg_install_dir)/usr/sbin/ser2net $ (1)/usr/sbin/$ (install_dir) $ (1)/etc $ (install_conf) $ (pkg_build_dir)/ser2net.cOnf $ (1)/etc/endef $ (eval $ (call buildpackage,ser2net)) 


#---The Makefile of uhttpd
Include $ (topdir)/rules.mk pkg_name:=uhttpd pkg_release:=31 Pkg_build_dir: = $ (Build_dir)/$ (pkg_name) PKG_CONFIG_ DEPENDS: = \ Config_package_uhttpd-mod-lua \ config_package_uhttpd-mod-tls \ config_package_uhttpd-mod-tls_cyassl \ CO Nfig_package_uhttpd-mod-tls_openssl include $ (include_dir)/package.mk define Package/uhttpd/default SECTION:=net CAT  Egory:=network submenu:=web servers/proxies title:=uhttpd-tiny, single threaded HTTP server Maintainer:=jo-philipp Wich endef define PACKAGE/UHTTPD $ (package/uhttpd/default) menu:=1 endef define Package/uhttpd/description uhttpd is a tiny single threaded HTTP server with TLS, CGI and Lua support.
It is intended as a drop-in replacement for the Busybox HTTP daemon. Endef define PACKAGE/UHTTPD-MOD-TLS $ (package/uhttpd/default) title+= (TLS plugin) depends:=uhttpd +PACKAGE_UHTTPD -mod-tls_cyassl:libcyassl +package_uhttpd-mod-tls_openssl:libopenssl endef Define package/uhttpd-mod-tls/ Description The TLS plugin adDS HTTPS support to UHTTPD.
                Endef define Package/uhttpd-mod-tls/config choice depends on Package_uhttpd-mod-tls Prompt "TLS Provider" default Package_uhttpd-mod-tls_cyassl config package_uhttpd-mod-
                        TLS_CYASSL bool "Cyassl" config Package_uhttpd-mod-tls_openssl BOOL "OpenSSL" Endchoice endef uhttpd_tls:= tls_cflags:= tls_ldflags:= ifneq ($ (config_package_uhttpd-mod- TLS_CYASSL),) Uhttpd_tls:=cyassl tls_cflags:=-i$ (staging_dir)/usr/include/cyassl-dtls_is_cyassl TLS_LDFLAGS:=- 
  LCYASSL-LM endif ifneq ($ (CONFIG_PACKAGE_UHTTPD-MOD-TLS_OPENSSL),) Uhttpd_tls:=openssl Tls_cflags:=-dtls_is_openssl Tls_ldflags:=-lssl endif define Package/uhttpd-mod-lua $ (package/uhttpd/default) title+= (LUA plugin) depends:=u httpd +liblua endef define package/uhttpd-mod-lua/description The Lua plugin adds a cgi-like LUA runtime interface to UH TtPd. endef Target_cflags + = $ (tls_cflags) Target_ldflags + =-wl,-rpath-link=$ (staging_dir)/usr/lib MAKE_VARS + = \ FPIC= " $ (FPIC) "\ lua_support=" $ (if $ (Config_package_uhttpd-mod-lua), 1) "\ tls_support=" $ (if $ (config_package_ UHTTPD-MOD-TLS), 1) "\ uhttpd_tls=" $ (uhttpd_tls) "\ tls_cflags=" $ (tls_cflags) "\ tls_ldflags=" $ (tls_ldflags) "Define Bu Ild/prepare mkdir-p $ (pkg_build_dir) $ (CP)./src/* $ (pkg_build_dir)/endef define Package/uhttpd/conffiles/etc/config /uhttpd/etc/uhttpd.crt/etc/uhttpd.key endef define Package/uhttpd/install $ (install_dir) $ (1)/ETC/INIT.D $ (INSTALL_B IN)./files/uhttpd.init $ (1)/etc/init.d/uhttpd $ (install_dir) $ (1)/etc/config $ (install_conf)./files/uhttpd.config $

(1)/etc/config/uhttpd $ (install_dir) $ (1)/usr/sbin $ (install_bin) $ (pkg_build_dir)/uhttpd $ (1)/usr/sbin/uhttpd Endef Define Package/uhttpd-mod-tls/install $ (install_dir) $ (1)/usr/lib $ (install_bin) $ (pkg_build_dir)/uhttpd_tls.so $ (1) /usr/lib/endef Define Package/uhttpd-mod-lua/instAll $ (Install_dir) $ (1)/usr/lib $ (install_bin) $ (pkg_build_dir)/uhttpd_lua.so $ (1)/usr/lib/endef $ (eval $ (call BUILDP ACKAGE,UHTTPD) $ (eval $ (call Buildpackage,uhttpd-mod-tls)) $ (eval $ (call Buildpackage,uhttpd-mod-lua))




Here's how:


Use the SDK to build your own IPK installation package,  
Download   http://pan.baidu.com/share/link?shareid=123840&uk=1577556057

1. Unzip the
Tar jxvf openwrt-sdk-ar71xx-for-linux-i486-gcc-4.6-linaro_uclibc-0.9.33.2.tar.bz2

2. Go to Directory
CD openwrt-sdk-ar71xx-for-linux-i486-gcc-4.6-linaro_uclibc-0.9.33.2

3. Copy your code directory to the package directory in this directory
    Note Makefile must comply with OPENWRT rules, refer to
   http://blog.chinaunix.net/uid-27194309-id-3432651.html

4. Compile, after successful in the Bin/ar71xx/packages directory can see the relevant IPK file, the use of WINSCP copy out
#编译所有组件
make v=99  

# Compile a component separately
make Package/hid/compile

5. Install to the router experiment, this you all know.

#注: Do not change the directory of the SDK, otherwise the following error will appear
xxg@xxg-desktop:~/sdk-ar71xx-gcc-4.6-linaro_uclibc-0.9.33.2$ make
/bin/sh:/home/xxg/ Openwrt-sdk-ar71xx-for-linux-i486-gcc-4.6-linaro_uclibc-0.9.33.2/staging_dir/host/bin/find:not found
/bin/sh :/home/xxg/openwrt-sdk-ar71xx-for-linux-i486-gcc-4.6-linaro_uclibc-0.9.33.2/staging_dir/host/bin/find:not found

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.