[arch-projects] [dbscripts] [PATCH 1/2] Preliminary work to break out svn-specific code.

2018-07-03 Thread Eli Schwartz via arch-projects
Introduce "db-functions-$VCS" which will eventually contain all
VCS-specific code, and make this configurable in config.

Move private arch_svn function and svn acl handling here, and introduce
a new source_pkgbuild function to handle discovering PKGBUILDs from the
configured VCS and sourcing them to extract metadata.

The PKGBUILD is the only file we ever check out from version control,
and only ever to scrape information from it, except for when we actually
want to db-move a whole directory (which is by necessity considerably
dependent on the VCS in use).

source_pkgbuild is inspired by commits from the dbscripts rewrite,
authored by Florian Pritz 

Signed-off-by: Eli Schwartz 
---
 config   |  7 +--
 db-functions | 50 +++-
 db-functions-svn | 27 ++
 db-move  |  5 +++--
 db-remove|  5 ++---
 db-update|  4 ++--
 6 files changed, 54 insertions(+), 44 deletions(-)
 create mode 100644 db-functions-svn

diff --git a/config b/config
index fd79b6ee..1cfe11f4 100644
--- a/config
+++ b/config
@@ -1,14 +1,17 @@
 #!/hint/bash
 
 FTP_BASE="/srv/ftp"
-SVNREPO=''
-SVNUSER=''
 PKGREPOS=()
 PKGPOOL=''
 SRCPOOL=''
 TESTING_REPO=''
 STABLE_REPOS=()
 
+# VCS backend
+VCS=svn
+SVNREPO=''
+SVNUSER=''
+
 CLEANUP_DESTDIR="/var/tmp"
 CLEANUP_DRYRUN=false
 # Time in days to keep moved packages
diff --git a/db-functions b/db-functions
index 0491c22d..3757b726 100644
--- a/db-functions
+++ b/db-functions
@@ -39,11 +39,6 @@ mv_acl() {
 
 # set up general environment
 WORKDIR=$(mktemp -dt "${0##*/}.XX")
-if [[ -n ${SVNUSER} ]]; then
-   setfacl -m u:"${SVNUSER}":rwx "${WORKDIR}"
-   setfacl -m d:u:"${USER}":rwx "${WORKDIR}"
-   setfacl -m d:u:"${SVNUSER}":rwx "${WORKDIR}"
-fi
 LOCKS=()
 REPO_MODIFIED=0
 
@@ -306,27 +301,24 @@ check_pkgfile() {
[[ ${pkgfile##*/} = "${pkgname}-${pkgver}-${pkgarch}"* ]]
 }
 
-check_pkgsvn() {
+# Check that the package file is consistent with the PKGBUILD in version 
control
+check_pkgvcs() {
local pkgfile="${1}"
+   local repo="${2}"
local _pkgbase="$(getpkgbase "${pkgfile}")" || return 1
local _pkgname="$(getpkgname "${pkgfile}")" || return 1
local _pkgver="$(getpkgver "${pkgfile}")" || return 1
local _pkgarch="$(getpkgarch "${pkgfile}")" || return 1
-   local repo="${2}"
 
in_array "${repo}" "${PKGREPOS[@]}" || return 1
 
-   if [[ ! -f ${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase} ]]; then
-   mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
-   arch_svn export -q 
"${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
-   "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" 
>/dev/null || return 1
-   fi
+   local vcsver vcsnames=()
+   read -rd'\n' vcsver vcsnames < <(source_pkgbuild "${_pkgbase}" 
"repos/${repo}-${_pkgarch}"; \
+get_full_version; echo "${pkgname[@]}")
+   read -ra vcsnames <<<"${vcsnames}"
 
-   local svnver="$(. 
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; get_full_version)"
-   [[ "${svnver}" = "${_pkgver}" ]] || return 1
-
-   local svnnames=($(. 
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}"))
-   in_array "${_pkgname}" "${svnnames[@]}" || return 1
+   [[ "${vcsver}" = "${_pkgver}" ]] || return 1
+   in_array "${_pkgname}" "${vcsnames[@]}" || return 1
 
return 0
 }
@@ -337,7 +329,7 @@ check_splitpkgs() {
local pkgfiles=("${@}")
local pkgfile
local pkgdir
-   local svnname
+   local vcsname
 
mkdir -p "${WORKDIR}/check_splitpkgs/"
pushd "${WORKDIR}/check_splitpkgs" >/dev/null
@@ -350,22 +342,16 @@ check_splitpkgs() {
mkdir -p "${repo}/${_pkgarch}/${_pkgbase}"
echo "${_pkgname}" >> "${repo}/${_pkgarch}/${_pkgbase}/staging"
 
-   if [[ ! -f ${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase} 
]]; then
-   mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
-   arch_svn export -q 
"${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
-   
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null || return 1
-   fi
-
-   local svnnames=($(. 
"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}"; echo "${pkgname[@]}"))
-   printf '%s\n' "${svnnames[@]}" >> 
"${repo}/${_pkgarch}/${_pkgbase}/svn"
+   local vcsnames=($(source_pkgbuild "${_pkgbase}" 
"repos/${repo}-${_pkgarch}"; echo "${pkgname[@]}"))
+   printf '%s\n' "${vcsnames[@]}" >> 
"${repo}/${_pkgarch}/${_pkgbase}/vcs"
done
popd >/dev/null
 
for pkgdir in "${WORKDIR}/check_splitpkgs/${repo}"/*/*; do
[[ ! -d ${pkgdir} ]] && continue
sort -u 

[arch-projects] [dbscripts] [GIT] Official repo DB scripts annotated tag 20180603 created. 20180603

2018-07-03 Thread Eli Schwartz via arch-projects
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Official repo DB scripts".

The annotated tag, 20180603 has been created
at  b9e1a487c7b89072904a5d6aabd8b827693e440f (tag)
   tagging  08995618eb606523b7d05ac987b1243981290839 (commit)
  replaces  20131102
 tagged by  Eli Schwartz
on  Tue Jul 3 22:05:48 2018 -0400

- Log -
Lots of fixes which presumably make us handle data more safely
-BEGIN PGP SIGNATURE-

iQJMBAABCgA2FiEEYEETBMCdNmKDQO7/zrFn77VyK9YFAls8LNEYHGVzY2h3YXJ0
ekBhcmNobGludXgub3JnAAoJEM6xZ++1civWMiIP/j3vBx4Ei2A7AvSn6/BDE54p
CpPTe5GD4DBp5x/X1Ja0aMpSvsMLs5dguesXglxBwZVPWNuDYcf/flP05V0uwK38
/0+b1dy/2Sn+tBh0fe/BxdiXfF6thH8axi8+92yonzEFhWz+TXRyg7IjGLALNaLu
DkWgC4YuLan+uuCqXBbQc7h0z+ZCE95fi4ymVrgA83VjFUp4Nkc46taQFgmN4lj7
mTCr962+9js2wm6shfeqbhSbYmj8KBXG9zdelE0uWgcpFz+Q9LgddDvqXFA4J9lW
ku+2AV9P+b+Zy838iduLDgshO2ZCd25tgSo87YngSLLxKfrpbf1HKcxW2ggZsWtk
xoO4AX3ElElSiFZL8gDUL9AQNpskfAck1Hrup71xKg8d2B3OrfAdrPef/8+cPLAR
5CQ+7a+NjmAcUbLo0fG5eAntgEM+foRqdRnnw2KgwvMwTj90BXi4soPPpf8CQ1gG
o0P/gnp0/f8IrzCd/PPOTRFnLfE/sGJFO65R2hVmlk3Y+xS7V+982sQirXj22wbF
3nTI1+eGrCLONhxGFM6moxQs/mF2FLQUJDCTC3jQdcv4d8/cKocKAWfSOuQHK8pH
ij9uu1qqKaBmW0VXu5pOpssg4hPZfFCWXtVWYXfKoDS62//08o5nVQPyq/iBMwOZ
C2MSqCydTte4YATTwkfH
=ihXJ
-END PGP SIGNATURE-

Dave Reisner (1):
  disallow packages without a valid PACKAGER

Eli Schwartz (17):
  Use return codes properly when checking for failed commands.
  Update messages to make full use of printf formatters
  ARCHES is an array, do not attempt to call it as a string
  Use modern bash to append to strings/arrays.
  Use more bashisms
  db-functions: deduplicate some repeated logic
  Use even more bashisms.
  Fix overloading PKGEXT to mean two things.
  db-update: replace external find command with bash globbing
  ftpdir-cleanup,sourceballs: replace external find command with bash 
globbing
  Globally set $PKGEXT to a bash extended glob representing valid choices.
  db-functions: unify the repo-add/repo-remove caller
  fixup! Update messages to make fuller use of printf formatters
  pacman 5.1 compatibility
  test: BUILDDIR must be owned by build user
  db-move: Don't store filepaths as a string with whitespace splitting
  hoist $tarch handling above $pkgname, since it is more efficient

Florian Pritz (1):
  Remove i686 from config

Jelle van der Waa (1):
  Disable integrity check for i686

Johannes Löthberg (1):
  config: add GPL3/LGPL3 to ALLOWED_LICENSES

Levente Polyak (1):
  disallow packages not built in a chroot

Luke Shumaker (18):
  test: db-update: verify that PKGEXT(S) is treated as a glob
  Update messages to make fuller use of printf formatters
  test: common.bash:__getCheckSum: Don't rely on IFS
  test: Fixup glob matching
  Export TMPDIR, and use mktemp -t instead of making it part of the template
  Normalize to tab indent
  Add "#!/hint/bash" to the beginning of several files
  Don't use `grep -q` when operating on piped stdin
  Remove uses of the "v=true; if $v ..." anti-pattern
  Fixups near unquoted variables
  Clean up printf-formatters for user messages
  README.md: fix spelling mistake: "overriden"->"overridden"
  README.md: Write an overview of the programs included
  test/: Verify that db-update won't release duplicate packages in the same 
transaction
  Fixup quoting around variables, especially arrays
  Consistently use "$(dirname "$(readlink -e "$0")")"
  devlist-mailer: Make LIST and FROM configurable
  test: Fix typoed variables

Pierre Schmitz (52):
  cron-jobs: Fix issues with empty repositories
  Remove separate creation of file databases
  Update bundled makepkg.conf
  Run tests using docker
  Add travis configuration
  Add editor configuration
  Compile tests into one file to reduce time spent on setup
  Simplify test setup
  Use a minimal travis environment
  testSuite is a simple file
  Fix package test
  Fix test package dependency
  Add ability to generate test coverage
  Replace bash script with Makefile
  Make test suite independent from code under test
  db-repo-add: Fix adding of 'any' packages
  db-repo-remove: Test removal of 'any' packages
  db-update: Check that packages with invalid signatures wont get added
  Signing packages is no longer optional
  ftpdir-cleanup: Test removal of old packages
  db-update: Disallow invalid package names
  db-update: Test if package cannot be added if svn is inconsistent
  db-update: Test package validation
  Make coverage folder writeable to the test user
  Avoid replacing the temporary dir by accident
  use makepkg library instead of local function copies