Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/import-package pkgtools/import-package: impor...
details: https://anonhg.NetBSD.org/pkgsrc/rev/68c7ba887d3d
branches: trunk
changeset: 437102:68c7ba887d3d
user: wiz <wiz%pkgsrc.org@localhost>
date: Sun Aug 16 20:57:09 2020 +0000
description:
pkgtools/import-package: import import-package-1.0
This is a package for wip/import-package.sh. Suggested by brooks.
This package contains a tool for importing a package to pkgsrc or
pkgsrc-wip.
diffstat:
pkgtools/import-package/DESCR | 2 +
pkgtools/import-package/Makefile | 25 +++
pkgtools/import-package/PLIST | 3 +
pkgtools/import-package/files/import-package.1 | 44 +++++
pkgtools/import-package/files/import-package.sh | 177 ++++++++++++++++++++++++
5 files changed, 251 insertions(+), 0 deletions(-)
diffs (271 lines):
diff -r 9070b2eda291 -r 68c7ba887d3d pkgtools/import-package/DESCR
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/import-package/DESCR Sun Aug 16 20:57:09 2020 +0000
@@ -0,0 +1,2 @@
+This package contains a tool for importing a package to pkgsrc or
+pkgsrc-wip.
diff -r 9070b2eda291 -r 68c7ba887d3d pkgtools/import-package/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/import-package/Makefile Sun Aug 16 20:57:09 2020 +0000
@@ -0,0 +1,25 @@
+# $NetBSD: Makefile,v 1.1 2020/08/16 20:57:09 wiz Exp $
+
+PKGNAME= import-package-1.0
+CATEGORIES= pkgtools
+
+MAINTAINER= wiz%NetBSD.org@localhost
+HOMEPAGE= https://www.NetBSD.org/docs/pkgsrc/
+COMMENT= Tool for importing a package
+
+WRKSRC= ${WRKDIR}
+NO_BUILD= yes
+USE_LANGUAGES= # none
+
+INSTALLATION_DIRS= bin ${PKGMANDIR}/man1
+
+do-extract:
+ cd ${FILESDIR} && ${CP} import-package.sh import-package.1 ${WRKSRC}
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/import-package.sh \
+ ${DESTDIR}${PREFIX}/bin/import-package
+ ${INSTALL_MAN} ${WRKSRC}/import-package.1 \
+ ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+
+.include "../../mk/bsd.pkg.mk"
diff -r 9070b2eda291 -r 68c7ba887d3d pkgtools/import-package/PLIST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/import-package/PLIST Sun Aug 16 20:57:09 2020 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2020/08/16 20:57:09 wiz Exp $
+bin/import-package
+man/man1/import-package.1
diff -r 9070b2eda291 -r 68c7ba887d3d pkgtools/import-package/files/import-package.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/import-package/files/import-package.1 Sun Aug 16 20:57:09 2020 +0000
@@ -0,0 +1,44 @@
+.\" $NetBSD: import-package.1,v 1.1 2020/08/16 20:57:09 wiz Exp $
+.\"
+.Dd August 16, 2020
+.Dt IMPORT_PACKAGE 1
+.Sh NAME
+.Nm import-package
+.Nd import package to pkgsrc
+.Sh SYNOPSIS
+.Nm
+.Sh DESCRIPTION
+.Nm
+is a script designed to make adding packages into pkgsrc or pkgsrc-wip
+easier.
+To use it, just
+.Ic cd
+to the package directory and run
+.Nm .
+.Pp
+.Nm
+will automatically create a nice import message based on
+.Pa DESCR
+and
+.Va PKGNAME ,
+set up the CVS tags correctly and autodetect what CVSROOT (or git)
+to use.
+.Nm
+also shows you what files will be imported, reminds you
+to run
+.Xr pkglint 1
+and asks for confirmation before doing anything.
+.Sh AUTHORS
+.An Tobias Nygren
+.An Filip Hajny
+.An Thomas Klausner
+.An dieter roelants
+.An Kamil Rytarowski
+.An Ryo ONODERA
+.Sh CAVEATS
+.Nm
+does not create the
+.Pa CHANGES-*
+entry, so please run
+.Dl "PKG_DEVELOPER=yes make cce CTYPE=Added"
+after the import, if importing into pkgsrc.
diff -r 9070b2eda291 -r 68c7ba887d3d pkgtools/import-package/files/import-package.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/import-package/files/import-package.sh Sun Aug 16 20:57:09 2020 +0000
@@ -0,0 +1,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@localhost\"'" 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
Home |
Main Index |
Thread Index |
Old Index