File: configure

package info (click to toggle)
pdbv 2.0.10.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 436 kB
  • ctags: 52
  • sloc: perl: 1,004; sh: 291; makefile: 129
file content (381 lines) | stat: -rwxr-xr-x 13,695 bytes parent folder | download
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#!/bin/bash
# (c) 2002-2005 Mathieu Roy <yeupou@gnu.org>
# This file is part of package_db_view
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#  take a look at http://gna.org/projects/pdbv
#  send comments at <pdbv-dev@gna.org>
#
#  $Id: configure,v 1.84 2005/02/23 10:43:07 yeupou Exp $

BINFILE=pdbv
CRONFILE=pdbv.cron
RCFILE=pdbvrc
ACCESSFILE=pdbv.htaccess
MAKEFILE=Makefile
MAKEFILE_PO=po/Makefile
MAKEFILE_MAN=man/Makefile
MAKEFILE_CSS=css/Makefile
PREFIX=/usr/local
CRONDIR=/etc/cron.d
RCDIR=/etc/pdbv
unset PDBV_TYPE LIBINFO LIBINFO_INCLUDED NO_EXPR

# List of perl modules.
# Spaces will be understood as line-breaks. Use __ to add a real space.
USE_LIST="strict__\"vars\" Locale::gettext POSIX Getopt::Long Term::ANSIColor__qw(:constants) File::stat Sys::Hostname Tie::IxHash"


# Get options
GETOPT_TEMP=`getopt -o hpbt --long help,prefix:,type:,build-only, \
     -n configure -- "$@"`
eval set -- "$GETOPT_TEMP"

while true ; do
    case "$1" in
	-p|--prefix) PREFIX="$2" ; shift 2 ;;
	-t|--type) FORCE_TYPE="$2" ; shift 2 ;;
	-b|--build-only) BUILD_ONLY=1 ; shift ;;
	-h|--help) HELP=1 ; break ;;
	*) break ;;
    esac
done


# show help
if [ $HELP ] ; then
        echo "options:"
        echo "  --prefix=\$PREFIX    installation prefix (default $PREFIX)"
        echo "  --type=\$TYPE        rpm or dpkg (default test)"
        exit
fi


# TESTS

item="package_db_view version"
  echo -n "checking for $item... "
  VERSION=`cat modules/initvars.pl | grep "sver = \"" | awk '{ print $4 }' | sed s/\"//g | sed s/\;//g`
  if [ "$VERSION" ]; then
      echo "$VERSION"
  else
      echo "not_understood"
  fi

# on Debian sid and woody, which doesnt support --skip-alias
# blocker
item=which
WHICH_PATH="/bin/which /usr/bin/which /usr/local/bin/which"
WHICH=""
  echo -n "checking for $item... "
  for WHICH_TEST in $WHICH_PATH; do
          if [ -x $WHICH_TEST ]; then
                  if $WHICH_TEST --version 2>&1 | grep -q "GNU which"; then
		      WHICH=$WHICH_TEST
		      which_option="--skip-alias"
		      echo "yes (GNU which)"
		      break
                  else
		      WHICH=$WHICH_TEST
		      echo "yes (non-gnu which)"
		      break
		  fi
          fi
  done  
  if [ ! $WHICH ]; then
          echo no
          echo "You are encouraged to download GNU which from ftp.gnu.org"
          exit
  fi

# If a blocker item is not found, we exit here.
BLOCKER_ITEM_LIST="perl install make gettext free uname awk"
for item in $BLOCKER_ITEM_LIST; do
  echo -n "checking for $item... "
  bin_item=`$WHICH $which_option $item 2>&1`
  if [ ! -x "$bin_item" ]; then 
      echo "no" 
      if [ ! $BUILD_ONLY ] ; then exit ; fi
  else 
      echo "yes"
  fi

done


item=gzip
  echo -n "checking for $item... "
  item=`$WHICH $which_option $item 2>&1`
  if [ ! -x "$item" ]; then echo "no" && NO_EXPR=1 ; else echo "yes" ; fi

# Database related
item=rpm
  echo -n "checking for $item... "
  item=`$WHICH $which_option $item 2>&1`
  if [ ! -x "$item" ]; then echo "no" ; else echo "yes" && PDBV_TYPE=rpm ; fi

item=dpkg
  echo -n "checking for $item... "
  item=`$WHICH $which_option $item 2>&1`
  if [ ! -x "$item" ]; then echo "no" ; else echo "yes" && PDBV_TYPE=dpkg ; fi
item=/var/lib/dpkg
  echo -n "checking whether $item exists... "
  if [ ! -e "$item" ]; then echo "no" ; else echo "yes" && DPKG_DIR=$item ; fi

# Blocker one more time - test issues from previous tests
if [ $PDBV_TYPE != "rpm" ] && [ $PDBV_TYPE != "dpkg" ]; then
  echo "Well, currently only RPM and dpkg are supported. Take a look at modules/rpm.sh, you maybe could do a similar file to support your package manager database :P"
  exit
fi
if [ $FORCE_TYPE ] ; then
    PDBV_TYPE=$FORCE_TYPE
fi
echo "selected package manager... $PDBV_TYPE"
if [ $PDBV_TYPE == "dpkg" ] && [ ! $DPKG_DIR ]; then
  echo "We have been unable to find informations about your database,"
  echo "usually found in /var/lib/dpkg"
  echo "Please, type the correct directory"
  read item
  echo -n "checking if $item exists... "
  if [ ! -e "$item" ]; then echo "no" && exit ; else echo "yes" && DPKG_DIR=$item ; fi
fi
    


# We create the "bin" file.
  echo -n "creating $BINFILE... "
  rm -f $BINFILE && touch $BINFILE

  # Headers.
  echo "#!`which perl`" > $BINFILE
  echo "# Copyright (c) 2002-2005 Mathieu Roy <yeupou@gnu.org>" >> $BINFILE
  echo "# This file is part of Package DataBase View" >> $BINFILE
  echo "# This file was generated `date`" >> $BINFILE
  echo "#" >> $BINFILE
  
  # Full authors list.
  echo "# FULL AUTHORS LIST:" >> $BINFILE
  cat AUTHORS | fmt -w 65 | sed s/^/"#     "/g >> $BINFILE
  echo "#" >> $BINFILE

  # Full GNU GPL
  echo "# LICENSE:" >> $BINFILE
  cat COPYING | fmt -w 65 | sed s/^/"#     "/g >> $BINFILE

  # Pointers.
  echo "#" >> $BINFILE
  echo "#  take a look at http://gna.org/projects/pdbv" >> $BINFILE
  echo "#  send comments at <pdbv-dev@gna.org>" >> $BINFILE
  echo "#  --\"read-only\" script, checkout the CVS tree or a tarball--" >> $BINFILE
  echo "#  --if you want to modify it with ease--" >> $BINFILE

  # Base configuration.
  for use in $USE_LIST; do
      use=`echo $use | sed s/__/\ /g`
      echo "use $use;" >> $BINFILE
  done
  echo "setlocale(LC_ALL, \"\");" >> $BINFILE
#  echo "bindtextdomain(\"$PREFIX/share/locale\");"  >> $BINFILE
  echo "textdomain(\"pdbv\");"  >> $BINFILE
  echo "our \$pdbv_type = \"$PDBV_TYPE\";" >> $BINFILE
  echo "our \$dpkg_dir=\"$DPKG_DIR\";" >> $BINFILE

  # Insertion of important modules.
  MODULES_ITEM_LIST="modules/initvars.pl modules/$PDBV_TYPE.pl modules/sysinfo.pl  modules/xhtml.pl core.pl"
# core.sh must be included at the end
  for item in $MODULES_ITEM_LIST; do
      cat -s $item | sed s/"print \"The purpose of this file is not being executed alone\"\;"//g | sed s/"exit\;"//g  | sed /^#.*$/d | sed /^$/d >> $BINFILE
  done
  echo "# end" >> $BINFILE
  chmod +x $BINFILE
  echo "done"

# we create the cronfile 
#
# /dev/null instead of &1
# see http://savannah.nongnu.org/bugs/?func=detailbug&bug_id=2691&group_id=2348
echo -n "creating $CRONFILE... "
echo "# May run on a daily basis (prefered for pdbv 1.x.x)." > $CRONFILE
echo "20 15 * * *  nobody  $PREFIX/bin/pdbv --cron=daily" >> $CRONFILE
echo " " >> $CRONFILE
echo "# May run on a hourly basis (prefered for pdbv 2.x.x)." >> $CRONFILE
echo "32 * * * *   nobody  $PREFIX/bin/pdbv --cron=hourly" >> $CRONFILE
echo " " >> $CRONFILE
echo "# Once per week, regenerate the whole output without tests." >> $CRONFILE
echo "# Can be useful in regard of pop-con results, or because" >> $CRONFILE
echo "# it happens that a package is replaced by a package of the" >> $CRONFILE
echo "# exact same version." >> $CRONFILE
echo "05 18 * * 1   nobody  $PREFIX/bin/pdbv --cron=daily --force" >> $CRONFILE
echo "05 18 * * 1   nobody  $PREFIX/bin/pdbv --cron=hourly --force" >> $CRONFILE
echo " " >> $CRONFILE
echo "done"


# we create the rcfile
echo -n "creating $RCFILE... "
echo "#!`which perl`" > $RCFILE
echo "###" >> $RCFILE
echo "### Sample pdbv initialization file .pdbvrc" >> $RCFILE
echo "###" >> $RCFILE
echo " " >> $RCFILE
echo "## You can use this file to change the default behaviour of pdbv or to" >> $RCFILE
echo "## avoid having to type many many command-line options." >> $RCFILE
echo "##" >> $RCFILE
echo "## pdbv initialization file can reside in /etc/pdbvrc" >> $RCFILE
echo "## (global, for all users) or \$HOME/.pdbvrc (for a single user)." >> $RCFILE
echo "##" >> $RCFILE
echo "## To use the settings in this file, you will have to uncomment them," >> $RCFILE
echo "## as well as change them, in most cases, as the values on the" >> $RCFILE
echo "## commented-out lines are the default values (e.g. \"off\")." >> $RCFILE
echo "##" >> $RCFILE
echo "## IMPORTANT SECURITY NOTE." >> $RCFILE
echo "## Note that this file should be execute-only for mosts users." >> $RCFILE
echo "## Only the user that actually configure the whole system should" >> $RCFILE
echo "## be able to edit. Pdbv get it's configuration by running this file." >> $RCFILE
echo "## While it offers the incredible advantages to avoid creating a boring" >> $RCFILE
echo "## config parser and to permit hackers to create very efficient config" >> $RCFILE
echo "## by using perl, if anybody can edit it, anybody can push pdbv to " >> $RCFILE
echo "## execute malicious code at start..."  >> $RCFILE
echo "## (But it's like a /etc/profile ... /etc is for admins)."  >> $RCFILE
echo "## (Default mode is 0711 for this file)."  >> $RCFILE
echo " " >> $RCFILE
echo "# Listing type." >> $RCFILE
echo "\$listing=\"all\";" >> $RCFILE
echo " " >> $RCFILE
echo "# Light - will generate faster a way less polished output." >> $RCFILE
echo "# (for instance, the listing will be reset to basic)" >> $RCFILE
echo "\$light=\"0\";" >> $RCFILE
echo " " >> $RCFILE
echo "# Output directory" >> $RCFILE
echo "\$output_dir=\"/var/www/pdbv\";" >> $RCFILE
echo " " >> $RCFILE
echo "# Run pdbv by cron on which basis: hourly/daily/no" >> $RCFILE
echo "# (no means no running pdbv via cron)" >> $RCFILE
echo "\$cron=\"hourly\";" >> $RCFILE
echo " " >> $RCFILE
echo "# You can modify the default.css or, better, you can create a new" >> $RCFILE
echo "# one. With this option, you can select with file will be used." >> $RCFILE
echo "\$css=\"/etc/pdbv/default.css\";" >> $RCFILE
echo " " >> $RCFILE
echo "# For a reason I ignore sometimes, cron ignore LC and LANG settings" >> $RCFILE
echo "# With this setting you can force usage of a LANG when run by cron" >> $RCFILE
echo "#\$cron_lang=\"fr_FR\";" >> $RCFILE
echo " " >> $RCFILE
echo "# Force. Do not performs tests, regenerate the whole output everytime" >> $RCFILE
echo "# Set this to 1 if you prefer keeping data always up to date, even if" >> $RCFILE
echo "# it means making pdbv slower." >> $RCFILE
echo "# The default behavior is to run in force mode only once per week." >> $RCFILE
echo "#\$force=\"0\";" >> $RCFILE
echo " " >> $RCFILE
echo "# Debug messages." >> $RCFILE
echo "#\$debug=\"0\";" >> $RCFILE
echo " " >> $RCFILE
echo "done"

# we create the accessfile
echo -n "creating $ACCESSFILE... "
echo "## Uncomment the following if you want the pdbv output to be" > $ACCESSFILE 
echo "## only accessible from the same computer (127.0.0.1) or from the" >> $ACCESSFILE
echo "## local network (assuming it's 192.168.1)." >> $ACCESSFILE
echo "## See the apache manual for more advanced configuration."  >> $ACCESSFILE
echo "##" >> $ACCESSFILE
echo "## Edit /etc/pdbv/htaccess !" >> $ACCESSFILE
echo "#Order Deny,Allow" >> $ACCESSFILE
echo "#Allow from 127.0.0.1 192.168.1" >> $ACCESSFILE
echo "#Deny from All" >> $ACCESSFILE
echo " " >> $ACCESSFILE
echo "done"

# we update makefiles
echo -n "updating $MAKEFILE_PO... "
echo "prefix=$PREFIX" > $MAKEFILE_PO
echo "INSTALLNLSDIR=\$(prefix)/share/locale" >> $MAKEFILE_PO
cat $MAKEFILE_PO.in >> $MAKEFILE_PO
echo "done"

echo -n "updating $MAKEFILE_MAN... "
echo "prefix=$PREFIX" > $MAKEFILE_MAN
echo "INSTALLMANDIR=\$(prefix)/share/man" >> $MAKEFILE_MAN
cat $MAKEFILE_MAN.in >> $MAKEFILE_MAN
echo "done"

echo -n "updating $MAKEFILE_CSS... "
echo "rcdir=$RCDIR" >> $MAKEFILE_CSS
cat $MAKEFILE_CSS.in >> $MAKEFILE_CSS
echo "done"

# now we create the general makefile
echo -n "creating $MAKEFILE... "
rm -f $MAKEFILE && touch $MAKEFILE


###################################
###################################

## set prefix
echo "prefix=$PREFIX" >> $MAKEFILE
echo "crondir=$CRONDIR" >> $MAKEFILE
echo "rcdir=$RCDIR" >> $MAKEFILE

## make all
echo "all:" >> $MAKEFILE
echo "	cd po && make" >> $MAKEFILE
echo "	@echo  " >> $MAKEFILE
echo "	@echo now, as root, type make install" >> $MAKEFILE

## make install
echo "install:" >> $MAKEFILE
echo "	install $BINFILE \$(prefix)/bin" >> $MAKEFILE
echo "	if [ ! -e \$(rcdir) ]; then mkdir \$(rcdir); fi" >> $MAKEFILE
echo "	install --mode=644 $CRONFILE \$(crondir)/`basename $CRONFILE .cron`" >> $MAKEFILE
echo "	install --mode=644 $ACCESSFILE \$(rcdir)/htaccess" >> $MAKEFILE
echo "	install --mode=711 $RCFILE \$(rcdir)/$RCFILE" >> $MAKEFILE
echo "	cd css && make install" >> $MAKEFILE
echo "	cd po && make install" >> $MAKEFILE
echo "	cd man && make install" >> $MAKEFILE
echo " " >> $MAKEFILE

##  po
echo "new-potfile:" >> $MAKEFILE
echo "	cd po && make new-pot-file-i-really-mean-it"  >> $MAKEFILE
echo "	cd debian && debconf2pot"  >> $MAKEFILE
echo " " >> $MAKEFILE
echo "update-po:" >> $MAKEFILE
echo "	cd po && make update-po"  >> $MAKEFILE
echo "	cd debian && debconf-updatepo" >> $MAKEFILE
echo " " >> $MAKEFILE


## make dist
## Must be made by dpkg-buildpackage
echo "dist:" >> $MAKEFILE
echo "	@if [ \"\$(rel)\" == \"\" ] ; then echo \"PLEASE give the release version as arg, like rel=1.0.0. Now exit with Ctrl-C\" && sleep 10m; fi" >> $MAKEFILE
echo "	cd .. && tar cfz pdbv-\$(rel).tar.gz pdbv && gpg --detach pdbv-\$(rel).tar.gz" >> $MAKEFILE
echo "	dpkg-buildpackage -rfakeroot">> $MAKEFILE
echo " " >> $MAKEFILE

echo " done"


## make clean
echo "clean:" >> $MAKEFILE
echo "	cd po && make clean" >> $MAKEFILE
echo "	rm -f $BINFILE $MAKEFILE $MAKEFILE_PO $MAKEFILE_MAN $MAKEFILE_CSS $CRONFILE $ACCESSFILE $RCFILE" >> $MAKEFILE
echo "	find . \( -name \"#*#\" -or -name \".#*\" -or -name \"*~\" -or -name \".*~\" \) -exec rm -f {} \;"  >> $MAKEFILE
echo " " >> $MAKEFILE

echo " done"



## help

echo " "
echo "now, type make"