Bug#818795: musescore: upstream revision is incorrect

Peter Jonas pjonas56 at gmail.com
Sun Mar 20 18:06:13 UTC 2016


Package: musescore
Version: 2.0.2+dfsg-2
Severity: normal

Dear maintainer,

MuseScore's Help -> About dialog displays a revision number which the
upstream developers use for tracking bug reports at
https://musescore.org/en/project/issues. The revision number should be set
to the first 7 digits of the git commit SHA corresponding to the upstream
release, however, this is not being done in the Debian packages (the
default value of "3543170" is being used each time instead). I have
attached code files which will set the revision number to the correct value
automatically.

The revision number is an upstream concept, so it should be performed
before the creation of orig.tar.gz. The upstream Makefile provides the
target "make revision" to set the revision number, but this target only
works inside a Git repository. It could be performed by the
"get-orig-source" function inside debian/rules, which would do a Git clone
of the upstream tag, run "make revision", and then tidy up and pack
everything into orig.tar.gz. However, if a future maintainer were to
perform a upstream update via debian/watch (i.e. `uscan`) instead of
`debian/rules get-orig-source` then the revision number would not be set.

The solution chosen here is not to clone the Git repo, but instead to use
`uscan` to download the upstream tarball and set the revision number by
grepping it from the tag page on GitHub. The "get-orig-source" target in
debian/rules simply calls `uscan`, so the revision number will be set
whichever method the maintainer uses.

Please find solution code in the attached files. The solution makes use of
the "action" field in debian/watch to launch the new script debian/repack,
which sets the revision number in the upstream tarball and makes changes
necessary for DFSG compliance.

musescore-debian-watch.txt - rename this debian/watch and replace existing
file.
musescore-debian-repack.txt - rename this debian/repack and give execute
permission.
musescore-debian-rules-getorigsource.txt - replace the existing
"get-orig-source" target in debian/rules with the contents of this file.

You might also want to add an explanation to debian/README.Debian. Maybe
something like:

> MuseScore's Help -> About dialog shows a revision number which is simply
the
> first 7 digits of the git commit SHA corresponding to the tagged upstream
> release. This number must be set in the upstream tarball after it has been
> downloaded (this is done automatically if the tarball is fetched using
`uscan`
> or the get-orig-source target in debian/rules). The revision number is
used by
> upstream for tracking bugs, so it shouldn't be changed on a Debian
revision.

I, the author and copyright holder for the attached files
"musescore-debian-watch.txt", "musescore-debian-repack.txt" and
"musescore-debian-rules-getorigsource.txt" give permission for their
contents to be modified and/or redistributed under the terms of the GNU
General Public License, version 2.

Thanks,
Peter Jonas
(a.k.a. "shoogle" on GitHub and MuseScore.org)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-multimedia-maintainers/attachments/20160320/de0d9e54/attachment-0001.html>
-------------- next part --------------
# debian/watch - check for a new upstream release and fetch it. See USCAN(1).
# The script 'debian/repack' is called to perform changes for DFSG compliance.
version=3
opts=\
dversionmangle=s/\+dfsg\d*$//,\
filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/MuseScore-$1\.tar\.gz/ \
  https://github.com/musescore/MuseScore/tags .*/v?(\d\S*)\.tar\.gz \
debian debian/repack
-------------- next part --------------
.PHONY: get-orig-source
## Usage: debian/rules get-orig-source
## Based on: http://wiki.debian.org/onlyjob/get-orig-source
get-orig-source: PKG_DIR:=$(abspath $(dir $(MAKEFILE_LIST)))
get-orig-source:
	# Simply call uscan (changes for DFSG done in debian/watch and debian/repack)
	uscan --noconf --verbose --destdir=$(CURDIR) \
	  --check-dirname-level=0 --force-download $(PKG_DIR)
-------------- next part --------------
#!/bin/bash
# debian/repack - Produce DFSG compliant orig.tar.gz from upstream tarball.
#  1) Unpack upstream tarball.
#  2) Set revision number in mscore/revision.h to match Git commit number.
#  3) Ensure DSFG compliance (removes precompiled binaries and PDFs).
#  4) Pack into orig.tar.gz

set -e # exit on error

function usage() {
cat <<EOF
debian/repack - Produce DFSG compliant orig.tar.gz from upstream tarball.

Usage:    debian/repack  --upstream-version  VERSION  UPSTREAM-TARBALL
Example:  debian/repack  --upstream-version  "2.0.1"  "../v2.0.1.tar.gz"
EOF
}

[[ "$1" == "--usage" || "$1" == "--help" || "$1" == -[h?] ]] && usage && exit

if [ "$1" != "--upstream-version" ] || [ ! "$2" ]; then
  printf "$0: Error! Upstream version was not specified.\n\n$(usage)\n" >&2
  exit 1
fi

if [ ! -f "$3" ]; then
  printf "$0: Error! Upstream tarball was not specified.\n\n$(usage)\n" >&2
  exit 1
fi

version="$2"
tarball="$(basename "$3")"
outdir="$(dirname "$3")" # output files to same dir as input files were located

cd "$outdir"

symlink=""
if [ -L "$tarball" ]; then
  # If $tarball was actually a symlink then resolve it
  symlink="$tarball"
  tarball="$(readlink "$symlink")"
fi

tempdir="tmp-musescore-$version"

# 1) Unpack upstream tarball
echo "Unpacking upstream tarball into '$tempdir'." >&2
mkdir "$tempdir"
tar -zxf "$tarball" -C "$tempdir"
cd "$tempdir/MuseScore-$version"

# 2) Set revision number in mscore/revision.h to match upstream Git commit
# Note: upstream has a Makefile target "make revision" to set the revision, but
# it only works inside a Git repo so we have to get the revision another way.
echo "Determining upstream revision (first 7 characters of Git commit SHA)." >&2
commit="$(wget -qO - "https://github.com/musescore/MuseScore/tree/v$version" \
 | grep "commit-tease-sha" \
 | sed -r 's|.*MuseScore/commit/([[:alnum:]]{7}).*|\1|')"
if [ ! "$commit" ]; then
 echo "$0: Error! Couldn't get upstream commit." >&2
 exit 1
fi
echo "Upstream revision is '$commit'." >&2

echo "Setting revision number in 'mscore/revision.h' to '$commit'." >&2
echo "$commit" > "mscore/revision.h"

# 3) Ensure DSFG compliance (remove precompiled binaries and PDFs, etc).
echo "Making changes to ensure DFSG compliance." >&2

echo "Removing PDF files." >&2
echo "Files-Excluded:"
find . -iname "*.pdf" -exec rm "{}" \; -exec echo "                {}" \;
echo  "Comment: PDFs removed for DFSG compliance (not a transparent format)."

echo "Removing precompiled binaries." >&2
echo "Files-Excluded:"
find -type f -executable \
  -exec sh -c "file -i '{}' | grep -q 'x-executable; charset=binary'" \; \
  -exec rm "{}" \; -exec echo "                {}" \;
echo "Comment: Binaries removed for DFSG compliance (not a transparent format)."

# 4) Pack into orig.tar.gz
cd .. # now inside $tempdir
mv "MuseScore-$version" "musescore-$version+dfsg"
tar -cf "../musescore_$version+dfsg.orig.tar" "musescore-$version+dfsg"
cd .. # now back to output directory (outside $tempdir)
gzip -9 "musescore_$version+dfsg.orig.tar"

# Tidy up
echo "Removing temporary files." >&2
rm -rf "$tempdir" "$tarball" "$symlink"

cat >&2 <<EOF
Finished!
The upstream code is in "$outdir/musescore_$version+dfsg.orig.tar.gz".
Use 'uupdate' to upgrade the source package based on the upstream release:
  uupdate  --upstream-version  $version  $outdir/musescore_$version+dfsg.orig.tar.gz
EOF


More information about the pkg-multimedia-maintainers mailing list