Am 2014-01-08 10:21, schrieb Alexander Dahl:
> Okay I edited them a little and attached it. Note: the scripts itself
> are put in a subfolder of the BSP here named "scripts".
Guess what I forgot to attach?!
Alex
--
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601 D1D5 8FBA 7744 CC87 10D0 ***
#!/bin/sh
# ----------------------------------------------------------------------
# Clone a git repository in get stage or check if it's the right one
# in case already cloned.
#
# Authors: Alexander Dahl <p...@lespocky.de>
#
# Copyright 2011,2012,2013 Alexander Dahl
# ----------------------------------------------------------------------
#set -x
#set -e
_RED="\033[31m"
_YELLOW="\033[33m\033[40m\033[1m"
_NOCOLOR="\033[0m\033[49m"
GITURL="$1"
DESTDIR="$2"
print_usage() {
echo "Usage: $0 giturl destdir"
}
if [ -z "$1" -o -z "$2" ]
then
print_usage
exit 1
fi
CHECKOUTDIR="$(basename ${DESTDIR})"
SRCDIR="$(dirname ${DESTDIR})"
if [ ! -d "${SRCDIR}" ]
then
echo "folder ${_YELLOW}local_src${_NOCOLOR} does not exist, please create it!"
exit 4
fi
cd "${SRCDIR}"
if [ ! -d "${CHECKOUTDIR}" ]
then
if [ -e "${CHECKOUTDIR}" ]
then
echo "${CHECKOUTDIR} exists but is no directory!"
exit 2
else
echo "${CHECKOUTDIR} does not exist."
fi
if git clone "${GITURL}" "${CHECKOUTDIR}"
then
echo 'git clone successful ...'
else
exit $?
fi
cd "${CHECKOUTDIR}"
if git fetch --all
then
echo 'git fetch successful ...'
else
exit $?
fi
else
if [ -L "${CHECKOUTDIR}" ]
then
echo "${_RED}WARNING: ${_YELLOW}${CHECKOUTDIR} is a symbolic link!${_NOCOLOR}"
exit 0
fi
cd "${CHECKOUTDIR}"
REMOTEURL="$(git remote -v | awk '/^origin.+(fetch)/ {print $2;}')"
if [ "${REMOTEURL}" = "${GITURL}" ]
then
echo "This already cloned repo is the right one."
exit 0
else
echo "Cloned repo remote is '${REMOTEURL}' but '${GITURL}' was expected!"
exit 3
fi
fi
# -*-makefile-*-
#
# Copyright (C) 2012 by Alexander Dahl <p...@lespocky.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#
#
# We provide this package
#
PACKAGES-$(PTXCONF_FOO) += foo
#
# Paths and names
#
FOO_VERSION := git
#FOO_MD5 :=
FOO := foo-$(FOO_VERSION)
#FOO_SUFFIX :=
#FOO_URL := /$(FOO).$(FOO_SUFFIX)
#FOO_SOURCE := $(SRCDIR)/$(FOO).$(FOO_SUFFIX)
#FOO_DIR := $(BUILDDIR)/$(FOO)
FOO_LICENSE := proprietary
FOO_SOURCE_LOCAL := $(PTXDIST_WORKSPACE)/local_src/$(FOO)
FOO_GIT_URL := $(PTXCONF_FOO_CLONE_URL)
FOO_CHECKOUT_ENTITY := $(PTXCONF_FOO_CHECKOUT_ENTITY)
FOO_DIR := $(FOO_SOURCE_LOCAL)
# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------
$(STATEDIR)/foo.get:
@$(call targetinfo)
@$(PTXDIST_WORKSPACE)/scripts/get-git.sh "$(FOO_GIT_URL)"
"$(FOO_SOURCE_LOCAL)"
@$(call touch)
# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------
$(STATEDIR)/foo.extract:
@$(call targetinfo)
@cd $(FOO_SOURCE_LOCAL) && \
$(PTXDIST_WORKSPACE)/scripts/extract-git.sh
"$(FOO_CHECKOUT_ENTITY)"
@$(call touch)
# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------
FOO_CONF_TOOL := cmake
# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------
$(STATEDIR)/foo.targetinstall:
@$(call targetinfo)
@$(call install_init, foo)
@$(call install_fixup, foo,PRIORITY,optional)
@$(call install_fixup, foo,SECTION,base)
@$(call install_fixup, foo,AUTHOR,"Alexander Dahl <p...@lespocky.de>")
@$(call install_fixup, foo,DESCRIPTION,missing)
@$(call install_copy, foo, 0, 0, 0755, -, /usr/bin/foo)
@$(call install_finish, foo)
@$(call touch)
# vim: ft=make noet
#!/bin/sh
# ----------------------------------------------------------------------
# In a git "working copy" checkout the given entity (branch, tag,
# changeset). In case of a branch pull the latest changes, in every
# other case leave it in detached HEAD state. This script performs no
# directory changes, so start it in the target directory!
#
# Authors: Alexander Dahl <p...@lespocky.de>
#
# Copyright 2011,2013 Alexander Dahl
# ----------------------------------------------------------------------
ENTITY="$1"
BRANCH_EXISTS="no"
print_usage() {
echo "Usage: $0 checkoutentity"
}
if [ -z "$1" ]
then
print_usage
exit 1
fi
if git fetch
then
echo 'Git fetch successful!'
else
exit $?
fi
if git checkout "$1"
then
echo 'Git checkout successful!'
else
exit $?
fi
for branch in $(git branch | cut -c3-)
do
if [ "${ENTITY}" = "${branch}" ]
then
BRANCH_EXISTS="yes"
fi
done
if [ "${BRANCH_EXISTS}" = "yes" ]
then
git pull
fi
if git submodule update --init --recursive
then
echo 'Git submodule update successful!'
else
exit $?
fi
exit 0
## SECTION=project_specific
menuconfig FOO
tristate
prompt "foo "
select HOST_CMAKE
default y
help
Foo like in bar.
config FOO_CLONE_URL
string
depends on FOO
prompt "Git url to clone from"
default "git://git.example.com/git/foo.git"
help
Git URL to clone from. Defaults to local server, but can be
overwritten with any local or remote URL.
config FOO_CHECKOUT_ENTITY
string
depends on FOO
prompt "Git entity to checkout."
default "stable"
help
Check out a specific branch, tag or changeset.
# vim: ft=kconfig noet tw=72
--
ptxdist mailing list
ptxdist@pengutronix.de