113 lines
1.8 KiB
Bash
Executable File
113 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# System Package Installer
|
|
|
|
DIR=${2}
|
|
TARGET=${3}
|
|
|
|
BINDIR=${DIR}/bin
|
|
SBINDIR=${DIR}/sbin
|
|
LIBDIR=${DIR}/lib
|
|
INCLUDEDIR=${DIR}/include
|
|
SHAREDIR=${DIR}/share
|
|
|
|
usage() {
|
|
printf "${0} - Install a package\n"
|
|
printf "usage: ${0} [-h] [-i] DIR TARGET\n"
|
|
printf "\n"
|
|
printf "${0} {-h} Show this message\n"
|
|
printf "${0} {-i DIR TARGET} Install package DIR to directory TARGET\n"
|
|
printf "\n"
|
|
printf "Spi is free software.\n"
|
|
printf "See the GNU GPL version 3 for details.\n"
|
|
}
|
|
|
|
usage_small() {
|
|
printf "usage ${0} [-h] [-i] DIR\n"
|
|
}
|
|
|
|
check_if_input_is_blank() {
|
|
if [ "${2}" == "" ]; then
|
|
printf "Package directory not specified.\n"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "${3}" == "" ]; then
|
|
printf "Target directory not specified.\n"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_if_dir_is_pkg() {
|
|
if [ ! -f "${DIR}/.ispkg" ]; then
|
|
printf "Directory isn't a package.\n"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
install_bin() {
|
|
if [ -d "${DIR}/bin" ]; then
|
|
cp -rv ${BINDIR}/* ${TARGET}/bin
|
|
else
|
|
printf "Skipping directory 'bin'\n"
|
|
fi
|
|
}
|
|
|
|
install_sbin() {
|
|
if [ -d "${DIR}/sbin" ]; then
|
|
cp -rv ${SBINDIR}/* ${TARGET}/sbin
|
|
else
|
|
printf "Skipping directory 'sbin'\n"
|
|
fi
|
|
}
|
|
|
|
install_lib() {
|
|
if [ -d "${DIR}/lib" ]; then
|
|
cp -rv ${LIBDIR}/* ${TARGET}/lib
|
|
else
|
|
printf "Skipping directory 'lib'\n"
|
|
fi
|
|
}
|
|
|
|
install_include() {
|
|
if [ -d "${DIR}/include" ]; then
|
|
cp -rv ${INCLUDEDIR}/* ${TARGET}/include
|
|
else
|
|
printf "Skipping directry 'include'\n"
|
|
fi
|
|
}
|
|
|
|
install_share() {
|
|
if [ -d "${DIR}/share" ]; then
|
|
cp -rv ${SHAREDIR}/* ${TARGET}/share
|
|
else
|
|
printf "Skipping directory 'share'\n"
|
|
fi
|
|
}
|
|
|
|
case $1 in
|
|
-h)
|
|
usage "$@"
|
|
exit 0
|
|
;;
|
|
-i)
|
|
check_if_input_is_blank "$@"
|
|
check_if_dir_is_pkg "$@"
|
|
install_bin "$@"
|
|
install_sbin "$@"
|
|
install_lib "$@"
|
|
install_include "$@"
|
|
install_share "$@"
|
|
exit 0
|
|
;;
|
|
-*)
|
|
usage_small "$@"
|
|
exit 1
|
|
;;
|
|
*)
|
|
usage_small "$@"
|
|
exit 1
|
|
esac
|
|
|
|
usage_small "$@"
|
|
exit q
|