diff options
Diffstat (limited to 'lib/cmd')
-rw-r--r-- | lib/cmd/build.sh | 152 | ||||
-rw-r--r-- | lib/cmd/help.sh | 47 | ||||
-rw-r--r-- | lib/cmd/install.sh | 81 | ||||
-rw-r--r-- | lib/cmd/installer-pc.sh | 101 | ||||
-rw-r--r-- | lib/cmd/local.mk | 8 | ||||
-rw-r--r-- | lib/cmd/opkg.sh | 112 | ||||
-rw-r--r-- | lib/cmd/shell.sh | 62 | ||||
-rw-r--r-- | lib/cmd/version.sh | 33 |
8 files changed, 0 insertions, 596 deletions
diff --git a/lib/cmd/build.sh b/lib/cmd/build.sh deleted file mode 100644 index 8d12691..0000000 --- a/lib/cmd/build.sh +++ /dev/null @@ -1,152 +0,0 @@ -# "build" command -# -# Copyright (C) 2014 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_build_root= -cmd_build_pkg_dir= -cmd_build_build_deps= - -cmd_build_main() -{ - local root= - local dev= - local opkbuild_optstring= - local arch= - local plat= - local first_arg= - local arg= - - if [ ${#} -lt 2 ]; then - print_cmd_usage 'build' >&2 - exit 1 - fi - - root="${1}" - shift 1 - - dev='' - if is_block "${root}"; then - dev="${root}" - root="$(block_mount "${dev}")" - fi - - cmd_build_root="${root}" - - opkbuild_optstring="$(cat "${root}/usr/share/opkbuild/optstring")" - arch="$(cat "${root}/etc/proteanos_arch")" - plat="$(cat "${root}/etc/proteanos_plat")" - while getopts "${opkbuild_optstring}" opt 2>/dev/null; do - case "${opt}" in - a) arch="${OPTARG}";; - p) plat="${OPTARG}";; - esac - done - - first_arg=true - cmd_build_pkg_dir='' - for arg in "${@}"; do - if ${first_arg}; then - set -- - first_arg=false - else - set -- "${@}" "${cmd_build_pkg_dir}" - fi - cmd_build_pkg_dir="${arg}" - done - - . "${root}/etc/os-release" - profile_set "${ID}" - - if ! [ -d "${cmd_build_pkg_dir}" ]; then - error 2 "$(get_msg 'cmd_build_not_a_dir')" \ - "${cmd_build_pkg_dir}" - fi - package_init "${cmd_build_pkg_dir}" - package_set_substvars "${arch}" "${plat}" - - session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false - - cmd_build_build_deps="$(package_get_build_deps "${arch}" "${plat}")" - if [ "x${cmd_build_build_deps}" != 'x' ]; then - cmd_build_make_deps_pkg - session_exec opkg install ../builddeps.opk - fi - - session_exec opkbuild "${@}" - - cmd_build_fini - - session_end - - if [ "x${dev}" != 'x' ]; then - block_umount "${root}" - fi -} - -cmd_build_make_deps_pkg() -{ - local pkg_dir= - - pkg_dir="${cmd_build_root}$(session_dir)/builddeps" - mkdir -p "${pkg_dir}/control" "${pkg_dir}/data" - printf '2.0\n' >"${pkg_dir}/debian-binary" - cat >"${pkg_dir}/control/control" <<-EOF - Package: prokit-builddeps-$(session_id) - Source: prokit - Version: 1.0 - Architecture: all - Platform: all - Depends: ${cmd_build_build_deps} - Description: Build dependencies metapackage generated by prokit - EOF - (cd "${pkg_dir}/data"; tar -czf ../data.tar.gz .) - (cd "${pkg_dir}/control"; tar -czf ../control.tar.gz .) - (cd "${pkg_dir}"; tar -czf ../builddeps.opk \ - 'debian-binary' 'data.tar.gz' 'control.tar.gz') - rm -Rf "${pkg_dir}" -} - -cmd_build_fini() -{ - local session_dir= - local f= - - session_dir="$(session_dir)" - - if [ "x${cmd_build_build_deps}" != 'x' ]; then - session_exec opkg --autoremove remove \ - prokit-builddeps-$(session_id) - rm "${cmd_build_root}${session_dir}/builddeps.opk" - # Hack to avoid this code branch if the function is called again - # in response to a signal. - cmd_build_build_deps='' - fi - - for f in "${cmd_build_root}${session_dir}/"*; do - [ -e "${f}" ] || continue - [ "x${f##*/}" = 'xwd' ] && continue - mv "${f}" "${cmd_build_pkg_dir}/.." - done -} - -cmd_build_register() -{ - register_cmd 'build' -} -__init cmd_build_register diff --git a/lib/cmd/help.sh b/lib/cmd/help.sh deleted file mode 100644 index c699c73..0000000 --- a/lib/cmd/help.sh +++ /dev/null @@ -1,47 +0,0 @@ -# "help" command -# -# Copyright (C) 2013 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_help_main() -{ - local cmd= - - if [ ${#} -eq 1 ]; then - cmd="${1}" - if is_cmd "${cmd}"; then - print_cmd_usage "${cmd}" - return 0 - fi - fi - - printf "$(get_msg 'cmd_help_head')\n\n" "${0}" - - printf "$(get_msg 'cmd_help_opts_head')\n" - print_opt_summaries - printf '\n' - - printf "$(get_msg 'cmd_help_summary_head')\n" - print_cmd_summaries -} - -cmd_help_register() -{ - register_cmd 'help' -} -__init cmd_help_register diff --git a/lib/cmd/install.sh b/lib/cmd/install.sh deleted file mode 100644 index e0bdc4e..0000000 --- a/lib/cmd/install.sh +++ /dev/null @@ -1,81 +0,0 @@ -# "install" command -# -# Copyright (C) 2013, 2014 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_install_optstring='a:p:m:F' - -cmd_install_main() -{ - local suite= - local chroot= - local profile= - local foreign= - local dev= - - if ! get_options "${@}"; then - print_cmd_usage 'install' >&2 - exit 1 - fi - shift $(($OPTIND - 1)) - - if [ ${#} -lt 2 ]; then - print_cmd_usage 'install' >&2 - exit 1 - fi - - # TODO: Consider making suite optional, getting a default suite from the - # profile. - suite="${1}" - chroot="${2}" - - if [ "x${suite%%:*}" != "x${suite}" ]; then - profile="${suite%%:*}" - suite="${suite#*:}" - else - profile='proteanos' - fi - profile_set "${profile}" - suite="$(profile_normalize_suite "${suite}")" - - if [ "x${cmd_install_opt_F+set}" = 'xset' ]; then - foreign=true - else - foreign=false - fi - - dev='' - if is_block "${chroot}"; then - dev="${chroot}" - chroot="$(block_mount "${dev}")" - fi - - install_system "${cmd_install_opt_m-}" "${suite}" \ - "${cmd_install_opt_a-}" "${cmd_install_opt_p-}" \ - "${chroot}" "${foreign}" - - if [ "x${dev}" != 'x' ]; then - block_umount "${chroot}" - fi -} - -cmd_install_register() -{ - register_cmd 'install' -} -__init cmd_install_register diff --git a/lib/cmd/installer-pc.sh b/lib/cmd/installer-pc.sh deleted file mode 100644 index dd01506..0000000 --- a/lib/cmd/installer-pc.sh +++ /dev/null @@ -1,101 +0,0 @@ -# "installer-pc" command -# -# Copyright (C) 2014 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_installer_pc_optstring='a:p:m:' - -cmd_installer_pc_main() -{ - local suite= - local dev= - local profile= - local root= - local b4= - local b3= - local b2= - local b1= - - if ! get_options "${@}"; then - print_cmd_usage 'installer-pc' >&2 - exit 1 - fi - shift $(($OPTIND - 1)) - - if [ "x${cmd_installer_pc_opt_a-}" = 'x' ]; then - print_cmd_usage 'installer-pc' >&2 - exit 1 - fi - if [ "x${cmd_installer_pc_opt_p-}" = 'x' ]; then - print_cmd_usage 'installer-pc' >&2 - exit 1 - fi - if [ ${#} -ne 2 ]; then - print_cmd_usage 'installer-pc' >&2 - exit 1 - fi - - suite="${1}" - dev="${2}" - check_block "${dev}" - - if [ "x${suite%%:*}" != "x${suite}" ]; then - profile="${suite%%:*}" - suite="${suite#*:}" - else - profile='proteanos' - fi - profile_set "${profile}" - suite="$(profile_normalize_suite "${suite}")" - - cmd_installer_pc_make_partition_and_fs "${dev}" - root="$(block_mount "${dev}1")" - - install_system "${cmd_installer_pc_opt_m-}" "${suite}" \ - "${cmd_installer_pc_opt_a-}" "${cmd_installer_pc_opt_p-}" \ - "${root}" false - - if [ -f "${root}/sbin/lilo" ]; then - read b4 b3 b2 b1 <<-EOF - $(od -An -tx1 -v -j 440 -N 4 "${dev}") - EOF - # This ln command won't be needed once lilo 24.1-1 is uploaded. - ln "${root}/boot/vmlinuz" "${root}/boot/vmlinuz.old" - session_begin "${root}" . : false - session_exec install-lilo \ - "${dev}" "PARTUUID=${b1}${b2}${b3}${b4}-01" - session_end - fi - - block_umount "${root}" -} - -cmd_installer_pc_make_partition_and_fs() -{ - local dev="${1}" - - dd if=/dev/zero of="${dev}" bs=512 count=1 - printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | fdisk "${dev}" - mke2fs -t ext4 "${dev}1" -} - -cmd_installer_pc_register() -{ - register_cmd 'installer-pc' -} -__init cmd_installer_pc_register diff --git a/lib/cmd/local.mk b/lib/cmd/local.mk deleted file mode 100644 index 768764d..0000000 --- a/lib/cmd/local.mk +++ /dev/null @@ -1,8 +0,0 @@ -prokit_SOURCES += \ - lib/cmd/help.sh \ - lib/cmd/version.sh \ - lib/cmd/install.sh \ - lib/cmd/shell.sh \ - lib/cmd/opkg.sh \ - lib/cmd/build.sh \ - lib/cmd/installer-pc.sh diff --git a/lib/cmd/opkg.sh b/lib/cmd/opkg.sh deleted file mode 100644 index e1fc8ce..0000000 --- a/lib/cmd/opkg.sh +++ /dev/null @@ -1,112 +0,0 @@ -# "opkg" command -# -# Copyright (C) 2014 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_opkg_opks= - -cmd_opkg_main() -{ - local root= - local dev= - local first_arg= - local install_cmd= - local arg= - local new_fname= - - if [ ${#} -lt 1 ]; then - print_cmd_usage 'opkg' >&2 - exit 1 - fi - - root="${1}" - shift 1 - - dev='' - if is_block "${root}"; then - dev="${root}" - root="$(block_mount "${dev}")" - fi - - first_arg=true - install_cmd=false - cmd_opkg_opks='' - for arg in "${@}"; do - if ${first_arg}; then - set -- - first_arg=false - fi - if ${install_cmd}; then - case "${arg}" in - *.opk|*.ipk|*.deb) - if ! [ -e "${arg}" ]; then - set -- "${@}" "${arg}" - continue - fi - rand - new_fname="/tmp/prokit.${rand_x}.opk" - cmd_opkg_opks="$(printf '%s %s\n' \ - "${cmd_opkg_opks}" \ - "${root}${new_fname}")" - cp "${arg}" "${root}${new_fname}" - set -- "${@}" "${new_fname}" - ;; - *) - set -- "${@}" "${arg}" - ;; - esac - else - set -- "${@}" "${arg}" - if [ "x${arg}" = 'xinstall' ]; then - install_cmd=true - fi - fi - done - - . "${root}/etc/os-release" - profile_set "${ID}" - - session_begin "${root}" . cmd_opkg_fini false - - session_exec opkg "${@}" - - cmd_opkg_fini - session_end - - if [ "x${dev}" != 'x' ]; then - block_umount "${root}" - fi -} - -cmd_opkg_fini() -{ - case "${cmd_opkg_opks}" in - *[!\ ]*) - rm -f ${cmd_opkg_opks} - # Hack to avoid this code branch if the function is - # called again in response to a signal. - cmd_opkg_opks='' - ;; - esac -} - -cmd_opkg_register() -{ - register_cmd 'opkg' -} -__init cmd_opkg_register diff --git a/lib/cmd/shell.sh b/lib/cmd/shell.sh deleted file mode 100644 index 468da0f..0000000 --- a/lib/cmd/shell.sh +++ /dev/null @@ -1,62 +0,0 @@ -# "shell" command -# -# Copyright (C) 2014 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_shell_main() -{ - local root= - local dev= - - if [ ${#} -lt 1 ]; then - print_cmd_usage 'shell' >&2 - exit 1 - fi - - root="${1}" - shift 1 - - dev='' - if is_block "${root}"; then - dev="${root}" - root="$(block_mount "${dev}")" - fi - - . "${root}/etc/os-release" - profile_set "${ID}" - - session_begin "${root}" . : false - if [ ${#} -eq 0 ]; then - session_exec /bin/sh - printf '\n' - info "$(get_msg 'cmd_shell_exiting')" - else - session_exec "${@}" - fi - session_end - - if [ "x${dev}" != 'x' ]; then - block_umount "${root}" - fi -} - -cmd_shell_register() -{ - register_cmd 'shell' -} -__init cmd_shell_register diff --git a/lib/cmd/version.sh b/lib/cmd/version.sh deleted file mode 100644 index 0105f20..0000000 --- a/lib/cmd/version.sh +++ /dev/null @@ -1,33 +0,0 @@ -# "version" command -# -# Copyright (C) 2013 Patrick "P. J." McDermott -# -# This file is part of the ProteanOS Development Kit. -# -# The ProteanOS Development Kit 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. -# -# The ProteanOS Development Kit 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 the ProteanOS Development Kit. If not, see -# <http://www.gnu.org/licenses/>. - -cmd_version_main() -{ - printf '%s (%s) %s\n' "${0##*/}" "${PACKAGE_NAME}" "${PACKAGE_VERSION}" - - printf "$(get_msg 'cmd_version_copyright')\n" \ - '2012, 2013, 2014' 'Patrick "P. J." McDermott' -} - -cmd_version_register() -{ - register_cmd 'version' -} -__init cmd_version_register |