OpenWrt编译番外篇(一)

https://blog.kos.org.cn/bw/7.html

#编译环境为Ubuntusudo apt-get update #升级组件包$安装编译需要的组件sudo apt-get install gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5-dev ncurses-term zlib1g-dev git-core gawk asciidoc libz-dev sphinxsearch libtool sphinx-common libssl-dev libsqlite3* intltool libiconv* gstreamer-0.10* glib2.0 libxml2-dev qemu(*64位系统需安装lib32z1 lib32ncurses5 lib32bz2-1.0)mkdir openwrt #使用非root用户登录,建立openwrt目录cd openwrt #进入openwrt目录svn checkout svn://svn.openwrt.org/openwrt/trunk #下载openwrt源码(这里以trunk版为例子)sudo chmod -R 777 trunk #赋予trunk目录权限cd trunk #进入trunk目录./scripts/feeds update -a #更新最新源码./scripts/feeds install -a #安装最新源码svn up #更新版本号make menuconfig #进入编译菜单Y:选择Y,该软件将被编译,并且加入到你的目标固件里;M:选择M,该软件包将会被编译,但不会被放入固件里。在需要它的时候,可以用OPKG软件包管理器进行安装;N:选择N,该软件包将不会被编译,也不会被安装进固件。#方向键是移动光标#回车键是确认空格键是选择,可以代替Y/M/N键的使用/:搜索$编译make V=99 #编译make clean #清除编译过程产生的临时文件make defconfig #恢复编译环境 OpenWrt编译番外篇(一)

package/kernel/mac80211/files/lib/wifi/mac80211.sh

feeds/luci/modules/base/root/etc/config/luci

feeds/luci/modules/admin-full/luasrc/controller/admin/index.lua

feeds/luci/modules/admin-full/luasrc/controller/admin/system.lua

<%:Perform reboot%>

feeds/luci/modules/admin-full/luasrc/controller/admin/system.lua

package/base-files/files/etc/ #你可以把你的备份文件导入进来

package/base-files/files/etc/shadow

package/base-files/files/etc/sysctl.conf

package/base-files/files/etc/config/system

目录结构<houzi>├Makefile├<files>│ ├<etc>│ │ ├<config>│ │ │ └houzi│ │ ├<init.d>│ │ │ └houzi│ ├<usr>│ │ ├<lib>│ │ │ ├<lua>│ │ │ │ ├<luci>│ │ │ │ │ ├<controller>│ │ │ │ │ │ └houzi.lua│ │ │ │ │ ├<model>│ │ │ │ │ │ ├<cbi>│ │ │ │ │ │ │ └houzi.lua│ │ ├<sbin>│ │ │ └houzi OpenWrt编译番外篇(一)

include $(TOPDIR)/rules.mkPKG_NAME:=houziPKG_VERSION:=2.0.1 PKG_RELEASE:=1PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)include $(INCLUDE_DIR)/package.mkdefine Package/houzi SECTION:=utils CATEGORY:=Utilities SUBMENU:=H3C inode TITLE:= iNode Compatible Client for HOUZI DEPENDS:=+libc +libgcc MAINTAINER:= RiceLyn <wojiaolinmu008@gmail.com>endefdefine Package/houzi/description iNode Compatible Client for HOUZIendefdefine Build/Prepareendefdefine Build/Configureendefdefine Build/Compileendefdefine Package/houzi/install $(CP) ./files/* $(1)/endef$(eval $(call BuildPackage,houzi)) OpenWrt编译番外篇(一)

#选择编译对象Target System (Atheros AR71XXX/AR91XXX) —> #目标系统,选择什么系列的socSubtarget (Genric) —> #子目录。选择固件的类型,我这里选择默认标准类型SPI flash固件,还有 NOR NAND flash的固件Target Profile (TP-LINK TL-W842N/ND) —> #目标的类型,选择要编译的机型,选择默认编译时是编译全机型Target Images —> #目标镜像,选择固件,选择默认就行了!这里不再对里面的类型进行解析#添加USB挂载Base system —> <*>block-mount#添加硬盘格式支持Kernel modules —> Filesystems —> <*> kmod-fs-ext4 (移动硬盘EXT4文件格式 )Kernel modules —> Filesystems —> <*> kmod-fs-vfat(FAT16 / FAT32文件格式 )Kernel modules —> Filesystems —> <*> kmod-fs-ntfs (NTFS文件格式 )#添加USB相关支持Kernel modules —> USB Support —> <*> kmod-usb-core.Kernel modules —> USB Support —> <*> kmod-usb-ohci.Kernel modules —> USB Support —> <*> kmod-usb-storage.Kernel modules —> USB Support —> <*> kmod-usb-storage-extras.Kernel modules —> USB Support —> <*> kmod-usb2.Kernel modules —> USB Support —> <*> kmod-usb3.#添加自动挂载工具Utilities —> Filesystem —> <*> badblocks#添加UTF8编码,CP437编码,ISO8859-1编码Kernel modules —> Native Language Support —> <*> kmod-nls-cp437Kernel modules —> Native Language Support —> <*> kmod-nls-iso8859-1Kernel modules —> Native Language Support —> <*> kmod-nls-utf8#添加SCSI支持Kernel modules —> Block Devices —> <*>kmod-scsi-core#添加luciLuCI ->Collections -> <*> luci#添加luci的中文语言包LuCI ->Translations -> <*> luci-i18n-chinese#添加LED支持LED modules —>< *> kmod-ledtrig-usbdev…………………………. LED USB device Trigger OpenWrt编译番外篇(一)

/feeds/feeds.conf.defaultsrc-git ramod git://github.com/ravageralpha/my_openwrt_mod.git #建议在后面添加,如果不使用可注释掉./scripts/update -a./scripts/install -a

*引用*#!/bin/sh#———————————————————————# Filename: 30-block_mount# Revision: 0.5.1# Data: Jul. 7, 2014# Email: kevinyu@vip.qq.com **(感谢)**# Contacts: QQ/TM 389191 or mail address above# Licensing: General Public License v2# Description: Created for automatic mount block devices on OpenWRT# Usage: Put this script into directory /etc/hotplug.d/block#———————————————————————## Global settings of auto-mount script ### Turn on|off auto-mount function for disk volumesVOL_ENABLED=1 # <0|1 0-Disable, 1-Enable># Turn on|off auto-mount function for sawp partition SWAP_ENABLED=1 # <0|1 0-Disable, 1-Enable># Set which method you want to name the mounted volumesUSE_VLABEL=1 # <0|1 0-Use device name, 1-Use volume label> Eg. /mnt/sda1 | /mnt/DataDisk## Note that if you choose name mount point by volume label but the volume’s label is empty,# the volume will be named to ‘volume_$PARTUUID’, such as the /mnt/volume_31173116-01# Also, if exist more than one device which have the same volume label, it will be renamed # as the original name + sequence number, such as the /mnt/DataDisk_n (n=1,2,3..9)# Show filesystem type as the prefix of mount point, requires set USE_VLABEL=1FSTYPE_IN_VLABEL=1 # <0|1 0-Disable, 1-Enable> Eg. /mnt/[ntfs]-DataDisk# Set access the mounted device with read-write or read-only permissionFS_READONLY=0 # <0|1 0-Read Write, 1-Read Only># Exclusion list of auto-mount function# Allows mixing the device name, volume label and UUID, each item must be separated by space(s)# Eg. EXCLUDE_LIST=”sda1 DataDisk f32b2ea6-4d42-43a5-bcec-7d818a163d07″ EXCLUDE_LIST=”” # Default: empty string# Specify a directory for mountsMOUNTS_PATH=”/mnt” # Default: /mnt , don’t need include the trailing slash (/)# Define the add-ons scripts directory for automatic executeADDSH_PATH=”/etc/hotplug.d/user” # Script naming rule: [0-9][0-9]-xxxxx, Eg. 20-backup-sdcard## End of global settings ### Purge the directory MOUNTS_PATHpurge_mnts(){local i RETVAL[ -d $MOUNTS_PATH ] || return 1for i in $MOUNTS_PATH/* ; do if [ -d $i ] ; then if [ -z “`ls -A $i 2>&-`” ] ; then `grep -qs “$i” /proc/mounts` || { rm -rf $i 2>/dev/null; RETVAL=$} if [ $RETVAL -eq 0 ] ; then logger -t Auto-Mount “[Notice] Unused mount point $i was removed” [ “$CLI” = “yes” ] && echo “[Notice] Unused mount point ‘$i’ was removed” else logger -t Auto-Mount “[Error] Remove unused mount point $i failed” [ “$CLI” = “yes” ] && echo “[Error] Remove unused mount point $i failed” fi fi fidone}# Unmount all block deviceumountall(){local i MOUNTSMOUNTS=`grep -os ‘^/dev/sd[a-z][1-9]’ /proc/mounts`for i in $MOUNTS ; do umount -f $i [ $-eq 0 ] && echo “[Notice] Device $i unmounted” | tee /proc/self/fd/2 | logger -t Auto-Mountdonepurge_mnts}# Detect blkid existsBLKID=`which blkid`if [ $-ne 0 ] ; then logger -t Auto-Mount “[Error] Unable to mount block devices automatically because ‘blkid’ does not exist” exit 1fiMOUNTS_PATH=${MOUNTS_PATH%/}[ -z “$ACTION” ] && ACTION=${1##*-}[ -n “$DEVICENAME” ] && DEV=$DEVICENAME || DEV=$2logger -t Auto-Mount “[Debug] action=’$ACTION’ devicename=’$DEV'”case “$ACTION” in add) [ -z “$DEV” ] && { logger -t Auto-Mount “[Error] Missing required arguments: $devicename”; exit 1; } if [ -n “$EXCLUDE_LIST” ] ; then UUID=`$BLKID -s UUID /dev/$DEV | awk -F ‘=’ ‘{print $NF}’ | tr -d ‘”| ‘` VLABEL=`$BLKID -d -s LABEL /dev/$DEV | awk -F ‘=’ ‘{print $NF}’ | tr -d ‘”| ‘` for i in $EXCLUDE_LIST ; do ignore=0 if `echo “$i” | grep -qs ‘^sd[a-z][1-9]$’` ; then # is device name [ $i = $DEV ] && ignore=1 elif `echo “$i” | grep -Eiqs ‘^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$’` ; then # is UUID [ $i = $UUID ] && ignore=1 else # as volume label [ $i = $VLABEL ] && ignore=1 fi [ $ignore -eq 1 ] && { logger -t Auto-Mount “[Notice] Device $DEV is ignored because it in exclusion list”; exit 0; } done fi if `echo “$DEV” | grep -qs ‘^sd[a-z][1-9]$’` ; then [ -z “$VLABEL” ] && VLABEL=`$BLKID -d -s LABEL /dev/$DEV | awk -F ‘=’ ‘{print $NF}’ | tr -d ‘”| ‘` [ -z “$VLABEL” ] && VLABEL=”unknown” FSTYPE=`$BLKID -s TYPE /dev/$DEV | awk -F ‘=’ ‘{print $NF}’ | tr -d ‘”| ‘` logger -t Auto-Mount “[Debug] devicename=’$DEV’ volume_label=’$VLABEL’ fstype=’$FSTYPE'” MCMD=”” # set default value [ $FS_READONLY -eq 1 ] && acs=”ro” || acs=”rw” case “$FSTYPE” in ext[234]) if `grep -vs ‘^nodev’ /proc/filesystems | grep -qs “$FSTYPE”` ; then MCMD=”mount -t $FSTYPE -o ${acs},noatime” fi ;; xfs|reiserfs) if `grep -vs ‘^nodev’ /proc/filesystems | grep -qs “$FSTYPE”` ; then MCMD=”mount -t $FSTYPE -o ${acs},noatime” fi ;; iso9660|udf) if `grep -vs ‘^nodev’ /proc/filesystems | grep -qs “$FSTYPE”` ; then MCMD=”mount -t $FSTYPE -o ro” fi ;; vfat|msdos) if `grep -vs ‘^nodev’ /proc/filesystems | grep -qs “$FSTYPE”` ; then MCMD=”mount -t $FSTYPE -o ${acs},codepage=936,umask=000″ #iocharset=utf8 fi ;; exfat) if `grep -Eqs ‘^[[:space:]]+fuseblk$’ /proc/filesystems` && `which mount.exfat >/dev/null` ; then MCMD=”mount.exfat -o ${acs},iocharset=cp936,umask=000″ fi ;; ntfs) if `grep -Eqs ‘^[[:space:]]+fuseblk$’ /proc/filesystems` && `which mount.ntfs-3g >/dev/null` ; then MCMD=”mount -t ntfs-3g -o ${acs},noatime,big_writes,async,umask=000″ fi ;; swap) [ $SWAP_ENABLED -ne 1 ] && exit 0 if [ `grep -vs ‘^Filename’ /proc/swaps | wc -l` -eq 0 ] ; then MCMD=”swapon /dev/$DEV” fi ;; *) MCMD=”” ;; esac [ $VOL_ENABLED -ne 1 ] && exit 0 if [ $FSTYPE = “swap” ] ; then MOPT=”” elif [ $FSTYPE = “iso9660” -o $FSTYPE = “udf” ] ; then CDROM=”cdrom” if `grep -qs “$MOUNTS_PATH/$CDROM ” /proc/mounts` ; then SUFFIX=1 while `grep -qs “$MOUNTS_PATH/$CDROM ” /proc/mounts` ; do [ $SUFFIX -lt 10 ] && CDROM=”${CDROM%_*}_$SUFFIX” || { CDROM=”${CDROM%_*}_99″; break; } let SUFFIX++ done fi MPOINT=$CDROM else if [ $USE_VLABEL -eq 1 ] ; then if [ $VLABEL = “unknown” ] ; then PARTUUID=`$BLKID -s PARTUUID /dev/$DEV | awk -F ‘=’ ‘{print $NF}’ | tr -d ‘”| ‘` [ -z “$PARTUUID” ] && PARTUUID=`cat /proc/sys/kernel/random/uuid | cut -f1 -d’-‘` VLABEL=”volume_${PARTUUID}” elif `grep -qis “$MOUNTS_PATH/$VLABEL ” /proc/mounts` ; then SUFFIX=1 while `grep -qis “$MOUNTS_PATH/$VLABEL ” /proc/mounts` ; do if [ $SUFFIX -lt 10 ] ; then VLABEL=”$(echo “$VLABEL” | sed ‘s/_[0-9]+$//’)_$SUFFIX” let SUFFIX++ else VLABEL=”$(echo “$VLABEL” | sed ‘s/_[0-9]+$//’)_99″ break fi done fi [ $FSTYPE_IN_VLABEL -eq 1 ] && MPOINT=”[${FSTYPE}]-${VLABEL}” || MPOINT=$VLABEL else MPOINT=$DEV fi MOPT=”/dev/$DEV $MOUNTS_PATH/$MPOINT” fi if [ -n “$MCMD” ] ; then if ! `grep -qs ‘/dev/$DEV’ /proc/mounts` ; then [ $FSTYPE = “swap” ] || { [ -d $MOUNTS_PATH/$MPOINT ] || mkdir -p $MOUNTS_PATH/$MPOINT; } logger -t Auto-Mount “[Debug] MountCMD=’$MCMD $MOPT'” # echo “[Debug] MountCMD=’$MCMD $MOPT'” >> /tmp/auto-mount-debug $MCMD $MOPT RETVAL=$ if [ $FSTYPE = “swap” ] ; then if [ $RETVAL -eq 0 ] ; then logger -t Auto-Mount “[Notice] Swap device /dev/$DEV turned on” fi else if [ $RETVAL -eq 0 ] ; then logger -t Auto-Mount “[Notice] Block device /dev/$DEV mounted on $MOUNTS_PATH/$MPOINT” else logger -t Auto-Mount “[Warning] Re-try mount the block device /dev/$DEV after 2 seconds…” sleep 2 $MCMD $MOPT if [ $-eq 0 ] ; then logger -t Auto-Mount “[Notice] Block device /dev/$DEV mounted on $MOUNTS_PATH/$MPOINT” else rm -rf $MOUNTS_PATH/$MPOINT 2>/dev/null logger -t Auto-Mount “[Error] Mount block device /dev/$DEV encounters an error” exit 1

来源:辛勤的摆渡人

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2016年5月19日
下一篇 2016年5月20日

相关推荐