blob: d6d8e8a8466f87cb45926b34355b4352de2002c9 (
plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
#! /bin/sh
#
# $NetBSD: import-package.sh,v 1.1 2020/08/16 20:57:09 wiz Exp $
#
# Script designed to make add packages into wip and main pkgsrc easier.
#
# Just cd to the package directory and run import-package
#
# It will automatically create a nice import message based on DESCR
# and PKGNAME, set up the CVS tags correctly and autodetect what CVSROOT
# to use. It also shows you what files will be imported, reminds you
# to run pkglint(1) and asks for confirmation before doing anything.
set -e
[ -n "${MKTEMP}" ] || MKTEMP=mktemp
[ -n "${EDITOR}" ] || EDITOR=vi
CLEANUP=""
DRYRUN="" # "echo dry-run:"
cleanup() {
if [ -n "${CLEANUP}" ]; then
rm -f ${CLEANUP}
fi
}
trap cleanup 0
if [ -z "${MAKE}" ]; then
if type bmake >/dev/null 2>&1; then
MAKE=bmake
else
MAKE=make
fi
fi
if [ ! -f "../../mk/bsd.pkg.mk" ]; then
echo "$0: ../../bsd.pkg.mk not found" 1>&2
exit 1
fi
stale=no
for cvsdir in $(find "$(pwd)" -type d -name CVS -print); do
echo "$0: stale CVS state directory found: ${cvsdir}" 1>&2
stale=yes
done
for gitdir in $(find "$(pwd)" -type d -name .git -print); do
echo "$0: stale git state directory found: ${gitdir}" 1>&2
stale=yes
done
for wrkdir in $(find "$(pwd)" -type d -name "work*" -print); do
echo "$0: stale work directory found: ${wrkdir}" 1>&2
stale=yes
done
if [ "${stale}" = "yes" ]; then
exit 1
fi
PACKAGE="$(basename $(pwd))"
CATEGORY="$(basename $(dirname $(pwd)))"
PKGPATH="${CATEGORY}/${PACKAGE}"
if [ "${CATEGORY}" = "wip" ]; then
SCM=GIT
if [ ! -d "../.git" ]; then
echo "$0: git state directory not found in ../.git" 1>&2
exit 1
fi
GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ "${GIT_BRANCH}" != "master" ]; then
echo "$0: ${GIT_BRANCH} is not the git master branch" 1>&2
exit 1
fi
if ! git config --get user.name > /dev/null; then
echo "$0: Please run 'git config --local user.name \"Your name here\"'" 1>&2
exit 1
fi
if ! git config --get user.email > /dev/null; then
echo "$0: Please run 'git config --local user.email \"you@example.com\"'" 1>&2
exit 1
fi
if git status | grep "Changes to be committed" > /dev/null; then
echo "$0: You have uncommitted changes staged!" 1>&2
echo "$0: Check output of 'git status'" 1>&2
exit 1
fi
if ! git fetch; then
echo "$0: git fetch failed"
fi
if ! git status -u no | egrep "Your branch is (up-to-date|up to date)" > /dev/null; then
echo "$0: git repository does not appear to be up to date." 1>&2
echo "$0: You should probably run 'git pull --rebase'" 1>&2
echo "$0: and 'git push' (if you have unpushed work)" 1>&2
exit 1
fi
else
SCM=CVS
CVSROOT="$(cat ../CVS/Root | tr A-Z a-z | sed -e 's/.*@//')"
if [ "${CVSROOT}" != "cvs.netbsd.org:/cvsroot" ]; then
echo "$0: wrong CVS root" 1>&2
exit 1
fi
fi
MSG="$(${MKTEMP} -t import-package.XXXXXXXX)"
CLEANUP="${MSG}"
echo "Please wait while determining PKGNAME and DESCR_SRC."
PKGNAME="$(${MAKE} show-var VARNAME=PKGNAME)"
DESCR_SRC="$(${MAKE} show-var VARNAME=DESCR_SRC) /dev/null"
DASH70=----------------------------------------------------------------------
echo "${CATEGORY}/${PACKAGE}: import ${PKGNAME}" > ${MSG}
echo "" >> ${MSG}
cat ${DESCR_SRC} >> ${MSG}
echo "${SCM}: ${DASH70}" >> ${MSG}
echo "${SCM}: Please edit the above message to give a brief description" >> ${MSG}
echo "${SCM}: of the package for those who read the *-changes@ list." >> ${MSG}
echo "${SCM}: Did you remember to run pkglint(1) before importing?" >> ${MSG}
echo "${SCM}:" >> ${MSG}
echo "${SCM}: Lines starting with ${SCM}: will be automatically removed." >> ${MSG}
echo "${SCM}:" >> ${MSG}
ADDLIST="$(${MKTEMP} -t import-package-files.XXXXXXXX)"
CLEANUP="${CLEANUP} ${ADDLIST}"
(
cd ..
if [ "${SCM}" = "GIT" ]; then
find ${PACKAGE} -type f -print
else
find ${PACKAGE} \( -type d \) -print | sed 's,$,/,'
find ${PACKAGE} \( -type f \) -print
fi
) | sed -e '/^\./d' -e '/\/CVS/d' -e '/[^+-_,./a-zA-Z0-9]/d' | sort > ${ADDLIST}
sed "s|^|${SCM}: will add: ${CATEGORY}/|" ${ADDLIST} >> ${MSG}
${EDITOR} ${MSG}
echo "Edited message follows:"
echo ${DASH70}
grep -v "^${SCM}:" < ${MSG}
echo ${DASH70}
echo "PKGPATH: ${PKGPATH}"
if [ "${SCM}" = "GIT" ]; then
echo "GIT_BRANCH: ${GIT_BRANCH}"
else
echo "CVSROOT: ${CVSROOT}"
fi
echo ""
printf "y + enter to import, any other text + enter to abort> "
read ANS
if [ "${ANS}" = "y" ]; then
if [ "${SCM}" = "GIT" ]; then
(
cd ..
cat ${ADDLIST} | xargs -L 100 ${DRYRUN} git add
${DRYRUN} git commit -m "$(grep -v "^${SCM}:" ${MSG})" ${PACKAGE}
${DRYRUN} git push
)
else
(
cd ..
export CVS_RSH=ssh
[ -e "${PACKAGE}/CVS" ] || ${DRYRUN} cvs add ${PACKAGE} || exit 1
grep '/$' ${ADDLIST} | fgrep -vx ${PACKAGE}/ |
xargs -L 100 ${DRYRUN} cvs add
grep -v '/$' ${ADDLIST} | xargs -L 100 ${DRYRUN} cvs add
${DRYRUN} cvs commit -m "$(grep -v "^${SCM}:" ${MSG})" ${PACKAGE}
)
fi
echo ${DASH70}
echo "Don't forget to add the package to ${CATEGORY}/Makefile."
echo "When imported to pkgsrc itself, please update the CHANGES-*"
echo "file and possibly remove the package from the TODO list."
echo ""
fi
|