diff options
Diffstat (limited to 'lib/profile/proteanos.sh')
-rw-r--r-- | lib/profile/proteanos.sh | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/lib/profile/proteanos.sh b/lib/profile/proteanos.sh new file mode 100644 index 0000000..d5654ae --- /dev/null +++ b/lib/profile/proteanos.sh @@ -0,0 +1,224 @@ +# ProteanOS Development Kit +# lib/profile/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/>. + +use opkg + +# 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_fstab_linux="\ +proc /proc proc defaults +sys /sys sysfs defaults +/dev /dev none bind +devpts /dev/pts devpts noexec,nosuid,gid=5,mode=0620 +" +prof_proteanos_install_service=\ +'#!/bin/sh /etc/rc.common + +start() +{ + log "Configuring packages" + printf "disabled\n" >/etc/rc.policy + opkg install $(opkg list-installed | cut -d " " -f 1) + printf "enabled\n" >/etc/rc.policy + rm "${SCRIPT}" +} +' +prof_proteanos_os_release_linux="\ +NAME='ProteanOS BusyBox/Linux-libre' +VERSION='1.0' +ID=proteanos +VERSION_ID='1.0' +PRETTY_NAME='ProteanOS BusyBox/Linux-libre 1.0' +ANSI_COLOR='1;34' +HOME_URL='http://www.proteanos.com/' +BUG_REPORT_URL='mailto:proteanos-dev@lists.proteanos.com' +" + +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 mirror="${1}" + local arch="${2}" + local plat="${3}" + local suite="${4}" + local a= + local p= + local s= + + for a in "${arch}" 'all'; do + for p in "${plat}" 'all'; do + for s in 'base'; do + printf 'src proteanos_%s_%s_%s_%s_%s ' \ + "${suite%/*}" "${suite#*/}" \ + "${a}" "${p}" "${s}" + printf '%s/feeds/%s/%s/%s/%s/Packages\n' \ + "${mirror}" "${suite}" \ + "${a}" "${p}" "${s}" + done + done + done + + for s in 'base'; do + printf 'src proteanos_%s_%s_%s_%s_%s ' \ + "${suite%/*}" "${suite#*/}" \ + 'src' 'all' "${s}" + printf '%s/feeds/%s/%s/%s/%s/Packages\n' \ + "${mirror}" "${suite}" \ + 'src' 'all' "${s}" + done +} + +prof_proteanos_dep_fields() +{ + printf 'Depends Pre-Depends' +} + +prof_proteanos_include_pkg() +{ + local name="${1}" + local value="${2}" + + if [ "x${name}" = 'xpackage' ]; then + case "${value}" in + base-files|busybox|libc.6|opkg) + return 0 + ;; + linux-image|proteanos-branding) + return 0 + ;; + esac + fi + + return 1 +} + +prof_proteanos_get_fstab() +{ + local arch="${1}" + local plat="${2}" + + case "${arch}" in + *-linux-*) + printf '%s\n' "${prof_proteanos_fstab_linux}" + ;; + esac +} + +prof_proteanos_configure_system_native() +{ + local root="${1}" + + printf 'disabled\n' >"${root}/etc/rc.policy" + opkg_install_all "${root}" + printf 'enabled\n' >"${root}/etc/rc.policy" + [ -r /etc/resolv.conf ] && cp /etc/resolv.conf "${root}/etc" + [ -r /etc/hostname ] && cp /etc/hostname "${root}/etc" + [ -e "${root}/etc/passwd" ] || printf \ + 'root::0:0:root:/root:/bin/sh\n' >"${root}/etc/passwd" +} + +prof_proteanos_configure_system_foreign() +{ + local root="${1}" + + printf '%s' "${prof_proteanos_install_service}" >"${root}/etc/rc.d/S10install" + chmod 0755 "${root}/etc/rc.d/S10install" + printf 'proteanos\n' >"${root}/etc/hostname" + [ -e "${root}/etc/passwd" ] || printf \ + 'root::0:0:root:/root:/bin/sh\n' >"${root}/etc/passwd" +} + +prof_proteanos_get_os_release() +{ + local arch="${1}" + local plat="${2}" + + case "${arch}" in + *-linux-*) + printf '%s\n' "${prof_proteanos_os_release_linux}" | \ + grep -v '^$' + ;; + esac +} |