3 # Copyright (C) 2013 Norbert Thiebaud
10 bin_library_info.sh is a tool that create a unique filename for a binary tar file that
11 contain the build of the given source tarfile. the unicity is based on the source tarfile which contains
12 a md5 already and the calculated sha1 of config_host_.mk and of the tree object associated with the top_level_module
15 syntax: bin_library_info.sh -m|--module <top_level_module> -l|--location <TARFILE_LOCATION> -s|--srcdir <SRCDIR> -b <BUILDDIR> -r|--tarfile <LIBRARY_TARFILE> [ -m|--mode verify|name ]
17 the default mode is 'name' which just print the associated binary tarfile name.
18 in 'verify' mode the program print the name if the associated binary tarfile exist
19 and print nothing and return an error code if the file does not exist
21 Note: --location --builddir and --srcdir are optional if they are already in the env in the form of TARFILE_LOCATION and BUILDDIR SRCDIR respectively
29 [ "$V" ] && echo "Error:" "$@"
36 pushd "${SRCDIR?}" > /dev
/null
37 git hash-object
"${BUILDDIR?}"/config_host.mk
41 get_library_gbuild_sha
()
45 pushd "${SRCDIR?}" > /dev
/null
46 if [ -d "${SRCDIR}/external/${module?}" ] ; then
47 git ls-tree
-d HEAD
"external/${module?}" | cut
-f 1 | cut
-d " " -f 3
49 git ls-tree
-d HEAD |
"{module?}" | cut
-f 1 | cut
-d " " -f 3
55 determine_binary_package_name
()
63 csha
=$
(get_config_sha
)
64 gsha
=$
(get_library_gbuild_sha
"${module?}")
65 if [ -n "${csha?}" -a -n "${gsha}" ] ; then
66 binfile
="${csha?}_${gsha?}_${tarball?}.${PLATFORM?}.tar.gz"
77 while [ "${1}" != "" ]; do
81 if [ "${1}" != "${parm?}" ] ; then
88 -h|
--help) # display help
93 if [ -z "${has_arg}" ] ; then
100 if [ -z "${has_arg}" ] ; then
108 if [ -z "${has_arg}" ] ; then
112 TARFILE_LOCATION
="${arg}"
115 # test if the binary package exist
116 if [ -z "${has_arg}" ] ; then
123 # test if the binary package exist
124 if [ -z "${has_arg}" ] ; then
133 -s|
--srcdir) # do not override the local autogen.lastrun if present
134 if [ -z "${has_arg}" ] ; then
142 if [ -z "${has_arg}" ] ; then
146 SOURCE_TARFILE
="${arg}"
149 die
"Invalid option $1"
152 die
"Invalid argument $1"
158 if [ -z "${MODULE?}" ] ; then
159 die
"Missing --module"
161 if [ -z "${TARFILE_LOCATION}" ] ; then
162 die
"Missing --location"
164 if [ -z "${SOURCE_TARFILE}" ] ; then
165 die
"Missing --tarfile"
167 if [ -z "${SRCDIR}" ] ; then
168 die
"Missing --srcdir"
172 BINARY_TARFILE
="$(determine_binary_package_name ${MODULE?} ${SOURCE_TARFILE?})"
174 if [ -z "${BINARY_TARFILE}" ] ; then
178 if [ "${MODE?}" = "verify" ] ; then
179 if [ -f "${TARFILE_LOCATION?}/${BINARY_TARFILE?}" ] ; then
180 echo "${BINARY_TARFILE?}"
185 echo "${BINARY_TARFILE?}"