source: trunk/debathena/scripts/dasource @ 22786

Revision 22786, 2.6 KB checked in by ghudson, 17 years ago (diff)
Factor out the creation of the orig tarball into a separate script. * debathena/scripts/daorig: New script to create orig tarball. * debathena/scripts/dasource: Use daorig.
  • Property svn:executable set to *
RevLine 
[22704]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
[22742]18die() {
19  echo "$@" >&2
20  exit 1
21}
22
23usage() {
24  die "dasource [-r repos] [packagename ...]"
25}
26
[22720]27: ${DEBATHENA_APT=/mit/debathena/apt}
28basedir=$(dirname "$0")
[22704]29repo=svn+ssh://svn.mit.edu/athena/trunk
30
31while getopts r: opt; do
32  case "$opt" in
33  r)
34    type="$OPTARG"
35    ;;
36  \?)
[22742]37    usage
[22704]38    ;;
39  esac
40done
41
42do_package() {
43  pkgname=$1
44  pkgpath=$2
45  if [ ! -d $pkgname ]; then
46    echo "Creating directory $pkgname"
47    mkdir $pkgname
48  fi
[22706]49
50  # Check out or update the package source.
[22767]51  pattern="$pkgname/$pkgname-[0-9]*[0-9]"
52  if [ $(echo $pattern | wc -w) -gt 1 ]; then
[22704]53    die "More than one checkout under $pkgname!"
[22767]54  elif [ -d $pattern ]; then
55    dir=$(echo $pattern)
[22712]56    echo "Updating and cleaning $dir"
57    (cd $dir && svn update && svn revert -R . &&
58     svn st | awk '/^?/ {print $2}' | xargs rm -vrf)
[22704]59  else
60    dir=$pkgname/$pkgname
61    echo "Checking out $repo/$pkgpath into $dir"
62    svn co $repo/$pkgpath $dir
63  fi
[22706]64
65  # Extract the changelog version and strip off the epoch and Debian component.
[22704]66  changever=$(cd $dir && dpkg-parsechangelog | sed -n 's/Version: //p')
[22706]67  sver=$(echo $changever | sed -re 's/^[0-9]+://p')
68  upver=$(echo $sver | sed -re 's/-[^-]*$//')
69
70  # Rename the source checkout if necessary.
[22704]71  correctdir=$pkgname/${pkgname}-$upver
72  if [ $dir != $correctdir ]; then
73    echo "Renaming $dir to $correctdir"
74    mv $dir $correctdir
75    dir=$correctdir
76  fi
[22706]77
[22720]78  # Add autoconf goo if it's an Athena source directory.
79  case $pkgpath in
80  athena/*)
81    (cd $dir && $basedir/daconfiscate)
82    ;;
83  esac
84
[22786]85  # Create a suitable orig tarball if necessary.
86  (cd $dir && daorig)
[22706]87
88  # Build an unsigned package, ignoring version control subdirs in the source.
[22704]89  echo "Creating source package"
[22766]90  (cd $dir && debuild -S -i -I.svn -sa -us -uc)
[22704]91}
92
[22745]93if [ ! -r packages ]; then
94  die "Can't read packages file; create with gen-packages"
95fi
96
[22704]97if [ $# -gt 0 ]; then
98  # Build specific source packages.
99  for pkgname; do
[22745]100    pkgpath=$(sed -nre "s/^$pkgname[[:space:]]+//p" packages)
[22704]101    [ -n "$pkgpath" ] || die "Can't find package $pkgname"
102    do_package $pkgname $pkgpath
103  done
104else
105  # Build all source packages.
[22745]106  exec <packages
[22704]107  while read pkgname pkgpath; do
108    do_package $pkgname $pkgpath
109  done
110fi
Note: See TracBrowser for help on using the repository browser.