-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfork-aur
More file actions
executable file
·54 lines (39 loc) · 1.21 KB
/
fork-aur
File metadata and controls
executable file
·54 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# This script forks an AUR package to a Kamarada (GitHub) repo
# Example:
# fork-aur paper-icon-theme
# Create an empty GitHub repo before running this script:
# https://github.com/organizations/kamarada/repositories/new
REPOS_DIR="/home/vinicius/dev/projects/git/kamarada"
REPOS_CONFIG="$REPOS_DIR/scripts/repos-config.json"
REPO_NAME=$1
UPSTREAM_REMOTE_URL="https://aur.archlinux.org/$REPO_NAME.git"
KAMARADA_REMOTE_URL="git@github.com:kamarada/$REPO_NAME.git"
git clone "$UPSTREAM_REMOTE_URL" "$REPO_NAME"
cd "$REPO_NAME"
git remote rename origin aur
git remote add origin "$KAMARADA_REMOTE_URL"
git branch -m stable
git branch --unset-upstream
git push origin -u stable
# Let's create the stable branch first so it becomes the default branch
git checkout -b aur
git push origin -u aur
git checkout -b testing
git push origin -u testing
git fetch aur
# Add to repos-config.json
NEW_REPO_CONFIG=$(cat <<EOF
{
"folder": "$REPO_NAME",
"upstream": "aur",
"upstream_url": "$UPSTREAM_REMOTE_URL",
"kamarada_url": "$KAMARADA_REMOTE_URL"
}
EOF
)
TMP_FILE=$(mktemp)
jq --argjson obj "$NEW_REPO_CONFIG" '
. + [$obj] | sort_by(.folder)
' "$REPOS_CONFIG" > "$TMP_FILE"
mv "$TMP_FILE" "$REPOS_CONFIG"