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