1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#!/bin/bash
#
# Copyright (C) 2013, 2014, 2015, 2016 Linaro, Inc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Given a git url or a tarball name, this function will return a stamp name.
#
# $1: Stamp type: configure, build, extract, fetch.
# $2: File URL or tarball name.
# $3: Special suffix, e.g., "stage1" or "stage2"
#
get_stamp_name()
{
local component=$1
local stamptype=$2
local git_or_tar=$3
local suffix=${4:-}
local validstamp="$(echo ${stamptype} | egrep -c "^configure$|^build$|^extract$|^fetch$")"
if test ${validstamp} -lt 1; then
error "Invalid stamp type selected."
return 1
fi
local name_fragment=
if test "$(echo "${git_or_tar}" | grep -c "\.tar")" -gt 0; then
# Strip the .tar.* from the archive file to get the stamp name.
name_fragment="$(echo "${git_or_tar}" | sed -e 's:\.tar.*::')"
# Strip any preceding directory information,
# e.g., infrastructure/gmp-2.1.2.tar.xz -> gmp-2.1.2
name_fragment="$(basename ${name_fragment})"
else
name_fragment="$(get_git_tag ${git_or_tar})" || return 1
if test x"${name_fragment}" = x; then
error "Couldn't determine stamp name."
return 1
fi
fi
echo "$component-${name_fragment}${suffix:+-${suffix}}-${stamptype}.stamp"
return 0
}
# $1 Stamp Location
# $2 Stamp Name
#
create_stamp()
{
local stamp_loc=$1
local stamp_name=$2
local ret=
# Strip trailing slashes from the location directory.
stamp_loc="$(echo ${stamp_loc} | sed 's#/*$##')"
if test ! -d "${stamp_loc}"; then
notice "'${stamp_loc}' doesn't exist, creating it."
dryrun "mkdir -p \"${stamp_loc}\""
fi
local full_stamp_path=
full_stamp_path="${stamp_loc}/${stamp_name}"
dryrun "touch \"${full_stamp_path}\""
ret=$?
notice "Creating stamp ${full_stamp_path} ($(dryrun "stat -c %Y ${full_stamp_path}"))"
return ${ret}
}
#
# $1 Stamp Location
# $2 Stamp Name
# $3 File to compare stamp against
# $4 Force
#
# If stamp file is newer than the compare file return 0
# If stamp file is NOT newer than the compare file return 1
# If stamp file does not exist return 1
#
# Return Value:
#
# 1 - If the test_stamp function returns 1 then regenerate the stamp
# after processing.
#
# 0 - Otherwise the test_stamp function returns 0 which means that
# you should not proceed with processing.
#
# 255 - There is an error condition during stamp generation. This is
# a bug in abe or the filesystem.
#
check_stamp()
{
local stamp_loc=$1
local stamp_name=$2
local compare_file=$3
local stamp_type=$4
local local_force=$5
if test ! -e "${compare_file}" -a x"${dryrun}" != xyes; then
fixme "Compare file '${compare_file}' does not exist."
return 255
fi
# Strip trailing slashes from the location directory.
stamp_loc="$(echo ${stamp_loc} | sed 's#/*$##')"
# stamp_type is only used for an informational message and we want to make
# the resultant message grammatically correct.
if test x"${stamp_type}" = x"configure"; then
stamp_type="configur"
fi
if test x"${dryrun}" = xyes; then
notice "--dryrun is being used${stamp_type:+, ${stamp_type}ing..}."
return 1
fi
notice "Checking for ${stamp_loc}/${stamp_name}"
if test ${compare_file} -nt ${stamp_loc}/${stamp_name} -o x"${local_force}" = xyes; then
if test ! -e "${stamp_loc}/${stamp_name}"; then
notice "${stamp_loc}/${stamp_name} does not yet exist${stamp_type:+, ${stamp_type}ing..}."
elif test x"${local_force}" = xyes; then
notice "--force is being used${stamp_type:+, ${stamp_type}ing..}."
else
notice "${compare_file} ($(dryrun "stat -c %Y ${compare_file}")) is newer than ${stamp_loc}/${stamp_name} ($(dryrun "stat -c %Y ${stamp_loc}/${stamp_name}"))${stamp_type:+, ${stamp_type}ing..}."
if [ -d "${compare_file}" ]; then
notice "Directory stamp for ${compare_file}/ ($(dryrun "stat -c %Y ${compare_file}/"))"
fi
fi
return 1
else
notice "${stamp_loc}/${stamp_name} ($(dryrun "stat -c %Y ${stamp_loc}/${stamp_name}")) is newer than ${compare_file} ($(dryrun "stat -c %Y ${compare_file}")). Nothing to be done."
fi
return 0
}
|