]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - builder.sh
6dbc356f176296452065f6375f315e5a0f5ad5ad
[packages/rpm-build-tools.git] / builder.sh
1 #!/bin/bash
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=""
14 LOGFILE=""
15
16 PATCHES=""
17 SOURCES=""
18 ICON=""
19 PACKAGE_RELEASE=""
20 PACKAGE_VERSION=""
21 PACKAGE_NAME=""
22
23 usage()
24 {
25 echo "\
26 Usage: builder [-V] [--version] [-a] [--as_anon] [-b] [--build]
27         [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
28         [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet] 
29         [-v] [--verbose] <package>.spec
30
31         -V, --version   - output builder version
32         -a, --as_anon   - get files via pserver as cvs@cvs.pld.org.pl,
33         -b, --build     - get all files from CVS repo and build
34                           package from <package>.spec,
35         -d, --cvsroot   - setup \$CVSROOT,
36         -g, --get       - get <package>.spec and all relayted files from
37                           CVS repo,
38         -h, --help      - this message,
39         -l, --logtofile - log all to file,
40         -q, --quiet     - be quiet,
41         -v, --verbose   - be verbose,
42
43 "
44 }
45
46 parse_spec()
47 {
48     sed -e "s/^Summary:*/Summary:\%dump/I" $SPECFILE > $SPECFILE.__
49
50     SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'`"
51     PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'`"
52     ICON="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/^Icon:/ {print $2}' ${SPEC}`"
53     PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
54     PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
55     PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
56
57     rm -f $SPECFILE.__
58
59     if [ "$BE_VERBOSE" != "" ]; then
60         echo -e "- Sources :\n  " $SOURCES
61         echo -e "- Patches :\n  " $PATCHES
62         if [ "$ICON" != "" ]; then
63             echo -e "- Icon    :\n  " $ICON
64         else
65             echo -e "- Icon    :  *no package icon*"
66         fi
67         echo -e "- Name    : " $PACKAGE_NAME
68         echo -e "- Version : " $PACKAGE_VERSION
69         echo -e "- Release : " $PACKAGE_RELEASE
70     fi
71 }
72
73 get_spec()
74 {
75     echo "get_spec"
76 }
77
78 get_all_files()
79 {
80     echo "get_all_files"
81 }
82
83 build_package()
84 {
85     echo "build_package"
86 }
87
88 while test $# -gt 0 ; do
89     case "${1}" in
90         -V | --version )
91             COMMAND="version"; shift ;;
92         -a | --as_anon )
93             CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
94         -b | --build )
95             COMMAND="build"; shift ;;
96         -d | --cvsroot )
97             shift; CVSROOT="${1}"; shift ;;
98         -g | --get )
99             COMMAND="get"; shift ;;
100         -h | --help )
101             COMMAND="usage"; shift ;;
102         -l | --logtofile )
103             shift; LOGFILE="${1}"; shift ;;
104         -q | --quiet )
105             QUIET="1"; shift ;;
106         -v | --verbose )
107             BE_VERBOSE="1"; shift ;;
108         * )
109             SPECFILE="${1}"; shift ;;
110     esac
111 done
112
113 case "$COMMAND" in
114     "build" )
115         if [ "$SPECFILE" != "" ]; then
116             get_spec;
117             parse_spec;
118             get_all_files;
119             build_package;
120         else
121             echo "ERROR: spec file name not specified.";
122             usage;
123         fi
124         ;;
125     "get" )
126         if [ "$SPECFILE" != "" ]; then
127             get_spec;
128             parse_spec;
129             get_all_files;
130         else
131             echo "ERROR: spec file name not specified.";
132             usage;
133         fi
134         ;;
135     "usage" )
136         usage;;
137     "version" )
138         echo "$VERSION";;
139 esac
This page took 0.027441 seconds and 2 git commands to generate.