Lakka-LibreELEC/scripts/install

160 lines
4.4 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2011-01-09 20:26:03 +00:00
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
#      Copyright (C) 2010-2011 Roman Weber (roman@openelec.tv)
2011-01-09 20:26:03 +00:00
#
# OpenELEC is free software: you can redistribute it and/or modify
2011-01-09 20:26:03 +00:00
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
2011-01-09 20:26:03 +00:00
#
# OpenELEC is distributed in the hope that it will be useful,
2011-01-09 20:26:03 +00:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2011-01-09 20:26:03 +00:00
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
2011-01-09 20:26:03 +00:00
################################################################################
2009-03-18 12:02:53 +00:00
. config/options $1
2009-03-18 12:02:53 +00:00
if [ -z "$1" ]; then
echo "usage: $0 package_name"
exit 1
fi
if [ -z "$INSTALL" ] ; then
echo "error: '\$INSTALL' not set! this script is not intended to be run manually"
exit 1
fi
# set defaults
2015-08-03 12:53:32 +00:00
PACKAGE_NAME=$(echo $1 | awk -F : '{print $1}')
TARGET=$(echo $1 | awk -F : '{print $2}')
if [ -z "$TARGET" ]; then
TARGET="target"
fi
STAMP=$STAMPS_INSTALL/$PACKAGE_NAME/install_$TARGET
mkdir -p $STAMPS_INSTALL/$PACKAGE_NAME
2009-03-18 12:02:53 +00:00
[ -f $STAMP -a $FORCE_INSTALL = "no" ] && exit 0
2009-03-18 12:02:53 +00:00
if [ -n "$PKG_ARCH" -a ! "$PKG_ARCH" = "any" ]; then
echo "$PKG_ARCH" | grep -q "$TARGET_ARCH" || exit 0
echo "$PKG_ARCH" | grep -q "\-$TARGET_ARCH" && exit 0
fi
if [ ! -f $PKG_DIR/package.mk ]; then
printf "${boldred}${PACKAGE_NAME}: no package.mk file found${endcolor}\n"
exit 1
fi
$SCRIPTS/build $@
printf "%${BUILD_INDENT}c ${boldgreen}INSTALL${endcolor} $PACKAGE_NAME ${boldwhite}($TARGET)${endcolor}\n" ' '>&$SILENT_OUT
export BUILD_INDENT=$((${BUILD_INDENT:-1}+$BUILD_INDENT_SIZE))
if [ "$TARGET" = target ] ; then
for p in $PKG_DEPENDS_TARGET; do
$SCRIPTS/install $p
done
elif [ "$TARGET" = init ] ; then
for p in $PKG_DEPENDS_INIT; do
$SCRIPTS/install $p
done
INSTALL=$BUILD/initramfs
fi
mkdir -p $INSTALL
if [ "$TARGET" = target ] ; then
if [ -d $PKG_DIR/profile.d ]; then
mkdir -p $INSTALL/etc/profile.d
cp $PKG_DIR/profile.d/*.conf $INSTALL/etc/profile.d/
fi
if [ -d $PKG_DIR/tmpfiles.d ]; then
mkdir -p $INSTALL/usr/lib/tmpfiles.d
cp $PKG_DIR/tmpfiles.d/*.conf $INSTALL/usr/lib/tmpfiles.d
fi
if [ -d $PKG_DIR/system.d ]; then
mkdir -p $INSTALL/usr/lib/systemd/system
cp $PKG_DIR/system.d/*.* $INSTALL/usr/lib/systemd/system
fi
if [ -d $PKG_DIR/udev.d ]; then
mkdir -p $INSTALL/usr/lib/udev/rules.d
cp $PKG_DIR/udev.d/*.rules $INSTALL/usr/lib/udev/rules.d
fi
if [ -d $PKG_DIR/sleep.d ]; then
mkdir -p $INSTALL/usr/lib/systemd/system-sleep/
cp $PKG_DIR/sleep.d/* $INSTALL/usr/lib/systemd/system-sleep/
fi
if [ -d $PKG_DIR/sleep.d.serial ]; then
mkdir -p $INSTALL/usr/lib/systemd/system-sleep.serial
cp $PKG_DIR/sleep.d.serial/* $INSTALL/usr/lib/systemd/system-sleep.serial
fi
if [ -d $PKG_DIR/sysctl.d ]; then
mkdir -p $INSTALL/usr/lib/sysctl.d/
cp $PKG_DIR/sysctl.d/*.conf $INSTALL/usr/lib/sysctl.d/
fi
if [ -d $PKG_DIR/modules-load.d ]; then
mkdir -p $INSTALL/usr/lib/modules-load.d/
cp $PKG_DIR/modules-load.d/*.conf $INSTALL/usr/lib/modules-load.d/
fi
if [ -d $PKG_DIR/sysconf.d ]; then
mkdir -p $INSTALL/etc/sysconf.d
cp $PKG_DIR/sysconf.d/*.conf $INSTALL/etc/sysconf.d
fi
if [ -d $PKG_DIR/debug.d ]; then
mkdir -p $INSTALL/usr/share/debugconf
2015-08-03 12:53:32 +00:00
cp $PKG_DIR/debug.d/*.conf $INSTALL/usr/share/debugconf
fi
if [ -d $PKG_DIR/modprobe.d ]; then
mkdir -p $INSTALL/lib/modprobe.d
cp $PKG_DIR/modprobe.d/*.conf $INSTALL/lib/modprobe.d
fi
fi
# unset functions
2015-08-03 12:53:32 +00:00
unset -f pre_install
unset -f post_install
# include buildfile
2015-08-03 12:53:32 +00:00
. $PKG_DIR/package.mk
# install
2015-08-03 12:53:32 +00:00
if [ "$TARGET" = target ] ; then
if [ "$(type -t pre_install)" = "function" ]; then
pre_install
fi
2015-08-03 12:53:32 +00:00
fi
2015-08-03 12:53:32 +00:00
if [ "$TARGET" = "target" -a -d $PKG_BUILD/.install_pkg ]; then
mkdir -p $INSTALL
cp -PR $PKG_BUILD/.install_pkg/* $INSTALL
elif [ "$TARGET" = "init" -a -d $PKG_BUILD/.install_init ]; then
mkdir -p $INSTALL
cp -PR $PKG_BUILD/.install_init/* $INSTALL
fi
2015-08-03 12:53:32 +00:00
if [ "$TARGET" = target ] ; then
if [ "$(type -t post_install)" = "function" ]; then
post_install
fi
2015-08-03 12:53:32 +00:00
fi
2015-08-03 12:53:32 +00:00
touch $STAMP