--- /dev/null
+#!/bin/bash
+
+function prepare_generation {
+ if [[ ! -f "./rs-config" ]]; then
+ echo "There is no rs-config."
+ exit 1
+ fi
+
+ local copy_dest=$1
+
+ sed -i 's@^export BUILD_REQUIRED_INSTALLED_PATH=""@export BUILD_REQUIRED_INSTALLED_PATH="/"@' "./rs-config"
+ sed -i 's@^export GBS_BUILDROOT=""@export GBS_BUILDROOT="'${copy_dest}'"@' "./rs-config"
+}
+
+function generate_rootstrap_i586 {
+ ./script/convert32.sh
+ if [[ $? -ne 0 ]]; then
+ echo "Failed to convert .xml files into 32-bit."
+ return $?
+ fi
+
+ ./make_rootstrap.sh -C rs-config ./rs_resource --clean --emulator
+ RET=$?
+ if [[ ${RET} -ne 0 ]]; then
+ echo "Failed to create rootstrap."
+ fi
+
+ return ${RET}
+}
+
+function generate_rootstrap_x86_64 {
+ ./script/convert64.sh
+ if [[ $? -ne 0 ]]; then
+ echo "Failed to convert .xml files into 64-bit"
+ return $?
+ fi
+
+ ./make_rootstrap_64.sh -C rs-config ./rs_resource --clean --emulator
+ RET=$?
+ if [[ ${RET} -ne 0 ]]; then
+ echo "Failed to create rootstrap."
+ fi
+
+ return ${RET}
+}
+
+function generate_rootstrap_arm {
+ ./script/convert32.sh
+ if [[ $? -ne 0 ]]; then
+ echo "Failed to convert .xml files into 32-bit."
+ return $?
+ fi
+
+ ./make_rootstrap.sh -C rs-config ./rs_resource --clean --target
+ RET=$?
+ if [[ ${RET} -ne 0 ]]; then
+ echo "Failed to create rootstrap."
+ fi
+
+ return ${RET}
+}
+
+function generate_rootstrap_aarch64 {
+ ./script/convert64.sh
+ if [[ $? -ne 0 ]]; then
+ echo "Failed to convert .xml files into 64-bit"
+ return $?
+ fi
+
+ ./make_rootstrap_64.sh -C rs-config ./rs_resource --clean --target
+ RET=$?
+ if [[ ${RET} -ne 0 ]]; then
+ echo "Failed to create rootstrap."
+ fi
+
+ return ${RET}
+}
+
+function generate_rootstrap {
+ local arch=$1
+
+ case "${arch}" in
+ "arm")
+ generate_rootstrap_arm
+ return $?
+ ;;
+ "aarch64")
+ generate_rootstrap_aarch64
+ return $?
+ ;;
+ "i586")
+ generate_rootstrap_i586
+ return $?
+ ;;
+ "x86_64")
+ generate_rootstrap_x86_64
+ return $?
+ ;;
+ *)
+ echo "Architecture not supported: ${arch}"
+ exit 1
+ ;;
+ esac
+}
+
+ARCH=$1
+COPY_DEST=$2
+
+if [[ -z "${ARCH}" ]] || [[ -z "${COPY_DEST}" ]]; then
+ echo "2 parameters are required: <architecture> <generate destination>"
+ exit 1
+fi
+
+prepare_generation "${COPY_DEST}"
+generate_rootstrap "${ARCH}"
%define name hal-rootstrap
%define devel_name hal-rootstrap-devel
+%define hal_rootstrap_install_path /opt/data/hal-rootstrap
%global _privatelibs .*\\.so.*
%global __requires_exclude %{_privatelibs}
%install
rm -rf %{buildroot}
mkdir %{buildroot}
-./copy_required_files.sh %{buildroot}
+./generate_rootstrap.sh "%{_arch}" "%{buildroot}%{hal_rootstrap_install_path}"
mkdir -p %{buildroot}%{_libdir}/pkgconfig/
cp packaging/hal-rootstrap.pc %{buildroot}%{_libdir}/pkgconfig/
%files
-/opt/data/hal-rootstrap/lib/*
-/opt/data/hal-rootstrap/%{_libdir}/*
+%{hal_rootstrap_install_path}/lib/*
+%{hal_rootstrap_install_path}/%{_libdir}/*
%files -n %{devel_name}
%defattr(-,root,root,-)
-/opt/data/hal-rootstrap/%{_includedir}/*
+%{hal_rootstrap_install_path}/%{_includedir}/*
+%{hal_rootstrap_install_path}/%{_libdir}/pkgconfig/*.pc
%{_libdir}/pkgconfig/*.pc
}
-function copy_header_and_so() # $1 : SRCDIR, $2 : DESTDIR, $3 xml
+function copy_header_and_so()
{
- log "***************** $FUNCNAME *****************"
- ALL=$(xmlstarlet sel -t -m "//necessary[count(file)=1]" -v "./file/text()" ${3})
- log "+ source directory : $1"
- log "+ destination directory : $2"
- log "+ xml source file : $3"
-
- TEMP_SRC_DIR="${1}";
- TEMP_DEST_DIR="${2}";
- COPY_ERROR=0;
- if [[ "${ALL}" == "*" ]] || [ "$INTERNAL" = true ]
- then
- (
- log "+ copy ALL file (h, a, o, so)"
- cd ${1}
- find . \( -name "*.h" -o -name "*.a" -o -name "*.o" -o -name "*.so" -o -name "*.so\.[0-9]*" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.x" -o -name "*.def" -o -name "*.so.*" \) \
- -exec echo "+ copy file [{}]" \; \
- -exec cp -L -R --parents {} ${2} \;
- )
- else
- log "+ copy necessary files .."
- for i in $(xmlstarlet sel -t -m "//necessary/file" -o "." -v "text()" -o " " -n ${3})
- do
- #(
- cd ${1}
- log "+ copy file from [${i}]"
- cp -L -R --parents ${i} ${2}
- if [ "$?" -ne "0" ]; then
- get_author "../${3}"
- let "COPY_ERROR+=1"
- fi
- cd -
- #)
- done
- fi
-
- if [ "$COPY_ERROR" -ne "0" ]; then
- log "Error Occurred Copy file .... " 1>&2
- exit $ERROR_NOT_EXIST_FILE
- fi
-#######
-# Pc
-#######
- if [ -d "${TEMP_SRC_DIR}/usr/lib/pkgconfig" ]
- then
- (
- cd ${TEMP_SRC_DIR}
- cp -P -R --parents "./usr/lib/pkgconfig" "${TEMP_DEST_DIR}" ;
- )
- fi
+ local src_dir=$1
+ local dest_dir=$2
+ local xml_file=$3
+ local copy_error=0
+ local files=()
+ local dest_path=""
+
+ log "***************** $FUNCNAME *****************"
+ ALL=$(xmlstarlet sel -t -m "//necessary[count(file)=1]" -v "./file/text()" ${xml_file})
+ log "+ source directory : ${src_dir}"
+ log "+ destination directory : ${dest_dir}"
+ log "+ xml source file : ${xml_file}"
+
+ if [[ "${ALL}" == "*" ]] || [[ "${INTERNAL}" == true ]]; then
+ log "ALL(*) and internal is not supported"
+ else
+ log "+ copy necessary files .."
+ for i in $(xmlstarlet sel -t -m "//necessary/file" -o "." -v "text()" -o " " -n ${xml_file}); do
+ cd ${src_dir}
+ log "+ copy file from [${i}]"
+ files=($(ls ${i}))
+ for file in ${files[@]}; do
+ dest_path="${dest_dir}/$(dirname ${file})"
+ mkdir -p ${dest_path}
+ cp -L -R ${file} "${dest_path}/."
+ if [[ "$?" -ne "0" ]]; then
+ get_author "../${xml_file}"
+ let "COPY_ERROR+=1"
+ fi
+ done
+ cd -
+ done
+ fi
+
+ if [[ "${copy_error}" -ne 0 ]]; then
+ log "Error Occurred Copy file .... " 1>&2
+ exit $ERROR_NOT_EXIST_FILE
+ fi
+}
+function copy_package_config()
+{
+ local src_dir=$1
+ local dest_dir=$2
+
+ log "***************** $FUNCNAME *****************"
+ log "+ source directory : ${src_dir}"
+ log "+ destination dierctory : ${dest_dir}"
+
+ if [[ ! -d "${src_dir}/usr/lib/pkgconfig" ]]; then
+ log "+ no pkgconfig directory(${src_dir}/usr/lib/pkgconfig)"
+ return 1
+ fi
+
+ cd ${src_dir}
+ local dest_path="${dest_dir}/usr/lib/pkgconfig"
+ mkdir -p ${dest_path}
+ cp -P -R ./usr/lib/pkgconfig/* "${dest_path}"
+ cd -
}
function check_prerequisite()
#script start
check_prerequisite
-OPTS=`getopt -o -t:u:b:l:i:p:wh --long type:,url:,base:,list:,id:,pw:,withlogin,help,internal,log: -n 'rootstrap_gen_1.0' -- "$@"`
+OPTS=`getopt -o -t:u:b:l:i:p:whq:r: --long type:,url:,base:,list:,id:,pw:,withlogin,help,internal,log: -n 'rootstrap_gen_1.0' -- "$@"`
if [ $? != 0 ] ; then log "Failed parsing options." >&2 ; exit 1 ; fi
log ""
while true; do
case "$1" in
+ -q ) BUILD_REQUIRED_INSTALLED_PATH="$2"; shift;shift ;;
+ -r ) GBS_BUILDROOT="$2"; shift;shift ;;
-t | --type ) ROOTSTRAP_TYPE="$2"; shift;shift ;;
-u | --url ) RPM_PKG_URL="$2"; shift;shift ;;
-b | --base ) BASE_PKG_URL="$2"; shift;shift ;;
continue;
fi
- #download rpm
- download_rpm $item
- if [ "$?" -ne "0" ]
- then
- continue;
- fi
-
- #unpack rpm
- unpack_rpm $item
-
- #remove unnessary header, so
- unnecessary_files $item
-
#copy only header & so to dest
- copy_header_and_so ${TMP} ${DEST} ${item}
+ copy_header_and_so ${BUILD_REQUIRED_INSTALLED_PATH} ${GBS_BUILDROOT} ${item}
#get build option from xml
#get_build_option $item
done #finish copy header & library
+copy_package_config ${BUILD_REQUIRED_INSTALLED_PATH} ${GBS_BUILDROOT}
##################################################################
#postlink for delete needed field from Library