1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-11-22 11:09:46 +01:00

Don't keep build directory

Use $PKGBUILDDIR for building packages. Delete it again after
the deploy is done. If the build fails, the script aborts and it
is kept. If the build and deploy pass, there is no reason to keep
it around.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-02-16 18:45:25 +01:00
parent 30aa5ce395
commit 05ae80634c
5 changed files with 17 additions and 19 deletions

3
mk.sh
View file

@ -23,7 +23,7 @@ PKGLOGDIR="$BUILDROOT/$BOARD/log"
PKGDOWNLOADDIR="$BUILDROOT/download" PKGDOWNLOADDIR="$BUILDROOT/download"
PACKAGELIST="$BUILDROOT/$BOARD/pkglist" PACKAGELIST="$BUILDROOT/$BOARD/pkglist"
mkdir -p "$PKGDOWNLOADDIR" "$PKGSRCDIR" "$PKGBUILDDIR" "$PKGLOGDIR" mkdir -p "$PKGDOWNLOADDIR" "$PKGSRCDIR" "$PKGLOGDIR"
mkdir -p "$PKGDEPLOYDIR" "$TCDIR/bin" mkdir -p "$PKGDEPLOYDIR" "$TCDIR/bin"
export PATH="$TCDIR/bin:$PATH" export PATH="$TCDIR/bin:$PATH"
@ -71,6 +71,7 @@ while read pkg; do
run_pkg_command "build" run_pkg_command "build"
run_pkg_command "deploy" run_pkg_command "deploy"
rm -rf "$PKGBUILDDIR"
restore_toolchain restore_toolchain
done < "$PACKAGELIST" done < "$PACKAGELIST"

View file

@ -67,20 +67,21 @@ dir_filelist() {
build() { build() {
local INPUT="$1" local INPUT="$1"
local OUTPUT="$2" local OUTPUT="$2"
local DEPLOY="$3"
# populate with default directory structure # populate with default directory structure
for dir in dev proc sys bin lib newroot images; do for dir in dev proc sys bin lib newroot images; do
mkdir -p "$OUTPUT/$dir" mkdir -p "$DEPLOY/$dir"
done done
ln -s "/bin" "$OUTPUT/sbin" ln -s "/bin" "$DEPLOY/sbin"
# add init script # add init script
cp "$SCRIPTDIR/pkg/initrd/initrd.skel" "$OUTPUT/init" cp "$SCRIPTDIR/pkg/initrd/initrd.skel" "$DEPLOY/init"
chmod +x "$OUTPUT/init" chmod +x "$DEPLOY/init"
# 'install' packages to initrd # 'install' packages to initrd
cp -r ${PKGDEPLOYDIR}/bbstatic/* "$OUTPUT" cp -r ${PKGDEPLOYDIR}/bbstatic/* "$DEPLOY"
} }
deploy() { deploy() {
@ -88,9 +89,11 @@ deploy() {
local BUILD="$2" local BUILD="$2"
local DEPLOY="$3" local DEPLOY="$3"
local LSTFILE="$DEPLOY/initrd.list" local LSTFILE="$BUILD/initrd.list"
dir_filelist "$BUILD" > "$LSTFILE" dir_filelist "$DEPLOY" > "$LSTFILE"
echo "dir /dev 0755 0 0" >> "$LSTFILE" echo "dir /dev 0755 0 0" >> "$LSTFILE"
echo "nod /dev/console 600 0 0 c 5 1" >> "$LSTFILE" echo "nod /dev/console 600 0 0 c 5 1" >> "$LSTFILE"
mv "$LSTFILE" "$DEPLOY"
} }

View file

@ -34,7 +34,5 @@ deploy() {
local BUILD="$2" local BUILD="$2"
local DEPLOY="$3" local DEPLOY="$3"
pushd "$PKGBUILDDIR" > /dev/null tar czf "$DEPLOY/$PKGNAME.tar.gz" *
tar czf "$DEPLOY/$PKGNAME.tar.gz" "$PKGNAME"
popd > /dev/null
} }

View file

@ -36,7 +36,5 @@ deploy() {
local BUILD="$2" local BUILD="$2"
local DEPLOY="$3" local DEPLOY="$3"
pushd "$PKGBUILDDIR" > /dev/null tar czf "$DEPLOY/$PKGNAME.tar.gz" *
tar czf "$DEPLOY/$PKGNAME.tar.gz" "$PKGNAME"
popd > /dev/null
} }

View file

@ -1,7 +1,6 @@
run_pkg_command() { run_pkg_command() {
local FUNCTION="$1" local FUNCTION="$1"
local DEPLOYDIR="$PKGDEPLOYDIR/$PKGNAME" local DEPLOYDIR="$PKGDEPLOYDIR/$PKGNAME"
local OUT="$PKGBUILDDIR/${PKGNAME}"
local CHECKFILE="$PKGLOGDIR/.${PKGNAME}-${FUNCTION}" local CHECKFILE="$PKGLOGDIR/.${PKGNAME}-${FUNCTION}"
echo "$PKGNAME - $FUNCTION" echo "$PKGNAME - $FUNCTION"
@ -13,14 +12,13 @@ run_pkg_command() {
local LOGFILE="$PKGLOGDIR/${PKGNAME}-${FUNCTION}.log" local LOGFILE="$PKGLOGDIR/${PKGNAME}-${FUNCTION}.log"
local SRC="$PKGSRCDIR/$SRCDIR" local SRC="$PKGSRCDIR/$SRCDIR"
mkdir -p "$DEPLOYDIR" "$OUT" "${DEPLOYDIR}-dev" mkdir -p "$DEPLOYDIR" "$PKGBUILDDIR" "${DEPLOYDIR}-dev"
pushd "$OUT" > /dev/null pushd "$PKGBUILDDIR" > /dev/null
$FUNCTION "$SRC" "$OUT" "$DEPLOYDIR" "${DEPLOYDIR}-dev" &>> "$LOGFILE" < /dev/null $FUNCTION "$SRC" "$PKGBUILDDIR" "$DEPLOYDIR" "${DEPLOYDIR}-dev" &>> "$LOGFILE" < /dev/null
popd > /dev/null popd > /dev/null
(rmdir "$DEPLOYDIR" || true) 2> /dev/null ; (rmdir "$DEPLOYDIR" || true) 2> /dev/null ;
(rmdir "$OUT" || true) 2> /dev/null ;
(rmdir "${DEPLOYDIR}-dev" || true) 2> /dev/null ; (rmdir "${DEPLOYDIR}-dev" || true) 2> /dev/null ;
touch "$CHECKFILE" touch "$CHECKFILE"