File: patch_dmidecode.sh

package info (click to toggle)
cpu-x 5.4.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,304 kB
  • sloc: ansic: 36,860; cpp: 8,094; asm: 7,291; sh: 693; xml: 190; makefile: 11
file content (31 lines) | stat: -rwxr-xr-x 1,099 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash

set -euo pipefail

CPUX_DIR="$(git rev-parse --show-toplevel)/src/core/dmidecode"
DMIDECODE_DIR="/tmp/dmidecode"
HASH_FILE="$CPUX_DIR/.hash"
OLD_HASH=$(cat "$HASH_FILE")
OLD_HASH_SHORT=${OLD_HASH:0:7}

# Get dmidecode source code
git clone https://git.savannah.gnu.org/git/dmidecode.git "$DMIDECODE_DIR"
cd "$DMIDECODE_DIR" || exit 255

# Retrieve informations about repo
VER=$(git describe --abbrev=0 --tags | sed 's/^dmidecode-//;s/-/./')
DATE=$(git show -s --format=%cd --date=format:%Y%m%d)
NEW_HASH=$(git rev-parse HEAD)
NEW_HASH_SHORT=$(git rev-parse --short HEAD)
git diff "$OLD_HASH" master > "dmidecode.patch"

# Patch to the new version
cd "$CPUX_DIR" || exit 255
echo "$NEW_HASH" > "$HASH_FILE"
sed -i "s/$OLD_HASH/$NEW_HASH/"                      "README.md"
sed -i "s/$OLD_HASH_SHORT/$NEW_HASH_SHORT/"          "README.md"
sed -i "s/VERSION \"[^ ]*\"/VERSION \"$VER.$DATE\"/" "CMakeLists.txt"
patch --batch --no-backup-if-mismatch --input="$DMIDECODE_DIR/dmidecode.patch"

# Commit
git commit "$CPUX_DIR" -m "Patch dmidecode to version $VER commit $NEW_HASH_SHORT"