-
Notifications
You must be signed in to change notification settings - Fork 1
/
subaur4
executable file
·110 lines (90 loc) · 3.36 KB
/
subaur4
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
# To run: ./subaur4 SUBMODULE_DIR
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Alexandre Magno ‒ [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Based in knowledge of import-to-aur4.sh [1] and aur4_make_submodule.sh [2]
#
# 1: http://github.com/ido/packages-archlinux/blob/master/bin/import-to-aur4.sh
# 2: http://github.com/JonnyJD/PKGBUILDs/blob/master/_bin/aur4_make_submodule.sh
which mksrcinfo &>/dev/null \
|| { echo "Please install the pkgbuild-introspection"; exit -1; }
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)
function execforme() {
echo "$1"
for i in `seq 1 ${#1}`; do printf -; done
if [ $2 ]; then
echo
shift
echo "$ $*"
$*
fi
echo
}
echo
execforme "remove the path from version control" \
git rm -r --cached "$path"
execforme "making backup" \
mv "$path" "${pkg}_aur4_bak"
execforme "add the AUR 4 package as a submodule at the previous path" \
git submodule add -f ssh+git://[email protected]/${pkg}.git $path
execforme "restore uncommited/unversioned files from backup" \
cp -r "${pkg}_aur4_bak/"* "$path"
execforme "remove backup directory" \
rm -rf "${pkg}_aur4_bak"
execforme "enter submodule direcotory" \
pushd ${path}
execforme "generating .SRCINFO" \
mksrcinfo
execforme "adding files to git" \
git add .
execforme "commit on child repository"
git commit -m "Begins as submodule at GitHub alexandre-mbm/arch-pkgs"; echo
execforme "exit submodule direcotory" \
popd
execforme "retry the submodule" \
git submodule add -f ssh+git://[email protected]/${pkg}.git $path
execforme "commit on root repository"
git commit -m "${pkg}: converted to AUR 4 submodule"; echo
# Some help to undo failures (the tip is see the "git status" for each step):
#
# $ git reset --soft HEAD~1
# $ git reset
# $ rm -rf .gitmodules adobe-digital-editions/
#
# NO! Take care regarding to erase .gitmodules
#
# $ git reset
# $ git checkout master -- adobe-digital-editions