]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - builder.sh
- exit 1 if error
[packages/rpm-build-tools.git] / builder.sh
1 #!/bin/bash -xv
2
3
4 VERSION="\
5 Build package utility from PLD CVS repository
6 V 0.1 (C) 1999 Tomasz K³oczko".
7
8 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
9
10 SPECFILE=""
11 BE_VERBOSE=""
12 QUIET=""
13 CVSROOT=${CVSROOT:-""}
14 LOGFILE=""
15
16 PATCHES=""
17 SOURCES=""
18 ICON=""
19 PACKAGE_RELEASE=""
20 PACKAGE_VERSION=""
21 PACKAGE_NAME=""
22
23 dumb_spec="\
24 Summary:        -
25 Name:           dumb
26 Version:        dumb
27 Release:        dumb
28 Copyright:      dumb
29 Group:          -
30 %description
31
32 %prep
33 echo SOURCE_DIR=%{_sourcedir}
34 echo SPECS_DIR=%{_specdir}"
35
36 #---------------------------------------------
37 # functions
38
39 usage()
40 {
41 echo "\
42 Usage: builder [-V] [--version] [-a] [--as_anon] [-b] [--build]
43         [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
44         [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet] 
45         [-v] [--verbose] <package>.spec
46
47         -V, --version   - output builder version
48         -a, --as_anon   - get files via pserver as cvs@cvs.pld.org.pl,
49         -b, --build     - get all files from CVS repo and build
50                           package from <package>.spec,
51         -d, --cvsroot   - setup \$CVSROOT,
52         -g, --get       - get <package>.spec and all relayted files from
53                           CVS repo,
54         -h, --help      - this message,
55         -l, --logtofile - log all to file,
56         -q, --quiet     - be quiet,
57         -v, --verbose   - be verbose,
58
59 "
60 }
61
62 parse_spec()
63 {
64     sed -e "s/^Summary:*/Summary:\%dump/I" $SPECFILE > $SPECFILE.__
65
66     SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'`"
67     PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'`"
68     ICON="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/^Icon:/ {print $2}' ${SPEC}`"
69     PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
70     PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
71     PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
72
73     rm -f $SPECFILE.__
74
75     if [ "$BE_VERBOSE" != "" ]; then
76         echo -e "- Sources :\n  " $SOURCES
77         echo -e "- Patches :\n  " $PATCHES
78         if [ "$ICON" != "" ]; then
79             echo -e "- Icon    :\n  " $ICON
80         else
81             echo -e "- Icon    :  *no package icon*"
82         fi
83         echo -e "- Name    : " $PACKAGE_NAME
84         echo -e "- Version : " $PACKAGE_VERSION
85         echo -e "- Release : " $PACKAGE_RELEASE
86     fi
87
88     DUMB_SPEC_FILE=`mktemp -q /tmp/bilder.XXXXXX`
89     echo $dumb_spec > $DUMB_SPEC_FILE
90     `rpm -bp $DUMB_SPEC_FILE | egrep -e "SOURCE_DIR|SPECS_DIR"`
91     rm -f $DUMB_SPEC_FILE
92
93 }
94
95 get_spec()
96 {
97     echo "get_spec"
98 }
99
100 get_all_files()
101 {
102     echo "get_all_files"
103 }
104
105 build_package()
106 {
107     echo "build_package"
108 }
109
110
111 #---------------------------------------------
112 # main()
113
114 if [ "$#" == 0 ]; then
115     usage;
116     exit 1
117 fi
118
119 while test $# -gt 0 ; do
120     case "${1}" in
121         -V | --version )
122             COMMAND="version"; shift ;;
123         -a | --as_anon )
124             CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
125         -b | --build )
126             COMMAND="build"; shift ;;
127         -d | --cvsroot )
128             shift; CVSROOT="${1}"; shift ;;
129         -g | --get )
130             COMMAND="get"; shift ;;
131         -h | --help )
132             COMMAND="usage"; shift ;;
133         -l | --logtofile )
134             shift; LOGFILE="${1}"; shift ;;
135         -q | --quiet )
136             QUIET="1"; shift ;;
137         -v | --verbose )
138             BE_VERBOSE="1"; shift ;;
139         * )
140             SPECFILE="${1}"; shift ;;
141     esac
142 done
143
144 case "$COMMAND" in
145     "build" )
146         if [ "$SPECFILE" != "" ]; then
147             get_spec;
148             parse_spec;
149             get_all_files;
150             build_package;
151         else
152             echo "ERROR: spec file name not specified.";
153             usage;
154             exit 1;
155         fi
156         ;;
157     "get" )
158         if [ "$SPECFILE" != "" ]; then
159             get_spec;
160             parse_spec;
161             get_all_files;
162         else
163             echo "ERROR: spec file name not specified.";
164             usage;
165             exit 1;
166         fi
167         ;;
168     "usage" )
169         usage;;
170     "version" )
171         echo "$VERSION";;
172 esac
This page took 0.034064 seconds and 4 git commands to generate.