public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] rfc: script to migrate to usr merged layout
@ 2020-07-03 14:51 William Hubbs
  0 siblings, 0 replies; only message in thread
From: William Hubbs @ 2020-07-03 14:51 UTC (permalink / raw
  To: gentoo development


[-- Attachment #1.1: Type: text/plain, Size: 477 bytes --]

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


[-- Attachment #1.2: usrmerge --]
[-- Type: text/plain, Size: 1236 bytes --]

#!/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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-03 14:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-03 14:51 [gentoo-dev] rfc: script to migrate to usr merged layout William Hubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox