Whamcloud - gitweb
cce4e56ea2dabb0200d630f5d3f3c4c6cd10a484
[fs/lustre-release.git] / contrib / lbuild / lbuild-sles12
1 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
2
3 # increment this if you have made a change that should force a new kernel
4 # to build built for this distribution (only -- if you want to force a kernel
5 # build on all distributions, update the BUILD_GEN variable in build/lbuild)
6 BUILD_GEN+=".0"
7
8 # This distro does not support zfs, so define WITH_ZFS
9 # use words that make the bash log readable.
10 WITH_ZFS="Zfs Not Supported"
11
12 source ${LBUILD_DIR}/lbuild-sles
13
14 kernel_srpm_location() {
15
16     local site="http://mgmt/cobbler/repo_mirror/updates-sles12.1-src"
17     echo "$site/src/"
18
19 }
20
21 edit_specs() {
22
23     # edit the SPECs with our changes
24     local spec
25     (cd $TOPDIR/SOURCES; ./mkspec --release ${lnxrel})
26     for spec in $RPMSMPTYPE source; do
27         #cp $TOPDIR/SOURCES/kernel-$spec.spec{,.orig}
28         sed -i -e "s/^\(Release: *\).*$/\1${lnxrel}_${buildid}/" \
29                -e '/^%setup /a\
30 cp  %_sourcedir/linux-3.12-lustre.patch %_builddir/%{name}-%{version}/lustre.patch\
31 ! grep -q lustre.patch %_sourcedir/series.conf && echo -e "\\n\\tlustre.patch" >> %_sourcedir/series.conf' \
32           SOURCES/kernel-${spec}.spec || \
33             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
34
35         if $KERNEL_LUSTRE_NAMING; then
36             # these are all of the changes needed because we change the package names
37             # to kernel-lustre-*.  these should all go away when we stop this insanity
38             sed -i -e 's/^\(Name:.*kernel-\)\(.*\)/\1lustre-\2/' \
39                    -e "/^Provides:  *kernel = /a\
40 Provides:       kernel-$spec = %{version}-%{release}
41 " \
42                    -e 's/^\([   ][      ]*-i %_builddir\/kernel-\)\(source-2.6.27.21\/\$patch; then\)/\1lustre-\2/' \
43                    -e '/^%build/,/^%changelog/s/\(kernel-\)\(source\.files\)/\1lustre-\2/g' \
44                    -e '/--no-backup-if-mismatch/,/fi/s/kernel-source-/kernel-lustre-source-/g' \
45                    -e "s/^\(%package -n kernel-\)\(.*\)/\1lustre-\2/" \
46                    -e "s/^\(%description -n kernel-\)\(.*\)/\1lustre-\2/" \
47                    -e "s/^\(%files -n kernel-\)\(.*\)/\1lustre-\2/" \
48                    -e "s/^\(Provides:.*kernel-\)\(.*\)/\1lustre-\2/" \
49                    -e "s/^\(Requires:.*kernel-\)\(.*\)/\1lustre-\2/" \
50                    -e "s/^\(Supplements:.*kernel-\)\(.*\)/\1lustre-\2/" \
51                 SOURCES/kernel-${spec}.spec || \
52                 fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
53         fi
54
55         # XXX - a building-on-Ubuntu hack
56         if grep -q "Ubuntu" /etc/issue; then
57             sed -i -e '/^%_sourcedir\/install-configs %_sourcedir .*/i\
58 curl ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.17/2.6.17-mm1/broken-out/i386-use-c-code-for-current_thread_info.patch | patch -p1' \
59                    -e 's/^\(BuildRequires: .*\)$/#NOU \1/g' \
60                    -e 's/%(\(chmod .*\))$/%(bash -c "\1")/' \
61                    -e 's/ -a 109//' \
62               SOURCES/kernel-${spec}.spec || \
63             fatal 1 "Error while editing SOURCES/kernel-${spec}.spec"
64         fi
65     done
66 }
67
68 unpack_linux_devel_rpm-sles12() {
69     local callers_rpm="$1"
70
71     local rpmdir="${callers_rpm%/*}"
72
73     local kernelrpm
74     local wanted_kernel="${lnxmaj}${lnxmin}-${lnxrel}"
75
76     # this is a hack that should go away when the modified lustre kernel
77     # Provides kernel-default-devel                       vvvvvvvvv
78     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?default-devel = $wanted_kernel"); then
79         fatal 1 "Could not find the kernel-default-devel in $rpmdir/"
80     fi
81
82     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
83         fatal 1 "Unpack error for $kernelrpm"
84     fi
85
86     if [ -d "${rpmdir}/../noarch" ]; then
87         rpmdir="${rpmdir%/*}"
88         rpmdir="${rpmdir}/noarch"
89     fi
90
91     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-(lustre-)?devel = $wanted_kernel"); then
92         fatal 1 "Could not find the kernel-devel in $rpmdir/"
93     fi
94
95     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
96         fatal 1 "Unpack error for $kernelrpm"
97     fi
98
99     # SLES also needs the kernel-source together with the kernel-default-devel
100     if ! kernelrpm=$(find_rpm "$rpmdir" provides "^kernel-source = $wanted_kernel"); then
101         fatal 1 "Could not find the kernel-source in $rpmdir/"
102     fi
103
104     if ! rpm2cpio < "$rpmdir/$kernelrpm" | cpio -id > /dev/null 2>&1; then
105         fatal 1 "Unpack error for $kernelrpm"
106     fi
107
108 }
109
110 find_linux_rpm-sles12() {
111     local prefix="$1"
112     local wanted_kernel="$2"
113     local pathtorpms=${3:-"$KERNELRPMSBASE/$lnxmaj/$DISTROMAJ/$TARGET_ARCH"}
114
115     local site="http://mgmt/cobbler/repo_mirror/updates-sles12.1-x86_64"
116     if [ ! -f $pathtorpms/kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm ]; then
117         fetch_url "$site/x86_64/kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm" $pathtorpms
118     fi
119     # SLES 12 also needs kernel-devel in addition to kernel-default-devel
120     if [ ! -f $pathtorpms/kernel-devel-$wanted_kernel.noarch.rpm ]; then
121         fetch_url "$site/noarch/kernel-devel-$wanted_kernel.noarch.rpm" $pathtorpms
122     fi
123     # SLES also needs the kernel-source along with kernel-devel
124     if [ ! -f $pathtorpms/kernel-source-$wanted_kernel.noarch.rpm ]; then
125         fetch_url "$site/noarch/kernel-source-$wanted_kernel.noarch.rpm" $pathtorpms
126     fi
127     echo "kernel-default-devel-$wanted_kernel.$(resolve_arch $TARGET_ARCH).rpm"
128
129     return 0
130
131 }