diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2008-11-07 13:37:11 +0200 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2008-12-07 04:32:46 +0200 |
commit | daf3b68da1ece0b3ca29ea365b313cc69abf1d38 (patch) | |
tree | 4e2b4a68a17264d8dcf0728ef8a2a770e74972b7 /utils | |
parent | 1b91adadbc3e22ef8f448a0b5db6e56f74cfdcf8 (diff) |
sb2 command: added option "-c": Makes a clone of target_root
- Can be used when session is created.
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/sb2 | 30 | ||||
-rwxr-xr-x | utils/sb2-check-pkg-mappings | 36 |
2 files changed, 46 insertions, 20 deletions
@@ -40,6 +40,9 @@ Options: -J file Don't create a new session; join an existing one (see -S) -D file delete an old session (see -S). Warning: this does not check if the session is still in use! + -c When creating a session, also create a private copy + of target_root (rootstrap). Note that this can be + really slow, depending on the size of the orig.target_root Examples: sb2 ./configure @@ -125,6 +128,27 @@ function sboxify_environment() . ~/.scratchbox2/$SBOX_TARGET/sb2.config + if [ -d $SBOX_SESSION_DIR/target_root ] + then + # A copy of target_root already exists, use that + # (this may happen when we are joining an old + # session, see options -J and -c) + SBOX_TARGET_ROOT=$SBOX_SESSION_DIR/target_root + SB2_TEMP_DPKG_ADMIN_DIR=$SBOX_SESSION_DIR/tmp-pkg-db + elif [ "$SBOX_CLONE_TARGET_ROOT" == "y" ] + then + # SBOX_TARGET_ROOT has been set, make a clone of it + echo "Copying target root from $SBOX_TARGET_ROOT..." + # cp -Rp does not preserve hard links, but cpio does + (cd $SBOX_TARGET_ROOT; find . -depth -print | + cpio -pamd $SBOX_SESSION_DIR/target_root) + SBOX_TARGET_ROOT=$SBOX_SESSION_DIR/target_root + SB2_TEMP_DPKG_ADMIN_DIR=$SBOX_SESSION_DIR/tmp-pkg-db + mkdir -p $SB2_TEMP_DPKG_ADMIN_DIR + else + SB2_TEMP_DPKG_ADMIN_DIR=$HOME/.scratchbox2/$SBOX_TARGET.tmp-pkg-db.$SBOX_MAPMODE + fi + # SBOX_MAPMODE has been set, read mode-specific settings if [ -f $SBOX_DIR/share/scratchbox2/modeconf/sb2rc.$SBOX_MAPMODE ] then @@ -232,6 +256,7 @@ sbox_mapmode="$SBOX_MAPMODE" sbox_mode_specific_options="$SBOX_MODE_SPECIFIC_OPTIONS" sbox_target_root="$SBOX_TARGET_ROOT" sbox_tools_root="$SBOX_TOOLS_ROOT" +sbox_temp_dpkg_admin_dir="$SB2_TEMP_DPKG_ADMIN_DIR" sbox_cpu="$SBOX_CPU" sbox_cputransparency_method="$SBOX_CPUTRANSPARENCY_METHOD" @@ -589,8 +614,9 @@ SBOX_WORKDIR=$(readlink -f $PWD) SBOX_FAKEROOT_PREFIX="" SBOX_CREATE_REVERSE_RULES="y" SBOX_MODE_SPECIFIC_OPTIONS="" +SBOX_CLONE_TARGET_ROOT="n" -while getopts vdht:em:s:L:Q:pM:ZrRS:J:D:O: foo +while getopts vdht:em:s:L:Q:pM:ZrRS:J:D:O:c foo do case $foo in (v) version ;; @@ -613,6 +639,7 @@ do (J) SBOX_JOIN_SESSION_FILE=$OPTARG ;; (D) SBOX_DELETE_SESSION_FILE=$OPTARG ;; (O) SBOX_MODE_SPECIFIC_OPTIONS=$OPTARG ;; + (c) SBOX_CLONE_TARGET_ROOT="y" ;; (*) usage ;; esac done @@ -669,6 +696,7 @@ then # error message has been printed. exit 1 fi + SBOX_CLONE_TARGET_ROOT="n" else # Create a new session if [ -n "$SBOX_WRITE_SESSION_INFO_TO_FILE" -a \ diff --git a/utils/sb2-check-pkg-mappings b/utils/sb2-check-pkg-mappings index 0eddf6f..7f55b1d 100755 --- a/utils/sb2-check-pkg-mappings +++ b/utils/sb2-check-pkg-mappings @@ -74,27 +74,26 @@ do done shift $(($OPTIND - 1)) -SB2_TEMP_DPKG_ADMIN_DIR=$HOME/.scratchbox2/$sbox_target.tmp-pkg-db.$sbox_mapmode # Target's real package db: TARGET_DPKG_ADMINDIR_ALL_PKGS=$sbox_target_root/var/lib/dpkg if [ $check_all_pkgs = "yes" -o "$check_if_out_of_date" = "yes" ] then - if [ ! -d $SB2_TEMP_DPKG_ADMIN_DIR ] + if [ ! -d $sbox_temp_dpkg_admin_dir ] then - mkdir $SB2_TEMP_DPKG_ADMIN_DIR + mkdir $sbox_temp_dpkg_admin_dir fi fi if [ "$update_timestamp_by_force" = "yes" ] then - if [ ! -f $SB2_TEMP_DPKG_ADMIN_DIR/status ] + if [ ! -f $sbox_temp_dpkg_admin_dir/status ] then - echo "FAILED: $SB2_TEMP_DPKG_ADMIN_DIR/status does not exist." + echo "FAILED: $sbox_temp_dpkg_admin_dir/status does not exist." exit 1 fi - touch $SB2_TEMP_DPKG_ADMIN_DIR/status - echo "$SB2_TEMP_DPKG_ADMIN_DIR/status pretends to be up-to-date now." + touch $sbox_temp_dpkg_admin_dir/status + echo "$sbox_temp_dpkg_admin_dir/status pretends to be up-to-date now." exit 0 fi @@ -104,25 +103,25 @@ then # That list is really a temporary package database, which contains only # packages that are usable thru this mapping mode. - if [ ! -f $SB2_TEMP_DPKG_ADMIN_DIR/status ] + if [ ! -f $sbox_temp_dpkg_admin_dir/status ] then - echo "$SB2_TEMP_DPKG_ADMIN_DIR/status does not exist." + echo "$sbox_temp_dpkg_admin_dir/status does not exist." echo "going to create it now. This is going to take a while.." echo check_all_pkgs="yes" - elif [ $SB2_TEMP_DPKG_ADMIN_DIR/status -ot \ + elif [ $sbox_temp_dpkg_admin_dir/status -ot \ $TARGET_DPKG_ADMINDIR_ALL_PKGS/status ] then echo "Target's primary package database has been updated =>" - echo "$SB2_TEMP_DPKG_ADMIN_DIR/status is out of date." + 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 [ $SB2_TEMP_DPKG_ADMIN_DIR/status -ot \ + 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 "$SB2_TEMP_DPKG_ADMIN_DIR/status might be out of date." + 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" @@ -130,7 +129,7 @@ then if [ "$check_all_pkgs" != "yes" ] then - echo "$SB2_TEMP_DPKG_ADMIN_DIR/status is up-to-date." + echo "$sbox_temp_dpkg_admin_dir/status is up-to-date." exit 0 fi fi @@ -217,11 +216,10 @@ echo "Checked $pkgnum packages: Ok=$num_ok, unusable=$num_failed" if [ $check_all_pkgs = "yes" ] then - SB2_TEMP_DPKG_ADMIN_DIR=$HOME/.scratchbox2/$sbox_target.tmp-pkg-db.$sbox_mapmode - if [ ! -d $SB2_TEMP_DPKG_ADMIN_DIR ] + if [ ! -d $sbox_temp_dpkg_admin_dir ] then - mkdir $SB2_TEMP_DPKG_ADMIN_DIR + mkdir $sbox_temp_dpkg_admin_dir fi - mv $status_file $SB2_TEMP_DPKG_ADMIN_DIR/status - echo "Results have been written to $SB2_TEMP_DPKG_ADMIN_DIR/status" + mv $status_file $sbox_temp_dpkg_admin_dir/status + echo "Results have been written to $sbox_temp_dpkg_admin_dir/status" fi |