Hey all,

I am hearing that there is interest from users in the usr merge layout
(turning off the split-usr use flag) on their systems.

You can't really do this on a live system without migrating your system
to the new layout. I wrote a script a while back that attempts this, but I
haven't packaged it yet because I'm not sure how safe it is.

I will attach the script here before I package it.

Any comments or suggestions for this would be very helpful.

Thanks,

William

#!/bin/bb

is_internal()
{
        [ -z "$1" ] && return 1
        case $(command -v $1) in
                */*) rc=1 ;;
                *) rc=0 ;;
        esac
        return $rc
}

run_command()
{
        local dry_run
        [ $DRYRUN -eq 1 ] && dry_run=echo
        $dry_run "$@"
}

DRYRUN=1
HELP=0
while [ $# -gt 0 ]; do
        case $1 in
                -d|--dryrun|--dry-run) DRYRUN=1 ;;
                -h|--help) HELP=1 ;;
        esac
        shift
done

if [ $HELP -eq 1 ]; then
        echo "$(basename $0) -h \| --help - displays this message"
        echo "$(basename $0) --dryrun \| --dry-run  - show what would be done"
        exit 0
fi

for cmd in cp ln; do
        if ! is_internal $cmd; then
                echo "Please rebuild busybox and include the $cmd command"
                exit 1
        fi
done

if [ -L /bin -a -L /sbin ]; then
        echo "It appears that the /usr merge has already been done on this 
system."
        exit 0
fi

# copy binaries
for dir in /bin /sbin /usr/sbin; do
        run_command cp -a $dir/* /usr/bin
done

# copy libraries
for dir in /lib*; do
        [ -L $dir ] && continue
        run_command cp -a $dir/* /usr$dir
done

# Create the /usr merge compatibility symlinks
for dir in /bin /sbin; do
run_command rm -rf $dir
run_command ln -s usr/bin $dir
done
run_command rm -rf /usr/sbin
run_command ln -s bin /usr/sbin
for dir in /lib*; do
        run_command rm -rf $dir
        run_command ln -s usr$dir $dir
done

Attachment: signature.asc
Description: PGP signature

Reply via email to