From c23af008662329a8ff7c5387cd33160542faa512 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 09 Oct 2012 17:10:45 -0400 Subject: Remove old utilities. Many of these are provided by opkbuild now. --- (limited to 'src/opkbuild.sh') diff --git a/src/opkbuild.sh b/src/opkbuild.sh deleted file mode 100644 index e1da8e4..0000000 --- a/src/opkbuild.sh +++ /dev/null @@ -1,471 +0,0 @@ -#!@@SH@@ -# -# opkhelper -# src/opkbuild -# Build opkg packages. -# -# Copyright (C) 2012 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 . - -. @@LIBDIR@@/messages -. @@LIBDIR@@/locale -. @@LIBDIR@@/changelog -. @@LIBDIR@@/control -. @@LIBDIR@@/cache - -# Environment variables: -export OH_SOURCE= -export OH_SOURCE_VERSION= -export OH_SOURCE_VERSION_UPSTREAM= -export OH_BINARY_VERSION= -export OH_BUILD_ARCH= -export OH_BUILD_ARCH_CPU= -export OH_BUILD_ARCH_KERNEL= -export OH_BUILD_ARCH_LIBS= -export OH_BUILD_PLATFORM= -export OH_BUILD_ARCH_GNU= -export OH_HOST_ARCH= -export OH_HOST_ARCH_CPU= -export OH_HOST_ARCH_KERNEL= -export OH_HOST_ARCH_LIBS= -export OH_HOST_PLATFORM= -export OH_HOST_ARCH_GNU= -export OH_TOOL_PREFIX= -export AR= -export AS= -export CC= -export CPP= -export CXXLD= -export NM= -export OBJCOPY= -export OBJDUMP= -export RANLIB= -export READELF= -export SIZE= -export STRINGS= -export STRIP= - -# Global parameters: -OPT_BUILD= -OPT_TARGET= -OPT_HOST_ARCH= -OPT_HOST_PLAT= -OPT_CHECK_BUILD_DEPS= -OPT_CLEAN= -OPT_UID0_CMD= - -main() -{ - oh_locale_set - oh_set_source_dir . - - get_options "${@}" - shift $(($OPTIND - 1)) - if [ "${#}" -ne 0 ]; then - oh_usage - exit 1 - fi - - test_uid0_cmd - - find_sanity - oh_changelog_parse setup_package - setup_source_control - - make_work_area - - if [ "${OPT_BUILD}" = 'source' -o "${OPT_BUILD}" = 'full' ]; then - build_source - fi - - if [ "${OPT_BUILD}" != 'source' ]; then - "${OPT_CHECK_BUILD_DEPS}" && oh-checkbuilddeps - setup_build - print_arch_stats - cp_step=$(oh_cache 'opkbuild.step') - if [ -n "${cp_step}" ]; then - "step_${cp_step}" - else - step_unpack - fi - fi -} - -get_options() -{ - # Parse and handle command-line options. - while getopts 'bBASFT:a:P:DdCcr:hV' opt; do - case "${opt}" in - b) - if [ -n "${OPT_BUILD}" ]; then - oh_error "${oh_str_bbasf_mutex}" - fi - OPT_BUILD=binary - ;; - B) - if [ -n "${OPT_BUILD}" ]; then - oh_error "${oh_str_bbasf_mutex}" - fi - OPT_BUILD=binary-arch - ;; - A) - if [ -n "${OPT_BUILD}" ]; then - oh_error "${oh_str_bbasf_mutex}" - fi - OPT_BUILD=binary-indep - ;; - S) - if [ -n "${OPT_BUILD}" ]; then - oh_error "${oh_str_bbasf_mutex}" - fi - OPT_BUILD=source - ;; - F) - if [ -n "${OPT_BUILD}" ]; then - oh_error "${oh_str_bbasf_mutex}" - fi - OPT_BUILD=full - ;; - T) - OPT_TARGET="${OPTARG}" - ;; - a) - OPT_HOST_ARCH="${OPTARG}" - ;; - P) - OPT_HOST_PLAT="${OPTARG}" - ;; - D) - OPT_CHECK_BUILD_DEPS=true - ;; - d) - OPT_CHECK_BUILD_DEPS=false - ;; - C) - OPT_CLEAN=true - ;; - c) - OPT_CLEAN=false - ;; - r) - OPT_UID0_CMD="${OPTARG}" - ;; - h) - oh_help - exit 0 - ;; - V) - oh_version - exit 0 - ;; - ?) - oh_error "${oh_str_bad_opt}" "${opt}" - exit 1 - ;; - esac - done - - # Set default option values. - [ -z "${OPT_BUILD}" ] && OPT_BUILD=full - [ -z "${OPT_CHECK_BUILD_DEPS}" ] && OPT_CHECK_BUILD_DEPS=true - [ -z "${OPT_UID0_CMD}" ] && OPT_UID0_CMD=fakeroot - - # Set default target and cleaning behavior. - if [ -n "${OPT_TARGET}" ]; then - [ -z "${OPT_CLEAN}" ] && OPT_CLEAN=false - else - if [ "${OPT_BUILD}" = 'full' ]; then - OPT_TARGET=binary - else - OPT_TARGET="${OPT_BUILD}" - fi - [ -z "${OPT_CLEAN}" ] && OPT_CLEAN=true - fi -} - -test_uid0_cmd() -{ - # Verify that the UID 0 command works. - test_uid=$("${OPT_UID0_CMD}" id -u) - if [ "${?}" -ne 0 ]; then - oh_error "${oh_str_uid0_cmd_not_found}" "${OPT_UID0_CMD}" - fi - if [ "${test_uid}" -ne 0 ]; then - oh_error "${oh_str_uid0_cmd_bad_uid}" "${OPT_UID0_CMD}" - fi -} - -find_sanity() -{ - oh_info "${oh_str_find_sanity}" - - format="$(cat format 2>/dev/null)" - if [ "${?}" -ne 0 ]; then - oh_error "${oh_str_no_format}" - fi - if [ "${format}" != '2.0' ]; then - oh_error "${oh_str_unsupported_format}" "${format}" - fi - - # Check for all files immediately required by SPF 2.0. - [ ! -f 'control' ] && oh_error "${oh_str_no_control}" - [ ! -x 'config' ] && oh_error "${oh_str_no_config}" - [ ! -f 'copyright' ] && oh_error "${oh_str_no_copyright}" - [ ! -f 'changelog' ] && oh_error "${oh_str_no_changelog}" -} - -setup_package() -{ - OH_SOURCE="${OH_CHANGELOG_SOURCE}" - OH_SOURCE_VERSION="${OH_CHANGELOG_VERSION}" - OH_SOURCE_VERSION_UPSTREAM="${OH_SOURCE_VERSION%%-*}" - OH_BINARY_VERSION="${OH_SOURCE_VERSION}" - - return 1 -} - -setup_source_control() -{ - oh_control_parse_source - for field in ${OH_CONTROL_SOURCE_FIELDS_REQUIRED} \ - ${OH_CONTROL_SOURCE_FIELDS_OPTIONAL}; do - field_tr=$(echo "${field}" | \ - LC_CTYPE=POSIX tr '[:lower:]-' '[:upper:]_') - param="OH_CONTROL_SOURCE_FIELD_${field_tr}" - oh_cache "src.control.${field}" \ - "$(eval echo \$\{"${param}"\})" - done -} - -make_work_area() -{ - if [ ! -d tmp ]; then - mkdir tmp || oh_error "${oh_str_cant_make_work_area}" - fi - cd tmp || oh_error "${oh_str_cant_enter_work_area}" - - oh_set_source_dir .. -} - -build_source() -{ - oh_info "${oh_str_installing_src_pkg_files}" - - src_pkg_data_base="src:${OH_SOURCE}.data/usr/src" - src_pkg_data_base="${src_pkg_data_base}/${OH_SOURCE}_${OH_SOURCE_VERSION}" - - "${OPT_UID0_CMD}" mkdir -p \ - "${src_pkg_data_base}" || \ - oh_error "${oh_str_cant_make_src_pkg_dir}" - - for file in ../*; do - case "${file}" in - ../tmp) - ;; - ../*) - "${OPT_UID0_CMD}" cp -R "${file}" "${src_pkg_data_base}" || \ - oh_error "${oh_str_cant_install_src_pkg_file}" - ;; - esac - done - - oh_control_gen_source - # TODO: oh-buildopk - - return 0 - rm -Rf "src:${OH_SOURCE}.data" || oh_error "${oh_str_cant_rm_src_pkg_data}" -} - -setup_build() -{ - setup_build_arch - setup_build_flags - setup_build_platform - setup_host_arch - setup_host_platform - setup_toolchain -} - -setup_build_arch() -{ - # TODO: Get build arch from opkg. - # TODO: Get GNU system type from table. - - IFS=- read OH_BUILD_ARCH_CPU OH_BUILD_ARCH_KERNEL OH_BUILD_ARCH_LIBS </dev/null 2>&1 - if [ "${?}" -ne 0 ]; then - oh_error "${oh_str_bad_binary_package_name}" "${pkg}" - fi - oh_control_parse_binary "${pkg}" - for field in ${OH_CONTROL_BINARY_FIELDS_REQUIRED} \ - ${OH_CONTROL_BINARY_FIELDS_OPTIONAL}; do - field_tr=$(echo "${field}" | \ - LC_CTYPE=POSIX tr '[:lower:]-' '[:upper:]_') - param="OH_CONTROL_BINARY_FIELD_${field_tr}" - oh_cache "bin.${pkg}.control.${field}" \ - "$(eval echo \$\{"${param}"\})" - done - done - - step_platconf -} - -step_platconf() -{ - oh_cache 'opkbuild.step' platconf - - oh-copyconfig - - step_build -} - -step_build() -{ - oh_cache 'opkbuild.step' build - - ./build "${OPT_TARGET}" - - "${OPT_CLEAN}" && step_clean -} - -step_clean() -{ - oh_cache 'opkbuild.step' clean - - ./config clean - - step_cleanwork -} - -step_cleanwork() -{ - cd .. - rm -Rf tmp -} - -main "${@}" -- cgit v0.9.1