1 |
# $Header: /magellan-cvs/smage/include/mtools.sminc,v 1.39 2008/04/20 08:28:23 niro Exp $ |
# $Id$ |
2 |
# some special build tools |
# some special build tools |
3 |
|
|
4 |
# automatical inherit mtools.minc |
# automatical inherit mtools.minc |
150 |
{ |
{ |
151 |
local udevrule |
local udevrule |
152 |
local file |
local file |
153 |
|
local udevrulesddir="/usr/lib/udev/rules.d" |
154 |
|
|
155 |
[[ -z "$1" ]] && die "No udev rule given" |
[[ -z "$1" ]] && die "No udev rule given" |
156 |
|
|
170 |
fi |
fi |
171 |
|
|
172 |
# needed directory |
# needed directory |
173 |
install -d ${BINDIR}/etc/udev/rules.d || die |
install -d ${BINDIR}${udevrulesddir} || die |
174 |
|
|
175 |
# install our udev rule |
# install our udev rule |
176 |
install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die |
install -v -m 0644 -o root -g root ${file} ${BINDIR}${udevrulesddir}/${udevrule} || die |
177 |
} |
} |
178 |
|
|
179 |
minstalludevhelper() |
minstalludevhelper() |
180 |
{ |
{ |
181 |
local udevhelper |
local udevhelper |
182 |
local file |
local file |
183 |
|
local udevdir="/usr/lib/udev" |
184 |
|
|
185 |
[[ -z "$1" ]] && die "No udev helper given" |
[[ -z "$1" ]] && die "No udev helper given" |
186 |
|
|
200 |
fi |
fi |
201 |
|
|
202 |
# needed directory |
# needed directory |
203 |
install -d ${BINDIR}/lib/udev || die |
install -d ${BINDIR}${udevdir} || die |
204 |
|
|
205 |
# install our udev-helper |
# install our udev-helper |
206 |
install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die |
install -v -m 0755 -o root -g root ${file} ${BINDIR}${udevdir}/${udevhelper} || die |
207 |
} |
} |
208 |
|
|
209 |
minstallhalinformation() |
minstallhalinformation() |
470 |
|
|
471 |
|
|
472 |
# installs logrotate configuration files |
# installs logrotate configuration files |
473 |
# minstallpam /path/to/logrotatefile {destfilename} |
# minstalllog /path/to/logrotatefile {destfilename} |
474 |
minstalllog() |
minstalllog() |
475 |
{ |
{ |
476 |
local logfile |
local logfile |
589 |
local dest |
local dest |
590 |
local verbose="-v" |
local verbose="-v" |
591 |
|
|
592 |
# check for busybox as it doesn'tz support 'ln -v' |
# check for busybox as it doesn't support 'ln -v' |
593 |
[[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
[[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
594 |
|
|
595 |
[[ -z $1 ]] && die "No file given" |
[[ -z $1 ]] && die "No file given" |
616 |
# install our library |
# install our library |
617 |
install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
618 |
|
|
619 |
# create libtool symlinks |
# prefer scanelf |
620 |
# 1. - library.so.1.0.0 -> library.so.1.0 |
if [[ -x $(type -P scanelf) ]] |
|
if [ "${file%.*}" != *.so ] |
|
|
then |
|
|
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
|
|
fi |
|
|
# 2. - library.so.1.0.0 -> library.so.1 |
|
|
if [ "${file%.*.*}" != *.so ] |
|
621 |
then |
then |
622 |
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
local soname="$(scanelf -qBF '%S#p' ${file})" |
623 |
|
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/${soname} || die |
624 |
|
else |
625 |
|
echo -e "${COLYELLOW}minstalllib(): Warning: scanelf not found, using fallback symlink method${COLDEFAULT}" |
626 |
|
|
627 |
|
# create libtool symlinks |
628 |
|
# 1. - library.so.1.0.0 -> library.so.1.0 |
629 |
|
if [ "${file%.*}" != *.so ] |
630 |
|
then |
631 |
|
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) || die |
632 |
|
fi |
633 |
|
# 2. - library.so.1.0.0 -> library.so.1 |
634 |
|
if [ "${file%.*.*}" != *.so ] |
635 |
|
then |
636 |
|
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) || die |
637 |
|
fi |
638 |
|
# 3. - library.so.1.0.0.0 -> library.so.1 |
639 |
|
if [ "${file%.*.*.*}" != *.so ] |
640 |
|
then |
641 |
|
ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*.*}) || die |
642 |
|
fi |
643 |
fi |
fi |
644 |
} |
} |
645 |
|
|
652 |
# recursive |
# recursive |
653 |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
654 |
then |
then |
655 |
opts="--recursive" |
opts="-R" |
656 |
source="$2" |
source="$2" |
657 |
dest="$3" |
dest="$3" |
658 |
fi |
fi |
660 |
# recursive |
# recursive |
661 |
if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
662 |
then |
then |
663 |
opts="--recursive --force" |
opts="-R -f" |
664 |
|
source="$2" |
665 |
|
dest="$3" |
666 |
|
fi |
667 |
|
|
668 |
|
if [[ $1 = -a ]] |
669 |
|
then |
670 |
|
opts="-a" |
671 |
source="$2" |
source="$2" |
672 |
dest="$3" |
dest="$3" |
673 |
fi |
fi |
678 |
cp -v ${opts} ${source} ${BINDIR}/${dest} || die |
cp -v ${opts} ${source} ${BINDIR}/${dest} || die |
679 |
} |
} |
680 |
|
|
681 |
|
mdelete() |
682 |
|
{ |
683 |
|
local dest="$1" |
684 |
|
local opts |
685 |
|
|
686 |
|
# recursive |
687 |
|
if [[ $1 = -r ]] || [[ $1 = -R ]] |
688 |
|
then |
689 |
|
opts="-r" |
690 |
|
dest="$2" |
691 |
|
fi |
692 |
|
|
693 |
|
# recursive |
694 |
|
if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] |
695 |
|
then |
696 |
|
opts="-r -f" |
697 |
|
dest="$2" |
698 |
|
fi |
699 |
|
|
700 |
|
[[ -z ${dest} ]] && die "No dest given." |
701 |
|
if [[ ! -e ${BINDIR}/${dest} ]] || [[ ! -L ${BINDIR}/${dest} ]] |
702 |
|
then |
703 |
|
die "${BINDIR}/${dest} does not exist." |
704 |
|
if |
705 |
|
|
706 |
|
rm -v ${opts} ${BINDIR}/${dest} || die |
707 |
|
} |
708 |
|
|
709 |
mmove() |
mmove() |
710 |
{ |
{ |
711 |
local source="$1" |
local source="$1" |
715 |
# force |
# force |
716 |
if [[ $1 = -f ]] |
if [[ $1 = -f ]] |
717 |
then |
then |
718 |
opts="--force" |
opts="-f" |
719 |
source="$2" |
source="$2" |
720 |
dest="$3" |
dest="$3" |
721 |
fi |
fi |
761 |
# recursive |
# recursive |
762 |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
763 |
then |
then |
764 |
local recursive="--recursive" |
local recursive="-R" |
765 |
local owner="$2" |
local owner="$2" |
766 |
local path="$3" |
local path="$3" |
767 |
fi |
fi |
781 |
# recursive |
# recursive |
782 |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
if [[ $1 = -r ]] || [[ $1 = -R ]] |
783 |
then |
then |
784 |
local recursive="--recursive" |
local recursive="-R" |
785 |
local posix="$2" |
local posix="$2" |
786 |
local path="$3" |
local path="$3" |
787 |
fi |
fi |
806 |
|
|
807 |
ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
808 |
} |
} |
809 |
|
|
810 |
|
# installs systemd units |
811 |
|
# minstallunit /path/to/unit-file {destfilename} |
812 |
|
minstallunit() |
813 |
|
{ |
814 |
|
local unit |
815 |
|
local file |
816 |
|
local systemdunitdir="/usr/lib/systemd/system" |
817 |
|
|
818 |
|
[[ -z "$1" ]] && die "No unit given" |
819 |
|
|
820 |
|
# if no fullpath given use file from sourcedir |
821 |
|
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
822 |
|
then |
823 |
|
file="${SOURCEDIR}/$(mpname)/$1" |
824 |
|
else |
825 |
|
file="$1" |
826 |
|
fi |
827 |
|
|
828 |
|
if [[ -n "$2" ]] |
829 |
|
then |
830 |
|
unit="$2" |
831 |
|
else |
832 |
|
unit="$(basename ${file})" |
833 |
|
fi |
834 |
|
|
835 |
|
# needed directory |
836 |
|
install -d ${BINDIR}${prefix}${systemdunitdir} || die |
837 |
|
|
838 |
|
# install our initscript |
839 |
|
install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}${systemdunitdir}/${unit} || die |
840 |
|
} |
841 |
|
|
842 |
|
# installs systemd tmp configs to /etc/tmpfiles.d |
843 |
|
# minstalltmp /path/to/tmpdfile {destfilename} |
844 |
|
minstalltmp() |
845 |
|
{ |
846 |
|
local tmpdfile |
847 |
|
local file |
848 |
|
|
849 |
|
[[ -z "$1" ]] && die "No tmpd file given" |
850 |
|
|
851 |
|
# if no fullpath given use file from sourcedir |
852 |
|
if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] |
853 |
|
then |
854 |
|
file="${SOURCEDIR}/$(mpname)/$1" |
855 |
|
else |
856 |
|
file="$1" |
857 |
|
fi |
858 |
|
|
859 |
|
if [[ -n "$2" ]] |
860 |
|
then |
861 |
|
tmpdfile="$2" |
862 |
|
else |
863 |
|
tmpdfile="$(basename ${file})" |
864 |
|
fi |
865 |
|
|
866 |
|
# needed directory |
867 |
|
install -d ${BINDIR}/etc/tmpfiles.d || die |
868 |
|
|
869 |
|
# install our tmpdfile |
870 |
|
install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die |
871 |
|
} |
872 |
|
|
873 |
|
mclearconfig() |
874 |
|
{ |
875 |
|
local confdir |
876 |
|
local prefix="${BINDIR}" |
877 |
|
[[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" |
878 |
|
|
879 |
|
# no bindir prefix if requested |
880 |
|
case $1 in |
881 |
|
-b|--no-bindir) prefix="";; |
882 |
|
esac |
883 |
|
|
884 |
|
confdir="$(dirname ${MCONFIG})" |
885 |
|
if [[ ! -d ${prefix}/${confdir} ]] |
886 |
|
then |
887 |
|
install -d ${prefix}/${confdir} || die |
888 |
|
fi |
889 |
|
: > ${prefix}/${MCONFIG} |
890 |
|
} |
891 |
|
|
892 |
|
maddconfig() |
893 |
|
{ |
894 |
|
local argv="$1" |
895 |
|
local confdir |
896 |
|
local prefix="${BINDIR}" |
897 |
|
|
898 |
|
[[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" |
899 |
|
|
900 |
|
# no bindir prefix if requested |
901 |
|
case $1 in |
902 |
|
-b|--no-bindir) prefix=""; argv="$2" ;; |
903 |
|
esac |
904 |
|
|
905 |
|
[[ -z ${argv} ]] && die "No argument given!" |
906 |
|
|
907 |
|
confdir="$(dirname ${MCONFIG})" |
908 |
|
if [[ ! -d ${prefix}/${confdir} ]] |
909 |
|
then |
910 |
|
install -d ${prefix}/${confdir} || die |
911 |
|
fi |
912 |
|
echo "${argv}" >> ${prefix}/${MCONFIG} || die |
913 |
|
} |