-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdist.sh
executable file
·49 lines (42 loc) · 1.42 KB
/
dist.sh
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
#!/bin/bash
# dist.sh
# Author: Tom "spot" Callaway <[email protected]>
# License: GPL
# This is a script to output the value for the %{dist}
# tag. The dist tag takes the following format: .$type$num
# Where $type is one of: el, fc, rh
# (for RHEL, Fedora Core, and RHL, respectively)
# And $num is the version number of the distribution.
# NOTE: We can't detect Rawhide or Fedora Test builds properly.
# If we successfully detect the version number, we output the
# dist tag. Otherwise, we exit with no output.
RELEASEFILE=/etc/meego-release
function check_num {
MAINVER=`cut -d "(" -f 1 < $RELEASEFILE | \
sed -e "s/[^0-9.]//g" -e "s/$//g" | cut -d "." -f 1`
echo $MAINVER | grep -q '[0-9]' && echo $MAINVER
}
function check_meego {
grep -q MeeGo $RELEASEFILE && echo $DISTNUM
}
DISTNUM=`check_num`
DISTMOB=`check_meego`
if [ -n "$DISTNUM" ]; then
if [ -n "$DISTMOB" ]; then
DISTTYPE=meego
fi
fi
[ -n "$DISTTYPE" -a -n "$DISTNUM" ] && DISTTAG=".${DISTTYPE}${DISTNUM}"
case "$1" in
--meego) echo -n "$DISTMOB" ;;
--distnum) echo -n "$DISTNUM" ;;
--disttype) echo -n "$DISTTYPE" ;;
--help)
printf "Usage: $0 [OPTIONS]\n"
printf " Default mode is --dist. Possible options:\n"
printf " --meego\t\tfor MeeGo version\n"
printf " --dist\t\tfor distribution tag\n"
printf " --distnum\tfor distribution number (major)\n"
printf " --disttype\tfor distribution type\n" ;;
*) echo -n "$DISTTAG" ;;
esac