Commit dca03035 authored by Sébastien Villemot's avatar Sébastien Villemot

Improve the script for creating download links

— factorize the two scripts into a single one
— various safety and style improvements
parent a5ddda6c
Pipeline #1719 failed with stage
in 11 seconds
......@@ -17,8 +17,7 @@ build:
before_script:
- gem install jekyll
- (cd _data && wget https://www.dynare.org/RePEc/cpm/dynare/wp.yml)
- ./setup-release.sh
- ./setup-snapshots.sh
- ./setup-download-links.sh
- bundle install
script:
- (cd assets/images/logo && make)
......
#!/bin/bash
set -e
for branch in release snapshot
do
mkdir -p "assets/$branch"
pushd "assets/$branch"
wget "https://www.dynare.org/$branch/macosx.json"
wget "https://www.dynare.org/$branch/source.json"
wget "https://www.dynare.org/$branch/windows.json"
wget "https://www.dynare.org/$branch/windows-zip.json"
arr=("macosx" "source" "windows" "windows-zip")
for dir in "${arr[@]}"
do
mkdir -p "$dir"
read -ra filenames < <(jq .[].filename "$dir.json")
read -ra timestamps < <(jq .[].date "$dir.json")
n=$(jq length "$dir.json")
pushd "$dir"
for ((i = 0; i < n; i++))
do
filename="${filenames[i]%\"}"
filename="${filename#\"}"
timestamp="${timestamps[i]%\"}"
timestamp="${timestamp#\"}"
echo "$filename $timestamp"
touch -amt "$timestamp" "$filename"
done
popd
done
rm -- *.json
popd
done
#!/bin/bash
mkdir -p assets/release
cd assets/release
wget http://www.dynare.org/release/macosx.json
wget http://www.dynare.org/release/source.json
wget http://www.dynare.org/release/windows.json
wget http://www.dynare.org/release/windows-zip.json
declare -a arr=("macosx" "source" "windows" "windows-zip")
for dir in "${arr[@]}"
do
mkdir $dir
filenames=(`jq .[].filename $dir.json`)
timestamps=(`jq .[].date $dir.json`)
n=`jq length $dir.json`
n=`expr $n - 1`
cd $dir
for i in `seq 0 $n`;
do
filename="${filenames[i]%\"}"
filename="${filename#\"}"
timestamp="${timestamps[i]%\"}"
timestamp="${timestamp#\"}"
echo $filename $timestamp
touch -amt $timestamp $filename
done
cd ..
done
rm *.json
cd ../..
#!/bin/bash
mkdir -p assets/snapshot
cd assets/snapshot
wget http://www.dynare.org/snapshot/macosx.json
wget http://www.dynare.org/snapshot/source.json
wget http://www.dynare.org/snapshot/windows.json
wget http://www.dynare.org/snapshot/windows-zip.json
declare -a arr=("macosx" "source" "windows" "windows-zip")
for dir in "${arr[@]}"
do
mkdir $dir
filenames=(`jq .[].filename $dir.json`)
timestamps=(`jq .[].date $dir.json`)
n=`jq length $dir.json`
n=`expr $n - 1`
cd $dir
for i in `seq 0 $n`;
do
filename="${filenames[i]%\"}"
filename="${filename#\"}"
timestamp="${timestamps[i]%\"}"
timestamp="${timestamp#\"}"
echo $filename $timestamp
touch -amt $timestamp $filename
done
cd ..
done
rm *.json
cd ../..
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment