pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/import-package



Module Name:    pkgsrc
Committed By:   wiz
Date:           Sun Aug 16 20:57:09 UTC 2020

Added Files:
        pkgsrc/pkgtools/import-package: DESCR Makefile PLIST
        pkgsrc/pkgtools/import-package/files: import-package.1
            import-package.sh

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/pkgtools/import-package/DESCR \
    pkgsrc/pkgtools/import-package/Makefile \
    pkgsrc/pkgtools/import-package/PLIST
cvs rdiff -u -r0 -r1.1 pkgsrc/pkgtools/import-package/files/import-package.1 \
    pkgsrc/pkgtools/import-package/files/import-package.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/pkgtools/import-package/DESCR
diff -u /dev/null pkgsrc/pkgtools/import-package/DESCR:1.1
--- /dev/null   Sun Aug 16 20:57:09 2020
+++ pkgsrc/pkgtools/import-package/DESCR        Sun Aug 16 20:57:09 2020
@@ -0,0 +1,2 @@
+This package contains a tool for importing a package to pkgsrc or
+pkgsrc-wip.
Index: pkgsrc/pkgtools/import-package/Makefile
diff -u /dev/null pkgsrc/pkgtools/import-package/Makefile:1.1
--- /dev/null   Sun Aug 16 20:57:09 2020
+++ pkgsrc/pkgtools/import-package/Makefile     Sun Aug 16 20:57:09 2020
@@ -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"
Index: pkgsrc/pkgtools/import-package/PLIST
diff -u /dev/null pkgsrc/pkgtools/import-package/PLIST:1.1
--- /dev/null   Sun Aug 16 20:57:09 2020
+++ pkgsrc/pkgtools/import-package/PLIST        Sun Aug 16 20:57:09 2020
@@ -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

Index: pkgsrc/pkgtools/import-package/files/import-package.1
diff -u /dev/null pkgsrc/pkgtools/import-package/files/import-package.1:1.1
--- /dev/null   Sun Aug 16 20:57:09 2020
+++ pkgsrc/pkgtools/import-package/files/import-package.1       Sun Aug 16 20:57:09 2020
@@ -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.
Index: pkgsrc/pkgtools/import-package/files/import-package.sh
diff -u /dev/null pkgsrc/pkgtools/import-package/files/import-package.sh:1.1
--- /dev/null   Sun Aug 16 20:57:09 2020
+++ pkgsrc/pkgtools/import-package/files/import-package.sh      Sun Aug 16 20:57:09 2020
@@ -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