Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 241 lines (195 sloc) 6.39 KB
#!/bin/sh
. config/options
add_control() {
local KEY="$1"
local VAL="$2"
[ -n "$KEY" -a -n "$VAL" ] && \
echo "${KEY}: $VAL" >> $INSTALL/CONTROL/control
return 0
}
get_overlay() {
local pkg_name="$1"
local file_name="$2"
local overlay_name
if [ -r $PACKAGES/$PKG_SECTION/$pkg_name/$file_name ] ; then
overlay_name=$PACKAGES/$PKG_SECTION/$pkg_name/$file_name
else
overlay_name="$PACKAGES/$pkg_name/$file_name"
fi
local name_ends_with=`expr substr $file_name ${#file_name} 1`
local temp_name=""
# check for platform-specific package overlay
temp_name="$PLATFORM_PACKAGES/$pkg_name/$file_name"
if [ $name_ends_with = "/" ] ; then
[ -d "$temp_name" ] && overlay_name="$temp_name"
else
[ -r "$temp_name" ] && overlay_name="$temp_name"
fi
# check for machine-specific package overlay
temp_name="$MACHINE_PACKAGES/$pkg_name/$file_name"
if [ $name_ends_with = "/" ] ; then
[ -d "$temp_name" ] && overlay_name="$temp_name"
else
[ -r "$temp_name" ] && overlay_name="$temp_name"
fi
# check for flavour-specific package overlay
temp_name="$FLAVOUR_PACKAGES/$pkg_name/$file_name"
if [ $name_ends_with = "/" ] ; then
[ -d "$temp_name" ] && overlay_name="$temp_name"
else
[ -r "$temp_name" ] && overlay_name="$temp_name"
fi
echo $overlay_name
}
[ -n "$REPO" ] && $SCRIPTS/get-opk $1
get_meta $1
if [ "$PKG_OPK_ARCH" = unsupported ]; then
echo "$1 is not supported on $TARGET_ARCH, aborting"
exit 1
fi
# locate install script
INSTALL_RULE=`get_overlay "$1" "install"`
# build
$SCRIPTS/build $1
BUILD_STAMP=$STAMPS/$1/build
mkdir -p $PKGROOT
STAMP="$PKGROOT/$PKG_OPK"
if [ -f $STAMP ] && [ $INSTALL_RULE -nt $STAMP -o $BUILD_STAMP -nt $STAMP ]; then
$SCRIPTS/uninstall $1
rm -f $STAMP
fi
if [ -f $STAMP ]; then
echo "$1 is already packaged, skipping..." >&$VERBOSE_OUT
exit 0
fi
if [ ! -f $INSTALL_RULE ]; then
echo "$1 is not a runtime package, skipping..." >&$VERBOSE_OUT
exit 0
fi
set_title "PACKAGE $1"
rm -f $STAMP
export INSTALL="$PKGROOT_STAGE/$1"
rm -rf $INSTALL
mkdir -p $INSTALL/CONTROL
# package runtime deps
for p in $PKG_RUN_DEPENDS; do
$SCRIPTS/package $p
done
# install to staging
if [ "$SYSTEMD" = yes ]; then
SOURCE_PATH=`get_overlay "$1" "unit/"`
if [ -d $SOURCE_PATH ]; then
mkdir -p $INSTALL/lib/systemd/system
for unit in ${SOURCE_PATH}* ; do
cp $unit $INSTALL/lib/systemd/system
systemctl_enable `basename $unit` $INSTALL
done
fi
SOURCE_PATH=`get_overlay "$1" "tmpfiles.d/"`
if [ -d $SOURCE_PATH ]; then
mkdir -p $INSTALL/usr/lib/tmpfiles.d
cp ${SOURCE_PATH}*.conf $INSTALL/usr/lib/tmpfiles.d
fi
SOURCE_PATH=`get_overlay "$1" "modules-load.d/"`
if [ -d $SOURCE_PATH ]; then
mkdir -p $INSTALL/usr/lib/modules-load.d
cp ${SOURCE_PATH}*.conf $INSTALL/usr/lib/modules-load.d
fi
SOURCE_PATH=`get_overlay "$1" "sysctl.d/"`
if [ -d $SOURCE_PATH ]; then
mkdir -p $INSTALL/usr/lib/sysctl.d
cp ${SOURCE_PATH}*.conf $INSTALL/usr/lib/sysctl.d
fi
fi
SOURCE_PATH=`get_overlay "$1" "modprobe.d/"`
if [ -d $SOURCE_PATH ]; then
mkdir -p $INSTALL/etc/modprobe.d
cp ${SOURCE_PATH}*.conf $INSTALL/etc/modprobe.d
fi
SOURCE_PATH=`get_overlay "$1" "profile.d/"`
if [ -d $SOURCE_PATH ]; then
mkdir -p $INSTALL/etc/profile.d
cp ${SOURCE_PATH}*.sh $INSTALL/etc/profile.d
fi
$INSTALL_RULE $1 >&$VERBOSE_OUT
# build opk package
SOURCE_PATH=`get_overlay "$1" "package/"`
if [ -d $SOURCE_PATH ]; then
cp ${SOURCE_PATH}/* $INSTALL/CONTROL
fi
if [ -n "$PKG_EPOCH" ]; then
OPK_VER_ID="${PKG_EPOCH}:${PKG_VERSION}-${PKG_REV}"
elif [ "$PKG_URL_PROTO" = git ]; then
OPK_VER_ID="1:${PKG_VERSION}-${PKG_REV}"
else
OPK_VER_ID="${PKG_VERSION}-${PKG_REV}"
fi
add_control "Package" "$PKG_NAME"
add_control "Version" "${OPK_VER_ID}"
add_control "Architecture" "$PKG_OPK_ARCH"
add_control "Depends" "$PKG_OPK_DEPENDS"
add_control "Priority" "$PKG_PRIORITY"
add_control "Section" "$PKG_SECTION"
add_control "Maintainer" "$DISTRO_MAINTAINER"
add_control "Source" "$DISTRO_SOURCE"
add_control "Description" "$PKG_SHORTDESC"
if [ -n "$PKG_SHORTDESC" -a -n "$PKG_LONGDESC" ]; then
echo "$PKG_LONGDESC" | sed 's/^ *//g' | fmt -w72 -u | sed 's/^/ /g' >> \
$INSTALL/CONTROL/control
# write enabled use flags in the package description
uses=""
for flag in $PKG_USE; do
type=`get_use_type $flag`
if [ -z "$type" ] && pkg_uses $PKG_NAME $flag; then
[ -z "$uses" ] && uses=$flag || uses="$uses $flag"
fi
done
if [ -n "$uses" ]; then
echo " ." >> $INSTALL/CONTROL/control
echo "Use flags: $uses" | fmt -w72 -u | sed 's/^/ /g' >> \
$INSTALL/CONTROL/control
fi
fi
opkg-build -O -o root -g root $INSTALL $PKGROOT >&$VERBOSE_OUT
if [ -d "$PKG_BUILD_DIR/.install-debuginfo" ]; then
DEBUGINFO="$PKG_BUILD_DIR/.install-debuginfo"
elif [ -d "$PKG_BUILD_DIR/objdir-target/.install-debuginfo" ]; then
DEBUGINFO="$PKG_BUILD_DIR/objdir-target/.install-debuginfo"
else
unset DEBUGINFO
fi
if [ -d "$DEBUGINFO" ]; then
# build runtime debug package
export INSTALL="$PKGROOT_STAGE/${PKG_NAME}-dbg"
rm -rf $INSTALL
mkdir -p $INSTALL/CONTROL
cp -PR $DEBUGINFO/* $INSTALL
# build opk package
add_control "Package" "${PKG_NAME}-dbg"
add_control "Version" "${OPK_VER_ID}"
add_control "Architecture" "$PKG_OPK_ARCH"
add_control "Depends" "$PKG_NAME"
add_control "Priority" "extra"
add_control "Section" "debug"
add_control "Maintainer" "$DISTRO_MAINTAINER"
add_control "Source" "$DISTRO_SOURCE"
add_control "Description" "debug symbols for $PKG_NAME"
echo "This package contains debug data of the $PKG_NAME package. Most people will not need this package. Please install it to produce useful stacktraces to help debugging $PKG_NAME." | fmt | sed 's/^/ /g' >> $INSTALL/CONTROL/control
opkg-build -O -o root -g root $INSTALL $PKGROOT >&$VERBOSE_OUT
# build devel debug package
export INSTALL="$DEVPKGROOT_STAGE/${PKG_NAME}-dbg"
rm -rf $INSTALL
mkdir -p $INSTALL/CONTROL
cp -PR $DEBUGINFO/* $INSTALL
# build opk package
add_control "Package" "${PKG_NAME}-dbg"
add_control "Version" "${OPK_VER_ID}dev${PKG_OPK_ARCH}"
add_control "Architecture" "`uname -m`"
add_control "Priority" "extra"
add_control "Section" "debug"
add_control "Maintainer" "$DISTRO_MAINTAINER"
add_control "Source" "$DISTRO_SOURCE"
add_control "Description" "debug symbols for $PKG_NAME (devel version)"
opkg-build -O -o root -g root $INSTALL $DEVPKGROOT >&$VERBOSE_OUT
fi
exit 0
Something went wrong with that request. Please try again.