summaryrefslogtreecommitdiff
path: root/support/dktools/sl6-build-rpm.sh
blob: 36dc0edffd2ab9962673e64735e6ce02c68c8603 (plain)
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
#! /bin/sh

VERSION=`cat version.txt`

# Check whether this script is run as unprivileged user
if [ "X$LOGNAME" = "Xroot" ]
then
  echo 'ERROR: This script must not be run as root!'
  exit 1
fi

# Check whether HOME environment variable is set
if [ "X$HOME" = "X" ]
then
  echo 'ERROR: Environment variable HOME not set!'
  exit 1
fi

# Check whether the version number was obtained
if [ "X$VERSION" = "X" ]
then
  echo 'ERROR: Failed to find version number!'
  echo 'Make sure to call this script in the correct directory!'
  exit 1
fi

# Create HOME/rpmbuild directory if not yet present
if [ ! -d ${HOME}/rpmbuild ]
then
  mkdir -p ${HOME}/rpmbuild
  chmod 755 ${HOME}/rpmbuild
fi

# Create subdirectories of HOME/rpmbuild if not yet present
for i in BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
do
  if [ ! -d ${HOME}/rpmbuild/${i} ]
  then
    mkdir -p ${HOME}/rpmbuild/${i}
    chmod 755 ${HOME}/rpmbuild/${i}
  fi
done

# Copy source tarball to HOME/rpmbuild/SOURCES
if [ -f ../dktools-${VERSION}.tar.gz ]
then
  cp ../dktools-${VERSION}.tar.gz ${HOME}/rpmbuild/SOURCES
else
  echo 'ERROR: File' ../dktools-${VERSION}.ta.gz 'not found!'
  exit 1
fi

# Copy *.spec file to HOME/rpmbuild/SPECS
if [ -f dktools-el6.spec ]
then
  cp dktools-el6.spec ${HOME}/rpmbuild/SPECS/dktools-el6.spec
  chmod 644 ${HOME}/rpmbuild/SPECS/dktools-el6.spec
else
  echo 'ERROR: File dktools-el6.spec not found!'
  exit 1
fi

# Build RPM file
cd ${HOME}/rpmbuild/SPECS
rpmbuild -ba dktools-el6.spec 2>&1 | tee errors

# Some final notes
echo ''
ls ${HOME}/rpmbuild/RPMS/*/dktools-*${VERSION}*.rpm
echo ''
echo 'If the previous command succeeded, you find your *.rpm files'
echo "in a subdirectory of the the ${HOME}/rpmbuild/RPMS directory."
echo 'If the rpmbuild command showed errors, make sure to run the'
echo 'sl6-prepare.sh script as root before running this one.'
echo ''