forked from fabiand/image-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap_anaconda
54 lines (42 loc) · 1.45 KB
/
bootstrap_anaconda
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
#!/usr/bin/bash
set -ex
usage() {
echo "Usage: $0 <distro> <releasever>"
}
die() {
echo $@ >&2 ; exit 42
}
DISTRO=$1
RELEASEVER=$2
MIRRORS=
if [[ "$DISTRO" = "fedora" ]];
then
MIRRORS="https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$RELEASEVER&arch=x86_64"
[[ "$RELEASEVER" = "21" ]] && die "Fedora 21 is not supported anymore"
[[ "$RELEASEVER" = "22" ]] && QEMU_APPEND="$QEMU_APPEND proxy=" || :
fi
if [[ "$DISTRO" = "centos" ]];
then
CENTOS_URL="http://mirror.centos.org/centos/7/os/x86_64/"
MIRRORS="http://mirrorlist.centos.org/?repo=os&release=$RELEASEVER&arch=x86_64"
fi
[[ -z $MIRRORS ]] && exit 3
mirrorcurl() {
[[ -f $(basename $1) ]] && grep -q "$1 = sha256:$(sha256sum $(basename $1) | cut -d' ' -f1)" .treeinfo && return
curl --location --fail -s "$MIRRORS" \
| sed -n 's/Everything/Server/ ; /^ht/ p' \
| while read BURL; do URL=$BURL$1 ; echo Using $URL ; curl --fail -L -O $URL && break ; done ; test -f $(basename $1)
}
cond_mirrorcurl() { grep -q $1 .treeinfo && mirrorcurl $1 || : ; }
rm -f .treeinfo
mirrorcurl .treeinfo
mirrorcurl images/pxeboot/vmlinuz
mirrorcurl images/pxeboot/initrd.img
cond_mirrorcurl images/pxeboot/upgrade.img
cond_mirrorcurl LiveOS/squashfs.img
echo "Adjusting squashfs image path, so anaconda finds it"
# Anaconda uses the .treeinfo file to find stuff
# Let the squashfs point to the PWD, not in some subdir
sed -i -e "s#=.*images/pxeboot/#= #" \
-e "s#=.*LiveOS/#= #" \
.treeinfo