Refactor setting default ipxe compile options

- reduce repeating code
- make parser more tolerant
This commit is contained in:
Peter Šurda 2022-09-20 18:54:44 +08:00
parent 943372ac70
commit b8b71aa1bd
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95

View File

@ -28,25 +28,23 @@ function sed_enabled_ipxe_features() {
return 1
fi
sed -ei 's/^\/\/\#define[[:space:]]+DOWNLOAD_PROTO_HTTPS/\#define\ DOWNLOAD_PROTO_HTTPS/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+NSLOOKUP_CMD/\#define\ NSLOOKUP_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+TIME_CMD/\#define\ TIME_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+DIGEST_CMD/\#define\ DIGEST_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+REBOOT_CMD/\#define\ REBOOT_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+POWEROFF_CMD/\#define\ POWEROFF_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+IMAGE_TRUST_CMD/\#define\ IMAGE_TRUST_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+NTP_CMD/\#define\ NTP_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\/\/\#define[[:space:]]+CERT_CMD/\#define\ CERT_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+DOWNLOAD_PROTO_HTTPS/\#define\ DOWNLOAD_PROTO_HTTPS/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+NSLOOKUP_CMD/\#define\ NSLOOKUP_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+TIME_CMD/\#define\ TIME_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+DIGEST_CMD/\#define\ DIGEST_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+REBOOT_CMD/\#define\ REBOOT_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+POWEROFF_CMD/\#define\ POWEROFF_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+IMAGE_TRUST_CMD/\#define\ IMAGE_TRUST_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+NTP_CMD/\#define\ NTP_CMD/g' "${ipxe_src_dir}/src/config/general.h"
sed -ei 's/^\#undef[[:space:]]+CERT_CMD/\#define\ CERT_CMD/g' "${ipxe_src_dir}/src/config/general.h"
for OPTION in DOWNLOAD_PROTO_HTTPS \
NSLOOKUP_CMD \
TIME_CMD \
DIGEST_CMD \
REBOOT_CMD \
POWEROFF_CMD \
IMAGE_TRUST_CMD \
NTP_CMD \
CERT_CMD
do
sed -ri \
"s/^\\/+#define[[:space:]]+$OPTION[[:space:]/#define $OPTION /g" \
"${ipxe_src_dir}/src/config/general.h"
sed -ri
"s/^#undef[[:space:]]+$OPTION[[:space:]/#define $OPTION /g" \
"${ipxe_src_dir}/src/config/general.h"
done
return 0
}