#!/bin/bash # # This script checks which .deb packages can be used from the rootstrap. # # dpkg-checkbuilddeps uses this to builds a new temporary "status" file of # all usable packages. # # Copyright (c) 2008 Nokia Corporation. All rights reserved. # Author: Lauri T. Aarnio # Licensed under LGPL version 2.1, see top level LICENSE file for details. function usage() { cat <" echo "$sbox_temp_dpkg_admin_dir/status is out of date." echo "going to update it now. This is going to take a while.." echo check_all_pkgs="yes" elif [ $sbox_temp_dpkg_admin_dir/status -ot \ $sbox_dir/share/scratchbox2/lua_scripts/pathmaps/$sbox_mapmode/00_default.lua ]; then echo "SB2's mapping rules have been updated =>" echo "$sbox_temp_dpkg_admin_dir/status might be out of date." echo "going to update it now. This is going to take a while.." echo check_all_pkgs="yes" fi if [ "$check_all_pkgs" != "yes" ]; then echo "$sbox_temp_dpkg_admin_dir/status is up-to-date." exit 0 fi fi pkgs2check="$*" tstamp=`/bin/date +%Y%m%d-%H%M` if [ -z "$pkgs2check" -a "$check_all_pkgs" = "yes" ]; then # check all installed packages pkgs2check=`dpkg --get-selections | grep 'install$' | sed -e 's/install$//'` status_file=STATUS-NEW.$tstamp.$$ bothreq_file=BOTH_REQ-NEW.$tstamp.$$ elif [ "$check_all_pkgs" = "yes" ]; then # -a and package names - illegal usage fi function add_pkg_to_status_file() { if [ $check_all_pkgs = "yes" ]; then if [ -f $status_file ]; then echo >>$status_file fi dpkg -s $pkg >>$status_file fi } function remove_temp_files { if [ -n "$status_file" -a -f "$status_file" ]; then echo "removing temp file '$status_file'" rm $status_file fi if [ -n "$bothreq_file" -a -f "$bothreq_file" ]; then echo "removing temp file '$bothreq_file'" rm $bothreq_file fi } trap remove_temp_files EXIT pkgnum=0 num_ok=0 num_failed=0 num_both_required=0 # Read the mode-specific path ignore list. SB2_CHECK_PKG_MAPPINGS_IGNORE_LIST="" if [ -f $sbox_dir/share/scratchbox2/modeconf/sb2rc.$sbox_mapmode ]; then . $sbox_dir/share/scratchbox2/modeconf/sb2rc.$sbox_mapmode "sb2-check-pkg-mappings" fi # for all installed packages.. for pkg in $pkgs2check; do pkgnum=`expr $pkgnum + 1` echo "=========== $pkgnum. Checking $pkg ===========" # get list of files installed by this package (dpkg -L), # and feed it to sb2-show to be verified (-D causes directories # to be ignored). Also ignore all files which are installed # to these diretories listed in $SB2_CHECK_PKG_MAPPINGS_IGNORE_LIST. sb2_pkg_chk=`mktemp /tmp/sb2-pkg-chk.XXXXXXXXXX` dpkg -L $pkg >$sb2_pkg_chk if [ $? != 0 ]; then num_failed=`expr $num_failed + 1` echo " $pkg is not available" else sed < $sb2_pkg_chk\ -e 's/diverted by .* to: //' \ -e 's/package diverts others to: //' | sb2-show -D verify-pathlist-mappings \ $VERBOSE_OPTION \ $sbox_target_root $SB2_CHECK_PKG_MAPPINGS_IGNORE_LIST pathlist_mappings_result=$? if [ $pathlist_mappings_result == 0 ]; then # package can be safely used, all mappings are OK: echo " $pkg = OK" num_ok=`expr $num_ok + 1` add_pkg_to_status_file elif [ $pathlist_mappings_result == 2 ]; then # package can be used, as long as it is installed to # the target_root AND to the tools echo " $pkg : required also from tools" num_both_required=`expr $num_both_required + 1` add_pkg_to_status_file if [ $check_all_pkgs = "yes" ]; then echo $pkg >>$bothreq_file fi else num_failed=`expr $num_failed + 1` echo " $pkg can not be used in this mode ($sbox_mapmode)" fi fi rm $sb2_pkg_chk done echo "Checked $pkgnum packages: Ok=$num_ok, unusable=$num_failed, both required=$num_both_required" if [ $check_all_pkgs = "yes" ]; then if [ ! -d $sbox_temp_dpkg_admin_dir ]; then mkdir $sbox_temp_dpkg_admin_dir fi mv $status_file $sbox_temp_dpkg_admin_dir/status mv $bothreq_file $sbox_temp_dpkg_admin_dir/both-required echo "Results have been written to $sbox_temp_dpkg_admin_dir/status" fi