aboutsummaryrefslogtreecommitdiff
path: root/0.4.0/src/install_TEST_setup.sh
blob: b511e8ea9dea1ac6828a02dc15422843645e476b (plain)
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
#!/bin/bash
# vim: set ft=sh sw=4 sts=4 et :

mkdir install_TEST_dir || exit 1
cd install_TEST_dir || exit 1

mkdir -p config/.paludis-install-test
cat <<END > config/.paludis-install-test/specpath
root = `pwd`/root
config-suffix =
END

mkdir -p root/${SYSCONFDIR}/paludis/repositories
cat <<END > root/${SYSCONFDIR}/paludis/use.conf
* foo
END

cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
* *
END

cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
* test
END

cat <<END > root/${SYSCONFDIR}/paludis/bashrc
export CHOST="my-chost"
export USER_BASHRC_WAS_USED=yes
END

cat <<END > root/${SYSCONFDIR}/paludis/repositories/repo1.conf
location = `pwd`/repo1
cache = /var/empty
format = portage
profiles = \${location}/profiles/testprofile \${location}/profiles/anothertestprofile
buildroot = `pwd`/build
END

mkdir -p root/tmp
touch root/${SYSCONFDIR}/ld.so.conf

mkdir -p repo1/{eclass,distfiles,profiles/{testprofile,anothertestprofile},test-category/target/files} || exit 1

mkdir -p src/target-2
cat <<"END" > src/target-2/testbin
#!/bin/bash
echo "Test was a success"
END
chmod +x src/target-2/testbin
cd src
tar zcf target-2.tar.gz target-2/
mv target-2.tar.gz ../repo1/distfiles/
cd ..
rm -fr src

cd repo1 || exit 1
echo "test-repo-1" > profiles/repo_name || exit 1
cat <<END > profiles/categories || exit 1
test-category
END
cat <<END > profiles/testprofile/make.defaults
ARCH=test
USERLAND=test
KERNEL=test
TESTPROFILE_WAS_SOURCED=yes
PROFILE_ORDERING=1
END
cat <<END > profiles/anothertestprofile/make.defaults
ARCH=test
USERLAND=test
KERNEL=test
ANOTHERTESTPROFILE_WAS_SOURCED=yes
PROFILE_ORDERING=2
END

cat <<"END" > eclass/foo.eclass
inherit_was_ok() {
    true
}
END

cat <<"END" > test-category/target/target-2.ebuild || exit 1
inherit foo

DESCRIPTION="Test target"
HOMEPAGE="http://paludis.berlios.de/"
SRC_URI="http://invalid.domain/${P}.tar.gz oink? ( http://example.com/foo.tar.gz )"
SLOT="0"
IUSE="oink"
LICENSE="GPL-2"
KEYWORDS="test"

pkg_setup() {
    [[ -z "${USER_BASHRC_WAS_USED}" ]] && die "bad env"
    [[ -z "${TESTPROFILE_WAS_SOURCED}" ]] && die "testprofile not sourced"
    [[ -z "${ANOTHERTESTPROFILE_WAS_SOURCED}" ]] && die "anothertestprofile not sourced"
    [[ ${PROFILE_ORDERING:-0} != 2 ]] && die "bad profile source ordering"
}

src_unpack() {
    hasq "${P}.tar.gz" ${A} || die
    hasq "${P}.tar.gz" ${AA} || die
    hasq "foo.tar.gz" ${A} && die
    hasq "foo.tar.gz" ${AA} || die
    unpack ${A}
}

src_compile() {
    inherit_was_ok || die "inherit didn't work"
}

src_test() {
    ./testbin | grep success || die "failure"
}

src_install() {
    dobin testbin
}
END
cd ..