-
Notifications
You must be signed in to change notification settings - Fork 0
/
arepo-init.sh
executable file
·163 lines (145 loc) · 4.34 KB
/
arepo-init.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
#!/bin/sh -efu
. gear-sh-functions
pkgs=
vers=
specfile=
hshopts='-q'
hshroot='/opt/builds/tmp'
hshrepo='/opt/builds/tmp/repo'
arepo_mode='lib'
pkgsdir='/ALT'
pkg_keep=
show_help() {
cat <<EOF
Usage: $PROG [options] <pkgs...>
Options:
-r, --release=RELEASE version to build, default is taken from .gear .spec;
--hsh-options=<OPTS> hasher initroot options;
--hsh-root=<PATH> hasher initroot location;
--hsh-repo=<PATH> hasher result repo location;
--arepo-mode=(lib|prog) arepo build mode;
--pkgsdir=<PATH> donor repo location;
--keep keep existing pkg versions;
-V, --version print program version and exit;
-h, --help show this text and exit.
EOF
exit
}
print_version() {
cat <<EOF
$PROG version $PROG_VERSION
Written by Konstantin Lepikhov <[email protected]>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit
}
# packages without native conflicts
native_packages="^wine-(staging|vanilla)$|^steam$"
TEMP=`getopt -n $PROG -o 'r:,o:h,V' -l 'release:,hsh-options:,hsh-root:,hsh-repo:,arepo-mode:,pkgsdir:,keep,help,version' -- "$@"` ||
show_usage
eval set -- "$TEMP"
while :; do
case "$1" in
-r|--release) shift; vers="$1"
;;
-o|--hsh-options) shift; hshopts="$1"
;;
--hsh-root) shift; hshroot="$1"
;;
--hsh-repo) shift; hshrepo="$1"
;;
--arepo-mode) shift; arepo_mode="$1"
;;
--pkgsdir) shift; pkgsdir="$1"
;;
--keep) pkg_keep=1
;;
-h|--help) show_help
;;
-V|--version) print_version
;;
--) shift; break
;;
esac
shift
done
case "$arepo_mode" in
lib|prog)
;;
*) fatal 'Invalid arepo mode, should either prog or lib!'
;;
esac
pkgs="${@:-}"
arepo="$hshrepo/x86_64-i586"
vers_orig=
[ -n "$pkgs" ] || show_usage
if [ -z "$vers" ]; then
guess_specfile
[ -s "$specfile" ] ||
fatal 'No specfile found.'
get_NVR_from_spec "$specfile"
pkg_name="$spec_name"
pkg_epoch="$spec_epoch"
pkg_version="$spec_version"
pkg_release="$spec_release"
vers="$pkg_version-$pkg_release"
fi
i386 hsh "$hshopts" --init --target=i586 --apt-config=/home/lakostis/Documents/apt.conf.i586 "$hshroot"
hsh-install "$hshopts" "$hshroot" rpmrebuild-arepo && \
xzcat "$pkgsdir"/Sisyphus/files/list/arepo-x86_64-i586.list.xz > "$hshroot"/chroot/.in/arepo-x86_64-i586.list
if [ -n "$pkgs" ]; then
for pkg in $pkgs; do
for arch in x86_64 i586; do
if [ "$arch" == "x86_64" ]; then
printf '%s' $pkg | egrep -qs "$native_packages" && continue
fi
if [ "$pkg" != "${pkg%%=*}" ]; then
vers_orig="$vers"
vers=${pkg##*=}
pkg=${pkg%%=*}
fi
if [ -s "$hshroot"/repo/$arch/RPMS.hasher/$pkg-$vers.$arch.rpm ]; then
cp -a "$hshroot"/repo/$arch/RPMS.hasher/$pkg-$vers.$arch.rpm "$hshroot"/chroot/.in/
elif [ -n "$hshrepo" -a "${hshrepo##/repo}" != "$hshroot" ]; then
[ -s "$hshrepo"/$arch/RPMS.hasher/$pkg-$vers.$arch.rpm ] && \
cp -a "$hshrepo"/$arch/RPMS.hasher/$pkg-$vers.$arch.rpm "$hshroot"/chroot/.in/
fi
done
[ -n "$vers_orig" ] && vers=$vers_orig
vers_orig=
done
fi
cat > "$hshroot"/chroot/.in/build.sh <<EOF
#!/bin/sh -eu
for i in *.i586.rpm; do
export AREPO_MODE="$arepo_mode"
export AREPO_PKGLIST=arepo-x86_64-i586.list
export AREPO_ARCH=i586
export AREPO_COMPAT="\$i"
[ -s \$(basename "\$i" .i586.rpm).x86_64.rpm ] && export AREPO_NATIVE="\$(basename "\$i" .i586.rpm).x86_64.rpm" ||:
rpmrebuild -np --include arepo.plug --define '_spec_line_buffer_size 262144' \\
--define '_allow_deps_with_beginning_dot 1' \$AREPO_COMPAT
done
EOF
chmod +x "$hshroot"/chroot/.in/build.sh
hsh-run "$hshopts" "$hshroot" ./build.sh && echo 'Build completed, copying pkgs back...'
for pkg in $pkgs; do
if [ "$pkg" != "${pkg%%=*}" ]; then
vers_orig="$vers"
vers=${pkg##*=}
pkg=${pkg%%=*}
printf 'Got pkg %s vers %s\n' $pkg $vers ||:
if [ ! -n "$pkg_keep" ]; then
set +f && \
rm -f $arepo/RPMS.hasher/i586-$pkg* ||:
fi
fi
[ -d $arepo/RPMS.hasher ] || mkdir -p $arepo/RPMS.hasher
cp -a "$hshroot"/chroot/usr/src/RPM/RPMS/i586/i586-$pkg-$vers.i586.rpm "$arepo"/RPMS.hasher/
[ -n "$vers_orig" ] && vers=$vers_orig
vers_orig=
done
echo -n 'Updating arepo repo...'
rm -rf $arepo/base && \
genbasedir --flat --create --topdir "$hshrepo" x86_64-i586 && echo 'Done!'