summaryrefslogtreecommitdiff
path: root/build
blob: 800c86ad9af1c067520428dfb74d3a9a6385f2af (plain) (blame)
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
#!/bin/bash

# Script to facilitate building r-base binaries for CRAN in a chroot
# Matching CRAN sources must be in /etc/apt/sources.list of the chroot
# TBD: Check if the build already exists in the local repository

usage()
{
echo "Usage: ./build [options] sourcepackage"
echo "Options:"
echo " -s, --skip    Skip apt-get update/upgrade"
}

command -v lsb_release >/dev/null 2>&1 || {
  echo "Could not find lsb_release. Please install lsb-release"
  exit 1
}
DIST=`lsb_release -cs`

# URL of the local CRAN repo for checking for existing builds
localcran="http://ryz/r-cran/$DIST-cran35/"

skip=false
while test -n "${1}"; do
  case "$1" in
    -s | --skip)
      skip=true
      shift
      ;;
    -*)
      echo "Error: Unknown option: $1" >&2
      usage
      exit 1
      ;;
    *) # No more options
      break
      ;;
  esac
done

# Positional argument
if [ $# -lt 1 ]; then usage; exit 1; fi
pkg=$1

if ls $pkg-* 1> /dev/null 2>&1
then
  echo "Please check if sources from previous backport or build need to be cleaned up"
  exit 1
fi

if [ "$skip" = false ]
then
  apt-get update
  apt-get upgrade
fi

# stretch needs --only-source (at least for rkward source packages), jessie
# does not know this argument
if [ $DIST == "jessie" ]; then
  apt-get build-dep $pkg
  apt-get source $pkg
fi
if [ $DIST == "stretch" ]; then
  apt --only-source build-dep $pkg
  apt --only-source source $pkg
fi


# Move sources to $DIST directory to enable parallel builds
mkdir -p $DIST
mv $pkg\_* $DIST
mv $pkg-* $DIST

cd $DIST/$pkg-*

if [ $DIST == "jessie" ]; then
  debuild --no-lintian -uc -us -B
else
  debuild --no-lintian -ui -uc -us -B
fi

cd ../..

keep=false # We do not want to keep local sources for binary builds
# Clean sources from $DIST directory
if [ "$keep" = false ]
then
  rm -f $DIST/$pkg\_*.{dsc,changes,diff.gz,tgz,tar.gz,tar.xz}
  #rm -rf $DIST/$pkg-* # This removes e.g. r-base-core* debs which is not intended
fi

Contact - Imprint