source: trunk/debathena/scripts/dasource @ 22726

Revision 22726, 3.0 KB checked in by ghudson, 16 years ago (diff)
* debathena/scripts/dasource: Don't create an orig archive if the package version contains no Debian component. We were checking that prior to r22720 but that check was removed due to confusion on my part. We need it for the config and meta packages which are Debian-native.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3# Usage: dasource [-r REPOS] [PACKAGENAME ...]
4
5# Creates or updates a checkout and source package for each listed
6# PACKAGENAME, or for all regular packages if no PACKAGENAME is
7# specified.
8
9# If REPOS is specified, it is used in preference to the canonical
10# Athena repository trunk.
11
12# Package subdirectories are created in the cwd.  The source checkout
13# will reside in PACKAGENAME/PACKAGENAME-VERSION and the source
14# package will be created in PACKAGENAME.
15
16set -e
17
18: ${DEBATHENA_APT=/mit/debathena/apt}
19basedir=$(dirname "$0")
20pkgfile=$basedir/packages
21repo=svn+ssh://svn.mit.edu/athena/trunk
22
23while getopts r: opt; do
24  case "$opt" in
25  r)
26    type="$OPTARG"
27    ;;
28  \?)
29    echo "$usage"
30    exit 1
31    ;;
32  esac
33done
34
35die() {
36  echo "$@" >&2
37  exit 1
38}
39
40do_package() {
41  pkgname=$1
42  pkgpath=$2
43  if [ ! -d $pkgname ]; then
44    echo "Creating directory $pkgname"
45    mkdir $pkgname
46  fi
47
48  # Check out or update the package source.
49  if [ $(echo $pkgname/$pkgname-* | wc -w) -gt 2 ]; then
50    die "More than one checkout under $pkgname!"
51  elif [ -d $pkgname/$pkgname-* ]; then
52    dir=$(echo $pkgname/$pkgname-*)
53    echo "Updating and cleaning $dir"
54    (cd $dir && svn update && svn revert -R . &&
55     svn st | awk '/^?/ {print $2}' | xargs rm -vrf)
56  else
57    dir=$pkgname/$pkgname
58    echo "Checking out $repo/$pkgpath into $dir"
59    svn co $repo/$pkgpath $dir
60  fi
61
62  # Extract the changelog version and strip off the epoch and Debian component.
63  changever=$(cd $dir && dpkg-parsechangelog | sed -n 's/Version: //p')
64  sver=$(echo $changever | sed -re 's/^[0-9]+://p')
65  upver=$(echo $sver | sed -re 's/-[^-]*$//')
66
67  # Rename the source checkout if necessary.
68  correctdir=$pkgname/${pkgname}-$upver
69  if [ $dir != $correctdir ]; then
70    echo "Renaming $dir to $correctdir"
71    mv $dir $correctdir
72    dir=$correctdir
73  fi
74
75  # Add autoconf goo if it's an Athena source directory.
76  case $pkgpath in
77  athena/*)
78    (cd $dir && $basedir/daconfiscate)
79    ;;
80  esac
81
82  # If the version has a debian component then we need an orig archive.
83  if [ $sver != $upver ]; then
84    tarfile=${pkgname}_$upver.orig.tar.gz
85    if [ ! -e $pkgname/$tarfile ]; then
86      aptorig=$(find ${DEBATHENA_APT}*/pool -name $tarfile | head -1)
87      if [ -n "$aptorig" ]; then
88        echo "Copying existing $aptorig to original source"
89        cp $aptorig $pkgname/$tarfile
90      else
91        echo "Creating original source archive"
92        (cd $pkgname && tar --exclude=.svn --exclude=debian $correctname -czf \
93         $tarfile ${pkgname}-$upver)
94      fi
95    fi
96  fi
97
98  # Build an unsigned package, ignoring version control subdirs in the source.
99  echo "Creating source package"
100  (cd $dir && debuild -S -i -I -sa -us -uc)
101}
102
103if [ $# -gt 0 ]; then
104  # Build specific source packages.
105  for pkgname; do
106    pkgpath=$(sed -nre "s/^$pkgname[[:space:]]+//p" $pkgfile)
107    [ -n "$pkgpath" ] || die "Can't find package $pkgname"
108    do_package $pkgname $pkgpath
109  done
110else
111  # Build all source packages.
112  exec <$pkgfile
113  while read pkgname pkgpath; do
114    do_package $pkgname $pkgpath
115  done
116fi
Note: See TracBrowser for help on using the repository browser.