@@ -1,236 +0,0 @@
2−PATH=@bash@/bin:@nix_prefetch_scripts@/bin:@common_updater_scripts@/bin:@git@/bin:@jq@/bin:@nix@/bin:@gnugrep@/bin:@gnused@/bin:@curl@/bin:$PATH
8−# ─── HOW TO USE ─────────────────────────────────────────────────────────────────
13−Usage: update.sh <repo_name> <attr>
18−# ─── POINTS YOU IN THE RIGHT DIRECTION ──────────────────────────────────────────
21− function usage_tip ( ) {
22− echo 'run `update.sh -h` for usage instructions' >&2
27−# ─── OPTIONS: RELEASE | MASTER ────────────────────────────────────────────────────
30− while getopts ":hrm" opt; do
45− echo "Invalid option: -$OPTARG" >&2
54−# ─── FAIL WITH MESSAGE AND NON-ZERO EXIT STATUS ─────────────────────────────────
63−# ─── UPDATES PACKAGE TO LATEST TAGGED RELEASE ───────────────────────────────
66− function update_to_latest_release ( ) {
70− version=$(get_latest_tag "$repo_name")
71− fetch=$(fetch "$repo_name" "refs/tags/${version}")
72− sha256=$(get_hash "${fetch}")
74− update-source-version "pantheon.$attr" "$version" "$sha256"
76− nix_file=$(get_file_path $attr)
78− if [ ! -f "$nix_file" ]; then
79− fail "Couldn't evaluate 'pantheon.$attr.meta.position' to locate the .nix file!"
82− correct_rev "$attr" "$nix_file" "version"
86−# ─── UPDATES PACKAGE TO MASTER ──────────────────────────────────────────────────
89− function update_to_master ( ) {
93− fetch=$(fetch "$repo_name" "refs/heads/master")
95− version=$(get_version "$fetch")
96− sha256=$(get_hash "$fetch")
97− proper_version=$(get_master_date "$fetch")
99− update-source-version "pantheon.$attr" "$proper_version" "$sha256"
101− nix_file=$(get_file_path $attr)
103− if [ ! -f "$nix_file" ]; then
104− fail "Couldn't evaluate 'pantheon.$attr.meta.position' to locate the .nix file!"
107− correct_rev "$attr" "$nix_file" '"'$version'"'
111−# ─── GETS THE LATEST TAGGED RELEASE NAME FROM GITHUB ─────────────────────
114− function get_latest_tag ( ) {
117− OAUTH_TOKEN=$(printenv OAUTH_TOKEN)
119− if [ -n "$OAUTH_TOKEN" ]; then
125− --header "Authorization: token $OAUTH_TOKEN" \
126− "https://api.github.com/repos/elementary/$repo_name/releases/latest" \
134− "https://api.github.com/repos/elementary/$repo_name/releases/latest" \
140−# ─── FETCHES REPO AND RETURNS RELEVANT INFORMATION ──────────────────
143− function fetch ( ) {
147− base_url="https://github.com/elementary"
148− full_url="$base_url/$repo_name"
150− nix-prefetch-git --quiet --no-deepClone --url "$full_url" --rev "$version"
154−# ─── PARSES GIT REVISION FROM FETCH ─────────────────────────────────────────────
157− function get_version ( ) {
160− echo "$fetch_info" | jq -r '.rev'
164−# ─── PARSES HASH FROM FETCH ─────────────────────────────────────────────────────
167− function get_hash ( ) {
170− echo "$fetch_info" | jq -r '.sha256'
174−# ─── PARSES DATE FROM FETCH AND NORMALIZES IT TO NIXPKGS STANDARD ───────────────
177− function get_master_date ( ) {
180− full_date=$(echo "$fetch_info" | jq -r '.date')
181− short_date=$(date -d "$full_date" +"%Y-%m-%d")
183− echo "unstable-$short_date"
187−# ─── RETURN NIX EXPRESSION PATH ─────────────────────────────────────────────────
190− function get_file_path () {
193− nix-instantiate --eval --strict -A "pantheon.$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/'
197−# ─── CORRECTS REV VERSION ───────────────────────────────────────────────────────────
200− function correct_rev ( ) {
205− check_pattern1='^\s*rev\s*=\s*"[0-9a-f]{5,40}"'
206− check_pattern2='^\s*rev\s*=\s*version'
208− replace_pattern1='/\brev\b\s*=/ s|\"[0-9a-f]{5,40}\"|'$rev'|'
209− replace_pattern2='/\brev\b\s*=/ s|version|'$rev'|'
211− if [ $(grep -c -P "$check_pattern1" "$nix_file") = 1 ]; then
212− pattern="$replace_pattern1"
213− elif [ $(grep -c -P "$check_pattern2" "$nix_file") = 1 ]; then
214− pattern="$replace_pattern2"
216− fail "Couldn't figure out where out where to patch in the correct version in pantheon.$attr!"
219− sed -i.bak "$nix_file" -re "$pattern"
220− rm -f "$nix_file.bak"
225−# ─── WHETHER TO UPDATE TO RELEASE OR MASTER ──────────────────────────────────
228− if [ $release = 1 ]; then
229− update_to_latest_release $1 $2
230− elif [ $master = 1 ]; then
231− update_to_master $1 $2
236−# ────────────────────────────────────────────────────────────────────────────────