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

Destdir install #172

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 87 additions & 44 deletions libs/build.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
# #
# Parts Copyrighted Stefan Wold 2020 under GPLv2 #
# #
# Parts Copyrighted Dave Brown 2018 under GPLv2 #
# #
############################################################


Expand Down Expand Up @@ -294,77 +296,110 @@ default_meson_config() {
}

default_install() {
verbose_msg "running \"default_install\""
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
if [ ! -d $DESTDIR ]
then
mkdir -p ${DESTDIR}
fi &&
make install DESTDIR=${DESTDIR}
else
prepare_install &&
make install
fi
}

default_python2_build() {
debug_msg "default_python2_build version ($@)"
verbose_msg "running \"default_python2_build\""

if [[ ${DESTDIR_BUILD:-off} == on ]]
then
mkdir -p "${DESTDIR}" &&
export PYTHONDONTWRITEBYTECODE=1 &&
python2 setup.py build &&
python2 setup.py install --root=$DESTDIR $OPTS
else
local _PYDESTDIR=$SOURCE_DIRECTORY/__pythondest2
mkdir -p "$_PYDESTDIR" &&

export PYTHONDONTWRITEBYTECODE=1 &&
python2 setup.py build &&
python2 setup.py install --root="$_PYDESTDIR" $OPTS &&
prepare_install &&
cp -rpfv --remove-destination "$_PYDESTDIR"/* /
fi
}

default_python3_build() {
debug_msg "default_python3_build ($@)"
verbose_msg "running \"default_python3_build\""

if [[ "${DESTDIR_BUILD:-off}" == on ]]
then
mkdir -p "$DESTDIR" &&
export PYTHONDONTWRITEBYTECODE=1 &&
python3 setup.py build &&
python3 setup.py install --root=$DESTDIR $OPTS
else
local _PYDESTDIR=$SOURCE_DIRECTORY/__pythondest3
mkdir -p "$_PYDESTDIR" &&

export PYTHONDONTWRITEBYTECODE=1 &&
python3 setup.py build &&
python3 setup.py install --root="$_PYDESTDIR" $OPTS &&
prepare_install &&
make install
cp -rpfv --remove-destination "$_PYDESTDIR"/* /
fi
}

default_meson_build() {
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
debug_msg "default_meson_build DESTDIR version ($@)"
verbose_msg "running \"default_meson_build\""
default_meson_config &&
ninja -C build/ &&
DESTDIR=${DESTDIR} ninja -C build/ install
else
debug_msg "default_meson_build ($@)"
verbose_msg "running \"default_meson_build\""
default_meson_config &&
ninja -C build/ &&
prepare_install &&
ninja -C build/ install
fi
}

default_make() {
debug_msg "default_make ($@)"
verbose_msg "running \"default_make\""
make ${MAKES:+-j${MAKES}} &&
make &&
default_install
}


default_game_build() {
debug_msg "default_game_build ($@)"
verbose_msg "running \"default_game_build\""
default_game_config &&
default_make
}


default_cmake_build() {
debug_msg "default_cmake_build ($@)"
verbose_msg "running \"default_cmake_build\""
default_cmake_config &&
default_make
}

default_meson_build() {
debug_msg "default_meson_build ($@)"
verbose_msg "running \"default_meson_build\""
default_meson_config &&
ninja -C build/ &&
prepare_install &&
ninja -C build/ install
}

default_perl_build() {
debug_msg "default_perl_build ($@)"
verbose_msg "running \"default_perl_build\""
perl Makefile.PL &&
default_make
}

default_python2_build() {
debug_msg "default_python2_build ($@)"
verbose_msg "running \"default_python2_build\""

local _PYDESTDIR=$SOURCE_DIRECTORY/__pythondest2
mkdir -p "$_PYDESTDIR" &&

export PYTHONDONTWRITEBYTECODE=1 &&
python2 setup.py build &&
python2 setup.py install --root="$_PYDESTDIR" $OPTS &&
prepare_install &&
cp -rpfv --remove-destination "$_PYDESTDIR"/* /
}

default_python3_build() {
debug_msg "default_python3_build ($@)"
verbose_msg "running \"default_python3_build\""

local _PYDESTDIR=$SOURCE_DIRECTORY/__pythondest3
mkdir -p "$_PYDESTDIR" &&

export PYTHONDONTWRITEBYTECODE=1 &&
python3 setup.py build &&
python3 setup.py install --root="$_PYDESTDIR" $OPTS &&
prepare_install &&
cp -rpfv --remove-destination "$_PYDESTDIR"/* /
}

default_gnu_build() {
debug_msg "default_gnu_build ($@)"
verbose_msg "running \"default_gnu_build\""
Expand Down Expand Up @@ -429,9 +464,17 @@ default_cpan_build() {
default_post_build() {
debug_msg "default_post_build ($@)"

if [ $(wc -l "$INSTALLWATCHFILE" | awk '{print$1}') == "0" ] && [ "$PROFILE" != "yes" ] ; then
message "${PROBLEM_COLOR}ERROR: ${DEFAULT_COLOR}${FILE_COLOR}BUILD${DEFAULT_COLOR}${PROBLEM_COLOR} does not call prepare_install or installs zero files!${DEFAULT_COLOR}"
return 1
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
if [ ! -d $DESTDIR ]
then
message "${PROBLEM_COLOR}WARNING: ${DEFAULT_COLOR}${FILE_COLOR}BUILD${DEFAULT_COLOR}${PROBLEM_COLOR} installs zero files into ${DESTDIR}!${DEFAULT_COLOR}"
fi
else
if [ $(wc -l "$INSTALLWATCHFILE" | awk '{print$1}') == "0" ] && [ "$PROFILE" != "yes" ] ; then
message "${PROBLEM_COLOR}ERROR: ${DEFAULT_COLOR}${FILE_COLOR}BUILD${DEFAULT_COLOR}${PROBLEM_COLOR} does not call prepare_install or installs zero files!${DEFAULT_COLOR}"
return 1
fi
fi

update_plugin $MODULE install
Expand Down
7 changes: 5 additions & 2 deletions libs/main.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ expand_cache_safe() {(
fi
done

debug_msg "tar xjf $1 -P -k -T $TMP_TARGETS_OK"
tar xf $1 -P -k -T $TMP_TARGETS_OK > /dev/null 2>&1
(
cd /
debug_msg "tar xjf $1 -P -k -T $TMP_TARGETS_OK"
tar xf $1 -P -k -T $TMP_TARGETS_OK > /dev/null 2>&1
)

temp_destroy $TMP_TARGETS
temp_destroy $TMP_TARGETS_OK
Expand Down
4 changes: 4 additions & 0 deletions libs/modules.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ run_details() {
SOURCE_DIRECTORY=${SOURCE_DIRECTORY:-$BUILD_DIRECTORY/$1-$VERSION}
MODULE_CONFIG=${MODULE_CONFIG:-$DEPENDS_CONFIG/$MODULE}
MODULE_PREFIX=${MODULE_PREFIX:-$DEFAULT_PREFIX}
if [[ ${DESTDIR_BUILD:-off} == on ]]; then
DESTDIR=${SOURCE_DIRECTORY}/_lunar_supply_pod
export DESTDIR
fi
if [ "$MODULE_PREFIX" != "$DEFAULT_PREFIX" ]; then
export PKG_CONFIG_PATH=$MODULE_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
export PATH=$PATH:$MODULE_PREFIX/bin
Expand Down
119 changes: 108 additions & 11 deletions libs/tracking.lunar
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,70 @@ parse_iw() {
cat "$INSTALLWATCHFILE" | cut -f4 | grep -v "^$SOURCE_DIRECTORY" | grep -v -f "$EXCLUDED" | grep "^/"
}

create_destdir_install_log() {
debug_msg "create_destdir_install_log"
(
cd $DESTDIR

# function : create_install_log
# usage : create_install_log
# purpose : create an install log
create_install_log() {
TMP_INST_LOG=$(temp_create "install-log")

INST_LOG="$INSTALL_LOGS/$MODULE-$VERSION"

rm -f $INST_LOG >/dev/null 2>&1
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}${INST_LOG}${DEFAULT_COLOR}"

find . -print | sed 's/^.//' | sort > $TMP_INST_LOG
echo "$INSTALL_LOGS/$MODULE-$VERSION" >> $TMP_INST_LOG
echo "$COMPILE_LOGS/$MODULE-$VERSION.${COMPRESS_METHOD}" >> $TMP_INST_LOG
echo "$MD5SUM_LOGS/$MODULE-$VERSION" >> $TMP_INST_LOG

install -m644 $TMP_INST_LOG $INST_LOG

temp_destroy $TMP_INST_LOG
)
}

create_destdir_md5sum_log() {
debug_msg "create_destdir_md5sum_log"
(
cd $DESTDIR
rm -f $MD5SUM_LOGS/$MODULE-$VERSION &> /dev/null
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$MD5SUM_LOGS/$MODULE-$VERSION${DEFAULT_COLOR}"

sed 's;^/;;' < $INSTALL_LOGS/$MODULE-$VERSION | files | xargs -d '\n' md5sum > $MD5SUM_LOGS/$MODULE-$VERSION
)
}

create_destdir_install_cache() {
debug_msg "create_destdir_install_cache ($@)"
if [[ $ARCHIVE == off ]]
then
return
fi

message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.${COMPRESS_METHOD}${DEFAULT_COLOR}"
(
cd $DESTDIR
tar cf - * | ${COMPRESS_METHOD/bz2/bzip2} $COMPRESS_METHOD_ARGS > "$INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.${COMPRESS_METHOD}"
)
}

finish_destdir_install() {
debug_msg "finish_destdir_install ($@)"

create_install_log &&
create_md5sum_log &&
create_install_cache &&
expand_cache_safe $INSTALL_CACHE/$MODULE-$VERSION-$BUILD.tar.${COMPRESS_METHOD} &&

cleanup_old_module_files "$TMP_OLD_INST_LOG" "$INSTALL_LOGS/$MODULE-$VERSION" &&
add_module $MODULE installed $VERSION $(find_module_size $MODULE $VERSION)
verbose_msg "module size is $(find_module_size $MODULE $VERSION)"
}

create_installwatch_install_log() {
local TMP_INST_LOG INST_LOG IFS MISOWNED_SYMLINKS
debug_msg "create_install_log ($@)"
debug_msg "create_installwatch_install_log ($@)"

TMP_INST_LOG=$(temp_create "install-log")
INST_LOG="$INSTALL_LOGS/$MODULE-$VERSION"
Expand All @@ -84,18 +141,18 @@ create_install_log() {
}


create_md5sum_log() {
create_installwatch_md5sum_log() {
local FILE
debug_msg "create_md5sum_log ($@)"
debug_msg "create_installwatch_md5sum_log ($@)"

rm -f $MD5SUM_LOGS/$MODULE-$VERSION &> /dev/null
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$MD5SUM_LOGS/$MODULE-$VERSION${DEFAULT_COLOR}"

IFS=$'\n' files < $INSTALL_LOGS/$MODULE-$VERSION | xargs -d '\n' md5sum >> $MD5SUM_LOGS/$MODULE-$VERSION
}

create_install_cache() {
debug_msg "create_install_cache($@)"
create_installwatch_install_cache() {
debug_msg "create_installwatch_install_cache($@)"

if [ "$ARCHIVE" == "off" ] ; then
return
Expand Down Expand Up @@ -126,8 +183,8 @@ delete_old_install_log() {
fi
}

finish_install() {
debug_msg "finish_install ($@)"
finish_installwatch_install() {
debug_msg "finish_installwatch_install ($@)"

create_install_log &&
create_md5sum_log &&
Expand All @@ -138,3 +195,43 @@ finish_install() {
add_module $MODULE installed $VERSION $(find_module_size $MODULE $VERSION)
verbose_msg "module size is $(find_module_size $MODULE $VERSION)"
}

create_install_log() {
debug_msg "create_install_log"
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
create_destdir_install_log
else
create_installwatch_install_log
fi
}

create_md5sum_log() {
debug_msg "create_md5sum_log"
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
create_destdir_md5sum_log
else
create_installwatch_md5sum_log
fi
}

create_install_cache() {
debug_msg "create_install_cache"
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
create_destdir_install_cache
else
create_installwatch_install_cache
fi
}

finish_install() {
debug_msg "finish_install"
if [[ ${DESTDIR_BUILD:-off} == on ]]
then
finish_destdir_install
else
finish_installwatch_install
fi
}