/usr/share/cdbs/1/rules/upstream-tarball.mk is in cdbs 0.4.156ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | # -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2007-2010, 2012, 2014-2016 Jonas Smedegaard <dr@jones.dk>
# Description: Convenience rules for dealing with upstream tarballs
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# 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/>.
_cdbs_scripts_path ?= /usr/lib/cdbs
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
_cdbs_class_path ?= /usr/share/cdbs/1/class
ifndef _cdbs_rules_upstream_tarball
_cdbs_rules_upstream_tarball = 1
include $(_cdbs_rules_path)/buildvars.mk$(_cdbs_makefile_suffix)
# Prefix for upstream location of all upstream tarballs (mandatory!)
#DEB_UPSTREAM_URL =
DEB_UPSTREAM_PACKAGE ?= $(DEB_SOURCE_PACKAGE)
DEB_UPSTREAM_TARBALL_VERSION ?= $(strip \
$(if $(strip $(DEB_UPSTREAM_REPACKAGE_EXCLUDES)),\
$(DEB_UPSTREAM_VERSION:$(DEB_UPSTREAM_REPACKAGE_DELIMITER)$(DEB_UPSTREAM_REPACKAGE_TAG)=),\
$(DEB_UPSTREAM_VERSION)))
DEB_UPSTREAM_TARBALL_DELIMITER ?= .
DEB_UPSTREAM_TARBALL_EXTENSION ?= tar.gz
# Checksum to ensure integrity of downloadeds using get-orig-source (optional)
# TODO: somehow support (auto-downloadable?) file containing checksums
#DEB_UPSTREAM_TARBALL_MD5 =
DEB_UPSTREAM_WORKDIR ?= ../tarballs
# Base filename (without extension) as used in upstream URL
DEB_UPSTREAM_TARBALL_BASENAME ?= $(DEB_UPSTREAM_PACKAGE)-$(DEB_UPSTREAM_TARBALL_VERSION)
# Perl regexp to change locally used string into that in upstream URL and srcdir
#DEB_UPSTREAM_TARBALL_BASENAME_MANGLE =
# Base directory within tarball
DEB_UPSTREAM_TARBALL_SRCDIR ?= $(cdbs_upstream_tarball_basename)
DEB_UPSTREAM_WGET_OPTS ?= -nv -T10 -t3
# Space-delimited list of directories and files to strip (optional)
# * strings with trailing / are located with "find -type d -path ..."
# * strings containing / not at end are located with "find -type f -path ..."
# * items without / are located with "find -type f -name ..."
#DEB_UPSTREAM_REPACKAGE_EXCLUDES = ./CVS/ .cvsignore ./doc/rfc*.txt ./doc/draft*.txt
cdbs_python_exclude_check = $(if $(DEB_UPSTREAM_REPACKAGE_EXCLUDE),\
$(error ERROR: DEB_UPSTREAM_REPACKAGE_EXCLUDE no longer works \
- use find-style DEB_UPSTREAM_REPACKAGE_EXCLUDES instead))
# Deprecated variable important to fix to not ship badly licensed source
DEB_UPSTREAM_REPACKAGE_EXCLUDES += $(cdbs_python_exclude_check)
# Delimiter and tag to append if repackaging:
# * if DEB_UPSTREAM_REPACKAGE_EXCLUDES are declared
# * if upstream packaging format is not supported by dpkg
DEB_UPSTREAM_REPACKAGE_TAG ?= dfsg
DEB_UPSTREAM_REPACKAGE_DELIMITER ?= ~
# extension of tarball as received
# * declare explicitly if wrong or missing at source (e.g. at github.com)
DEB_UPSTREAM_RECEIVED_EXTENSION ?= $(strip \
$(if $(findstring $(DEB_UPSTREAM_TARBALL_EXTENSION),tgz),\
tar.gz,\
$(DEB_UPSTREAM_TARBALL_EXTENSION)))
cdbs_upstream_tarball_basename = $(strip \
$(if $(DEB_UPSTREAM_TARBALL_BASENAME_MANGLE),\
$(shell echo '$(DEB_UPSTREAM_TARBALL_BASENAME)' \
| perl -pe '$(DEB_UPSTREAM_TARBALL_BASENAME_MANGLE)'),\
$(DEB_UPSTREAM_TARBALL_BASENAME)))
cdbs_upstream_tarball = $(subst $(space),,$(strip \
$(cdbs_upstream_tarball_basename) \
$(DEB_UPSTREAM_TARBALL_DELIMITER) \
$(DEB_UPSTREAM_TARBALL_EXTENSION)))
cdbs_upstream_received_tarball = $(subst $(space),,$(strip \
$(DEB_SOURCE_PACKAGE)_$(DEB_UPSTREAM_TARBALL_VERSION)\
.orig\
.$(DEB_UPSTREAM_RECEIVED_EXTENSION)))
cdbs_upstream_local_basename = $(subst $(space),,$(strip \
$(DEB_SOURCE_PACKAGE)_$(DEB_UPSTREAM_TARBALL_VERSION)\
$(if $(strip $(DEB_UPSTREAM_REPACKAGE_EXCLUDES)),\
$(DEB_UPSTREAM_REPACKAGE_DELIMITER)\
$(DEB_UPSTREAM_REPACKAGE_TAG))))
cdbs_upstream_local_srcdir = $(subst $(space),,$(strip \
$(cdbs_upstream_tarball_basename)\
$(if $(strip $(DEB_UPSTREAM_REPACKAGE_EXCLUDES)),\
$(DEB_UPSTREAM_REPACKAGE_DELIMITER)\
$(DEB_UPSTREAM_REPACKAGE_TAG))))
cdbs_upstream_findargs_dirs = $(if $(filter %/,$(DEB_UPSTREAM_REPACKAGE_EXCLUDES)),\
-type d \
\( \
$(call cdbs_findargs-path-or-name,\
$(patsubst %/,%,\
$(filter %/,\
$(DEB_UPSTREAM_REPACKAGE_EXCLUDES)))) \
\))
cdbs_upstream_findargs_files = $(strip \
$(if $(filter-out %/,$(DEB_UPSTREAM_REPACKAGE_EXCLUDES)),\
-type f \
\( \
$(call cdbs_findargs-path-or-name,\
$(filter-out %/,\
$(DEB_UPSTREAM_REPACKAGE_EXCLUDES))) \
\)))
print-version:
@@echo "Debian version: $(DEB_VERSION)"
@@echo "Upstream version: $(DEB_UPSTREAM_TARBALL_VERSION)"
get-orig-source:
@@dh_testdir
$(shell mkdir -p '$(DEB_UPSTREAM_WORKDIR)')
$(if $(wildcard $(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)),\
$(call cdbs_info,Upstream source tarball already downloaded: \
$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)), \
wget $(DEB_UPSTREAM_WGET_OPTS) \
-O "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" \
"$(DEB_UPSTREAM_URL)/$(cdbs_upstream_tarball)")
@md5current=`md5sum "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" | sed -e 's/ .*//'`; \
if [ -n "$(DEB_UPSTREAM_TARBALL_MD5)" ]; then \
if [ "$$md5current" != "$(DEB_UPSTREAM_TARBALL_MD5)" ]; then \
echo "Expecting upstream tarball md5sum $(DEB_UPSTREAM_TARBALL_MD5), but $$md5current found"; \
echo "Upstream tarball md5sum is NOT trusted! Possible upstream tarball forge!"; \
echo "Purging downloaded file. Try new download."; \
rm -f "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)"; \
false; \
else \
echo "Upstream tarball is trusted!"; \
fi; \
else \
echo "Upstream tarball NOT trusted (current md5sum is $$md5current)!" ; \
fi
# TODO: Rewrite using make variables like cdbs_upstream_unpack_cmd and
# DEB_UPSTREAM_SUPPORTED_COMPRESSIONS (recent dpkg supports bz2)
# TODO: Add .orig suffix to top folder inside tarball when only
# recompressing (when $uncompress set and ...REPACKAGE_EXCLUDE unset)
@untar="tar -x -C"; \
case "$(cdbs_upstream_received_tarball)" in \
*.tar.gz) unpack="gunzip -c";; \
*.tar.bz2) unpack="bunzip2 -c"; grep -q '3.0 (quilt)' debian/source/format || uncompress="bunzip2";; \
*.tar.xz) unpack="unxz -c"; grep -q '3.0 (quilt)' debian/source/format || uncompress="unxz";; \
*.tar.Z) unpack="uncompress -c"; uncompress="uncompress";; \
*.zip) unpack="unzip -q"; uncompress="false"; untar="-d"; nopipe="true";; \
*.tar) unpack="cat"; uncompress="true";; \
*) echo "Unknown extension for upstream tarball $(cdbs_upstream_received_tarball)"; false;; \
esac && \
if [ -n "$(strip $(DEB_UPSTREAM_REPACKAGE_EXCLUDES))" ] || [ "$$uncompress" = "false" ]; then \
echo "Repackaging tarball ..." && \
mkdir -p "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)" && \
if [ -n "$$nopipe" ]; then \
$$unpack "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" \
$$untar "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)"; \
else \
$$unpack "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)" \
| $$untar "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)"; \
fi && \
if [ -n "$(cdbs_upstream_findargs_files)" ]; then \
(set -e; \
cd "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(DEB_UPSTREAM_TARBALL_SRCDIR)" \
&& find $(cdbs_upstream_findargs_files) \
-delete); \
fi && \
if [ -n "$(cdbs_upstream_findargs_dirs)" ]; then \
(set -e; \
cd "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(DEB_UPSTREAM_TARBALL_SRCDIR)" \
&& find $(cdbs_upstream_findargs_dirs) \
-exec rm -rf '{}' +;) \
fi && \
if [ "$(DEB_UPSTREAM_TARBALL_SRCDIR)" != "$(cdbs_upstream_local_srcdir)" ]; then \
mv -T "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(DEB_UPSTREAM_TARBALL_SRCDIR)" \
"$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)/$(cdbs_upstream_local_srcdir)"; \
fi && \
GZIP="--best --no-name" tar \
-b1 --owner=root --group=root --mode=a+rX \
-czf "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_local_basename).orig.tar.gz" \
-C "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)" \
"$(cdbs_upstream_local_srcdir)" && \
echo "Cleaning up" && \
rm -rf "$(DEB_UPSTREAM_WORKDIR)/$(DEB_UPSTREAM_REPACKAGE_TAG)"; \
elif [ -n "$$uncompress" ]; then \
echo "Recompressing tarball ..." && \
$$uncompress "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_received_tarball)"; \
gzip -9 "$(DEB_UPSTREAM_WORKDIR)/$(cdbs_upstream_local_basename).orig.tar"; \
fi
DEB_PHONY_RULES += print-version get-orig-source
endif
|