Changeset - 0fd306d51f35
[Not reviewed]
default
0 0 10
Nathan Brink (binki) - 14 years ago 2010-12-28 10:04:07
ohnobinki@ohnopublishing.net
sys-apps/busybox: Import busybox-1.18.1 from portage.

(Portage version: 2.2.0_alpha2-r1/hg/Linux x86_64, signed Manifest commit with key 6BA81050)
10 files changed with 603 insertions and 0 deletions:
0 comments (0 inline, 0 general)
sys-apps/busybox/Manifest
Show inline comments
 
new file 100644
 
-----BEGIN PGP SIGNED MESSAGE-----
 
Hash: SHA256
 

	
 
AUX busybox-1.18.0-bb.patch 918 RMD160 e6a7be911deb07510ddf46b8a4b8b24ef5b1b29a SHA1 f4815f4cd948c300d65e553486c949c780f05752 SHA256 9e713de11f26a07e5a17d7e62eed7a10b163de91331d50541dcc2c037acbcb67
 
AUX mdev-start.sh 2758 RMD160 c177aac4940b177bd857bc98ff2ac031e0489bbc SHA1 5a5b95da36c489cd12820513434a7a17ac3bffd1 SHA256 9904263c8dfe2b8c3e968a9b4245fa0c162a2413110c037cdd797ac3773587d7
 
AUX mdev.rc 282 RMD160 6a11e23fbed92acd24088a7885bdc52b9c845fac SHA1 46f1a0494e009332e83b62599842f8213b60ba60 SHA256 e52abbc3399fc85ce1f097e8f12b25a5ca7fe2e3d648bee60c061b547ba39dc5
 
AUX mdev/dvbdev 356 RMD160 db7f546ae6e47b59cca9712f1e218cdbc3985c78 SHA1 993c0ab79fa41912f84db95e7dd09aa0965aa8c7 SHA256 ef091bb4c8943a99b9a97b556cdc15ddd20275f5afa8287e201419b08c4e71de
 
AUX mdev/ide_links 440 RMD160 5d133f27d1ab4db5f6f1b5063837b033f47b71ae SHA1 725deaf4c35e46dec89fc35f221c4c52b2542129 SHA256 3fccc9ee437e3dcc8ac73bfe3713334a7156a112fe442e052fff4f26ff0f6a88
 
AUX mdev/usbdev 1624 RMD160 a448558f058566223072c993cb4ae52f9aa43da3 SHA1 4d1a7a19e58549416dd3bde4fcf2f584adc4feb7 SHA256 113ecaa722fa1f4e1c76489e2a7b24099778615a5bccd443aa9cbab28c6d05d0
 
AUX mdev/usbdisk_link 984 RMD160 9b86d85f5f27f03f894a062c9f00d3583c4db3ae SHA1 690290b25fa1b90f6d9d7b8947a55746920991a4 SHA256 4957f6991e0cb988b263b5276b582f1757deecad19cddebe3c615b381df9f858
 
DIST busybox-1.18.1.tar.bz2 2129404 RMD160 fb40d19103945eb1cd785a6041e5545f4055b8f6 SHA1 83b86858599870e46236da8d370d335d48cee77e SHA256 33eb25ea7b20c727c3af769256b21408a1ac1f927ff9f89a1f1e3767c18c9967
 
EBUILD busybox-1.18.1.ebuild 7879 RMD160 37a61f1aad0924dd093cd17aade4c8231ec0a674 SHA1 6385245b1e0476e1c45ebb24cb31bb43bbc8d58a SHA256 7eecfc226d3f2ae6d10a7b40be69c08daaef57132db2401f028d107ca2fd7ecb
 
MISC metadata.xml 368 RMD160 2facee7f44b7469c85383961c2dd4338ea6fffcb SHA1 eae78f6b5eb3a21aeae692f9a7420ab536be3739 SHA256 033b1cb2abe759f73b184ce43b5c791454716638090767c2bc70cc52b4ef187f
 
-----BEGIN PGP SIGNATURE-----
 
Version: GnuPG v2.0.14 (GNU/Linux)
 

	
 
iQIcBAEBCAAGBQJNGfxnAAoJEHQ6UuhrqBBQcH8P/iTluW4iPVDQNw9QHN7IJM+L
 
9hNKzVRiS3TN2Jxol0A4YSlJV5wyAvFTDRPFfwYa+TGZnvxCEJFbQJks5aLVdN5m
 
Znt0M6mg/EeyP8c54G99YMKgNIRZFUYsxzGT7Gp+zu5CdXMND4qeBc5CEVE18SsU
 
GGM96pI1g4mRNcSgDXVAdziHbiY0VjndGL8GLJW8QW4htI3ggm+X2uwMR+q5DMjz
 
7DeCUZabDJi5E19auMps3abGgV2FyNhV23wJp0ZtCohP8h8ic3fQjGGH3D31d+se
 
FVpuwXVmWZMdpoXVAy2PynwyvsO8mRXLW6RQdEVvfgG142er09GaV98ebg6VxVJv
 
ivPP30A0wG9/opCKQReR+4DSRMYarUP6lTzycc457+RYj/PgYEiMP0lFwVXxbEIU
 
3LVsf07XOW8ljVBJDgHMDX09rwdz8P4g2+CbED8ZEnjaJEvB7NzkuZ98Wpy4y6XK
 
lAw2nrpPUGZ4JYyBB7TtZ47x8k5uZitCTaFlqKm1IUroMdTPpcgoAU5hoMfOzYFj
 
4RVvhq1wYMepEtkQBqsOAkq3yxC1d+UmZgaL4Qn12yjc2ACKKbwmfUWq3VQSSaty
 
7aJJw6S2vT9aUuG6R/H8pBxLT3UnRY2aKUsI1z8vbsnXP6JUWrOglezG/W+KK4GK
 
cpnEQ6aNLn2BW9ZIjxd1
 
=0E2D
 
-----END PGP SIGNATURE-----
sys-apps/busybox/busybox-1.18.1.ebuild
Show inline comments
 
new file 100644
 
# Copyright 1999-2010 Gentoo Foundation
 
# Distributed under the terms of the GNU General Public License v2
 
# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/busybox-1.18.1.ebuild,v 1.1 2010/12/21 23:32:46 vapier Exp $
 

	
 
EAPI=2
 
inherit eutils flag-o-matic savedconfig toolchain-funcs
 

	
 
################################################################################
 
# BUSYBOX ALTERNATE CONFIG MINI-HOWTO
 
#
 
# Busybox can be modified in many different ways. Here's a few ways to do it:
 
#
 
# (1) Emerge busybox with FEATURES=keepwork so the work directory won't
 
#     get erased afterwards. Add a definition like ROOT=/my/root/path to the
 
#     start of the line if you're installing to somewhere else than the root
 
#     directory. This command will save the default configuration to
 
#     ${PORTAGE_CONFIGROOT} (or ${ROOT} if ${PORTAGE_CONFIGROOT} is not
 
#     defined), and it will tell you that it has done this. Note the location
 
#     where the config file was saved.
 
#
 
#     FEATURES=keepwork USE=savedconfig emerge busybox
 
#
 
# (2) Go to the work directory and change the configuration of busybox using its
 
#     menuconfig feature.
 
#
 
#     cd /var/tmp/portage/busybox*/work/busybox-*
 
#     make menuconfig
 
#
 
# (3) Save your configuration to the default location and copy it to the
 
#     one of the locations listed in /usr/portage/eclass/savedconfig.eclass
 
#
 
# (4) Emerge busybox with USE=savedconfig to use the configuration file you
 
#     just generated.
 
#
 
################################################################################
 
#
 
# (1) Alternatively skip the above steps and simply emerge busybox without
 
#     USE=savedconfig.
 
#
 
# (2) Edit the file it saves by hand. ${ROOT}"/etc/portage/savedconfig/${CATEGORY}/${PF}
 
#
 
# (3) Remerge busybox as using USE=savedconfig.
 
#
 
################################################################################
 

	
 
#SNAPSHOT=20040726
 
SNAPSHOT=""
 

	
 
DESCRIPTION="Utilities for rescue and embedded systems"
 
HOMEPAGE="http://www.busybox.net/"
 
if [[ -n ${SNAPSHOT} ]] ; then
 
	MY_P=${PN}
 
	SRC_URI="http://www.busybox.net/downloads/snapshots/${PN}-${SNAPSHOT}.tar.bz2"
 
else
 
	MY_P=${PN}-${PV/_/-}
 
	SRC_URI="http://www.busybox.net/downloads/${MY_P}.tar.bz2"
 
fi
 
LICENSE="GPL-2"
 
SLOT="0"
 
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
 
IUSE="debug ipv6 make-symlinks +mdev -pam selinux static elibc_glibc"
 
RESTRICT="test"
 

	
 
DEPEND="selinux? ( sys-libs/libselinux )
 
	pam? ( sys-libs/pam )"
 

	
 
S=${WORKDIR}/${MY_P}
 

	
 
busybox_config_option() {
 
	case $1 in
 
		y) sed -i -e "s:.*\<CONFIG_$2\>.*set:CONFIG_$2=y:g" .config;;
 
		n) sed -i -e "s:CONFIG_$2=y:# CONFIG_$2 is not set:g" .config;;
 
		*) use $1 \
 
		       && busybox_config_option y $2 \
 
		       || busybox_config_option n $2
 
		   return 0
 
		   ;;
 
	esac
 
	einfo $(grep "CONFIG_$2[= ]" .config || echo Could not find CONFIG_$2 ...)
 
}
 

	
 
src_prepare() {
 
	unset KBUILD_OUTPUT #88088
 
	append-flags -fno-strict-aliasing #310413
 

	
 
	# patches go here!
 
	epatch "${FILESDIR}"/busybox-1.18.0-bb.patch
 
	#epatch "${FILESDIR}"/busybox-${PV}-*.patch
 

	
 
	# flag cleanup
 
	sed -i -r \
 
		-e 's:[[:space:]]?-(Werror|Os|falign-(functions|jumps|loops|labels)=1|fomit-frame-pointer)\>::g' \
 
		Makefile.flags || die
 
	#sed -i '/bbsh/s:^//::' include/applets.h
 
	sed -i '/^#error Aborting compilation./d' applets/applets.c || die
 
	use elibc_glibc && sed -i 's:-Wl,--gc-sections::' Makefile
 
	sed -i \
 
		-e "/^CROSS_COMPILE/s:=.*:= ${CHOST}-:" \
 
		-e "/^AR\>/s:=.*:= $(tc-getAR):" \
 
		-e "/^CC\>/s:=.*:= $(tc-getCC):" \
 
		-e "/^LD\>/s:=.*:= $(tc-getLD):" \
 
		-e "/^HOSTCC/s:=.*:= $(tc-getBUILD_CC):" \
 
		Makefile || die
 
}
 

	
 
src_configure() {
 
	# check for a busybox config before making one of our own.
 
	# if one exist lets return and use it.
 

	
 
	restore_config .config
 
	if [ -f .config ]; then
 
		yes "" | emake -j1 oldconfig > /dev/null
 
		return 0
 
	else
 
		ewarn "Could not locate user configfile, so we will save a default one"
 
	fi
 

	
 
	# setup the config file
 
	emake -j1 allyesconfig > /dev/null
 
	busybox_config_option n DMALLOC
 
	busybox_config_option n FEATURE_SUID_CONFIG
 
	busybox_config_option n BUILD_AT_ONCE
 
	busybox_config_option n BUILD_LIBBUSYBOX
 
	busybox_config_option n NOMMU
 
	busybox_config_option n MONOTONIC_SYSCALL
 

	
 
	# If these are not set and we are using a uclibc/busybox setup
 
	# all calls to system() will fail.
 
	busybox_config_option y ASH
 
	busybox_config_option n HUSH
 

	
 
	# disable ipv6 applets
 
	if ! use ipv6; then
 
		busybox_config_option n FEATURE_IPV6
 
		busybox_config_option n TRACEROUTE6
 
		busybox_config_option n PING6
 
	fi
 

	
 
	if use static && use pam ; then
 
		ewarn "You cannot have USE='static pam'.  Assuming static is more important."
 
	fi
 
	use static \
 
		&& busybox_config_option n PAM \
 
		|| busybox_config_option pam PAM
 
	busybox_config_option static STATIC
 
	busybox_config_option debug DEBUG
 
	use debug \
 
		&& busybox_config_option y NO_DEBUG_LIB \
 
		&& busybox_config_option n DMALLOC \
 
		&& busybox_config_option n EFENCE
 

	
 
	busybox_config_option selinux SELINUX
 

	
 
	# default a bunch of uncommon options to off
 
	local opt
 
	for opt in \
 
		CRONTAB \
 
		DC DEVFSD DNSD DPKG \
 
		FAKEIDENTD FBSPLASH FOLD FTP{GET,PUT} \
 
		HOSTID HUSH \
 
		INETD INOTIFYD IPCALC \
 
		LASH LOCALE_SUPPORT LOGNAME LPD \
 
		MSH \
 
		OD \
 
		RFKILL \
 
		SLATTACH SULOGIN \
 
		TASKSET TCPSVD \
 
		RPM RPM2CPIO \
 
		UDPSVD UUDECODE UUENCODE
 
	do
 
		busybox_config_option n ${opt}
 
	done
 

	
 
	emake -j1 oldconfig > /dev/null
 
}
 

	
 
src_compile() {
 
	unset KBUILD_OUTPUT #88088
 
	export SKIP_STRIP=y
 

	
 
	emake busybox || die "build failed"
 
	if ! use static ; then
 
		cp .config{,.bak}
 
		mv busybox_unstripped{,.bak}
 
		use pam && busybox_config_option n PAM
 
		emake CONFIG_STATIC=y busybox || die "static build failed"
 
		mv busybox_unstripped bb
 
		mv busybox_unstripped{.bak,}
 
		mv .config{.bak,}
 
	fi
 
}
 

	
 
src_install() {
 
	unset KBUILD_OUTPUT #88088
 
	save_config .config
 

	
 
	into /
 
	newbin busybox_unstripped busybox || die
 
	if use static ; then
 
		dosym busybox /bin/bb || die
 
		dosym bb /bin/busybox.static || die
 
	else
 
		dobin bb || die
 
	fi
 
	if use mdev ; then
 
		dodir /$(get_libdir)/mdev/
 
		use make-symlinks || dosym /bin/bb /sbin/mdev
 
		cp "${S}"/examples/mdev_fat.conf "${D}"/etc/mdev.conf
 

	
 
		exeinto /$(get_libdir)/mdev/
 
		doexe "${FILESDIR}"/mdev/*
 

	
 
		insinto /$(get_libdir)/rcscripts/addons
 
		doins "${FILESDIR}"/mdev-start.sh || die
 
		newinitd "${FILESDIR}"/mdev.rc mdev || die
 
	fi
 

	
 
	# bundle up the symlink files for use later
 
	emake install || die
 
	rm _install/bin/busybox
 
	tar cf busybox-links.tar -C _install . || : #;die
 
	insinto /usr/share/${PN}
 
	doins busybox-links.tar || die
 
	newins .config ${PF}.config || die
 

	
 
	dodoc AUTHORS README TODO
 

	
 
	cd docs || die
 
	docinto txt
 
	dodoc *.txt
 
	docinto pod
 
	dodoc *.pod
 
	dohtml *.html
 

	
 
	cd ../examples || die
 
	docinto examples
 
	dodoc inittab depmod.pl *.conf *.script undeb unrpm
 

	
 
	cd bootfloppy || die
 
	docinto bootfloppy
 
	dodoc $(find . -type f)
 
}
 

	
 
pkg_preinst() {
 
	if use make-symlinks && [[ ! ${VERY_BRAVE_OR_VERY_DUMB} == "yes" ]] && [[ ${ROOT} == "/" ]] ; then
 
		ewarn "setting USE=make-symlinks and emerging to / is very dangerous."
 
		ewarn "it WILL overwrite lots of system programs like: ls bash awk grep (bug 60805 for full list)."
 
		ewarn "If you are creating a binary only and not merging this is probably ok."
 
		ewarn "set env VERY_BRAVE_OR_VERY_DUMB=yes if this is realy what you want."
 
		die "silly options will destroy your system"
 
	fi
 

	
 
	if use make-symlinks ; then
 
		mv "${D}"/usr/share/${PN}/busybox-links.tar "${T}"/ || die
 
	fi
 
}
 

	
 
pkg_postinst() {
 
	if use make-symlinks ; then
 
		cd "${T}" || die
 
		mkdir _install
 
		tar xf busybox-links.tar -C _install || die
 
		cp -vpPR _install/* "${ROOT}"/ || die "copying links for ${x} failed"
 
	fi
 

	
 
	echo
 
	einfo "This ebuild has support for user defined configs"
 
	einfo "Please read this ebuild for more details and re-emerge as needed"
 
	einfo "if you want to add or remove functionality for ${PN}"
 
	echo
 
}
sys-apps/busybox/files/busybox-1.18.0-bb.patch
Show inline comments
 
new file 100644
 
--- a/shell/ash.c
 
+++ b/shell/ash.c
 
@@ -75,6 +75,8 @@
 
 //applet:IF_ASH(APPLET(ash, _BB_DIR_BIN, _BB_SUID_DROP))
 
 //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, _BB_DIR_BIN, _BB_SUID_DROP, sh))
 
 //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, _BB_DIR_BIN, _BB_SUID_DROP, bash))
 
+//applet:IF_ASH(APPLET_ODDNAME(bb, ash, _BB_DIR_BIN, _BB_SUID_DROP, ash))
 
+//applet:IF_ASH(APPLET_ODDNAME(bbsh, ash, _BB_DIR_BIN, _BB_SUID_DROP, ash))
 
 
 
 //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o
 
 //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o
 
--- a/shell/ash.c
 
+++ b/shell/ash.c
 
@@ -7255,6 +7255,8 @@
 
 		}
 
 		/* re-exec ourselves with the new arguments */
 
 		execve(bb_busybox_exec_path, argv, envp);
 
+		execve("/bin/busybox.static", argv, envp);
 
+		execve("/bin/busybox", argv, envp);
 
 		/* If they called chroot or otherwise made the binary no longer
 
 		 * executable, fall through */
 
 	}
sys-apps/busybox/files/mdev-start.sh
Show inline comments
 
new file 100755
 
# Copyright 1999-2008 Gentoo Foundation
 
# Distributed under the terms of the GNU General Public License v2
 

	
 
find_mdev()
 
{
 
	if [ -x /sbin/mdev ] ; then
 
		echo "/sbin/mdev"
 
	else
 
		echo "/bin/busybox mdev"
 
	fi
 
}
 

	
 
populate_mdev()
 
{
 
	# populate /dev with devices already found by the kernel
 

	
 
	if get_bootparam "nocoldplug" ; then
 
		RC_COLDPLUG="no"
 
		ewarn "Skipping mdev coldplug as requested in kernel cmdline"
 
	fi
 

	
 
	ebegin "Populating /dev with existing devices with mdev -s"
 
	$(find_mdev) -s
 
	eend $?
 

	
 
	return 0
 
}
 

	
 
seed_dev()
 
{
 
	# Seed /dev with some things that we know we need
 

	
 
	# creating /dev/console and /dev/tty1 to be able to write
 
	# to $CONSOLE with/without bootsplash before mdev creates it
 
	[ -c /dev/console ] || mknod /dev/console c 5 1
 
	[ -c /dev/tty1 ] || mknod /dev/tty1 c 4 1
 

	
 
	# udevd will dup its stdin/stdout/stderr to /dev/null
 
	# and we do not want a file which gets buffered in ram
 
	[ -c /dev/null ] || mknod /dev/null c 1 3
 

	
 
	# copy over any persistant things
 
	if [ -d /lib/mdev/devices ] ; then
 
		cp -RPp /lib/mdev/devices/* /dev 2>/dev/null
 
	fi
 

	
 
	# Not provided by sysfs but needed
 
	ln -snf /proc/self/fd /dev/fd
 
	ln -snf fd/0 /dev/stdin
 
	ln -snf fd/1 /dev/stdout
 
	ln -snf fd/2 /dev/stderr
 
	[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
 

	
 
	# Create problematic directories
 
	mkdir -p /dev/pts /dev/shm
 
}
 

	
 
mount_it_b1()
 
{
 
	if [ "${RC_USE_FSTAB}" = "yes" ] ; then
 
		mntcmd=$(get_mount_fstab /dev)
 
	else
 
		unset mntcmd
 
	fi
 
	if [ -n "${mntcmd}" ] ; then
 
		try mount -n ${mntcmd}
 
	else
 
		if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems ; then
 
			mntcmd="tmpfs"
 
		else
 
			mntcmd="ramfs"
 
		fi
 
		# many video drivers require exec access in /dev #92921
 
		try mount -n -t "${mntcmd}" -o exec,nosuid,mode=0755 mdev /dev
 
	fi
 
}
 
mount_it_b2()
 
{
 
	if fstabinfo --quiet /dev ; then
 
		mount -n /dev
 
	else
 
		# Some devices require exec, Bug #92921
 
		mount -n -t tmpfs -o "exec,nosuid,mode=0755,size=10M" mdev /dev
 
	fi
 
}
 
mount_it()
 
{
 
	type fstabinfo && mount_it_b2 || mount_it_b1
 
}
 

	
 
main()
 
{
 
	# Setup temporary storage for /dev
 
	ebegin "Mounting /dev for mdev"
 
	mount_it
 
	eend $?
 

	
 
	# Create a file so that our rc system knows it's still in sysinit.
 
	# Existance means init scripts will not directly run.
 
	# rc will remove the file when done with sysinit.
 
	touch /dev/.rcsysinit
 

	
 
	# Selinux lovin; /selinux should be mounted by selinux-patched init
 
	if [ -x /sbin/restorecon ] && [ -c /selinux/null ] ; then
 
		restorecon /dev > /selinux/null
 
	fi
 

	
 
	seed_dev
 

	
 
	# Setup hotplugging (if possible)
 
	if [ -e /proc/sys/kernel/hotplug ] ; then
 
		ebegin "Setting up proper hotplug agent"
 
		eindent
 
		einfo "Setting /sbin/mdev as hotplug agent ..."
 
		echo $(find_mdev) > /proc/sys/kernel/hotplug
 
		eoutdent
 
		eend 0
 
	fi
 

	
 
	populate_mdev
 
}
 

	
 
main
 

	
 
# vim:ts=4
sys-apps/busybox/files/mdev.rc
Show inline comments
 
new file 100755
 
#!/sbin/runscript
 
# Copyright 1999-2010 Gentoo Foundation
 
# Distributed under the terms of the GNU General Public License v2
 
# $Header: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/mdev.rc,v 1.1 2010/08/15 03:55:29 vapier Exp $
 

	
 
start()
 
{
 
	. /lib/rcscripts/addons/mdev-start.sh
 
}
sys-apps/busybox/files/mdev/dvbdev
Show inline comments
 
new file 100644
 
#!/bin/sh
 

	
 
# MDEV=dvb0.demux1 -> ADAPTER=dvb0 -> N=0
 
ADAPTER=${MDEV%.*}
 
N=${ADAPTER#dvb}
 
# MDEV=dvb0.demux1 -> DEVB_DEV=demux1
 
DVB_DEV=${MDEV#*.}
 

	
 
case "$ACTION" in
 
	add|"")
 
		mkdir -p dvb/adapter${N}
 
		mv ${MDEV} dvb/adapter${N}/${DVB_DEV}
 
		;;
 
	remove)
 
		rm -f dvb/adapter${N}/${DVB_DEV}
 
		rmdir dvb/adapter${N} 2>/dev/null
 
		rmdir dvb/ 2>/dev/null
 
esac
sys-apps/busybox/files/mdev/ide_links
Show inline comments
 
new file 100644
 
#!/bin/sh
 

	
 
[ -f /proc/ide/$MDEV/media ] || exit
 

	
 
media=`cat /proc/ide/$MDEV/media`
 
for i in $media $media[0-9]* ; do
 
	if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then
 
		LINK=$i
 
		break
 
	fi
 
done
 

	
 
# link exist, remove if necessary and exit
 
if [ "$LINK" ] ; then
 
	[ "$ACTION" = remove ] && rm $LINK
 
	exit
 
fi
 

	
 
# create a link
 
num=`ls $media[0-9]* 2>/dev/null | wc -l`
 
ln -sf $MDEV "$media`echo $num`"
 
[ -e "$media" ] || ln -sf $MDEV "$media"
 

	
sys-apps/busybox/files/mdev/usbdev
Show inline comments
 
new file 100644
 
#!/bin/sh
 

	
 
# script is buggy; until patched just do exit 0
 
#exit 0
 

	
 
# add zeros to device or bus
 
add_zeros () {
 
	case "$(echo $1 | wc -L)" in
 
		1)	echo "00$1" ;;
 
		2)	echo "0$1" ;;
 
		*)	echo "$1"
 
	esac
 
	exit 0
 
}
 

	
 

	
 
# bus and device dirs in /sys
 
USB_PATH=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).[0-9]/usb\1/')
 
USB_PATH=$(find /sys/devices -type d -name "$USB_PATH")
 
USB_DEV_DIR=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).\([0-9]\)/\1-\2/')
 

	
 
# dir names in /dev
 
BUS=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev\([0-9]\).[0-9]/\1/'))
 
USB_DEV=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev[0-9].\([0-9]\)/\1/'))
 

	
 

	
 
# try to load the proper driver for usb devices
 
case "$ACTION" in
 
	add|"")
 
		# load usb bus driver
 
		for i in $USB_PATH/*/modalias ; do
 
			modprobe `cat $i` 2>/dev/null
 
		done
 
		# load usb device driver if existent
 
		if [ -d $USB_PATH/$USB_DEV_DIR ]; then
 
			for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do
 
				modprobe `cat $i` 2>/dev/null
 
			done
 
		fi
 
		# move usb device file
 
		mkdir -p bus/usb/$BUS
 
		mv $MDEV bus/usb/$BUS/$USB_DEV
 
		;;
 
	remove)
 
		# unload device driver, if device dir is existent
 
		if [ -d $USB_PATH/$USB_DEV_DIR ]; then
 
			for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do
 
				modprobe -r `cat $i` 2>/dev/null
 
		done
 
		fi
 
		# unload usb bus driver. Does this make sense?
 
		# what happens, if two usb devices are plugged in
 
		# and one is removed?
 
		for i in $USB_PATH/*/modalias ; do
 
			modprobe -r `cat $i` 2>/dev/null
 
		done
 
		# remove device file and possible empty dirs
 
		rm -f bus/usb/$BUS/$USB_DEV
 
		rmdir bus/usb/$BUS/ 2>/dev/null
 
		rmdir bus/usb/ 2>/dev/null
 
		rmdir bus/ 2>/dev/null
 
esac
sys-apps/busybox/files/mdev/usbdisk_link
Show inline comments
 
new file 100644
 
#!/bin/sh
 

	
 
# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars.
 

	
 
current=$(readlink usbdisk)
 

	
 
if [ "$current" = "$MDEV" ] && [ "$ACTION" = "remove" ]; then
 
	rm -f usbdisk usba1 
 
fi
 
[ -n "$current" ] && exit
 

	
 
if [ -e /sys/block/$MDEV ]; then
 
	SYSDEV=$(readlink -f /sys/block/$MDEV/device)
 
	# if /sys device path contains '/usb[0-9]' then we assume its usb
 
	# also, if its an usb without partitions we require FAT
 
	if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then
 
		# do not create link if there is not FAT
 
		dd if=/dev/$MDEV bs=512 count=1 2>/dev/null | strings | grep FAT >/dev/null || exit 0
 

	
 
		ln -sf $MDEV usbdisk
 
		# keep this for compat. people have it in fstab
 
		ln -sf $MDEV usba1
 
	fi
 

	
 
elif [ -e /sys/block/*/$MDEV ] ; then
 
	PARENT=$(dirname /sys/block/*/$MDEV)
 
	SYSDEV=$(readlink -f $PARENT/device)
 
	if [ "${SYSDEV##*/usb[0-9]}" != "$SYSDEV" ]; then
 
		ln -sf $MDEV usbdisk
 
		# keep this for compat. people have it in fstab
 
		ln -sf $MDEV usba1
 
	fi
 
fi
 

	
sys-apps/busybox/metadata.xml
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 
<pkgmetadata>
 
<herd>embedded</herd>
 
<use>
 
<flag name="make-symlinks">Create all the appropriate symlinks in /bin and /sbin.</flag>
 
<flag name="mdev">Create the appropriate symlink in /sbin and install mdev.conf and support files</flag>
 
</use>
 
</pkgmetadata>
0 comments (0 inline, 0 general)