mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 03:38:09 +02:00
makerepo: better detect current source directory
Fix detecting "NetworkManager-0.8.1" directory in "NetworkManager-0.8.1.git20100811.tar.bz2" tarball for rhel-6.
This commit is contained in:
parent
4b797b69ee
commit
086113a646
1 changed files with 21 additions and 19 deletions
|
|
@ -228,29 +228,31 @@ detect_build_type() {
|
||||||
detect_dirname() {
|
detect_dirname() {
|
||||||
local BUILD_TYPE="$1"
|
local BUILD_TYPE="$1"
|
||||||
local DIRS=()
|
local DIRS=()
|
||||||
local SOURCES
|
local SOURCES
|
||||||
local D suffix T
|
local D suffix T
|
||||||
|
|
||||||
SOURCES=$(sed 's/.* //' ./sources 2>/dev/null)
|
SOURCES=$(sed 's/.* //' ./sources 2>/dev/null)
|
||||||
|
|
||||||
for suffix in .tar.gz .tar.bz .tar.xz .tgz ; do
|
for suffix in .tar.gz .tar.bz .tar.xz .tgz .tar.bz2 ; do
|
||||||
for T in ${SOURCES[@]}; do
|
for T in ${SOURCES[@]}; do
|
||||||
if [[ "$T" == *$suffix ]]; then
|
if [[ "$T" == *$suffix ]]; then
|
||||||
D="${T%$suffix}"
|
D="${T%$suffix}"
|
||||||
[[ -d "$D" ]] && DIRS=("${DIRS[@]}" "$D")
|
[[ -d "$D" ]] && DIRS=("${DIRS[@]}" "$D")
|
||||||
fi
|
D="$(tar -tf "$T" | sed 's#/.*##' | sort | uniq)"
|
||||||
done
|
[[ -d "$D" ]] && DIRS=("${DIRS[@]}" "$D")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# iterate over all tarballs that start with "$BUILD_TYPE" and
|
# iterate over all tarballs that start with "$BUILD_TYPE" and
|
||||||
# see if there exists a directory with the same name as
|
# see if there exists a directory with the same name as
|
||||||
# the unpacked tarball (that is, stripping the suffix).
|
# the unpacked tarball (that is, stripping the suffix).
|
||||||
for T in $(ls -1 "$BUILD_TYPE"*"$suffix" 2>/dev/null); do
|
for T in $(ls -1 "$BUILD_TYPE"*"$suffix" 2>/dev/null); do
|
||||||
D="${T%$suffix}"
|
D="${T%$suffix}"
|
||||||
[[ -d "$D" ]] && DIRS=("${DIRS[@]}" "$D")
|
[[ -d "$D" ]] && DIRS=("${DIRS[@]}" "$D")
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
D=
|
D=
|
||||||
if [[ ${#DIRS[@]} -ge 1 ]]; then
|
if [[ ${#DIRS[@]} -ge 1 ]]; then
|
||||||
# return the newest directory.
|
# return the newest directory.
|
||||||
D="$(ls -1d --sort=time --time=ctime "${DIRS[@]}" 2>/dev/null | head -n1)"
|
D="$(ls -1d --sort=time --time=ctime "${DIRS[@]}" 2>/dev/null | head -n1)"
|
||||||
|
|
@ -259,7 +261,7 @@ detect_dirname() {
|
||||||
printf "%s" "$D"
|
printf "%s" "$D"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
BUILD_TYPE=
|
BUILD_TYPE=
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue