Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help support reinstated #101

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
*~
*.orig
*.backup
*.pyc
*.o
*.so
*.so.*
*.swp
*.kate-swp
*.patch
*.diff

build
*.log
*.notes
*.petes
*.tux
*.mingus
*.stuff
.gitignore
10 changes: 7 additions & 3 deletions buildconf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INCLUDEDIR ?= $(INCLUDE_PREFIX)/include
ETCDIR ?= $(PREFIX)/etc
ETCDIR_VDEV ?= $(ETCDIR)/vdev
SHAREDIR ?= $(PREFIX)/share
PKGCONFIG ?= $(INCLUDE_PREFIX)/share/pkgconfig
PKGCONFIG ?= $(INCLUDE_PREFIX)/share/pkgconfig
RUNDIR ?= $(PREFIX)/run
RUNDIR_VDEV ?= $(RUNDIR)/vdev
LOGDIR ?= $(PREFIX)/var/log
Expand Down Expand Up @@ -68,8 +68,12 @@ BUILD_HWDB := $(BUILD_LIBDIR)/vdev/hwdb
BUILD_HWDB_DIRS := $(BUILD_HWDB)
INSTALL_HWDB := $(DESTDIR)$(LIBDIR)/vdev/hwdb

# compiler
CFLAGS := -Wall -std=c99 -g -fPIC -fstack-protector -fstack-protector-all -pthread -Wno-unused-variable -Wno-unused-but-set-variable
# compiler original settings
#CFLAGS := -Wall -std=c99 -g -fPIC -fstack-protector -fstack-protector-all -pthread -Wno-unused-variable -Wno-unused-but-set-variable
# compiler : headers also set some C standards though perhaps boiler plate ?
# noiser settings for hair shirted types and deeper testing and analysis.
CFLAGS := -g -fPIC -fstack-protector -fstack-protector-all -pthread\
-Wall -Wextra -std=c11 #-pedantic-errors
LDFLAGS :=
INC := -I. -I$(ROOT_DIR) -I$(BUILD_INCLUDEDIR)
DEFS := -D_THREAD_SAFE -D__STDC_FORMAT_MACROS -D_VDEV_OS_$(OS) -D_XOPEN_SOURCE=700
Expand Down
31 changes: 31 additions & 0 deletions debian.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

LIC=gpl3
#EMAIL=ralph.ronnquist@gmail.com
EMAIL=pete.gossner@gmail.com
VERSION=1.0alpha-petes
ARCH=$(shell uname -r)
HOMEPAGE="github.com/PeteGozz/vdev"

DEBS += vdevd_$(VERSION)_$(ARCH).deb
DEBS += libudev1-compat_$(VERSION)_$(ARCH).deb
DEBS += vdev_$(VERSION)_$(ARCH).deb

all: $(DEBS)

vdevd_$(VERSION)_$(ARCH).deb:
$(MAKE) -C vdevd -f ../debian.mk deb PACKAGE=vdevd

libudev1-compat_$(VERSION)_$(ARCH).deb:
$(MAKE) -C libudev-compat -f ../debian.mk deb PACKAGE=libudev1-compat

vdev_$(VERSION)_$(ARCH).deb:
$(MAKE) -C example -f ../debian.mk deb PACKAGE=vdev

vdevfs_$(VERSION)_$(ARCH).deb:
$(MAKE) -C fs -f ../debian.mk deb PACKAGE=vdevfs

.PHONY: deb
deb:
dh_make -a -s -n -y -e "$(EMAIL)" -p $(PACKAGE)_$(VERSION) -c $(LIC)
PREFIX= INCLUDE_PREFIX=/usr dpkg-buildpackage -b -uc

119 changes: 88 additions & 31 deletions example/initramfs/hooks/vdev
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh -e
# posix shell or maybe dash only
#debug# set -x

PREREQS=""

Expand All @@ -11,29 +13,41 @@ case "$1" in
;;
esac

. /usr/share/initramfs-tools/hook-functions
. /usr/share/initramfs-tools/hook-functions

# Needed for keyboard or most mice
# see: /dev/input/*

force_load evdev
if [ $? != 0 ]; then
echo "WARNING:[Xorg] eventfs _may_ not present X with keyboard or mouse devices"
sleep 2;
fi

# helper programs
mkdir -p $DESTDIR/lib/vdev
for prog in /lib/vdev/*; do

mkdir -vp $DESTDIR/lib/vdev

for prog in /lib/vdev/*; do
# shell script or library?
if [ -z "${prog#*.sh}" ]; then

cp -a $prog $DESTDIR/lib/vdev/
else

# binary?
if [ -f $prog -a -x $prog ]; then

copy_exec $prog /lib/vdev
fi
fi
done

# libudev-compat
if [ -f /lib/libudev.so.1 ] ; then
copy_exec /lib/libudev.so.1
fi

# config
mkdir -p $DESTDIR/etc/vdev
cp -a /etc/vdev/* $DESTDIR/etc/vdev/
mkdir -pv $DESTDIR/etc/vdev
cp -avf /etc/vdev/* $DESTDIR/etc/vdev/

# the daemon itself
copy_exec /sbin/vdevd
Expand All @@ -42,39 +56,51 @@ copy_exec /sbin/vdevd
if [ -f /sbin/blkid ]; then
copy_exec /sbin/blkid
else
echo "WARN: could not find blkid in /sbin/blkid. /dev/disk symlinks will not be created."
echo "WARN: could not find blkid in /sbin/blkid."
echo " /dev/disk symlinks will not be created."
fi

# lvm tools (needed by vdevd's helpers)
if [ -f /sbin/lvs ]; then
copy_exec /sbin/lvs
else
echo "WARN: could not find lvs in /sbin/lvs. Logical volume symlinks will not be created."
echo "WARN: could not find lvs in /sbin/lvs."
echo " Logical volume symlinks will not be created."
fi

if [ -f /sbin/pvs ]; then
copy_exec /sbin/pvs
else
echo "WARN: could not find pvs in /sbin/pvs. Physical volume symlinks will not be created."
echo "WARN: could not find pvs in /sbin/pvs."
echo " Physical volume symlinks will not be created."
fi

if [ -f /sbin/lvm ]; then
copy_exec /sbin/lvm
else
echo "WARN: could not find lvm in /sbin/lvm. Logical volume symlinks will not be created."
echo "WARN: could not find lvm in /sbin/lvm."
echo " Logical volume symlinks will not be created."
fi

#
# network tools (needed by vdevd's helpers)
# busy box may provide alternatives
# for human uses. (?)
#
if ! [ -f /sbin/ip ] && ! [ -f /bin/ip ]; then
echo "WARN: could not find iproute2 in /bin/ip or /sbin/ip."
echo " Networking may not be available"
fi

if [ -f /bin/ip ]; then
copy_exec /bin/ip
fi

if [ -f /sbin/ip ]; then
copy_exec /sbin/ip
fi

if ! [ -f /sbin/ip ] && ! [ -f /bin/ip ]; then
echo "WARN: could not find iproute2 in /bin/ip or /sbin/ip. Network interfaces will not be configured."
else [ -f /sbin/ifconfig ]; then
# try the classical tool
copy_exec /sbin/ifconfig
echo "NOTE: installing /sbin/ifconfig as networking tool"
fi

# SELinux tools
Expand All @@ -83,23 +109,31 @@ if [ -f /sbin/restorecon ]; then
fi

# device tools
# prefer most current
if [ -f /sbin/MAKEDEV ]; then
copy_exec /sbin/MAKEDEV || true
copy_exec /sbin/MAKEDEV
else
echo "WARNING: No MAKEDEV found to install"
echo "vdev --once may be your best alternative"
fi

# device mapper tools
if [ -f /sbin/dmsetup ]; then
copy_exec /sbin/dmsetup
else
echo "WARN: could not find dmsetup in /sbin/dmsetup. Device mapper symlinks will not be created."
echo "WARN: could not find dmsetup in /sbin/dmsetup."
echo " Device mapper symlinks will not be created."
fi

# hardware database
if [ -f /lib/vdev/hwdb/hwdb.squashfs ]; then
copy_exec /sbin/losetup
mkdir -p $DESTDIR/lib/vdev/hwdb
cp -a /lib/vdev/hwdb/hwdb.squashfs $DESTDIR/lib/vdev/hwdb
else
echo "WARN: could not find hardware database in /lib/vdev/hwdb. Some hardware metadata may not be generated."
echo "WARN: could not find hardware database in /lib/vdev/hwdb."
echo "Some hardware metadata may not be generated."
sleep 2
fi

# GNU tools (not the busybox equivalents)
Expand All @@ -112,19 +146,42 @@ copy_exec /bin/egrep
copy_exec /bin/kmod

# users and groups databases
cp -a /etc/passwd $DESTDIR/etc/passwd
cp -a /etc/group $DESTDIR/etc/group

# extra libc goodies
copy_exec /lib/x86_64-linux-gnu/libc.so.6
copy_exec /lib/x86_64-linux-gnu/libnss_compat.so.2
copy_exec /lib/x86_64-linux-gnu/libnsl.so.1
copy_exec /lib/x86_64-linux-gnu/libnss_nis.so.2
copy_exec /lib/x86_64-linux-gnu/libnss_files.so.2
cp -va /etc/passwd $DESTDIR/etc/passwd
cp -va /etc/group $DESTDIR/etc/group

#
# extra libc goodies
# Falling to i386 if i686 is the uname machine type
# and the i686 libc version is not found.
#
#
if [ -d /lib/$(arch)-linux-gnu ]; then
LIBC=/lib/$(arch)-linux-gnu
elif [ -d /lib/i386-linux-gnu ]; then
LIBC=/lib/i386-linux-gnu
else
# make noise and trigger -e if set
echo "Unable to find libc shared object files for $(arch)"
sleep 1
echo "Please check dependancies or package install order"
sleep 2
/bin/false
fi

# since vdevd is multi-threaded, libpthread will dynamically load libgcc_s
copy_exec $LIBC/libc.so.6 || echo "$LIBC/libc.so.6 (still) not found"
copy_exec $LIBC/libnss_compat.so.2
copy_exec $LIBC/libnsl.so.1
copy_exec $LIBC/libnss_nis.so.2
copy_exec $LIBC/libnss_files.so.2
#
# since vdevd is multi-threaded,
# libpthread will need to dynamically load libgcc_s
# (and copy_exec won't detect this)
copy_exec /lib/`gcc -print-multiarch`/libgcc_s.so.1
#
copy_exec $LIBC/libgcc_s.so.1 || echo "libpthread needs libgcc_s"

# until we're confident that the scripts work with busybox's sh, use dash
copy_exec /bin/dash

# be polite
exit
22 changes: 11 additions & 11 deletions example/sysv-initscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Provides: udev
# Required-Start: mountkernfs
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Start vdevd, populate /dev and load drivers.
### END INIT INFO

Expand Down Expand Up @@ -33,16 +33,15 @@ source_ini_file() {

FILE_PATH=$1
NAMESPACE=$2

# convert [ini style header] to ""
/bin/cat $FILE_PATH | /bin/sed "s/.*\[.*\].*//g" | \
while read line; do

KEY=$(echo $line | /bin/sed "s/\(^.*\)=.*/\1/g");
VALUE=$(echo $line | /bin/sed "s/^.*=\(.*\)$/\1/g");

if [ -n "$KEY" ]; then

echo "${NAMESPACE}${KEY}=${VALUE}"
echo "${NAMESPACE}${KEY}=${VALUE}"
fi
done
}
Expand Down Expand Up @@ -79,7 +78,7 @@ eval $(source_ini_file $VDEV_CONFIG "vdev_config_")
# config sanity check
if [ -z "$vdev_config_pidfile" ]; then
log_warning_msg "No PID file defined in $VDEV_CONFIG. Please set the pidfile= directive."
log_warning_msg "You will be unable stop or restart vdevd with this script."
log_warning_msg "You will be unable control vdevd with this init script."
fi


Expand Down Expand Up @@ -119,12 +118,13 @@ vdevd_start() {

# start vdev
if "$VDEV_BIN" -c "$VDEV_CONFIG" $@ "$VDEV_MOUNTPOINT"; then
log_end_msg $?

log_end_msg $?
else
log_warning_msg $?
log_warning_msg "Waiting 15 seconds and trying to continue anyway"
sleep 15
log_warning_msg $?
log_warning_msg "Errors when starting \"$VDEV_BIN\" -c \"$VDEV_CONFIG\" "
log_warning_msg "Waiting 15 seconds and trying to continue anyway"
sleep 15
fi

return 0
Expand Down
1 change: 1 addition & 0 deletions example/vdevd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[vdev-config]

firmware=/lib/firmware
acls=./build/etc/vdev/acls
actions=./build/etc/vdev/actions
Expand Down
Loading