summaryrefslogtreecommitdiffstats
path: root/lib/profiles/proteanos.sh
blob: a7946a500e0c0e8615225ed2733142e1f13a6aae (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
122
123
124
125
126
127
128
129
130
131
# ProteanOS Development Kit
# lib/profiles/proteanos.sh
# ProteanOS architecture detection and feeds lists.
#
# Copyright (C) 2013  Patrick "P. J." McDermott
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# TODO: This should be replaced with a prof_proteanos_validate_archplat()
# function that gets valid architectures and platforms from the package archive
# (which pro-archman needs to list in the distribution).
prof_proteanos_archplats='
amd64-linux-glibc                       dev
i686-linux-glibc                        dev
i686-linux-glibc                        ao751h
i686-linux-glibc                        dimension2400
i686-linux-glibc                        x60
'

prof_proteanos_normalize_suite()
{
	local suite="${1}"

	case "${suite}" in
		*/*) printf '%s\n' "${suite}";;
		*)   printf 'dev/%s\n' "${suite}";;
	esac

	return 0
}

prof_proteanos_detect_arch()
{
	local uname_m=
	local uname_s=
	local arch=

	uname_m="$( (uname -m) 2>/dev/null)" || uname_m='unknown'
	uname_s="$( (uname -s) 2>/dev/null)" || uname_s='unknown'

	case "${uname_m}:${uname_s}" in
		'x86_64:Linux')
			arch='amd64-linux-glibc'
			;;
		'i686:Linux')
			arch='i686-linux-glibc'
			;;
		*)
			arch=''
	esac

	printf '%s\n' "${arch}"
}

prof_proteanos_default_plat()
{
	printf 'dev\n'
}

prof_proteanos_select_mirror()
{
	local rand=
	local mirror=

	rand=$(date '+%S')
	rand=$(($rand % 2))
	case ${rand} in
		0)
			mirror='http://mirror.gnu.dk/pub/proteanos'
			;;
		1)
			mirror='http://mirror.oss.maxcdn.com/proteanos'
			;;
	esac

	printf '%s\n' "${mirror}"
}

prof_proteanos_feeds()
{
	local arch="${1}"
	local plat="${2}"
	local suite="${3}"
	local archive=
	local a=
	local p=
	local s=
	
	archive='http://files.proteanos.com/pub/proteanos'

	for a in "${arch}" 'all'; do
		for p in "${plat}" 'all'; do
			for s in 'base'; do
				printf 'proteanos_%s_%s_%s_%s_%s ' \
					"${suite%/*}" "${suite#*/}" \
					"${a}" "${p}" "${s}"
				printf '%s/feeds/%s/%s/%s/%s/Packages\n' \
					"${archive}" "${suite}" \
					"${a}" "${p}" "${s}"
			done
		done
	done
}

prof_proteanos_dep_fields()
{
	printf 'Depends Pre-Depends'
}

prof_proteanos_include_pkg()
{
	local name="${1}"
	local value="${2}"

	if [ "x${name}" = 'xPackage' ] && [ "x${value}" = 'xbase' ]; then
		return 0
	else
		return 1
	fi
}