source: trunk/debathena/scripts/dasource @ 23064

Revision 23064, 3.0 KB checked in by ghudson, 16 years ago (diff)
In dasource, chmod build dir parents to mode 777 to make work around a bad AFS-perl interaction in dpkg-source.
  • 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
18die() {
19  echo "$@" >&2
20  exit 1
21}
22
23usage() {
24  die "dasource [-r repos] [packagename ...]"
25}
26
27: ${DEBATHENA_APT=/mit/debathena/apt}
28basedir=$(dirname "$0")
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  \?)
37    usage
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
49
50  # Work around a bad interaction between dpkg-source and AFS.
51  # (dpkg-source invokes perl's Tempfile which checks if the parent
52  # directory is writable using mode bits).  This will not actually
53  # grant any outside access to the directory since AFS ignores
54  # non-user mode bits.
55  if fs whichcell . >/dev/null 2>&1; then
56    chmod 777 $pkgname
57  fi
58
59  # Check out or update the package source.
60  pattern="$pkgname/$pkgname-[0-9]*[0-9]"
61  if [ $(echo $pattern | wc -w) -gt 1 ]; then
62    die "More than one checkout under $pkgname!"
63  elif [ -d $pattern ]; then
64    dir=$(echo $pattern)
65    echo "Updating and cleaning $dir"
66    (cd $dir && svn update && svn revert -R . &&
67     svn st | awk '/^?/ {print $2}' | xargs rm -vrf)
68  else
69    dir=$pkgname/$pkgname
70    echo "Checking out $repo/$pkgpath into $dir"
71    svn co $repo/$pkgpath $dir
72  fi
73
74  # Extract the changelog version and strip off the epoch and Debian component.
75  changever=$(cd $dir && dpkg-parsechangelog | sed -n 's/Version: //p')
76  sver=$(echo $changever | sed -re 's/^[0-9]+://p')
77  upver=$(echo $sver | sed -re 's/-[^-]*$//')
78
79  # Rename the source checkout if necessary.
80  correctdir=$pkgname/${pkgname}-$upver
81  if [ $dir != $correctdir ]; then
82    echo "Renaming $dir to $correctdir"
83    mv $dir $correctdir
84    dir=$correctdir
85  fi
86
87  # Add autoconf goo if it's an Athena source directory.
88  case $pkgpath in
89  athena/*)
90    (cd $dir && $basedir/daconfiscate)
91    ;;
92  esac
93
94  # Create a suitable orig tarball if necessary.
95  (cd $dir && daorig)
96
97  # Build an unsigned package, ignoring version control subdirs in the source.
98  echo "Creating source package"
99  (cd $dir && debuild -S -i -I.svn -sa -us -uc)
100}
101
102if [ ! -r packages ]; then
103  die "Can't read packages file; create with gen-packages"
104fi
105
106if [ $# -gt 0 ]; then
107  # Build specific source packages.
108  for pkgname; do
109    pkgpath=$(sed -nre "s/^$pkgname[[:space:]]+//p" packages)
110    [ -n "$pkgpath" ] || die "Can't find package $pkgname"
111    do_package $pkgname $pkgpath
112  done
113else
114  # Build all source packages.
115  exec <packages
116  while read pkgname pkgpath; do
117    do_package $pkgname $pkgpath
118  done
119fi
Note: See TracBrowser for help on using the repository browser.