1#!/bin/bash 2# 3# Copyright 2006-2008 (C) Kees Cook <kees@ubuntu.com> 4# Modified by Siegfried-A. Gevatter <rainct@ubuntu.com> 5# Modified by Daniel Hahler <ubuntu@thequod.de> 6# 7# ################################################################## 8# 9# This program is free software; you can redistribute it and/or 10# modify it under the terms of the GNU General Public License 11# as published by the Free Software Foundation; either version 3 12# of the License, or (at your option) any later version. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# See file /usr/share/common-licenses/GPL for more details. 20# 21# ################################################################## 22# 23# By default only the name of the patch system is printed. Verbose mode can be 24# enabled with -v. 25 26if [ "$1" = "-h" ] || [ "$1" = "--help" ] 27then 28 cat <<EOM 29Usage: $0 [-v] 30 31Run this inside the source directory of a Debian package and it will detect 32the patch system that it uses. 33 34 -v: Enable verbose mode: 35 - Print a list of all those files outside the debian/ directory that have 36 been modified (if any). 37 - Report additional details about patch systems, if available. 38EOM 39 exit 0 40fi 41 42while [ ! -r debian/rules ]; 43do 44 if [ "$PWD" = "/" ]; then 45 echo "Can't find debian/rules." 46 exit 1 47 fi 48 cd .. 49done 50 51VERBOSE=0 52if [ "$1" = "-v" ] 53then 54 VERBOSE=1 55fi 56 57if [ "$VERBOSE" -gt 0 ]; then 58 files=`lsdiff -z ../$(dpkg-parsechangelog -SSource)_$(dpkg-parsechangelog -SVersion).diff.gz 2>/dev/null | grep -v 'debian/'` 59 if [ -n "$files" ] 60 then 61 echo "Following files were modified outside of the debian/ directory:" 62 echo "$files" 63 echo "--------------------" 64 echo 65 echo -n "Patch System: " 66 fi 67fi 68 69if grep -qF quilt debian/source/format 2>/dev/null; then 70 echo "quilt" 71 exit 0 72fi 73 74# Do not change the output of existing checks by default, as there are build 75# tools that rely on the exisitng output. If changes in reporting is needed, 76# please check the "VERBOSE" flag (see below for examples). Feel free 77# to add new patchsystem detection and reporting. 78for filename in $(echo "debian/rules"; grep ^include debian/rules | grep -vF '$(' | awk '{print $2}') 79do 80 grep -F patchsys.mk "$filename" | grep -q -v "^#" && { 81 if [ "$VERBOSE" -eq 0 ]; then 82 echo "cdbs"; exit 0; 83 else 84 echo "cdbs (patchsys.mk: see 'cdbs-edit-patch')"; exit 0; 85 fi 86 } 87 grep -F quilt "$filename" | grep -q -v "^#" && { echo "quilt"; exit 0; } 88 grep -F dbs-build.mk "$filename" | grep -q -v "^#" && { 89 if [ "$VERBOSE" -eq 0 ]; then 90 echo "dbs"; exit 0; 91 else 92 echo "dbs (see 'dbs-edit-patch')"; exit 0; 93 fi 94 } 95 grep -F dpatch "$filename" | grep -q -v "^#" && { 96 if [ "$VERBOSE" -eq 0 ]; then 97 echo "dpatch"; exit 0; 98 else 99 echo "dpatch (see 'patch-edit-patch')"; exit 0; 100 fi 101 } 102 grep -F '*.diff' "$filename" | grep -q -v "^#" && { 103 if [ "$VERBOSE" -eq 0 ]; then 104 echo "diff splash"; exit 0; 105 else 106 echo "diff splash (check debian/rules)"; exit 0; 107 fi 108 } 109done 110[ -d debian/patches ] || { 111 if [ "$VERBOSE" -eq 0 ]; then 112 echo "patchless?"; exit 0; 113 else 114 echo "patchless? (did not find debian/patches/)"; exit 0; 115 fi 116} 117if [ "$VERBOSE" -eq 0 ]; then 118 echo "unknown patch system" 119else 120 echo "unknown patch system (see debian/patches/ and debian/rules)" 121fi 122