• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/support/misc/relocate-sdk.sh
Wolfgang GrandeggerWolfgang Grandegger committed f45f0c2d40e20 Jul 2017
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
1
#!/bin/sh
2
#
3
if [ "$#" -ne 0 ]; then
4
    echo "Run this script to relocate the buildroot SDK at that location"
5
    exit 1
6
fi
7
​
8
LOCFILE="share/buildroot/sdk-location"
9
FILEPATH="$(readlink -f "$0")"
10
NEWPATH="$(dirname "${FILEPATH}")"
11
​
12
cd "${NEWPATH}"
13
if [ ! -r "${LOCFILE}" ]; then
14
    echo "Previous location of the buildroot SDK not found!"
15
    exit 1
16
fi
17
OLDPATH="$(cat "${LOCFILE}")"
18
​
19
if [ "${NEWPATH}" = "${OLDPATH}" ]; then
20
    echo "This buildroot SDK has already been relocated!"
21
    exit 0
22
fi
23
​
24
# Check if the path substitution does work properly, e.g.  a tree
25
# "/a/b/c" copied into "/a/b/c/a/b/c/" would not be allowed.
26
newpath="$(sed -e "s|${OLDPATH}|${NEWPATH}|g" "${LOCFILE}")"
27
if [ "${NEWPATH}" != "${newpath}" ]; then
28
    echo "Something went wrong with substituting the path!"
29
    echo "Please choose another location for your SDK!"
30
    exit 1
31
fi
32
​
33
echo "Relocating the buildroot SDK from ${OLDPATH} to ${NEWPATH} ..."
34
​
35
# Make sure file uses the right language
36
export LC_ALL=C
37
# Replace the old path with the new one in all text files
38
grep -lr "${OLDPATH}" . | while read -r FILE ; do
39
    if file -b --mime-type "${FILE}" | grep -q '^text/' && [ "${FILE}" != "${LOCFILE}" ]
40
    then
41
        sed -i "s|${OLDPATH}|${NEWPATH}|g" "${FILE}"
42
    fi
43
done
44
​
45
# At the very end, we update the location file to not break the
46
# SDK if this script gets interruted.
47
sed -i "s|${OLDPATH}|${NEWPATH}|g" ${LOCFILE}
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.