fix: Switch to space-separated sources.conf format

- Change from colon to space separation to avoid URL parsing issues
- Update sources.conf format: TYPE NAME URL VERSION BUILD_FUNCTION [EXTRA]
- Implement awk-based parsing for reliable field extraction
- Fix firmware package list (remove unavailable linux-firmware-marvell)
This commit is contained in:
2025-08-31 13:26:05 +02:00
parent e8d0d486d8
commit ed98e24503
1103 changed files with 332715 additions and 48 deletions

View File

@@ -0,0 +1,37 @@
# Echo the interface flags, reason and message options
if [ "$reason" = "TEST" ]; then
# General variables at the top
set | while read line; do
case "$line" in
interface=*|pid=*|reason=*|protocol=*|profile=*|skip_hooks=*)
echo "$line";;
esac
done
# Interface flags
set | while read line; do
case "$line" in
ifcarrier=*|ifflags=*|ifmetric=*|ifmtu=*|ifwireless=*|ifssid=*)
echo "$line";;
esac
done
# Old lease
set | while read line; do
case "$line" in
old_*) echo "$line";;
esac
done
# New lease
set | while read line; do
case "$line" in
new_*) echo "$line";;
esac
done
# Router Advertisements
set | while read line; do
case "$line" in
nd[0-9]*_*) echo "$line";;
esac
done
exit 0
fi

View File

@@ -0,0 +1,233 @@
# Generate /etc/resolv.conf
# Support resolvconf(8) if available
# We can merge other dhcpcd resolv.conf files into one like resolvconf,
# but resolvconf is preferred as other applications like VPN clients
# can readily hook into it.
# Also, resolvconf can configure local nameservers such as bind
# or dnsmasq. This is important as the libc resolver isn't that powerful.
resolv_conf_dir="$state_dir/resolv.conf"
nocarrier_roaming_dir="$state_dir/roaming"
NL="
"
: ${resolvconf:=resolvconf}
if command -v "$resolvconf" >/dev/null 2>&1; then
have_resolvconf=true
else
have_resolvconf=false
fi
build_resolv_conf()
{
cf="$state_dir/resolv.conf.$ifname"
# Build a list of interfaces
interfaces=$(list_interfaces "$resolv_conf_dir")
# Build the resolv.conf
header=
if [ -n "$interfaces" ]; then
# Build the header
for x in ${interfaces}; do
header="$header${header:+, }$x"
done
# Build the search list
domain=$(cd "$resolv_conf_dir"; \
key_get_value "domain " ${interfaces})
search=$(cd "$resolv_conf_dir"; \
key_get_value "search " ${interfaces})
set -- ${domain}
domain="$1"
[ -n "$2" ] && search="$search $*"
[ -n "$search" ] && search="$(uniqify $search)"
[ "$domain" = "$search" ] && search=
[ -n "$domain" ] && domain="domain $domain$NL"
[ -n "$search" ] && search="search $search$NL"
# Build the nameserver list
srvs=$(cd "$resolv_conf_dir"; \
key_get_value "nameserver " ${interfaces})
for x in $(uniqify $srvs); do
servers="${servers}nameserver $x$NL"
done
fi
header="$signature_base${header:+ $from }$header"
# Assemble resolv.conf using our head and tail files
[ -f "$cf" ] && rm -f "$cf"
[ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
echo "$header" > "$cf"
if [ -f /etc/resolv.conf.head ]; then
cat /etc/resolv.conf.head >> "$cf"
else
echo "# /etc/resolv.conf.head can replace this line" >> "$cf"
fi
printf %s "$domain$search$servers" >> "$cf"
if [ -f /etc/resolv.conf.tail ]; then
cat /etc/resolv.conf.tail >> "$cf"
else
echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
fi
if change_file /etc/resolv.conf "$cf"; then
chmod 644 /etc/resolv.conf
fi
rm -f "$cf"
}
# Extract any ND DNS options from the RA
# Obey the lifetimes
eval_nd_dns()
{
eval rdnsstime=\$nd${i}_rdnss${j}_lifetime
if [ -n "$rdnsstime" ]; then
ltime=$(($rdnsstime - $offset))
if [ "$ltime" -gt 0 ]; then
eval rdnss=\$nd${i}_rdnss${j}_servers
if [ -n "$rdnss" ]; then
new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
fi
fi
fi
eval dnssltime=\$nd${i}_dnssl${j}_lifetime
if [ -n "$dnssltime" ]; then
ltime=$(($dnssltime - $offset))
if [ "$ltime" -gt 0 ]; then
eval dnssl=\$nd${i}_dnssl${j}_search
if [ -n "$dnssl" ]; then
new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
fi
fi
fi
# Break when we don't have either
[ -z "$rdnsstime" ] && [ -z "$dnssltime" ] && return 1
j=$(($j + 1))
return 0
}
add_resolv_conf()
{
conf="$signature$NL"
warn=true
# Loop to extract the ND DNS options using our indexed shell values
i=1
j=1
while true; do
eval acquired=\$nd${i}_acquired
[ -z "$acquired" ] && break
eval now=\$nd${i}_now
[ -z "$now" ] && break
offset=$(($now - $acquired))
while true; do
eval_nd_dns || break
done
i=$(($i + 1))
j=1
done
[ -n "$new_rdnss" ] && \
new_domain_name_servers="$new_domain_name_servers${new_domain_name_servers:+ }$new_rdnss"
[ -n "$new_dnssl" ] && \
new_domain_search="$new_domain_search${new_domain_search:+ }$new_dnssl"
# Derive a new domain from our various hostname options
if [ -z "$new_domain_name" ]; then
if [ "$new_dhcp6_fqdn" != "${new_dhcp6_fqdn#*.}" ]; then
new_domain_name="${new_dhcp6_fqdn#*.}"
elif [ "$new_fqdn" != "${new_fqdn#*.}" ]; then
new_domain_name="${new_fqdn#*.}"
elif [ "$new_host_name" != "${new_host_name#*.}" ]; then
new_domain_name="${new_host_name#*.}"
fi
fi
# If we don't have any configuration, remove it
if [ -z "$new_domain_name_servers" ] &&
[ -z "$new_domain_name" ] &&
[ -z "$new_domain_search" ]; then
remove_resolv_conf
return $?
fi
if [ -n "$new_domain_name" ]; then
set -- $new_domain_name
if valid_domainname "$1"; then
conf="${conf}domain $1$NL"
else
syslog err "Invalid domain name: $1"
fi
# If there is no search this, make this one
if [ -z "$new_domain_search" ]; then
new_domain_search="$new_domain_name"
[ "$new_domain_name" = "$1" ] && warn=true
fi
fi
if [ -n "$new_domain_search" ]; then
new_domain_search=$(uniqify $new_domain_search)
if valid_domainname_list $new_domain_search; then
conf="${conf}search $new_domain_search$NL"
elif ! $warn; then
syslog err "Invalid domain name in list:" \
"$new_domain_search"
fi
fi
new_domain_name_servers=$(uniqify $new_domain_name_servers)
for x in ${new_domain_name_servers}; do
conf="${conf}nameserver $x$NL"
done
if $have_resolvconf; then
[ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
printf %s "$conf" | "$resolvconf" -a "$ifname"
return $?
fi
if [ -e "$resolv_conf_dir/$ifname" ]; then
rm -f "$resolv_conf_dir/$ifname"
fi
[ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
printf %s "$conf" > "$resolv_conf_dir/$ifname"
build_resolv_conf
}
remove_resolv_conf()
{
if $have_resolvconf; then
"$resolvconf" -d "$ifname" -f
else
if [ -e "$resolv_conf_dir/$ifname" ]; then
rm -f "$resolv_conf_dir/$ifname"
fi
build_resolv_conf
fi
}
# For ease of use, map DHCP6 names onto our DHCP4 names
case "$reason" in
BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
new_domain_name_servers="$new_dhcp6_name_servers"
new_domain_search="$new_dhcp6_domain_search"
;;
esac
if $if_configured; then
if $have_resolvconf && [ "$reason" = NOCARRIER_ROAMING ]; then
# avoid calling resolvconf -c on CARRIER unless we roam
mkdir -p "$nocarrier_roaming_dir"
echo " " >"$nocarrier_roaming_dir/$interface"
"$resolvconf" -C "$interface.*"
elif $have_resolvconf && [ "$reason" = CARRIER ]; then
# Not all resolvconf implementations support -c
if [ -e "$nocarrier_roaming_dir/$interface" ]; then
rm -f "$nocarrier_roaming_dir/$interface"
"$resolvconf" -c "$interface.*"
fi
elif $if_up || [ "$reason" = ROUTERADVERT ]; then
add_resolv_conf
elif $if_down; then
remove_resolv_conf
fi
fi

View File

@@ -0,0 +1,158 @@
# Set the hostname from DHCP data if required
# A hostname can either be a short hostname or a FQDN.
# hostname_fqdn=true
# hostname_fqdn=false
# hostname_fqdn=server
# A value of server means just what the server says, don't manipulate it.
# This could lead to an inconsistent hostname on a DHCPv4 and DHCPv6 network
# where the DHCPv4 hostname is short and the DHCPv6 has an FQDN.
# DHCPv6 has no hostname option.
# RFC4702 section 3.1 says FQDN should be prefered over hostname.
#
# As such, the default is hostname_fqdn=true so that a consistent hostname
# is always assigned.
: ${hostname_fqdn:=true}
# If we used to set the hostname, but relinquish control of it, we should
# reset to the default value.
: ${hostname_default=(none)}
# Some systems don't have hostname(1)
_hostname()
{
if [ -z "${1+x}" ]; then
if [ -r /proc/sys/kernel/hostname ]; then
read name </proc/sys/kernel/hostname && echo "$name"
elif command -v hostname >/dev/null 2>/dev/null; then
hostname
elif sysctl kern.hostname >/dev/null 2>&1; then
sysctl -n kern.hostname
elif sysctl kernel.hostname >/dev/null 2>&1; then
sysctl -n kernel.hostname
else
return 1
fi
return $?
fi
if [ -w /proc/sys/kernel/hostname ]; then
echo "$1" >/proc/sys/kernel/hostname
elif [ -n "$1" ] && command -v hostname >/dev/null 2>&1; then
hostname "$1"
elif sysctl kern.hostname >/dev/null 2>&1; then
sysctl -w "kern.hostname=$1" >/dev/null
elif sysctl kernel.hostname >/dev/null 2>&1; then
sysctl -w "kernel.hostname=$1" >/dev/null
else
# May fail to set a blank hostname
hostname "$1"
fi
}
is_default_hostname()
{
case "$1" in
""|"$hostname_default"|localhost|localhost.localdomain)
return 0;;
esac
return 1
}
need_hostname()
{
# Always load the hostname variable for future use
hostname="$(_hostname)"
is_default_hostname "$hostname" && return 0
case "$force_hostname" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
esac
if [ -n "$old_fqdn" ]; then
if ${hfqdn} || ! ${hshort}; then
[ "$hostname" = "$old_fqdn" ]
else
[ "$hostname" = "${old_fqdn%%.*}" ]
fi
elif [ -n "$old_host_name" ]; then
if ${hfqdn}; then
if [ -n "$old_domain_name" ] &&
[ "$old_host_name" = "${old_host_name#*.}" ]
then
[ "$hostname" = \
"$old_host_name.$old_domain_name" ]
else
[ "$hostname" = "$old_host_name" ]
fi
elif ${hshort}; then
[ "$hostname" = "${old_host_name%%.*}" ]
else
[ "$hostname" = "$old_host_name" ]
fi
else
# No old hostname
false
fi
}
try_hostname()
{
[ "$hostname" = "$1" ] && return 0
if valid_domainname "$1"; then
syslog info "Setting hostname: $1"
_hostname "$1"
else
syslog err "Invalid hostname: $1"
fi
}
set_hostname()
{
hfqdn=false
hshort=false
case "$hostname_fqdn" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
""|[Ss][Ee][Rr][Vv][Ee][Rr]) ;;
*) hshort=true;;
esac
need_hostname || return 0
if [ -n "$new_fqdn" ]; then
if ${hfqdn} || ! ${hshort}; then
try_hostname "$new_fqdn"
else
try_hostname "${new_fqdn%%.*}"
fi
elif [ -n "$new_host_name" ]; then
if ${hfqdn}; then
if [ -n "$new_domain_name" ] &&
[ "$new_host_name" = "${new_host_name#*.}" ]
then
try_hostname "$new_host_name.$new_domain_name"
else
try_hostname "$new_host_name"
fi
elif ${hshort}; then
try_hostname "${new_host_name%%.*}"
else
try_hostname "$new_host_name"
fi
elif ! is_default_hostname "$hostname"; then
try_hostname "$hostname_default"
fi
}
# For ease of use, map DHCP6 names onto our DHCP4 names
case "$reason" in
BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
new_fqdn="$new_dhcp6_fqdn"
old_fqdn="$old_dhcp6_fqdn"
;;
esac
if $if_configured && $if_up && [ "$reason" != ROUTERADVERT ]; then
set_hostname
fi

View File

@@ -0,0 +1,144 @@
# Sample dhcpcd hook script for NTP
# It will configure either one of NTP, OpenNTP or Chrony (in that order)
# and will default to NTP if no default config is found.
# Like our resolv.conf hook script, we store a database of ntp.conf files
# and merge into /etc/ntp.conf
# You can set the env var NTP_CONF to override the derived default on
# systems with >1 NTP client installed.
# Here is an example for OpenNTP
# dhcpcd -e NTP_CONF=/usr/pkg/etc/ntpd.conf
# or by adding this to /etc/dhcpcd.conf
# env NTP_CONF=/usr/pkg/etc/ntpd.conf
# or by adding this to /etc/dhcpcd.enter-hook
# NTP_CONF=/usr/pkg/etc/ntpd.conf
# To use Chrony instead, simply change ntpd.conf to chrony.conf in the
# above examples.
: ${ntp_confs:=ntp.conf ntpd.conf chrony.conf}
: ${ntp_conf_dirs=/etc /etc/chrony /usr/pkg/etc /usr/local/etc}
ntp_conf_dir="$state_dir/ntp.conf"
# If NTP_CONF is not set, work out a good default
if [ -z "$NTP_CONF" ]; then
for d in ${ntp_conf_dirs}; do
for f in ${ntp_confs}; do
if [ -e "$d/$f" ]; then
NTP_CONF="$d/$f"
break 2
fi
done
done
[ -e "$NTP_CONF" ] || NTP_CONF=/etc/ntp.conf
fi
# Derive service name from configuration
if [ -z "$ntp_service" ]; then
case "$NTP_CONF" in
*chrony.conf) ntp_service=chronyd;;
*) ntp_service=ntpd;;
esac
fi
# Debian has a separate file for DHCP config to avoid stamping on
# the master.
if [ "$ntp_service" = ntpd ] && command -v invoke-rc.d >/dev/null 2>&1; then
[ -e /var/lib/ntp ] || mkdir /var/lib/ntp
: ${ntp_service:=ntp}
: ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
fi
: ${ntp_restart_cmd:=service_condcommand $ntp_service restart}
ntp_conf=${NTP_CONF}
NL="
"
build_ntp_conf()
{
cf="$state_dir/ntp.conf.$ifname"
# Build a list of interfaces
interfaces=$(list_interfaces "$ntp_conf_dir")
header=
servers=
if [ -n "$interfaces" ]; then
# Build the header
for x in ${interfaces}; do
header="$header${header:+, }$x"
done
# Build a server list
srvs=$(cd "$ntp_conf_dir";
key_get_value "server " $interfaces)
if [ -n "$srvs" ]; then
for x in $(uniqify $srvs); do
servers="${servers}server $x$NL"
done
fi
fi
# Merge our config into ntp.conf
[ -e "$cf" ] && rm -f "$cf"
[ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
if [ -n "$NTP_DHCP_CONF" ]; then
[ -e "$ntp_conf" ] && cp "$ntp_conf" "$cf"
ntp_conf="$NTP_DHCP_CONF"
elif [ -e "$ntp_conf" ]; then
remove_markers "$signature_base" "$signature_base_end" \
"$ntp_conf" > "$cf"
fi
if [ -n "$servers" ]; then
echo "$signature_base${header:+ $from }$header" >> "$cf"
printf %s "$servers" >> "$cf"
echo "$signature_base_end${header:+ $from }$header" >> "$cf"
else
[ -e "$ntp_conf" ] && [ -e "$cf" ] || return
fi
# If we changed anything, restart ntpd
if change_file "$ntp_conf" "$cf"; then
[ -n "$ntp_restart_cmd" ] && eval $ntp_restart_cmd
fi
}
add_ntp_conf()
{
cf="$ntp_conf_dir/$ifname"
[ -e "$cf" ] && rm "$cf"
[ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
if [ -n "$new_ntp_servers" ]; then
for x in $(uniqify $new_ntp_servers); do
echo "server $x" >> "$cf"
done
fi
build_ntp_conf
}
remove_ntp_conf()
{
if [ -e "$ntp_conf_dir/$ifname" ]; then
rm "$ntp_conf_dir/$ifname"
fi
build_ntp_conf
}
# For ease of use, map DHCP6 names onto our DHCP4 names
case "$reason" in
BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
new_ntp_servers="$new_dhcp6_sntp_servers $new_dhcp6_ntp_server_addr $new_dhcp6_ntp_server_fqdn"
;;
esac
if $if_configured; then
if $if_up; then
add_ntp_conf
elif $if_down; then
remove_ntp_conf
fi
fi