-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·186 lines (149 loc) · 4.93 KB
/
install.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
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
#!/bin/sh -x
# ALT: /etc/rpm/macros.d
# Scientific: /etc/rpm/macros.name (who else?)
# suse asplinux RPM: macros
# DESTFILE=macros
# WARNING: we will override any /etc/rpm/macroses
# I do not know what the platfrom needs it.
#%if %{_vendor} == "redhat"
#DESTFILE=macros.%name
#%endif
buildroot=$1
bindir=$buildroot/$2
o_rpmmacrosdir=$3
rpmmacrosdir=$buildroot/$3
macroname=$4
pkgtype=$(bin/distr_vendor -p) || exit
[ -n "$pkgtype" ] || exit
distr=$(bin/distr_vendor -s) || exit
[ -n "$distr" ] || exit
version=$(bin/distr_vendor -v) || exit
[ -n "$version" ] || exit
archname=$(bin/distr_vendor -a) || exit
[ -n "$archname" ] || exit
# hack for a compatibility
[ "$archname" = "x86" ] && archname="i586"
echo "Distro: $distr, Version: $version, Pkg: $pkgtype, Arch: $archname"
mkdir -p $bindir $rpmmacrosdir
# See tests/get_macros_distro.sh
# vendor, arch, distro
get_macros_distro()
{
local REPLBASE=macros.distro/macros
local PKGVENDOR="$1"
local ARCH="$2"
local FINDPKG="$3"
local ARCHEXT=".$ARCH"
[ -z "$ARCH" ] && ARCHEXT=
if [ "$ARCH" = "x86_64" ] ; then
ls -1 $REPLBASE.$PKGVENDOR*.$ARCH 2>/dev/null | \
grep -v "$PKGVENDOR\.$ARCH\$"
echo "$REPLBASE.$FINDPKG.$ARCH"
else
ls -1 $REPLBASE.$PKGVENDOR* 2>/dev/null | \
grep -v "i586" | grep -v "x86_64" | grep -v "$PKGVENDOR\$"
echo "$REPLBASE.$FINDPKG"
fi | \
sort -u | sort -r -n -t . -k 4 | grep "^$REPLBASE.$FINDPKG$ARCHEXT$" -A1000 | sort -r -n -t . -k 4 | head -n2
}
# arch distro version
get_macros_distro_file()
{
local i
for i in $(get_macros_distro "$2" "$1" "$2.$3") ; do
test -r "$i" && echo "$i" && return
done
return 1
}
# Add files from param to DESTFILE
copy_macros()
{
local MI
for MI in $@ ; do
test -r "$MI" && echo "Applied $MI..." || { echo "Skipping $MI (missed)..." ; continue ; }
echo >>$DESTFILE
echo "# Included from file $MI" >>$DESTFILE
cat $MI >>$DESTFILE
done
}
# TODO: use fixbashisms project here
fixbashisms()
{
local DESTFILE="$1"
# FIXME: we need use bash in rpm for any case?
# for systems with ash as sh (f.i., Ubuntu)
bin/subst "s|pushd \(.*\)|cd \1|g" $DESTFILE
bin/subst "s|popd|cd - >/dev/null|g" $DESTFILE
}
copy_distro_macros()
{
local mfile
# Distro/version section. (f.i., .suse.10) or prev. version
mfile=$(get_macros_distro_file $archname $distr $version)
if [ -n "$mfile" ] ; then
copy_macros $mfile
else
mfile=$(get_macros_distro_file "" $distr $version)
copy_macros $mfile
fi
}
create_distr_vendor_macros()
{
local dname="$(bin/distr_vendor -d)" || exit
[ -n "$dname" ] || exit
cat <<EOF >macros.distr_vendor
# The distribution info how it was be retrieved via distro_info
%_distro_pkgtype $pkgtype
%_distro_name $dname
%_distro_version $version
EOF
}
if [ $distr = "alt" ] ; then
install -m755 bin/distr_vendor $bindir
DESTFILE=$rpmmacrosdir/etersoft-intro
create_distr_vendor_macros
copy_macros macros.distr_vendor
# new macros, introduced for ALT and other, but not applied
copy_macros macros.intro/macros.intro
# Copy base distro macros (f.i., .alt or alt.x86_64)
copy_macros macros.distro/macros.$distr macros.distro/macros.$distr.$archname
DESTFILE=$rpmmacrosdir/etersoft-intro-conflicts
# conflicts macros introduced for ALT
# copy base distro macros (f.i., .alt or alt.x86_64)
copy_macros macros.intro.conflicts/macros.$distr macros.intro.conflicts/macros.$distr.$archname
if [ "$version" = "Sisyphus" ] ; then
COMDESTFILE=$rpmmacrosdir/compat
echo "# This file have to be empty for ALT Linux Sisyphus" >> $COMDESTFILE
echo "# (see rpm-build-intro and rpm-macros-intro-conflicts packages for real macros)" >> $COMDESTFILE
echo "# Build at $(date)" >> $COMDESTFILE
else
fixbashisms $DESTFILE
# For ALT will put distro/version section in rpm-build-compat package
DESTFILE=$rpmmacrosdir/compat
# TODO: move to separate alt.p6 and so on (what will with non alt? - load it all)
copy_macros macros.intro/macros.intro.backport
# alt.p6 and so on
copy_distro_macros
fi
else
DESTFILE=$rpmmacrosdir/$macroname
# hack to set platform dependent macros dir
# check if it is supported
#bin/subst "s|^%_rpmmacrosdir.*|%_rpmmacrosdir $o_rpmmacrosdir|" macros.intro/macros.intro.backport
# Add macros copied from ALT's rpm-build-* packages
copy_macros macros.rpm-build/[0-9a-z]*
# new macros, introduced for ALT and other
copy_macros macros.intro/macros.intro
# ALT Linux only macros applied in ALT already (for ALT will add it in distro/version section)
copy_macros macros.intro/macros.intro.backport
# Copy pkgtype related ALT compatibility for other platform (f.i., .deb or .deb.x86_64)
[ "$pkgtype" = "deb" ] || [ "$pkgtype" = "rpm" ] || pkgtype="generic"
copy_macros macros.base/macros.compat macros.base/macros.$pkgtype macros.base/macros.$pkgtype.$archname
# Copy base distro macros (f.i., .suse or suse.x86_64)
copy_macros macros.distro/macros.$distr macros.distro/macros.$distr.$archname
# suse/11 and so on
copy_distro_macros
install -m755 bin/* $bindir
fi
fixbashisms $DESTFILE
ls -l $DESTFILE