Unverified Commit 453ec734 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Remove non-printable characters (#228)

parent cdf3e9df
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ RUN apk --update --no-cache add unzip && \
    rm -rf /tmp/* /var/tmp/* /var/cache/apk/*

FROM scratch AS runner
COPY --from=qemux/qemu:7.04 / /
COPY --from=qemux/qemu:7.05 / /

ARG VERSION_ARG="0.0"
ARG VERSION_KVM_OPENCORE="v21"
+2 −1
Original line number Diff line number Diff line
@@ -168,13 +168,14 @@ else
fi

CLOCKSOURCE="tsc"
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"

if [ ! -f "$CLOCK" ]; then
  warn "file \"$CLOCK\" cannot not found?"
else
  result=$(<"$CLOCK")
  result="${result//[![:print:]]/}"
  case "${result,,}" in
    "${CLOCKSOURCE,,}" ) ;;
    "kvm-clock" )
+6 −0
Original line number Diff line number Diff line
@@ -154,10 +154,12 @@ generateID() {

  [ -n "$UUID" ] && return 0
  [ -s "$file" ] && UUID=$(<"$file")
  UUID="${UUID//[![:print:]]/}"
  [ -n "$UUID" ] && return 0

  UUID=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random)
  UUID="${UUID^^}"
  UUID="${UUID//[![:print:]]/}"
  echo "$UUID" > "$file"

  return 0
@@ -169,6 +171,7 @@ generateAddress() {

  [ -n "$MAC" ] && return 0
  [ -s "$file" ] && MAC=$(<"$file")
  MAC="${MAC//[![:print:]]/}"
  [ -n "$MAC" ] && return 0

  # Generate Apple MAC address based on Docker container ID in hostname
@@ -187,6 +190,8 @@ generateSerial() {
  [ -n "$SN" ] && [ -n "$MLB" ] && return 0
  [ -s "$file" ] && SN=$(<"$file")
  [ -s "$file2" ] && MLB=$(<"$file2")
  SN="${SN//[![:print:]]/}"
  MLB="${MLB//[![:print:]]/}"
  [ -n "$SN" ] && [ -n "$MLB" ] && return 0

  # Generate unique serial numbers for machine
@@ -213,6 +218,7 @@ fi
STORED_VERSION=""
if [ -f "$BASE_VERSION" ]; then
  STORED_VERSION=$(<"$BASE_VERSION")
  STORED_VERSION="${STORED_VERSION//[![:print:]]/}"
fi

if [ "$VERSION" != "$STORED_VERSION" ]; then