Keep original image
This commit is contained in:
parent
80dafd8bff
commit
c363172933
|
@ -47,7 +47,7 @@ GENERIC_IMAGE_PASSWORD='freedombone'
|
||||||
IMAGE_TYPE='beaglebone'
|
IMAGE_TYPE='beaglebone'
|
||||||
CURR_DIR=$(pwd)
|
CURR_DIR=$(pwd)
|
||||||
CURR_USER=$(echo $USER)
|
CURR_USER=$(echo $USER)
|
||||||
BUILD_DIR=~/.tmp_${PROJECT_NAME}_build
|
TEMPBUILD_DIR=~/.tmp_${PROJECT_NAME}_build
|
||||||
VMDEBOOTSTRAP_REPO=git://git.liw.fi/vmdebootstrap
|
VMDEBOOTSTRAP_REPO=git://git.liw.fi/vmdebootstrap
|
||||||
VMDEBOOTSTRAP_VERSION=0.8
|
VMDEBOOTSTRAP_VERSION=0.8
|
||||||
MAKEFILE=${PROJECT_NAME}-image-makefile
|
MAKEFILE=${PROJECT_NAME}-image-makefile
|
||||||
|
@ -244,33 +244,47 @@ if [ ! $PASSWORD ]; then
|
||||||
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Move any existing images into a build subdirectory
|
||||||
image_types=( xz img sig vdi qcow2 )
|
image_types=( xz img sig vdi qcow2 )
|
||||||
for im in "${image_types[@]}"
|
for im in "${image_types[@]}"
|
||||||
do
|
do
|
||||||
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
||||||
if (( no_of_files > 0 )); then
|
if (( no_of_files > 0 )); then
|
||||||
rm ${CURR_DIR}/${PROJECT_NAME}*.${im}
|
if [ ! -d ${CURR_DIR}/build ]; then
|
||||||
|
mkdir ${CURR_DIR}/build
|
||||||
|
fi
|
||||||
|
mv -f ${CURR_DIR}/${PROJECT_NAME}*.${im} ${CURR_DIR}/build
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Delete anything which didn't move
|
||||||
|
for im in "${image_types[@]}"
|
||||||
|
do
|
||||||
|
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
|
||||||
|
if (( no_of_files > 0 )); then
|
||||||
|
rm -f ${CURR_DIR}/${PROJECT_NAME}*.${im}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Remove any existing login credentials file
|
||||||
if [ -f ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt ]; then
|
if [ -f ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt ]; then
|
||||||
rm ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt
|
rm ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $BUILD_DIR ]; then
|
if [ -d $TEMPBUILD_DIR ]; then
|
||||||
rm -rf $BUILD_DIR
|
rm -rf $TEMPBUILD_DIR
|
||||||
fi
|
fi
|
||||||
mkdir -p $BUILD_DIR
|
mkdir -p $TEMPBUILD_DIR
|
||||||
if [ -f /usr/local/bin/$MAKEFILE ]; then
|
if [ -f /usr/local/bin/$MAKEFILE ]; then
|
||||||
cp /usr/local/bin/$MAKEFILE $BUILD_DIR/Makefile
|
cp /usr/local/bin/$MAKEFILE $TEMPBUILD_DIR/Makefile
|
||||||
else
|
else
|
||||||
cp /usr/bin/$MAKEFILE $BUILD_DIR/Makefile
|
cp /usr/bin/$MAKEFILE $TEMPBUILD_DIR/Makefile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -r /etc/${PROJECT_NAME}/* $BUILD_DIR
|
cp -r /etc/${PROJECT_NAME}/* $TEMPBUILD_DIR
|
||||||
rm -rf $BUILD_DIR/vendor
|
rm -rf $TEMPBUILD_DIR/vendor
|
||||||
chown -R $CURR_USER:$CURR_USER $BUILD_DIR
|
chown -R $CURR_USER:$CURR_USER $TEMPBUILD_DIR
|
||||||
cd $BUILD_DIR
|
cd $TEMPBUILD_DIR
|
||||||
|
|
||||||
if [[ $MINIMAL_INSTALL == "yes" ]]; then
|
if [[ $MINIMAL_INSTALL == "yes" ]]; then
|
||||||
IMAGE_NAME='min'
|
IMAGE_NAME='min'
|
||||||
|
@ -280,7 +294,7 @@ if [[ $ONION_ONLY != "no" ]]; then
|
||||||
IMAGE_NAME='onion'
|
IMAGE_NAME='onion'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $BUILD_DIR
|
cd $TEMPBUILD_DIR
|
||||||
make $IMAGE_TYPE \
|
make $IMAGE_TYPE \
|
||||||
USERNAME="$USERNAME" \
|
USERNAME="$USERNAME" \
|
||||||
PASSWORD="$PASSWORD" \
|
PASSWORD="$PASSWORD" \
|
||||||
|
@ -303,7 +317,7 @@ make $IMAGE_TYPE \
|
||||||
|
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
echo $'Build failed'
|
echo $'Build failed'
|
||||||
rm -rf $BUILD_DIR
|
rm -rf $TEMPBUILD_DIR
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -319,11 +333,11 @@ shopt -s nullglob
|
||||||
imgfiles=(build/${PROJECT_NAME}*.${EXPECTED_EXTENSION})
|
imgfiles=(build/${PROJECT_NAME}*.${EXPECTED_EXTENSION})
|
||||||
if [ ${#imgfiles[@]} -eq 0 ]; then
|
if [ ${#imgfiles[@]} -eq 0 ]; then
|
||||||
echo $'Image was not created'
|
echo $'Image was not created'
|
||||||
rm -rf $BUILD_DIR
|
rm -rf $TEMPBUILD_DIR
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Move images to the current directory
|
# Move images from temporary directory to the current directory
|
||||||
for im in "${image_types[@]}"
|
for im in "${image_types[@]}"
|
||||||
do
|
do
|
||||||
no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l)
|
no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l)
|
||||||
|
@ -332,7 +346,8 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -rf ${BUILD_DIR}
|
# Remove the temporary directory
|
||||||
|
rm -rf ${TEMPBUILD_DIR}
|
||||||
|
|
||||||
cd ${CURR_DIR}
|
cd ${CURR_DIR}
|
||||||
|
|
||||||
|
@ -380,7 +395,7 @@ if [[ $IMAGE_TYPE != "virtualbox"* && $IMAGE_TYPE != "qemu"* ]]; then
|
||||||
echo ''
|
echo ''
|
||||||
echo $'You can copy the image to a microSD card with:'
|
echo $'You can copy the image to a microSD card with:'
|
||||||
echo ''
|
echo ''
|
||||||
echo " unxz ${PROJECT_NAME}*.img.xz"
|
echo " unxz -k ${PROJECT_NAME}*.img.xz"
|
||||||
echo " sudo dd bs=1M if=${PROJECT_NAME}*.img of=/dev/sdX conv=fdatasync"
|
echo " sudo dd bs=1M if=${PROJECT_NAME}*.img of=/dev/sdX conv=fdatasync"
|
||||||
echo ''
|
echo ''
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue