mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-02 16:14:28 +01:00
Compare commits
2 Commits
v1-prefixe
...
v1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e110b44c0 | ||
|
|
7f7b7332e3 |
125
.travis.yml
125
.travis.yml
@@ -35,7 +35,7 @@ script:
|
|||||||
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
|
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
|
||||||
then
|
then
|
||||||
CURR=$(tail -n1 sizes | awk '{print $1}')
|
CURR=$(tail -n1 sizes | awk '{print $1}')
|
||||||
PREV=$(curl -u $GEKY_BOT_STATUSES https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
PREV=$(curl -u "$GEKY_BOT_STATUSES" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
|
||||||
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
|
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
|
||||||
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
|
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
|
||||||
| capture(\"code size is (?<size>[0-9]+)\").size" \
|
| capture(\"code size is (?<size>[0-9]+)\").size" \
|
||||||
@@ -100,6 +100,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
- STAGE=test
|
- STAGE=test
|
||||||
- NAME=littlefs-fuse
|
- NAME=littlefs-fuse
|
||||||
|
if: branch !~ -prefix$
|
||||||
install:
|
install:
|
||||||
- sudo apt-get install libfuse-dev
|
- sudo apt-get install libfuse-dev
|
||||||
- git clone --depth 1 https://github.com/geky/littlefs-fuse
|
- git clone --depth 1 https://github.com/geky/littlefs-fuse
|
||||||
@@ -128,70 +129,88 @@ jobs:
|
|||||||
- ls
|
- ls
|
||||||
- make -B test_dirs test_files QUIET=1
|
- make -B test_dirs test_files QUIET=1
|
||||||
|
|
||||||
# Automatically update releases
|
# Automatically create releases
|
||||||
- stage: deploy
|
- stage: deploy
|
||||||
env:
|
env:
|
||||||
- STAGE=deploy
|
- STAGE=deploy
|
||||||
- NAME=deploy
|
- NAME=deploy
|
||||||
script:
|
script:
|
||||||
# Find version defined in lfs.h
|
|
||||||
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
|
|
||||||
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
|
|
||||||
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
|
||||||
# Grab latests patch from repo tags, default to 0, needs finagling to get past github's pagination api
|
|
||||||
- PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
|
|
||||||
- PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I
|
|
||||||
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1'
|
|
||||||
|| echo $PREV_URL)
|
|
||||||
- LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL"
|
|
||||||
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
|
|
||||||
.captures[].string | tonumber) | max + 1'
|
|
||||||
|| echo 0)
|
|
||||||
# We have our new version
|
|
||||||
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
|
|
||||||
- echo "VERSION $LFS_VERSION"
|
|
||||||
- |
|
- |
|
||||||
|
bash << 'SCRIPT'
|
||||||
|
set -ev
|
||||||
|
# Find version defined in lfs.h
|
||||||
|
LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
|
||||||
|
LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
|
||||||
|
LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
||||||
|
# Grab latests patch from repo tags, default to 0, needs finagling
|
||||||
|
# to get past github's pagination api
|
||||||
|
PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
|
||||||
|
PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I \
|
||||||
|
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1' \
|
||||||
|
|| echo $PREV_URL)
|
||||||
|
LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" \
|
||||||
|
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
|
||||||
|
.captures[].string | tonumber) | max + 1' \
|
||||||
|
|| echo 0)
|
||||||
|
# We have our new version
|
||||||
|
LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
|
||||||
|
echo "VERSION $LFS_VERSION"
|
||||||
# Check that we're the most recent commit
|
# Check that we're the most recent commit
|
||||||
CURRENT_COMMIT=$(curl -f -u "$GEKY_BOT_RELEASES" \
|
CURRENT_COMMIT=$(curl -f -u "$GEKY_BOT_RELEASES" \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/commits/master \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/commits/master \
|
||||||
| jq -re '.sha')
|
| jq -re '.sha')
|
||||||
if [ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ]
|
[ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ] || exit 0
|
||||||
|
# Create major branch
|
||||||
|
git branch v$LFS_VERSION_MAJOR HEAD
|
||||||
|
# Create major prefix branch
|
||||||
|
git config user.name "geky bot"
|
||||||
|
git config user.email "bot@geky.net"
|
||||||
|
git fetch https://github.com/$TRAVIS_REPO_SLUG.git \
|
||||||
|
--depth=50 v$LFS_VERSION_MAJOR-prefix || true
|
||||||
|
./scripts/prefix.py lfs$LFS_VERSION_MAJOR
|
||||||
|
git branch v$LFS_VERSION_MAJOR-prefix $( \
|
||||||
|
git commit-tree $(git write-tree) \
|
||||||
|
$(git rev-parse --verify -q FETCH_HEAD | sed -e 's/^/-p /') \
|
||||||
|
-p HEAD \
|
||||||
|
-m "Generated v$LFS_VERSION_MAJOR prefixes")
|
||||||
|
git reset --hard
|
||||||
|
# Update major version branches (vN and vN-prefix)
|
||||||
|
git push https://$GEKY_BOT_RELEASES@github.com/$TRAVIS_REPO_SLUG.git \
|
||||||
|
v$LFS_VERSION_MAJOR \
|
||||||
|
v$LFS_VERSION_MAJOR-prefix
|
||||||
|
# Create patch version tag (vN.N.N)
|
||||||
|
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
||||||
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
|
||||||
|
-d "{
|
||||||
|
\"ref\": \"refs/tags/$LFS_VERSION\",
|
||||||
|
\"sha\": \"$TRAVIS_COMMIT\"
|
||||||
|
}"
|
||||||
|
# Create minor release?
|
||||||
|
[[ "$LFS_VERSION" == *.0 ]] || exit 0
|
||||||
|
# Build release notes
|
||||||
|
PREV=$(git tag --sort=-v:refname -l "v*.0" | head -1)
|
||||||
|
if [ ! -z "$PREV" ]
|
||||||
then
|
then
|
||||||
# Create a simple tag
|
echo "PREV $PREV"
|
||||||
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
CHANGES=$'### Changes\n\n'$( \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
|
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
|
||||||
-d "{
|
printf "CHANGES\n%s\n\n" "$CHANGES"
|
||||||
\"ref\": \"refs/tags/$LFS_VERSION\",
|
|
||||||
\"sha\": \"$TRAVIS_COMMIT\"
|
|
||||||
}"
|
|
||||||
# Minor release?
|
|
||||||
if [[ "$LFS_VERSION" == *.0 ]]
|
|
||||||
then
|
|
||||||
# Build release notes
|
|
||||||
PREV=$(git tag --sort=-v:refname -l "v*.0" | head -1)
|
|
||||||
if [ ! -z "$PREV" ]
|
|
||||||
then
|
|
||||||
echo "PREV $PREV"
|
|
||||||
CHANGES=$'### Changes\n\n'$( \
|
|
||||||
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
|
|
||||||
printf "CHANGES\n%s\n\n" "$CHANGES"
|
|
||||||
fi
|
|
||||||
# Create the release
|
|
||||||
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"$LFS_VERSION\",
|
|
||||||
\"name\": \"${LFS_VERSION%.0}\",
|
|
||||||
\"draft\": true,
|
|
||||||
\"body\": $(jq -sR '.' <<< "$CHANGES")
|
|
||||||
}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
# Create the release
|
||||||
|
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
||||||
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
|
||||||
|
-d "{
|
||||||
|
\"tag_name\": \"$LFS_VERSION\",
|
||||||
|
\"name\": \"${LFS_VERSION%.0}\",
|
||||||
|
\"draft\": true,
|
||||||
|
\"body\": $(jq -sR '.' <<< "$CHANGES")
|
||||||
|
}" #"
|
||||||
|
SCRIPT
|
||||||
|
|
||||||
# Manage statuses
|
# Manage statuses
|
||||||
before_install:
|
before_install:
|
||||||
- |
|
- |
|
||||||
curl -u $GEKY_BOT_STATUSES -X POST \
|
curl -u "$GEKY_BOT_STATUSES" -X POST \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
||||||
-d "{
|
-d "{
|
||||||
\"context\": \"$STAGE/$NAME\",
|
\"context\": \"$STAGE/$NAME\",
|
||||||
@@ -202,7 +221,7 @@ before_install:
|
|||||||
|
|
||||||
after_failure:
|
after_failure:
|
||||||
- |
|
- |
|
||||||
curl -u $GEKY_BOT_STATUSES -X POST \
|
curl -u "$GEKY_BOT_STATUSES" -X POST \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
||||||
-d "{
|
-d "{
|
||||||
\"context\": \"$STAGE/$NAME\",
|
\"context\": \"$STAGE/$NAME\",
|
||||||
@@ -213,7 +232,7 @@ after_failure:
|
|||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- |
|
- |
|
||||||
curl -u $GEKY_BOT_STATUSES -X POST \
|
curl -u "$GEKY_BOT_STATUSES" -X POST \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT} \
|
||||||
-d "{
|
-d "{
|
||||||
\"context\": \"$STAGE/$NAME\",
|
\"context\": \"$STAGE/$NAME\",
|
||||||
|
|||||||
61
scripts/prefix.py
Executable file
61
scripts/prefix.py
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# This script replaces prefixes of files, and symbols in that file.
|
||||||
|
# Useful for creating different versions of the codebase that don't
|
||||||
|
# conflict at compile time.
|
||||||
|
#
|
||||||
|
# example:
|
||||||
|
# $ ./scripts/prefix.py lfs2
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import re
|
||||||
|
import glob
|
||||||
|
import itertools
|
||||||
|
import tempfile
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
DEFAULT_PREFIX = "lfs"
|
||||||
|
|
||||||
|
def subn(from_prefix, to_prefix, name):
|
||||||
|
name, count1 = re.subn('\\b'+from_prefix, to_prefix, name)
|
||||||
|
name, count2 = re.subn('\\b'+from_prefix.upper(), to_prefix.upper(), name)
|
||||||
|
name, count3 = re.subn('\\B-D'+from_prefix.upper(),
|
||||||
|
'-D'+to_prefix.upper(), name)
|
||||||
|
return name, count1+count2+count3
|
||||||
|
|
||||||
|
def main(from_prefix, to_prefix=None, files=None):
|
||||||
|
if not to_prefix:
|
||||||
|
from_prefix, to_prefix = DEFAULT_PREFIX, from_prefix
|
||||||
|
|
||||||
|
if not files:
|
||||||
|
files = subprocess.check_output([
|
||||||
|
'git', 'ls-tree', '-r', '--name-only', 'HEAD']).split()
|
||||||
|
|
||||||
|
for oldname in files:
|
||||||
|
# Rename any matching file names
|
||||||
|
newname, namecount = subn(from_prefix, to_prefix, oldname)
|
||||||
|
if namecount:
|
||||||
|
subprocess.check_call(['git', 'mv', oldname, newname])
|
||||||
|
|
||||||
|
# Rename any prefixes in file
|
||||||
|
count = 0
|
||||||
|
with open(newname+'~', 'w') as tempf:
|
||||||
|
with open(newname) as newf:
|
||||||
|
for line in newf:
|
||||||
|
line, n = subn(from_prefix, to_prefix, line)
|
||||||
|
count += n
|
||||||
|
tempf.write(line)
|
||||||
|
shutil.copystat(newname, newname+'~')
|
||||||
|
os.rename(newname+'~', newname)
|
||||||
|
subprocess.check_call(['git', 'add', newname])
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
print '%s: %d replacements' % (
|
||||||
|
'%s -> %s' % (oldname, newname) if namecount else oldname,
|
||||||
|
count)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import sys
|
||||||
|
sys.exit(main(*sys.argv[1:]))
|
||||||
Reference in New Issue
Block a user