build/checkout: remove git_clear in favour of proper stage; #8
This will make it a bit harder to build clean sets in the future, but it has been requested so here it is. ;)
This commit is contained in:
parent
ac66d5fe68
commit
a5814e2465
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
STEPS= base kernel ports core iso memstick nano \
|
||||
regress clean release skim
|
||||
regress clean release skim checkout
|
||||
.PHONY: ${STEPS}
|
||||
|
||||
PAGER?= less
|
||||
|
|
|
@ -110,6 +110,11 @@ A direct disk image in NanoBSD style is created using:
|
|||
About other scripts and tweaks
|
||||
==============================
|
||||
|
||||
A known state can be checked out, removing all unwanted files
|
||||
from the repository, fetching all remote updates, via:
|
||||
|
||||
# make checkout[-<repo_branch_or_tag>]
|
||||
|
||||
Before building images, you can run the regression tests
|
||||
to check the integrity of your core.git modifications plus
|
||||
generate output for the style checker:
|
||||
|
@ -127,7 +132,7 @@ generated and modified by ports.sh and core.sh.
|
|||
|
||||
Release sets can be built using:
|
||||
|
||||
# make release[-<versiontag>]
|
||||
# make release
|
||||
|
||||
Kernel, base, packages and release sets are stored under /tmp/sets
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ set -e
|
|||
|
||||
sh ./clean.sh base
|
||||
|
||||
git_clear ${SRCDIR}
|
||||
git_describe ${SRCDIR}
|
||||
|
||||
MAKEARGS="SRCCONF=${PRODUCT_CONFIG}/src.conf COMPILER_TYPE=clang __MAKE_CONF="
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2015 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
set -e
|
||||
|
||||
. ./common.sh && $(${SCRUB_ARGS})
|
||||
|
||||
for GITDIR in ${SRCDIR} ${PORTSDIR} ${COREDIR}; do
|
||||
echo ">>> Checking out ${GITDIR}:"
|
||||
git -C ${GITDIR} fetch --all --prune --quiet
|
||||
git_checkout ${GITDIR} ${1}
|
||||
done
|
|
@ -74,7 +74,7 @@ export TARGET_ARCH=${ARCH}
|
|||
export TARGETARCH=${ARCH}
|
||||
|
||||
# define target directories
|
||||
export PACKAGESDIR="/packages"
|
||||
export PACKAGESDIR="/.pkg"
|
||||
export STAGEDIR="/usr/local/stage"
|
||||
export IMAGESDIR="/tmp/images"
|
||||
export SETSDIR="/tmp/sets"
|
||||
|
@ -91,18 +91,14 @@ export NANOIMG="${IMAGESDIR}/${PRODUCT_RELEASE}-nano-${ARCH}.img"
|
|||
# print environment to showcase all of our variables
|
||||
env | sort
|
||||
|
||||
git_clear()
|
||||
git_checkout()
|
||||
{
|
||||
# Reset the git repository into a known state by
|
||||
# enforcing a hard-reset to HEAD (so you keep your
|
||||
# selected commit, but no manual changes) and all
|
||||
# unknown files are cleared (so it looks like a
|
||||
# freshly cloned repository).
|
||||
|
||||
echo -n ">>> Resetting ${1}... "
|
||||
|
||||
git -C ${1} reset --hard HEAD
|
||||
git -C ${1} clean -xdqf .
|
||||
REPO_TAG=${2}
|
||||
if [ -z "${REPO_TAG}" ]; then
|
||||
git_tag ${1} ${PRODUCT_VERSION}
|
||||
fi
|
||||
git -C ${1} reset --hard ${REPO_TAG}
|
||||
}
|
||||
|
||||
git_describe()
|
||||
|
@ -119,6 +115,38 @@ git_describe()
|
|||
export REPO_COMMENT=${COMMENT}
|
||||
}
|
||||
|
||||
git_tag()
|
||||
{
|
||||
# Fuzzy-match a tag and return it for the caller.
|
||||
|
||||
POOL=$(git -C ${1} tag | grep ^${2}\$ || true)
|
||||
if [ -z "${POOL}" ]; then
|
||||
VERSION=${2%.*}
|
||||
FUZZY=${2##${VERSION}.}
|
||||
|
||||
for _POOL in $(git -C ${1} tag | grep ^${VERSION} | sort -r); do
|
||||
_POOL=${_POOL##${VERSION}}
|
||||
if [ -z "${_POOL}" ]; then
|
||||
POOL=${VERSION}${_POOL}
|
||||
break
|
||||
fi
|
||||
if [ ${_POOL##.} -lt ${FUZZY} ]; then
|
||||
POOL=${VERSION}${_POOL}
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "${POOL}" ]; then
|
||||
echo ">>> ${1} doesn't match tag ${2}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ">>> ${1} matches tag ${2} -> ${POOL}"
|
||||
|
||||
export REPO_TAG=${POOL}
|
||||
}
|
||||
|
||||
setup_clone()
|
||||
{
|
||||
echo ">>> Setting up ${2} in ${1}"
|
||||
|
|
|
@ -29,8 +29,6 @@ set -e
|
|||
|
||||
. ./common.sh && $(${SCRUB_ARGS})
|
||||
|
||||
git_clear ${PORTSDIR}
|
||||
git_clear ${COREDIR}
|
||||
git_describe ${COREDIR}
|
||||
|
||||
setup_stage ${STAGEDIR}
|
||||
|
|
|
@ -31,7 +31,6 @@ set -e
|
|||
|
||||
sh ./clean.sh kernel
|
||||
|
||||
git_clear ${SRCDIR}
|
||||
git_describe ${SRCDIR}
|
||||
|
||||
BUILD_KERNEL="SMP"
|
||||
|
|
|
@ -31,9 +31,6 @@ set -e
|
|||
|
||||
PORT_LIST=$(cat ${PRODUCT_CONFIG}/ports.conf)
|
||||
|
||||
git_clear ${PORTSDIR}
|
||||
git_clear ${SRCDIR}
|
||||
|
||||
setup_stage ${STAGEDIR}
|
||||
setup_base ${STAGEDIR}
|
||||
setup_clone ${STAGEDIR} ${PORTSDIR}
|
||||
|
|
|
@ -29,8 +29,6 @@ set -e
|
|||
|
||||
. ./common.sh && $(${SCRUB_ARGS})
|
||||
|
||||
git_clear ${COREDIR}
|
||||
|
||||
setup_stage ${STAGEDIR}
|
||||
setup_base ${STAGEDIR}
|
||||
setup_clone ${STAGEDIR} ${COREDIR}
|
||||
|
|
Loading…
Reference in New Issue