Merge pull request #19370 from mrc0mmand/shellcheck-pt4
More shellcheck shenanigans
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
$1 -E -dM -include sys/socket.h -include "$2" -include "$3" - </dev/null | \
|
||||
grep -Ev 'AF_UNSPEC|AF_MAX' | \
|
||||
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'
|
||||
${1:?} -E -dM -include sys/socket.h -include "${2:?}" -include "${3:?}" - </dev/null | \
|
||||
grep -Ev 'AF_UNSPEC|AF_MAX' | \
|
||||
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
$1 -dM -include linux/if_arp.h -include "$2" - </dev/null | \
|
||||
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
|
||||
sed -e 's/ARPHRD_//'
|
||||
${1:?} -dM -include linux/if_arp.h -include "${2:?}" - </dev/null | \
|
||||
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
|
||||
sed -e 's/ARPHRD_//'
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
$1 -dM -include linux/capability.h -include "$2" -include "$3" - </dev/null | \
|
||||
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
|
||||
grep -v CAP_LAST_CAP
|
||||
${1:?} -dM -include linux/capability.h -include "${2:?}" -include "${3:?}" - </dev/null | \
|
||||
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
|
||||
grep -v CAP_LAST_CAP
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
$1 -dM -include errno.h - </dev/null | \
|
||||
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
|
||||
${1:?} -dM -include errno.h - </dev/null | \
|
||||
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
for i in *.h */*.h; do
|
||||
if [[ $i == 'loadavg.h' ]]; then
|
||||
curl --fail https://raw.githubusercontent.com/torvalds/linux/master/include/linux/sched/$i -o $i
|
||||
if [[ "$i" == "loadavg.h" ]]; then
|
||||
curl --fail "https://raw.githubusercontent.com/torvalds/linux/master/include/linux/sched/$i" -o "$i"
|
||||
else
|
||||
curl --fail https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/$i -o $i
|
||||
curl --fail "https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/$i" -o "$i"
|
||||
fi
|
||||
|
||||
sed -i -e 's/__user //g' -e '/^#include <linux\/compiler.h>/ d' $i
|
||||
sed -i -e 's/__user //g' -e '/^#include <linux\/compiler.h>/ d' "$i"
|
||||
done
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
if nm -D -u "$1" | grep ' U '; then
|
||||
if nm -D -u "${1:?}" | grep ' U '; then
|
||||
echo "Undefined symbols detected!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
cpp="$1"
|
||||
cpp="${1:?}"
|
||||
shift
|
||||
|
||||
includes=""
|
||||
includes=()
|
||||
for i in "$@"; do
|
||||
includes="$includes -include $i"
|
||||
includes+=(-include "$i")
|
||||
done
|
||||
|
||||
$cpp -dM $includes - </dev/null | \
|
||||
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
|
||||
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
|
||||
sort -k2
|
||||
$cpp -dM "${includes[@]}" - </dev/null | \
|
||||
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
|
||||
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
|
||||
sort -k2
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -ex
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
[[ -e /dev/loop-control ]] || exit 77
|
||||
|
||||
repart=$1
|
||||
test -x $repart
|
||||
repart="${1:?}"
|
||||
test -x "$repart"
|
||||
|
||||
D=$(mktemp --tmpdir --directory "test-repart.XXXXXXXXXX")
|
||||
D="$(mktemp --tmpdir --directory "test-repart.XXXXXXXXXX")"
|
||||
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$D'" EXIT INT QUIT PIPE
|
||||
mkdir -p $D/definitions
|
||||
mkdir -p "$D/definitions"
|
||||
|
||||
SEED=e2a40bf9-73f1-4278-9160-49c031e7aef8
|
||||
|
||||
echo "### Testing systemd-repart --empty=create ###"
|
||||
|
||||
$repart $D/zzz --empty=create --size=1G --seed=$SEED
|
||||
"$repart" "$D/zzz" --empty=create --size=1G --seed="$SEED"
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/empty
|
||||
sfdisk -d "$D/zzz" | grep -v -e 'sector-size' -e '^$' >"$D/empty"
|
||||
|
||||
cmp $D/empty - <<EOF
|
||||
cmp "$D/empty" - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
@@ -30,32 +33,32 @@ EOF
|
||||
|
||||
echo "### Testing with root, root2, home, & swap ###"
|
||||
|
||||
cat >$D/definitions/root.conf <<EOF
|
||||
cat >"$D/definitions/root.conf" <<EOF
|
||||
[Partition]
|
||||
Type=root-x86-64
|
||||
EOF
|
||||
|
||||
ln -s root.conf $D/definitions/root2.conf
|
||||
ln -s root.conf "$D/definitions/root2.conf"
|
||||
|
||||
cat >$D/definitions/home.conf <<EOF
|
||||
cat >"$D/definitions/home.conf" <<EOF
|
||||
[Partition]
|
||||
Type=home
|
||||
Label=home-first
|
||||
Label=home-always-too-long-xxxxxxxxxxxxxx-%v
|
||||
EOF
|
||||
|
||||
cat >$D/definitions/swap.conf <<EOF
|
||||
cat >"$D/definitions/swap.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
PaddingMinBytes=92M
|
||||
EOF
|
||||
|
||||
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
"$repart" "$D/zzz" --dry-run=no --seed="$SEED" --definitions="$D/definitions"
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated
|
||||
sfdisk -d "$D/zzz" | grep -v -e 'sector-size' -e '^$' >"$D/populated"
|
||||
|
||||
cmp $D/populated - <<EOF
|
||||
cmp "$D/populated" - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
@@ -70,27 +73,27 @@ EOF
|
||||
|
||||
echo "### Testing with root, root2, home, swap, & another partition ###"
|
||||
|
||||
cat >$D/definitions/swap.conf <<EOF
|
||||
cat >"$D/definitions/swap.conf" <<EOF
|
||||
[Partition]
|
||||
Type=swap
|
||||
SizeMaxBytes=64M
|
||||
EOF
|
||||
|
||||
cat >$D/definitions/extra.conf <<EOF
|
||||
cat >"$D/definitions/extra.conf" <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
Label=custom_label
|
||||
UUID=a0a1a2a3a4a5a6a7a8a9aaabacadaeaf
|
||||
EOF
|
||||
|
||||
echo "Label=ignored_label" >>$D/definitions/home.conf
|
||||
echo "UUID=b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" >>$D/definitions/home.conf
|
||||
echo "Label=ignored_label" >>"$D/definitions/home.conf"
|
||||
echo "UUID=b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" >>"$D/definitions/home.conf"
|
||||
|
||||
$repart $D/zzz --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
"$repart" "$D/zzz" --dry-run=no --seed="$SEED" --definitions="$D/definitions"
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated2
|
||||
sfdisk -d "$D/zzz" | grep -v -e 'sector-size' -e '^$' >"$D/populated2"
|
||||
|
||||
cmp $D/populated2 - <<EOF
|
||||
cmp "$D/populated2" - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
@@ -106,11 +109,11 @@ EOF
|
||||
|
||||
echo "### Resizing to 2G ###"
|
||||
|
||||
$repart $D/zzz --size=2G --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
"$repart" "$D/zzz" --size=2G --dry-run=no --seed="$SEED" --definitions="$D/definitions"
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated3
|
||||
sfdisk -d "$D/zzz" | grep -v -e 'sector-size' -e '^$' >"$D/populated3"
|
||||
|
||||
cmp $D/populated3 - <<EOF
|
||||
cmp "$D/populated3" - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
@@ -124,11 +127,11 @@ $D/zzz4 : start= 1777624, size= 131072, type=0657FD6D-A4AB-43C4-84E5-09
|
||||
$D/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=A0A1A2A3-A4A5-A6A7-A8A9-AAABACADAEAF, name="custom_label"
|
||||
EOF
|
||||
|
||||
dd if=/dev/urandom of=$D/block-copy bs=4096 count=10240
|
||||
dd if=/dev/urandom of="$D/block-copy" bs=4096 count=10240
|
||||
|
||||
echo "### Testing with root, root2, home, swap, another partition, & partition copy ###"
|
||||
|
||||
cat >$D/definitions/extra2.conf <<EOF
|
||||
cat >"$D/definitions/extra2.conf" <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
Label=block-copy
|
||||
@@ -136,11 +139,11 @@ UUID=2a1d97e1d0a346cca26eadc643926617
|
||||
CopyBlocks=$D/block-copy
|
||||
EOF
|
||||
|
||||
$repart $D/zzz --size=3G --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
"$repart" "$D/zzz" --size=3G --dry-run=no --seed="$SEED" --definitions="$D/definitions"
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated4
|
||||
sfdisk -d "$D/zzz" | grep -v -e 'sector-size' -e '^$' >"$D/populated4"
|
||||
|
||||
cmp $D/populated4 - <<EOF
|
||||
cmp "$D/populated4" - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
@@ -155,14 +158,14 @@ $D/zzz5 : start= 1908696, size= 2285568, type=0FC63DAF-8483-4772-8E79-3D
|
||||
$D/zzz6 : start= 4194264, size= 2097152, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=2A1D97E1-D0A3-46CC-A26E-ADC643926617, name="block-copy"
|
||||
EOF
|
||||
|
||||
cmp --bytes=41943040 --ignore-initial=0:$((512*4194264)) $D/block-copy $D/zzz
|
||||
cmp --bytes=41943040 --ignore-initial=0:$((512*4194264)) "$D/block-copy" "$D/zzz"
|
||||
|
||||
if [ `id -u` == 0 ] && type -P cryptsetup diff losetup > /dev/null ; then
|
||||
if [ "$(id -u)" -eq 0 ] && type -P cryptsetup diff losetup >/dev/null ; then
|
||||
echo "### Testing Format=/Encrypt=/CopyFiles="
|
||||
|
||||
# These tests require privileges unfortunately
|
||||
|
||||
cat >$D/definitions/extra3.conf <<EOF
|
||||
cat >"$D/definitions/extra3.conf" <<EOF
|
||||
[Partition]
|
||||
Type=linux-generic
|
||||
Label=luks-format-copy
|
||||
@@ -173,11 +176,11 @@ CopyFiles=$D/definitions:/def
|
||||
SizeMinBytes=48M
|
||||
EOF
|
||||
|
||||
$repart $D/zzz --size=auto --dry-run=no --seed=$SEED --definitions=$D/definitions
|
||||
"$repart" "$D/zzz" --size=auto --dry-run=no --seed="$SEED" --definitions="$D/definitions"
|
||||
|
||||
sfdisk -d $D/zzz | grep -v -e 'sector-size' -e '^$' >$D/populated5
|
||||
sfdisk -d "$D/zzz" | grep -v -e 'sector-size' -e '^$' >"$D/populated5"
|
||||
|
||||
cmp $D/populated5 - <<EOF
|
||||
cmp "$D/populated5" - <<EOF
|
||||
label: gpt
|
||||
label-id: EF7F7EE2-47B3-4251-B1A1-09EA8BF12D5D
|
||||
device: $D/zzz
|
||||
@@ -193,23 +196,23 @@ $D/zzz6 : start= 4194264, size= 2097152, type=0FC63DAF-8483-4772-8E79-3D
|
||||
$D/zzz7 : start= 6291416, size= 98304, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7B93D1F2-595D-4CE3-B0B9-837FBD9E63B0, name="luks-format-copy"
|
||||
EOF
|
||||
|
||||
LOOP=`losetup -P --show --find $D/zzz`
|
||||
VOLUME=test-repart-$RANDOM
|
||||
LOOP="$(losetup -P --show --find "$D/zzz")"
|
||||
VOLUME="test-repart-$RANDOM"
|
||||
|
||||
touch $D/empty-password
|
||||
cryptsetup open --type=luks2 --key-file=$D/empty-password ${LOOP}p7 $VOLUME
|
||||
mkdir $D/mount
|
||||
mount -t ext4 /dev/mapper/$VOLUME $D/mount
|
||||
touch "$D/empty-password"
|
||||
cryptsetup open --type=luks2 --key-file="$D/empty-password" "${LOOP}p7" "$VOLUME"
|
||||
mkdir "$D/mount"
|
||||
mount -t ext4 "/dev/mapper/$VOLUME" "$D/mount"
|
||||
# Use deferred closing on the mapper and autoclear on the loop, so they are cleaned up on umount
|
||||
cryptsetup close --deferred $VOLUME
|
||||
losetup -d $LOOP
|
||||
diff -r $D/mount/def $D/definitions > /dev/null
|
||||
umount $D/mount
|
||||
cryptsetup close --deferred "$VOLUME"
|
||||
losetup -d "$LOOP"
|
||||
diff -r "$D/mount/def" "$D/definitions" >/dev/null
|
||||
umount "$D/mount"
|
||||
else
|
||||
echo "### Skipping Format=/Encrypt=/CopyFiles= test, lacking privileges or missing cryptsetup/diff/losetup"
|
||||
fi
|
||||
|
||||
echo "### Testing json output ###"
|
||||
$repart $D/zzz --size=3G --dry-run=no --seed=$SEED --definitions=$D/definitions --json=help
|
||||
$repart $D/zzz --size=3G --dry-run=no --seed=$SEED --definitions=$D/definitions --json=pretty
|
||||
$repart $D/zzz --size=3G --dry-run=no --seed=$SEED --definitions=$D/definitions --json=short
|
||||
"$repart" "$D/zzz" --size=3G --dry-run=no --seed="$SEED" --definitions="$D/definitions" --json=help
|
||||
"$repart" "$D/zzz" --size=3G --dry-run=no --seed="$SEED" --definitions="$D/definitions" --json=pretty
|
||||
"$repart" "$D/zzz" --size=3G --dry-run=no --seed="$SEED" --definitions="$D/definitions" --json=short
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
$1 -dM -include netinet/in.h - </dev/null | \
|
||||
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
|
||||
sed -e 's/IPPROTO_//'
|
||||
${1:?} -dM -include netinet/in.h - </dev/null | \
|
||||
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
|
||||
sed -e 's/IPPROTO_//'
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
# shellcheck disable=SC1004
|
||||
awk '
|
||||
BEGIN {
|
||||
print "%{\n\
|
||||
@@ -16,4 +17,4 @@ _Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\
|
||||
|
||||
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
|
||||
{ print tolower($1) ", " $1 }
|
||||
' < "$1"
|
||||
' < "${1:?}"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
$1 -dM -include linux/input.h - </dev/null | awk '
|
||||
${1:?} -dM -include linux/input.h - </dev/null | awk '
|
||||
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
|
||||
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
|
||||
'
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
cd "$MESON_SOURCE_ROOT"
|
||||
cd "${MESON_SOURCE_ROOT:?}"
|
||||
|
||||
if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then
|
||||
if [ ! -f .git/hooks/pre-commit.sample ] || [ -f .git/hooks/pre-commit ]; then
|
||||
exit 2 # not needed
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,31 +1,32 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
sd_good=0
|
||||
sd_total=0
|
||||
udev_good=0
|
||||
udev_total=0
|
||||
|
||||
deprecated="
|
||||
deprecated=(
|
||||
-e sd_bus_try_close
|
||||
-e sd_bus_process_priority
|
||||
-e sd_bus_message_get_priority
|
||||
-e sd_bus_message_set_priority
|
||||
-e sd_seat_can_multi_session
|
||||
-e sd_journal_open_container
|
||||
"
|
||||
)
|
||||
|
||||
for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | grep -wv $deprecated | sort -u` ; do
|
||||
if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then
|
||||
for symbol in $(nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | grep -wv "${deprecated[@]}" | sort -u); do
|
||||
if test -f "${MESON_BUILD_ROOT:?}/man/$symbol.3"; then
|
||||
echo "✓ Symbol $symbol() is documented."
|
||||
good=1
|
||||
else
|
||||
printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n"
|
||||
echo -e " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m"
|
||||
good=0
|
||||
fi
|
||||
|
||||
case $symbol in
|
||||
case "$symbol" in
|
||||
sd_*)
|
||||
((sd_good+=good))
|
||||
((sd_total+=1))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
SOURCE_ROOT="${1:?Missing argument: project source root}"
|
||||
BUILD_ROOT="${2:?Missing argument: project build root}"
|
||||
|
||||
+21
-10
@@ -1,30 +1,41 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
# Note: `grep ... >/dev/null` instead of just `grep -q` is used intentionally
|
||||
# here, since `grep -q` exits on the first match causing SIGPIPE being
|
||||
# sent to the sender.
|
||||
|
||||
BINARY="${1:?}"
|
||||
export SYSTEMD_LOG_LEVEL=info
|
||||
|
||||
if [[ ! -x "$BINARY" ]]; then
|
||||
echo "$BINARY is not an executable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# output width
|
||||
if "$1" --help | grep -v 'default:' | grep -E -q '.{80}.'; then
|
||||
echo "$(basename "$1") --help output is too wide:"
|
||||
"$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}'
|
||||
if "$BINARY" --help | grep -v 'default:' | grep -E '.{80}.' >/dev/null; then
|
||||
echo "$(basename "$BINARY") --help output is too wide:"
|
||||
"$BINARY" --help | awk 'length > 80' | grep -E --color=yes '.{80}'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --help prints something. Also catches case where args are ignored.
|
||||
if ! "$1" --help | grep -q .; then
|
||||
echo "$(basename "$1") --help output is empty."
|
||||
if ! "$BINARY" --help | grep . >/dev/null; then
|
||||
echo "$(basename "$BINARY") --help output is empty."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# no --help output to stdout
|
||||
if "$1" --help 2>&1 1>/dev/null | grep .; then
|
||||
echo "$(basename "$1") --help prints to stderr"
|
||||
if "$BINARY" --help 2>&1 1>/dev/null | grep .; then
|
||||
echo "$(basename "$BINARY") --help prints to stderr"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# error output to stderr
|
||||
if ! "$1" --no-such-parameter 2>&1 1>/dev/null | grep -q .; then
|
||||
echo "$(basename "$1") with an unknown parameter does not print to stderr"
|
||||
if ! ("$BINARY" --no-such-parameter 2>&1 1>/dev/null || :) | grep . >/dev/null; then
|
||||
echo "$(basename "$BINARY") with an unknown parameter does not print to stderr"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
# Try to guess the build directory:
|
||||
# we look for subdirectories of the parent directory that look like ninja build dirs.
|
||||
|
||||
if [ -n "$BUILD_DIR" ]; then
|
||||
echo "$(realpath "$BUILD_DIR")"
|
||||
if [ -n "${BUILD_DIR:=}" ]; then
|
||||
realpath "$BUILD_DIR"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -14,20 +14,20 @@ root="$(dirname "$(realpath "$0")")"
|
||||
|
||||
found=
|
||||
for i in "$root"/../*/build.ninja; do
|
||||
c="$(dirname $i)"
|
||||
c="$(dirname "$i")"
|
||||
[ -d "$c" ] || continue
|
||||
[ "$(basename "$c")" != mkosi.builddir ] || continue
|
||||
|
||||
if [ -n "$found" ]; then
|
||||
echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
|
||||
echo "Found multiple candidates, specify build directory with \$BUILD_DIR" >&2
|
||||
exit 2
|
||||
fi
|
||||
found="$c"
|
||||
done
|
||||
|
||||
if [ -z "$found" ]; then
|
||||
echo 'Specify build directory with $BUILD_DIR' >&2
|
||||
echo "Specify build directory with \$BUILD_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$(realpath $found)"
|
||||
realpath "$found"
|
||||
|
||||
@@ -1,38 +1,40 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
TOP=`git rev-parse --show-toplevel`
|
||||
set -eu
|
||||
|
||||
case "$1" in
|
||||
TOP="$(git rev-parse --show-toplevel)"
|
||||
|
||||
case "${1:-}" in
|
||||
recdiff)
|
||||
if [ "$2" = "" ] ; then
|
||||
if [ "${2:-}" = "" ] ; then
|
||||
DIR="$TOP"
|
||||
else
|
||||
DIR="$2"
|
||||
fi
|
||||
|
||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \;
|
||||
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" diff \{\} \;
|
||||
;;
|
||||
|
||||
recpatch)
|
||||
if [ "$2" = "" ] ; then
|
||||
if [ "${2:-}" = "" ] ; then
|
||||
DIR="$TOP"
|
||||
else
|
||||
DIR="$2"
|
||||
fi
|
||||
|
||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \;
|
||||
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" patch \{\} \;
|
||||
;;
|
||||
|
||||
diff)
|
||||
T=`mktemp`
|
||||
sed '/^$/N;/^\n$/D' < "$2" > "$T"
|
||||
T="$(mktemp)"
|
||||
sed '/^$/N;/^\n$/D' <"${2:?}" >"$T"
|
||||
diff -u "$2" "$T"
|
||||
rm -f "$T"
|
||||
;;
|
||||
|
||||
patch)
|
||||
sed -i '/^$/N;/^\n$/D' "$2"
|
||||
sed -i '/^$/N;/^\n$/D' "${2:?}"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
+11
-9
@@ -1,38 +1,40 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
TOP=`git rev-parse --show-toplevel`
|
||||
set -eu
|
||||
|
||||
case "$1" in
|
||||
TOP="$(git rev-parse --show-toplevel)"
|
||||
|
||||
case "${1:-}" in
|
||||
recdiff)
|
||||
if [ "$2" = "" ] ; then
|
||||
if [ "${2:-}" = "" ] ; then
|
||||
DIR="$TOP"
|
||||
else
|
||||
DIR="$2"
|
||||
fi
|
||||
|
||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \;
|
||||
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" diff \{\} \;
|
||||
;;
|
||||
|
||||
recpatch)
|
||||
if [ "$2" = "" ] ; then
|
||||
if [ "${2:-}" = "" ] ; then
|
||||
DIR="$TOP"
|
||||
else
|
||||
DIR="$2"
|
||||
fi
|
||||
|
||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \;
|
||||
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" patch \{\} \;
|
||||
;;
|
||||
|
||||
diff)
|
||||
T=`mktemp`
|
||||
sed 's/\t/ /g' < "$2" > "$T"
|
||||
T="$(mktemp)"
|
||||
sed 's/\t/ /g' <"${2:?}" >"$T"
|
||||
diff -u "$2" "$T"
|
||||
rm -f "$T"
|
||||
;;
|
||||
|
||||
patch)
|
||||
sed -i 's/\t/ /g' "$2"
|
||||
sed -i 's/\t/ /g' "${2:?}"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
+8
-12
@@ -1,25 +1,21 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
CONFIG=$1
|
||||
TARGET=$2
|
||||
CONFIG="${1:?Missing path to config.h}"
|
||||
TARGET="${2:?Missing target m4 file}"
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo 'Invalid number of arguments.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f $CONFIG ]; then
|
||||
if [ ! -f "$CONFIG" ]; then
|
||||
echo "$CONFIG not found."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f $TARGET ]; then
|
||||
if [ ! -f "$TARGET" ]; then
|
||||
echo "$TARGET not found."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG)
|
||||
DEFINES=()
|
||||
mapfile -t DEFINES < <(awk '$1 == "#define" && $3 == "1" { printf "-D%s\n", $2 }' "$CONFIG")
|
||||
|
||||
m4 -P $DEFINES $TARGET
|
||||
m4 -P "${DEFINES[@]}" "$TARGET"
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
SOURCE="${1:?}"
|
||||
TARGET="${2:?}"
|
||||
|
||||
if [ "${MESON_INSTALL_QUIET:-0}" = 1 ] ; then
|
||||
VERBOSE=""
|
||||
else
|
||||
@@ -11,9 +14,9 @@ fi
|
||||
# this is needed mostly because $DESTDIR is provided as a variable,
|
||||
# and we need to create the target directory...
|
||||
|
||||
mkdir -${VERBOSE}p "$(dirname "${DESTDIR:-}$2")"
|
||||
if [ "$(dirname $1)" = . -o "$(dirname $1)" = .. ]; then
|
||||
ln -${VERBOSE}fs -T -- "$1" "${DESTDIR:-}$2"
|
||||
mkdir -${VERBOSE}p "$(dirname "${DESTDIR:-}$TARGET")"
|
||||
if [ "$(dirname "$SOURCE")" = . ] || [ "$(dirname "$SOURCE")" = .. ]; then
|
||||
ln -${VERBOSE}fs -T -- "$SOURCE" "${DESTDIR:-}$TARGET"
|
||||
else
|
||||
ln -${VERBOSE}fs -T --relative -- "${DESTDIR:-}$1" "${DESTDIR:-}$2"
|
||||
ln -${VERBOSE}fs -T --relative -- "${DESTDIR:-}$SOURCE" "${DESTDIR:-}$TARGET"
|
||||
fi
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
dir="$1"
|
||||
fallback="$2"
|
||||
dir="${1:?}"
|
||||
fallback="${2:?}"
|
||||
|
||||
# Apparently git describe has a bug where it always considers the work-tree
|
||||
# dirty when invoked with --git-dir (even though 'git status' is happy). Work
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
cd "$1"
|
||||
cd "${1:?}"
|
||||
|
||||
(curl --fail -L 'https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py?format=TEXT'; echo) \
|
||||
| base64 -d > tools/chromiumos/gen_autosuspend_rules.py
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
cd "$1"
|
||||
cd "${1:?}"
|
||||
|
||||
unset permissive
|
||||
if [ "${2:-}" = "-p" ]; then
|
||||
@@ -28,6 +28,6 @@ if [ "${2:-}" != "-n" ]; then (
|
||||
set -x
|
||||
./acpi-update.py >20-acpi-vendor.hwdb.base
|
||||
patch -p0 -o- 20-acpi-vendor.hwdb.base <20-acpi-vendor.hwdb.patch >20-acpi-vendor.hwdb
|
||||
! diff -u 20-acpi-vendor.hwdb.base 20-acpi-vendor.hwdb >20-acpi-vendor.hwdb.patch
|
||||
diff -u 20-acpi-vendor.hwdb.base 20-acpi-vendor.hwdb >20-acpi-vendor.hwdb.patch && exit 1
|
||||
|
||||
./ids_parser.py
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eu
|
||||
|
||||
cd "$1" && shift
|
||||
cd "${1:?}" && shift
|
||||
|
||||
curl --fail -L -o syscall-list.txt 'https://raw.githubusercontent.com/hrw/syscalls-table/master/syscall-names.text'
|
||||
|
||||
for arch in "$@"; do
|
||||
curl --fail -L -o syscalls-$arch.txt "https://raw.githubusercontent.com/hrw/syscalls-table/master/tables/syscalls-$arch"
|
||||
curl --fail -L -o "syscalls-$arch.txt" "https://raw.githubusercontent.com/hrw/syscalls-table/master/tables/syscalls-$arch"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user