-
Notifications
You must be signed in to change notification settings - Fork 2
/
aur4_make_submodule.sh
68 lines (52 loc) · 1.85 KB
/
aur4_make_submodule.sh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
if [ $# -lt 1 -o \( "$1" = "-h" -o "$1" = "--help" \) ]; then
echo "usage: $0 <path/to/package>"
echo "(should be done in root of the original repository)"
exit -1
fi
path=${1%/} # the trailing / is removed
pkg=`basename $path`
email=`git config user.email`
# remove the path from version control
echo git rm -r \"$path\"
git rm -r --cached "$path"
# backup uncommited files like previously built packages (OPTIONAL)
echo mv \"$path\" \"${pkg}_aur4_bak\"
mv "$path" "${pkg}_aur4_bak"
# add the AUR 4 package as a submodule at the previous path
echo git submodule add ssh+git://[email protected]/${pkg}.git $path
git submodule add -f ssh+git://[email protected]/${pkg}.git $path
# add a separate pushurl for write access
# (OPTIONAL, you can also just use the url above)
# (we need to be in the root of the repository to find .gitmodules)
echo git config --file=.gitmodules submodule.${path}.pushurl \
ssh+git://[email protected]/${pkg}.git $path
git config --file=.gitmodules submodule.${path}.pushurl \
ssh+git://[email protected]/${pkg}.git $path
# write urls from .gitmodules to separate .git/modules/*/config files
echo git submodule sync
git submodule sync
# mark changes in .gitmodules to be committed
echo git add .gitmodules
git add .gitmodules
# restore uncommited/unversioned files from backup (OPTIONAL)
echo cp -r \"${pkg}_aur4_bak/\"* \"$path\"
#mkdir $path
cp -r "${pkg}_aur4_bak/"* "$path"
# remove backup directory (OPTIONAL)
echo rm -rf \"${pkg}_aur4_bak/\"
rm -rf "${pkg}_aur4_bak"
# change to new submodule
echo pushd ${path}
pushd ${path}
# set same commit email as for the original repository (OPTIONAL)
echo git config user.email $email
git config user.email $email
mksrcinfo
git add *
git add .SRCINFO
git commit -m "initial import"
git push origin master
# return to original directory
echo popd
popd