File: get-orig-source.sh

package info (click to toggle)
meshlab 2020.09+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 45,124 kB
  • sloc: cpp: 400,238; ansic: 31,952; javascript: 1,578; sh: 387; yacc: 238; lex: 139; python: 86; makefile: 29
file content (70 lines) | stat: -rwxr-xr-x 2,673 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
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
62
63
64
65
66
67
68
69
70
#!/bin/sh
# This gets/makes an original tarball.
# By default, it uses the version in debian/changelog.
# (By default using a tagged release)
# This means that if you are upgrading upstream versions, please override VER in the environment!
set -e

COMMIT_HASH=
# Only set explicitly in case we need a snapshot between releases
# COMMIT_HASH=3d405f6a0427c411d30cc7ef4129e2e887f35e28
REPACK_SUFFIX=$(dpkg-parsechangelog -S Version | sed -E 's/.*([+~]dfsg[0-9]+)-.*/\1/')

if [ "x${VER}" = x ]; then
    VER=$(dpkg-parsechangelog -S Version | sed -e 's,.*:,,' -e 's,+dfsg.*,,')
    echo "# Parsed upstream version to acquire from debian/changelog: $VER"
else
    echo "# Version to acquire overridden by environment: VER=$VER"
fi

for cmd in jq curl wget; do
    if ! command -v $cmd > /dev/null; then
        echo "# Need to install $cmd!"
        exit 1
    fi
done

if [ "x${COMMIT_HASH}" = "x" ]; then
    echo "# Looking up SHA for MeshLab version ${VER}"
    COMMIT_HASH=$(curl -s https://api.github.com/repos/cnr-isti-vclab/meshlab/git/ref/tags/Meshlab-${VER} | jq --raw-output '.object.sha' | tr [:upper:] [:lower:])
fi

echo "# MeshLab downloading commit ${COMMIT_HASH} ..."
wget --continue -O meshlab_${VER}.orig.tar.gz https://github.com/cnr-isti-vclab/meshlab/archive/${COMMIT_HASH}.tar.gz


echo "# Determining vcglib commit..."
VCGLIB_HASH=$(curl -s https://api.github.com/repos/cnr-isti-vclab/meshlab/git/trees/${COMMIT_HASH} | jq --raw-output '(.tree[] | select(.path == "vcglib") ).sha' | tr [:upper:] [:lower:])


echo "# vcglib commit ${VCGLIB_HASH} downloading..."
wget --continue -O meshlab_vcglib_${VER}.orig.tar.gz https://github.com/cnr-isti-vclab/vcglib/archive/${VCGLIB_HASH}.tar.gz

echo "# Decompressing MeshLab"
gunzip "meshlab_${VER}.orig.tar.gz"

BASE_DIR=$(pwd)
export BASE_DIR
REPACK_DIR=$(mktemp -d)
trap "rm -rf $REPACK_DIR" EXIT
(
    echo "# Extracting vcglib"
    cd "$REPACK_DIR"
    tar xzf "${BASE_DIR}/meshlab_vcglib_${VER}.orig.tar.gz" --transform="s/-${VCGLIB_HASH}//"
    mkdir meshlab-${COMMIT_HASH}
    mv vcglib meshlab-${COMMIT_HASH}/
    echo "# Appending vcglib to tarball"
    tar rf "${BASE_DIR}/meshlab_${VER}.orig.tar" meshlab-${COMMIT_HASH}
)


echo "# Repacking with mk-origtargz"
mk-origtargz --repack --compression xz -S ${REPACK_SUFFIX} -C .. "meshlab_${VER}.orig.tar" -v ${VER}

echo "# Cleaning up files"
rm -f "meshlab_vcglib_${VER}.orig.tar.gz" "meshlab_${VER}.orig.tar"


echo "# Run the following to update debian/copyright:"
echo "sed -i 's:meshlab/archive/.*:meshlab/archive/${COMMIT_HASH}.tar.gz:' debian/copyright"
echo "sed -i 's:vcglib/archive/.*:vcglib/archive/${VCGLIB_HASH}.tar.gz:' debian/copyright"