File: unpack.sh

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (61 lines) | stat: -rw-r--r-- 2,011 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
set -e
ORIG_VERSION=19
MAJOR_VERSION=19 # 8.0.1
REV=`ls -1 *${ORIG_VERSION}_${MAJOR_VERSION}*~+*xz | tail -1|perl -ne 'print "$1\n" if /~\+(.*)\.orig/;'  | sort -ru`

VERSION=$REV

if test -z "$VERSION"; then
	echo "Could not find the version"
	exit 0
fi
LLVM_ARCHIVE=llvm-toolchain-${ORIG_VERSION}_$MAJOR_VERSION~+$VERSION.orig.tar.xz
echo "unpack of $LLVM_ARCHIVE"
tar Jxf $LLVM_ARCHIVE
cd llvm-toolchain-${ORIG_VERSION}_$MAJOR_VERSION~+$VERSION/

VER_FOUND=$(grep "LLVM_VERSION_MAJOR " cmake/Modules/LLVMVersion.cmake|awk '{print $2}'|cut -d\) -f1)
if test "${MAJOR_VERSION}" != "$VER_FOUND" -a "${MAJOR_VERSION}.0.0" != "$VER_FOUND" -a "${MAJOR_VERSION}.0.0git" != "$VER_FOUND" -a "${MAJOR_VERSION}git" != "$VER_FOUND"; then
    echo "Mismatch of version"
    echo "Expected $MAJOR_VERSION / Found $VER_FOUND"
    echo "Update unpack.sh"
    exit 1
fi

cp -R ../$ORIG_VERSION/debian .

export QUILT_PATCHES=debian/patches/

attempt=0
max_attempts=5

while [ $attempt -lt $max_attempts ]; do
    echo $attempt
    attempt=$((attempt+1))
    echo "Attempt $attempt of $max_attempts"

    # Attempt to apply patches without allowing fuzz
    output=$(quilt push -a --fuzz=0 || true 2>&1)

    echo "$output"

    # Check if the quilt push command failed due to a hunk failure
    if echo "$output" | grep -q "hunk FAILED"; then
        echo "Initial quilt push failed, trying without --fuzz=0..."
        output=$(quilt push || true 2>&1)
        echo "$output"
        # Check if the output contains a line indicating fuzz was applied
        if echo "$output" | grep -q "with fuzz"; then
            echo "Fuzz detected, refreshing patch..."
            quilt refresh
            cp -R debian/patches/* ../$ORIG_VERSION/debian/patches/
        fi
    else
        echo "Patches applied successfully."
        break # Exit the loop if patches were applied successfully
    fi
done

if [ $attempt -eq $max_attempts ]; then
    echo "Reached maximum attempt limit without successfully applying all patches."
fi