2009-03-05 15:14:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# grab-merge - grab a merge
|
|
|
|
#
|
|
|
|
# Copyright © 2008 Canonical Ltd.
|
|
|
|
# Author: Scott James Remnant <scott@ubuntu.com>.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of version 3 of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# Uncomment if you have an account on casey
|
|
|
|
#RSYNC=y
|
|
|
|
|
|
|
|
# Uncomment if you know that this deletes all the files in the CWD
|
|
|
|
#EXPERT=y
|
|
|
|
|
|
|
|
# Or uncomment if you want to use named subdirectories
|
|
|
|
SUBDIR=y
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
MERGE=$1
|
|
|
|
|
2011-02-13 15:04:40 +02:00
|
|
|
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then
|
2009-03-26 22:48:07 +00:00
|
|
|
echo "Usage: $0 <package name>"
|
|
|
|
echo ""
|
|
|
|
echo "grab-merge downloads a merge's packaging files and report from"
|
|
|
|
echo "merges.ubuntu.com, placing them into a new subdirectory for working"
|
|
|
|
echo "from."
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2009-03-05 15:14:21 +00:00
|
|
|
if [ "$SUBDIR" = "y" ]; then
|
2009-05-06 23:22:39 +02:00
|
|
|
[ -d "$MERGE" ] || { mkdir $MERGE; CREATED_DIR=1; }
|
2009-03-05 15:14:21 +00:00
|
|
|
cd $MERGE
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$EXPERT" != "y" ] && [ -n "$(ls)" ]; then
|
2009-05-06 23:22:39 +02:00
|
|
|
echo -n "Are you sure you want to delete all the files in $(pwd) [yN]? "
|
2009-03-05 15:14:21 +00:00
|
|
|
read ANSWER
|
2009-05-06 23:22:39 +02:00
|
|
|
[ "$ANSWER" = "y" ] || exit 1
|
2009-03-05 15:14:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${MERGE#lib}" != "${MERGE}" ]; then
|
|
|
|
HASH=${MERGE%${MERGE#????}}
|
|
|
|
else
|
|
|
|
HASH=${MERGE%${MERGE#?}}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$RSYNC" = "y" ]; then
|
2009-04-30 22:19:43 +02:00
|
|
|
URL="merges.ubuntu.com:/srv/patches.ubuntu.com/merges/$HASH/$MERGE/"
|
2009-03-05 15:14:21 +00:00
|
|
|
rsync --verbose --archive --progress --compress --delete \
|
2011-11-12 23:05:15 +02:00
|
|
|
"$URL" . || { echo "Error while rsyncing $URL"; exit 1; }
|
2009-03-05 15:14:21 +00:00
|
|
|
else
|
2009-05-06 23:22:39 +02:00
|
|
|
rm -rf --one-file-system *
|
2011-11-12 23:05:15 +02:00
|
|
|
wget -nv https://merges.ubuntu.com/$HASH/$MERGE/REPORT || {
|
2009-05-06 23:22:39 +02:00
|
|
|
echo "Package not found on merges.ubuntu.com."
|
|
|
|
[ "$CREATED_DIR" != "1" ] || { cd ..; rmdir $MERGE; }
|
|
|
|
exit 1
|
|
|
|
}
|
2009-03-05 15:14:21 +00:00
|
|
|
|
|
|
|
for NAME in $(sed -n -e "/^ /p" REPORT); do
|
2009-11-24 17:04:06 -05:00
|
|
|
if [ ! -f "$NAME" ]; then
|
|
|
|
echo "Getting $NAME..."
|
|
|
|
URL="https://merges.ubuntu.com/$HASH/$MERGE/$NAME"
|
|
|
|
wget -q "$URL" || { echo "Error downloading $URL"; exit 1; }
|
|
|
|
fi
|
2009-03-05 15:14:21 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
|
|
|
|
if grep "^generated: " REPORT >/dev/null; then
|
|
|
|
VERSION=$(sed -n -e "/^generated:/s/^generated: *//p" REPORT)
|
2010-11-24 21:06:23 +02:00
|
|
|
DEB_VENDOR=Ubuntu dpkg-source -x ${MERGE}_${VERSION#*:}.dsc
|
2009-03-05 15:14:21 +00:00
|
|
|
echo
|
|
|
|
else
|
|
|
|
TARBALL=$(sed -n -e "/\.src\.tar\.gz$/p" REPORT)
|
|
|
|
|
|
|
|
echo unpacking $TARBALL
|
|
|
|
tar xf $TARBALL
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep "^ C" REPORT; then
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "#!/bin/sh" > merge-genchanges
|
|
|
|
echo "exec $(sed -n -e '/^ $ /s/^ $ //p' REPORT) \"\$@\"" \
|
|
|
|
>> merge-genchanges
|
|
|
|
chmod +x merge-genchanges
|
|
|
|
|
|
|
|
echo "#!/bin/sh" > merge-buildpackage
|
|
|
|
echo "exec $(sed -n -e '/^ $ /s/^ $ dpkg-genchanges/dpkg-buildpackage/p' REPORT) \"\$@\"" \
|
|
|
|
>> merge-buildpackage
|
|
|
|
chmod +x merge-buildpackage
|
|
|
|
|
2010-10-06 22:33:04 +03:00
|
|
|
echo "#!/bin/sh" > merge-debuild
|
2010-10-06 22:36:15 +03:00
|
|
|
echo "exec $(sed -n -e '/^ $ /s/^ $ dpkg-genchanges/debuild/p' REPORT) \"\$@\"" \
|
2010-10-06 22:33:04 +03:00
|
|
|
>> merge-debuild
|
|
|
|
chmod +x merge-debuild
|
|
|
|
|
|
|
|
echo "Run ../merge-genchanges , ../merge-buildpackage or ../merge-debuild when done"
|
2009-03-05 15:14:21 +00:00
|
|
|
|
|
|
|
if grep "^Vcs-" *.dsc >/dev/null; then
|
|
|
|
echo
|
|
|
|
echo "*** WARNING ***"
|
|
|
|
echo
|
|
|
|
echo "It looks like this package is maintained in revision control:"
|
|
|
|
echo
|
|
|
|
grep "^Vcs-" *.dsc
|
|
|
|
echo
|
|
|
|
echo "You almost certainly don't want to continue without investigating."
|
|
|
|
exit 1
|
|
|
|
fi
|