OpenWrt之package: Using Dependencies
foreword
In this article, I translated from the OpenWrt document, and I will talk about the analysis of DEPENDS
, @
, &
, there will inevitably be some problems. Welcome to point out that students with English foundation can go straight to the official||
()
https://openwrt.org/docs/guide-developer/dependencies
https://openwrt.org/docs/guide-developer/packages
Overview/ Topic
A package Makefile includes the following sections:
define Package/tcpdump/default
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libpcap
TITLE:=Network monitoring and data acquisition tool
URL:=http://www.tcpdump.org/
endef
This article will describe what DEPENDS:=+libpcap
the row should look like
Dependency types / Dependency types
- Not selectable unless
libpcap
selectedtcpdump
DEPENDS:=libpcap
- If
tcpdump
selected,libpcap
will also be selected
DEPENDS:=+libpcap
- If
tcpdump
it is selected,arpd也会被选中
.libpcap
It can be selected at this time, otherwise it cannot be selected.
DEPENDS:=+PACKAGE_arpd:libpcap
BUSYBOX
HOSTNAME
select if not innet-tools-hostname
DEPENDS:=+!BUSYBOX_CONFIG_HOSTNAME:net-tools-hostname
- This option must exist
USB_SUPPORT
(defined), otherwise you will not seetcpdump
this option
DEPENDS:=@USB_SUPPORT
- If
tcpdump
selected,KERNEL_DEBUG_FS
related items (including selected) will be automatically configured.
DEPENDS:=+@KERNEL_DEBUG_FS
Note: opkg install
It will not check KERNEL_DEBUG_FS
whether it is installed when using
- If
net-tools-hostname
it is not selected,BUSYBOX_CONFIG_HOSTNAME
related items will be automatically configured (including selected).
DEPENDS:=+@!PACKAGE_net-tools-hostname:BUSYBOX_CONFIG_HOSTNAME
Special Instructions / Special Notes
- You can
Makefile
define one that OpenWrt does not havePackage
, andDEPENDS
call it in
define Package/package-name/config
...config stuff
endef
Include the following commands:
Order | meaning |
---|---|
select package | If tcpdump checked, package it will also be checked. |
select package if packageb | If packageb selected, package will also be selected |
select package if SYMBOL | Not optional unless CONFIG_SYMBOL definedpackage |
depends packageb | tcpdump Depends on packageb , not packageb visible unless selectedtcpdump |
depends packageb if packagec | If packagec selected, tcpdump will depend onpackageb |
select SYMBOL | If tcpdump checked, set to CONFIG_SYMBOL=y . |
select SYMBOL if packageb | If packageb selected, select SYMBOL the action to perform |
select SYMBOL if SYMBOL2 | If SYMBOL2 defined, select SYMBOL the action to perform |
It should be noted that when Package/foo/config
using select bar
, compile will be selected bar
, but when using opkg install foo
, there is no need to ensure foo
whether it is installed
Warnings/Caveats
Packages and package dependencies cannot depend on each other ( Package A
depend on Package B
, Package B
depend on Package A
), this situation is not allowed, if this kind of circular dependency is caused, make menuconfig
other problems will occur in time.
Using boolean operators
-
DEPENDS:@SYMBOL
andDEPENDS:@SYMBOL:package
syntactically support the bool operator operation of if, including:!
,&&
,||
-
DEPENDS:+SYMBOL:package
The syntax has restrictions on the operation of the bool operator, which!
can only be used for the entire condition.括号
It is only for readability, and it has no effect.&&
The priority is higher than that||
. So+(YYY||FOO&&BAR):package
if whenYYY
is selected orFOO
bothBAR
are selected,package
it can be selected. -
+YYY||(FOO&&BAR):package
For readability, it could be better -
But
+(YYY||FOO)&&BAR:package
this parenthesis does not change the priority,括号
it is just for readability and has no effect.
Afterword
The translation is still relatively weak, I don’t know if I can understand it, at least I understand it myself.
Welcome to pay attention to the WeChat public account: NueXiniShare
Enjoy it ~