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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
|
#!/bin/bash
# Copyright (C) 2014 Free Software Foundation, Inc.
#
# Author: Ivan Vucica <ivan@vucica.net>
#
# This file is part of the GNUstep Makefile Package.
#
# This library 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
# of the License, or (at your option) any later version.
#
# You should have received a copy of the GNU General Public
# License along with this library; see the file COPYING.
# If not, write to the Free Software Foundation,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
if [ -z "${1}" ] ; then
echo "usage: "$(basename "${0}")" [source_code_directory]"
exit 1
fi
cd ${1} && destination="$(pwd)" && cd -
destination="${destination}"/debian
if mkdir -p "${destination}" ; then : else exit 1 ; fi
rm "${destination}"/control 2> /dev/null
rm "${destination}"/changelog 2> /dev/null
deb_lowercase_package_name=$(echo ${PACKAGE_NAME} | sed -e 's/\(.*\)/\L\1/')
if [ ! -z "${SVNPREFIX}" ] ; then
svn_path="${SVNPREFIX}"
fi
if [ ! -z "${SVN_BASE_URL}" ] && [ ! -z "${SVN_MODULE_NAME}" ] ; then
svn_path=${SVN_BASE_URL}/${SVN_MODULE_NAME}
fi
default_distribution="unstable"
distrib_id="$(grep DISTRIB_ID /etc/lsb-release | sed 's/DISTRIB_ID=\(.*\)$/\1/')"
if [[ "${distrib_id}" == "Ubuntu" ]] ; then
default_distribution=$(grep DISTRIB_CODENAME /etc/lsb-release | sed 's/DISTRIB_CODENAME=//')
fi
if true ; then
# Forcing 'any' as we'd like Launchpad to build packages for all architectures.
# DEB_ARCHITECTURE can still be overridden.
target_arch=any
else
target_arch=${GNUSTEP_TARGET_CPU:-any}
if [[ "${target_arch}" == "i686" ]] ; then
target_arch=i386
elif [[ "${target_arch}" == "x86_64" ]] ; then
target_arch=amd64
fi
fi
PACKAGE_VERSION=${PACKAGE_VERSION:-${VERSION}}
DEB_SOURCE=${DEB_SOURCE:-${deb_lowercase_package_name}}
DEB_PACKAGE=${DEB_PACKAGE:-${deb_lowercase_package_name}}
DEB_ARCHITECTURE=${DEB_ARCHITECTURE:-${target_arch}} #$(shell (/bin/bash -c "$(CC) -dumpmachine | sed -e 's,\\([^-]*\\).*,\\1,g'"))}
DEB_SECTION=${DEB_SECTION:-gnustep}
DEB_PRIORITY=${DEB_PRIORITY:-optional}
DEB_VCS_SVN=${DEB_VCS_SVN:-${svn_path}}
DEB_VERSION=${DEB_VERSION:-${TARBALL_VERSION:-${PACKAGE_VERSION}}}
if [ -z "${DEB_BUILD_DEPENDS}" ] ; then
DEB_BUILD_DEPENDS="debhelper (>= 9), cdbs"
else
DEB_BUILD_DEPENDS="${DEB_BUILD_DEPENDS}, debhelper (>= 9), cdbs"
fi
if [ ! -z "${DEB_DEPENDS}" ]; then
DEB_DEPENDS=", ${DEB_DEPENDS}"
fi
DEB_DEPENDS='${shlibs:Depends}, ${misc:Depends}'" ${DEB_DEPENDS}"
DEB_DISTRIBUTION=${DEB_DISTRIBUTION:-${default_distribution}}
# DEB_VERSION_SUFFIX intentionally unset.
# Attempt to extract information from a .spec or a .spec.in file.
if which python > /dev/null ; then
FN=$(python - << _EOF
import tempfile
import sys
def process_specfile(specfilename):
description_mode=False
with open(specfilename) as specfile:
with tempfile.NamedTemporaryFile(delete=False) as tf:
print tf.name
vars={}
for line in specfile.readlines():
line=line.rstrip()
for var in vars:
line=line.replace('%{' + var + '}', vars[var])
if description_mode:
if len(line.lstrip()) > 0 and line.lstrip()[0] == '#':
continue
if len(line.lstrip()) > 0 and line.lstrip()[0] == '%':
description_mode=False
continue
tf.write("RPM_DESCRIPTION=\"\${RPM_DESCRIPTION}%s\\n\"\n" % line.replace('\\'', '\\\\\\'').replace('\\"', '\\\\\\"').replace('(', '\\(').replace(')', '\\)'))
continue
if not len(line):
continue
components=line.split(':')
if len(components)>=2:
key=components[0]
value=':'.join(components[1:]).lstrip()
if key=="Name":
tf.write("DEB_PACKAGE=\${DEB_PACKAGE:-%s}\n" % value)
tf.write("DEB_SOURCE=\${DEB_SOURCE:-%s}\n" % value)
elif key=="Release":
tf.write("DEB_VERSION_SUFFIX=\${DEB_VERSION_SUFFIX:-%s}\n" % value)
elif key=="Source":
# Source URL is not mappable to anything useful.
# Possibly only includable in README.Debian.
pass
elif key=="License":
tf.write("DEB_LICENSE=\${DEB_LICENSE:-%s}\n" % value)
elif key=="Copyright":
# Seems to do the same as License?
pass
elif key=="Group":
# Ignore; not easily mappable, plus Debian has separate
# 'gnustep' section.
pass
elif key=="Summary":
# First line of 'Description' field
tf.write("RPM_DESCRIPTION=\"%s\n\"\n" % value)
elif key=="Packager":
tf.write("DEB_MAINTAINER=\${DEB_MAINTAINER:-\"%s\"}\n" % value)
elif key=="Vendor":
# Ignore; not useful anywhere in .deb
pass
elif key=="URL":
tf.write("DEB_HOMEPAGE=\${DEB_HOMEPAGE:-%s}\n" % value)
elif key=="Requires":
# We support only comma separated dependencies (to simplify version handling).
# Also, version mapping is very trivial.
rpmdeps = value.split(',')
debdeps = []
for rpmdep in rpmdeps:
rpmdepcomponents = rpmdep.split(' ')
debdep = rpmdepcomponents[0]
if len(rpmdepcomponents) > 1:
debdep += ' (%s)' % ' '.join(rpmdepcomponents[1:])
debdeps.append(debdep)
tf.write("if [ -z \\"\${DEB_DEPENDS}\\" ] ; then\n")
tf.write(" DEB_DEPENDS=\"%s\"\n" % ', '.join(debdeps))
tf.write("else\n")
tf.write(" DEB_DEPENDS=\"\${DEB_DEPENDS}, %s\"\n" % ', '.join(debdeps))
tf.write("fi\n")
elif key=="Provides":
tf.write("if [ -z \\"\${DEB_PROVIDES}\\" ] ; then\n")
tf.write(" DEB_PROVIDES=\"%s\"\n" % value)
tf.write("else\n")
tf.write(" DEB_PROVIDES=\"\${DEB_PROVIDES}, %s\"\n" % value)
elif key=="Version":
tf.write("DEB_VERSION=\${DEB_VERSION:-%s}\n" % value)
else:
if line == "%description":
description_mode = True
elif line.startswith('%define'):
segs=line[len('%define')+1:].lstrip().replace('\\t', ' ').split(' ')
segs=[seg.rstrip().lstrip() for seg in segs]
vars[segs[0]] = ' '.join(segs[1:])
try:
process_specfile('${DEB_PACKAGE}.spec')
except:
try:
process_specfile('${DEB_PACKAGE}.spec.in')
except Exception as e:
sys.stderr.write('could not process either ${DEB_PACKAGE}.spec or ${DEB_PACKAGE}.spec.in\n')
raise
_EOF
)
if [ ! -z "${FN}" ] ; then
. $FN
DEB_DESCRIPTION="${DEB_DESCRIPTION:-${RPM_DESCRIPTION}}"
fi
fi
DEB_DESCRIPTION="${DEB_DESCRIPTION:-$(printf "Debian packaging for GNUstep based software ${PACKAGE_NAME}.\nThis package was built using gnustep-make.\n")}"
# Check that maintainer and package builder are set.
if [ -z "${DEB_MAINTAINER}" ] ; then
echo "error: You must set DEB_MAINTAINER in GNUmakefile, in .spec file, or on command line."
exit 1
fi
if [ -z "${DEB_PACKAGE_BUILDER}" ] ; then
echo "error: You must set DEB_PACKAGE_BUILDER in GNUmakefile or on command line."
echo "(It's recommended you set it on the command line, so other people"
echo "don't accidentally claim you built their package.)"
exit 1
fi
# Check some other fields
if [ -z "${DEB_PACKAGE}" ] ; then
echo "error: Package name was not properly set in GNUmakefile."
exit 1
fi
if [ -z "${DEB_VERSION}" ] ; then
echo "error: Package version was not properly set in GNUmakefile."
exit 1
fi
if [ ! -z "${DEB_VERSION_SUFFIX}" ] ; then
DEB_VERSION=${DEB_VERSION}-${DEB_VERSION_SUFFIX}
#ln -s ${destination}/../../${PACKAGE_NAME}-${VERSION}.orig.tar.gz ${destination}/../../${PACKAGE_NAME}-${DEB_VERSION}.orig.tar.gz
fi
echo ${destination}
# For documentation, see:
# https://www.debian.org/doc/debian-policy/ch-controlfields.html
echo "Source: " ${DEB_SOURCE} >> "${destination}"/control
echo "Maintainer:" ${DEB_MAINTAINER} >> "${destination}"/control
echo "Section:" ${DEB_SECTION} >> "${destination}"/control
echo "Priority:" ${DEB_PRIORITY} >> "${destination}"/control
if [ ! -z "${DEB_BUILD_DEPENDS}" ] ; then
echo "Build-Depends:" ${DEB_BUILD_DEPENDS} >> "${destination}"/control
fi
echo "Standards-Version: 3.9.4" >> "${destination}"/control
if [ ! -z "${DEB_HOMEPAGE}" ] ; then
echo "Homepage:" ${DEB_HOMEPAGE} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_BROWSER}" ] ; then
echo "Vcs-Browser:" ${DEB_VCS_BROWSER} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_ARCH}" ] ; then
echo "Vcs-Arch:" ${DEB_VCS_ARCH} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_BZR}" ] ; then
echo "Vcs-Bzr:" ${DEB_VCS_BZR} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_CVS}" ] ; then
echo "Vcs-Cvs:" ${DEB_VCS_CVS} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_DARCS}" ] ; then
echo "Vcs-Darcs:" ${DEB_VCS_DARCS} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_GIT}" ] ; then
echo "Vcs-Git:" ${DEB_VCS_GIT} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_HG}" ] ; then
echo "Vcs-Hg:" ${DEB_VCS_HG} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_MTN}" ] ; then
echo "Vcs-Mtn:" ${DEB_VCS_MTN} >> "${destination}"/control
fi
if [ ! -z "${DEB_VCS_SVN}" ] ; then
echo "Vcs-Svn:" ${DEB_VCS_SVN} >> "${destination}"/control
fi
echo "" >> "${destination}"/control
echo "Package:" ${DEB_PACKAGE} >> "${destination}"/control
echo "Architecture:" ${DEB_ARCHITECTURE} >> "${destination}"/control
# Comma-separated lists of packages
if [ ! -z "${DEB_PRE_DEPENDS}" ] ; then
echo "Pre-Depends:" ${DEB_PRE_DEPENDS} >> "${destination}"/control
fi
if [ ! -z "${DEB_DEPENDS}" ] ; then
echo "Depends:" ${DEB_DEPENDS} >> "${destination}"/control
fi
if [ ! -z "${DEB_RECOMMENDS}" ] ; then
echo "Recommends:" ${DEB_RECOMMENDS} >> "${destination}"/control
fi
if [ ! -z "${DEB_SUGGESTS}" ] ; then
echo "Suggests:" ${DEB_SUGGESTS} >> "${destination}"/control
fi
if [ ! -z "${DEB_PROVIDES}" ] ; then
echo "Provides:" ${DEB_PROVIDES} >> "${destination}"/control
fi
if [ ! -z "${DEB_REPLACES}" ] ; then
echo "Replaces:" ${DEB_REPLACES} >> "${destination}"/control
fi
if [ ! -z "${DEB_ESSENTIAL}" ] ; then
echo "Essential:" ${DEB_ESSENTIAL} >> "${destination}"/control
fi
echo "Description:" "$(echo "${DEB_DESCRIPTION}" | sed 's/^[\s]*$/./' | sed 's/\(.*\)/ \1/' | tail -c+2)" >> "${destination}"/control
###########
echo "${DEB_SOURCE} (${DEB_VERSION}) ${DEB_DISTRIBUTION}; urgency=low" >> "${destination}"/changelog
echo "" >> "${destination}"/changelog
echo " * New build." >> "${destination}"/changelog
echo "" >> "${destination}"/changelog
echo "" >> "${destination}"/changelog
echo " -- ${DEB_PACKAGE_BUILDER} $(date -R)" >> "${destination}"/changelog
##########
# Intentionally overwriting.
echo "9" > "${destination}"/compat
mkdir -p "${destination}"/source
echo "3.0 (quilt)" > "${destination}"/source/format
###########
# Intentionally overwriting.
cat > "${destination}"/rules << _EOF
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
ifneq (\$(wildcard configure),)
include /usr/share/cdbs/1/class/autotools.mk
else
include /usr/share/cdbs/1/class/makefile.mk
DEB_MAKE_INSTALL_TARGET := install DESTDIR=\$(CURDIR)/debian/${deb_lowercase_package_name}
endif
DEB_BUILD_PARALLEL = 1
DEB_CONFIGURE_EXTRA_FLAGS += ${DEB_CONFIGURE_EXTRA_FLAGS}
DEB_CONFIGURE_SCRIPT_ENV += ${DEB_CONFIGURE_SCRIPT_ENV}
DEB_DH_LINK_ARGS += ${DEB_DH_LINK_ARGS}
DEB_SHLIBS_ARGS_ALL += ${DEB_SHLIBS_ARGS_ALL}
DEB_SHLIBS_ARGS += ${DEB_SHLIBS_ARGS}
DEB_SHLIBS_INCLUDE += ${DEB_SHLIBS_INCLUDE}
DEB_MAKE_ENVVARS += BUILDING_DEB=1
export build :
ifneq (${PACKAGE_NAME}, gnustep-make)
GNUSTEP_MAKEFILES = \$(shell gnustep-config --variable=GNUSTEP_MAKEFILES)
ifneq (\$(GNUSTEP_MAKEFILES), )
DEB_MAKE_ENVVARS += \$(shell sh -c ". \$(GNUSTEP_MAKEFILES)/GNUstep.sh && env |grep GNUSTEP")
else
\$(error Failed to get GNUSTEP_MAKEFILES variable. Is gnustep-config properly installed?)
exit 1
endif
endif
_EOF
chmod 755 "${destination}"/rules
##########
if [ -e COPYING ] ; then
cp COPYING ${destination}/copyright
fi
if [ -e LICENSE ] ; then
cp LICENSE ${destination}/copyright
fi
|