Skip to content

Commit

Permalink
build: improve opnsense-update(8) marker file write
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Mar 13, 2015
1 parent 6365e3d commit 132641c
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,53 @@ setup_chroot()
chroot ${1} /etc/rc.d/ldconfig start
}

setup_marker()
{
# Let opnsense-update(8) know it's up to date
local MARKER="/usr/local/opnsense/version/os-update"

if [ ! -f ${1}${MARKER} ]; then
# first call means bootstrap the marker file
mkdir -p ${1}$(dirname ${MARKER})
echo ${2} > ${1}${MARKER}
else
# subsequent call means make sure version matches
# (base and kernel must be in sync at all times)
if [ $(cat ${1}${MARKER}) != ${2} ]; then
echo "base/kernel version mismatch"
exit 1
fi
fi
}

setup_base()
{
echo ">>> Setting up world in ${1}"

local BASE_SET=$(ls ${SETSDIR}/base-*-${ARCH}.txz)

# /home is needed for LiveCD images, and since it
# belongs to the base system, we create it from here.
mkdir -p ${1}/home

(cd ${1} && tar -Jxpf ${SETSDIR}/base-*-${ARCH}.txz)
tar -C ${1} -Jxpf ${BASE_SET}

local BASE_VER=${BASE_SET##${SETSDIR}/base-}

setup_marker ${1} ${BASE_VER%%.txz}
}

setup_kernel()
{
echo ">>> Setting up kernel in ${1}"

(cd ${1} && tar -Jxpf ${SETSDIR}/kernel-*-${ARCH}.txz)
local KERNEL_SET=$(ls ${SETSDIR}/kernel-*-${ARCH}.txz)

tar -C ${1} -Jxpf ${KERNEL_SET}

local KERNEL_VER=${KERNEL_SET##${SETSDIR}/kernel-}

setup_marker ${1} ${KERNEL_VER%%.txz}
}

setup_packages()
Expand Down Expand Up @@ -165,11 +196,6 @@ setup_platform()
mkdir -p ${1}/conf
touch ${1}/conf/trigger_initial_wizard

# Let opnsense-update(8) know it's up to date
local MARKER="/usr/local/opnsense/version/os-update"
mkdir -p ${1}$(dirname ${MARKER})
echo ${PRODUCT_VERSION}-${ARCH} > ${1}${MARKER}

echo cdrom > ${1}/usr/local/etc/platform

# Set sane defaults via rc.conf(5)
Expand Down

0 comments on commit 132641c

Please sign in to comment.