-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild
executable file
·94 lines (82 loc) · 2.54 KB
/
build
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
#!/bin/sh
set -e
set -x
usage() {
echo "usage: $0 image" >&2
exit 2
}
src=https://github.com/oasislinux/oasis.git
root=https://github.com/oasislinux/root-x86_64.git
etc=https://github.com/oasislinux/etc.git
while getopts e:r:s: opt ; do
case $opt in
e) etc=$OPTARG ;;
r) root=$OPTARG ;;
s) src=$OPTARG ;;
?) usage ;;
esac
done
shift $(($OPTIND - 1))
[ $# = 1 ] || usage
img=$1
tmp=$(mktemp -d)
nbd=0
mnt=0
if [ -d "$root" ] && ! expr "$root" : '^/' ; then
root=$PWD/$root
fi
cleanup() {
test "$mnt" = 0 || umount "$tmp/mnt"
test "$nbd" = 0 || qemu-nbd --disconnect /dev/nbd0
rm -rf "$tmp"
}
trap cleanup EXIT
mkdir "$tmp/mnt"
qemu-img create -f qcow2 "$img" 8G
qemu-nbd --connect=/dev/nbd0 "$img" ; nbd=1
mke2fs -t ext4 /dev/nbd0
mount -t ext4 /dev/nbd0 "$tmp/mnt" ; mnt=1
git -C "$tmp/mnt" clone -c 'core.sharedRepository=group' "$src" src/oasis
sed "
/repo=/,/}/c repo={path='../..', flags='', tag='tree', branch='oasis'},
/sets\.core/{
i {sets.devel},
s/sets.core,/& sets.extra, sets.desktop,/
}
" "$tmp/mnt/src/oasis/config.def.lua" >"$tmp/mnt/src/oasis/config.lua"
git init --template "$tmp/mnt/src/oasis/template" "$tmp/mnt"
chgrp -R 1 "$tmp/mnt/src" "$tmp/mnt/.git"
git -C "$tmp/mnt" remote add origin "$root"
git -C "$tmp/mnt" config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git -C "$tmp/mnt" fetch --depth=1 origin core extra desktop
git -C "$tmp/mnt" checkout -b master origin/core
GIT_AUTHOR_NAME='oasis' GIT_AUTHOR_EMAIL='oasis' \
GIT_COMMITTER_NAME='oasis' GIT_COMMITTER_EMAIL='oasis' \
git -C "$tmp/mnt" merge --allow-unrelated --no-edit origin/extra
GIT_AUTHOR_NAME='oasis' GIT_AUTHOR_EMAIL='oasis' \
GIT_COMMITTER_NAME='oasis' GIT_COMMITTER_EMAIL='oasis' \
git -C "$tmp/mnt" merge --allow-unrelated --no-edit origin/desktop
git -C "$tmp/mnt" branch oasis master
git -C "$tmp/mnt" config branch.master.remote .
git -C "$tmp/mnt" config branch.master.merge oasis
if [ -d "$root" ] ; then
git -C "$tmp/mnt" remote remove origin
fi
git clone "$etc" "$tmp/etc"
GIT_WORK_TREE="$tmp/mnt/etc" git -C "$tmp/etc" checkout -f qemu
git -C "$tmp/mnt" remote add toolchain https://github.com/oasislinux/toolchain.git
"$tmp/mnt/libexec/applyperms" -d "$tmp/mnt/etc"
"$tmp/mnt/bin/makewhatis" "$tmp/mnt/share/man"
cat >"$tmp/mnt/root/.gitconfig" <<EOF
[user]
name = oasis
email = oasis
[pull]
rebase = false
EOF
mkdir "$tmp/mnt/home/oasis"
cp "$tmp/mnt/root/.gitconfig" "$tmp/mnt/home/oasis/.gitconfig"
cp README.md "$tmp/mnt/root"
cp README.md "$tmp/mnt/home/oasis"
chown -R 1000:1000 "$tmp/mnt/home/oasis"
chmod -R g+w "$tmp/mnt/src/oasis"