summaryrefslogtreecommitdiff
path: root/src/abslibre-tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/abslibre-tools')
-rw-r--r--src/abslibre-tools/Makefile3
-rwxr-xr-xsrc/abslibre-tools/createworkdir63
-rwxr-xr-xsrc/abslibre-tools/libreaddiff97
-rwxr-xr-xsrc/abslibre-tools/librerelease155
-rwxr-xr-xsrc/abslibre-tools/librestage137
5 files changed, 455 insertions, 0 deletions
diff --git a/src/abslibre-tools/Makefile b/src/abslibre-tools/Makefile
new file mode 100644
index 0000000..f2cec54
--- /dev/null
+++ b/src/abslibre-tools/Makefile
@@ -0,0 +1,3 @@
+libre_execdir=$(bindir)
+libre_datadir=$(sysconfdir)/libretools.d
+include ../../common.mk
diff --git a/src/abslibre-tools/createworkdir b/src/abslibre-tools/createworkdir
new file mode 100755
index 0000000..b443c08
--- /dev/null
+++ b/src/abslibre-tools/createworkdir
@@ -0,0 +1,63 @@
+#!/bin/bash
+# CreateWorkDir
+# Creates a dir structure for working with Parabola packages
+
+# Copyright 2010 Nicolás Reynolds
+
+# ---------- GNU General Public License 3 ----------
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+source /etc/libretools.conf
+custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
+[[ -e $custom_config ]] && source $custom_config
+
+[[ ! -d ${WORKDIR} ]] && { # Create the WORKDIR
+
+ msg "Creating WORKDIR on ${WORKDIR}"
+ mkdir -p ${WORKDIR} ||{
+ error "Could not create ${WORKDIR}"; exit 1
+ }
+
+}
+
+for _repo in ${REPOS[@]}; do # Create the staging dirs
+
+ [[ ! -d ${WORKDIR}/staging/${_repo} ]] && {
+ mkdir -p ${WORKDIR}/staging/${_repo} || {
+ error "Can't create ${WORKDIR}/staging/${_repo}"
+ exit 1
+ }
+ }
+
+done
+
+[[ ! -d ${WORKDIR}/abslibre/.git ]] && {
+ msg "Cloning into ABSLibre"
+ CMD="git clone ${ABSLIBREGIT} ${WORKDIR}/abslibre"
+ ${CMD} || {
+ error "Could not clone ABSLibre"
+ plain "Try running this command:"
+ echo
+ plain "${CMD}"
+ exit 1
+ }
+}
+
+msg "Finished, your packaging dir tree looks like this now:"
+ls --color=always ${WORKDIR}/*/*
+
+exit 0
diff --git a/src/abslibre-tools/libreaddiff b/src/abslibre-tools/libreaddiff
new file mode 100755
index 0000000..98646a2
--- /dev/null
+++ b/src/abslibre-tools/libreaddiff
@@ -0,0 +1,97 @@
+#!/bin/bash
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011, 2012 Michał Masłowski <mtjm@mtjm.eu>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+set -e
+
+. /etc/libretools.conf
+custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
+[ -e $custom_config ] && . $custom_config
+
+for arg in "$@" ; do
+ case "$arg" in
+ -h|--h|--he|--hel|--help|-\?)
+ echo 'Usage: libreaddiff repo [arch]
+
+This script outputs a diff of package names and versions in repo
+between pacman'\''s sync db and abslibre checkout.' >&2
+ exit 0
+ ;;
+ esac
+done
+
+# The repo to find missing packages in.
+repo=$1
+# The arch to check in Arch repos, other will have all arches checked.
+arch=${2:-mips64el}
+# A Python tuple of repos which don't have arch=any packages.
+archrepos='("core", "extra", "community")'
+
+diff -U0 \
+ <( (
+ cd /var/lib/pacman/sync
+ for f in $repo.db ; do
+ tar xOf $f | python -c 'import sys
+arch = None
+name = None
+version = None
+it = iter(sys.stdin)
+try:
+ while True:
+ line = next(it)
+ if line == "%ARCH%\n":
+ arch = next(it)
+ if arch == "'"$arch"'\n" or "'$repo'" not in '"$archrepos"':
+ print("%s-%s" % (name.strip(), version.strip()))
+ if line == "%NAME%\n":
+ name = next(it)
+ if line == "%VERSION%\n":
+ version = next(it)
+except StopIteration:
+ pass
+'
+ done
+ ) | sort ) \
+ <( (
+ cd "${WORKDIR}/abslibre"
+ # Needed to not include pkgnames specific to other arches.
+ CARCH=$arch
+ for f in $repo/* ; do
+ unset pkgname
+ unset epoch
+ unset pkgver
+ unset pkgrel
+ unset arch
+ . $f/PKGBUILD || continue
+ is_here=false
+ for arc in ${arch[@]} ; do
+ if [ "$arc" = "any" -o "$arc" = "$CARCH" ] ; then
+ is_here=true
+ break
+ fi
+ done
+ if [ "$is_here" = "true" ] ; then
+ for name in ${pkgname[@]} ; do
+ if [ -z "$epoch" ] ; then
+ echo $name-$pkgver-$pkgrel
+ else
+ echo $name-$epoch:$pkgver-$pkgrel
+ fi
+ done
+ fi
+ done
+ ) | sort ) | sed -rn 's/^[+-][^+-].+$/&/p'
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease
new file mode 100755
index 0000000..efb698e
--- /dev/null
+++ b/src/abslibre-tools/librerelease
@@ -0,0 +1,155 @@
+#!/bin/bash
+# Librerelease
+# Uploads packages into [staging]
+
+# Copyright 2010 Nicolás Reynolds
+
+# ---------- GNU General Public License 3 ----------
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+source /etc/libretools.conf
+custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
+
+function usage {
+ echo "$(gettext "Usage: $0")"
+ echo
+ echo "$(gettext "This script uploads packages on $WORKDIR/stagging")"
+ echo "$(gettext "to parabola server.")"
+ echo
+ echo "$(gettext "OPTIONS:")"
+ echo "$(gettext " -h this message.")"
+ echo "$(gettext " -l only list packages but not upload them.")"
+ echo "$(gettext " -c clean packages on $WORKDIR/staging.")"
+ echo "$(gettext " -n dry-run")"
+}
+
+function list_packages {
+ repos=($(find "$WORKDIR/staging/" -mindepth 1 -type d \! -empty -printf '%f ' 2>/dev/null))
+ for _repo in ${repos[@]}; do
+ msg2 "$_repo"
+ find ${WORKDIR}/staging/${_repo} -type f -printf "%f\n"
+ done
+ unset repos
+}
+
+function sign_packages {
+ if [ -z "${SIGEXT}" ]; then
+ SIGEXT=.sig
+ warning "Empty SIGEXT var, using default .sig"
+ fi
+
+ if [ -z "${GPG_AGENT_INFO}" ]; then
+ warning "It's better to use gpg-agent to sign packages in batches"
+ fi
+
+ packages=($(find "${WORKDIR}/staging/" -type f -iname '*.pkg.tar.?z'))
+ for package in ${packages[@]}; do
+ if [ -f "${package}${SIGEXT}" ]; then
+
+ warning "Package signature found, verifying..."
+
+# Verify that the signature is correct, else remove for re-signing
+ if ! gpg --quiet --verify "${package}${SIGEXT}" >/dev/null 2>&1; then
+ error "Failed! Resigning..."
+ rm -f "${package}${SIGEXT}"
+ fi
+ fi
+
+ msg2 "Signing ${package}..."
+ gpg --default-key "${SIGID}" --output "${package}${SIGEXT}" \
+ --detach-sig "${package}" || {
+ error "Signing failed"
+ exit 2
+ }
+
+ done
+}
+
+# Remove everything that's not a package or a signature
+function clean_non_packages {
+ find $WORKDIR/staging/ -type f \
+ \! -iname "*.pkg.tar.?z" -a \! -iname "*.pkg.tar.?z.sig" \
+ -delete
+}
+
+# Clean everything if not on dry-run mode
+function clean {
+ [ -z ${dryrun} ] && \
+ rm -f $@
+}
+
+if [ -w / ]; then
+ error "Run $0 as normal user"
+ exit 1
+fi
+
+while getopts 'hlcn' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ l) list_packages; exit 0 ;;
+ c) clean; exit $? ;;
+ n) dryrun="--dry-run" ;;
+ esac
+done
+
+[[ -e $custom_config ]] && source $custom_config
+
+[[ ! -z ${HOOKPRERELEASE} ]] && bash -c "${HOOKPRERELEASE}"
+
+clean_non_packages
+if [ ! -z "${SIGID}" ]; then
+ sign_packages
+else
+ error "Package signing is *required*, please set SIGID on your libretools.conf"
+ exit 1
+fi
+
+# Make the permissions of the packages 644 otherwise the user will get access
+# denied error when they try to download (rsync --no-perms doesn't seem to
+# work).
+find ${WORKDIR}/staging -type f -exec chmod 644 {} \;
+find ${WORKDIR}/staging -type d -exec chmod 755 {} \;
+
+# Get the synced files
+SYNCED_FILES=($(find ${WORKDIR}/staging -type f))
+
+msg "%s to upload" $(du -h -d 0 ${WORKDIR}/staging | tr "\t" " " | cut -d" " -f1)
+msg "Uploading packages..."
+rsync --recursive \
+ ${dryrun} \
+ --no-group \
+ --no-perms \
+ --copy-links \
+ --hard-links \
+ --partial \
+ --prune-empty-dirs \
+ --human-readable \
+ --progress \
+ -e "ssh " \
+ ${WORKDIR}/staging \
+ ${PARABOLAHOST}:${LIBREDESTDIR}/ || {
+ error "Sync failed, try again"
+ exit 1
+ }
+
+msg "Removing ${#SYNCED_FILES[@]} files from local [staging]"
+clean ${SYNCED_FILES[@]}
+
+msg "Running db-update on repos"
+ssh ${PARABOLAHOST} dbscripts/db-update
+
+exit 0
diff --git a/src/abslibre-tools/librestage b/src/abslibre-tools/librestage
new file mode 100755
index 0000000..ae66cce
--- /dev/null
+++ b/src/abslibre-tools/librestage
@@ -0,0 +1,137 @@
+#!/bin/bash
+# LibreStage
+# Prepares packages for upload into [staging]
+
+# Copyright 2010 Nicolás Reynolds
+
+# ---------- GNU General Public License 3 ----------
+
+# This file is part of Parabola.
+
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+
+source /etc/libretools.conf
+custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf
+[[ -e $custom_config ]] && source $custom_config
+
+if [ -w / ]; then
+ error "This script should be run as regular user"
+ exit 1
+fi
+
+
+# End Config
+
+usage() {
+ cat <<EOU
+LibreStage Copyright (C) 2011 Nicolás Reynolds
+This program comes with ABSOLUTELY NO WARRANTY.
+This is free software, and you are welcome to redistribute it
+under the terms of the GNU General Public License version 3 or later.
+
+
+Usage: $(basename $0) <repo> [<repo2> ... ]
+
+LibreRelease will stage for upload the package(s) built by the PKGBUILD on
+the current directory to the specified repo(s).
+EOU
+}
+
+repos=$@
+
+while getopts 'h' arg; do
+ case $arg in
+ h) usage; exit 0 ;;
+ esac
+done
+
+if [ ${#repos} -eq 0 ]; then
+ usage
+ exit 1;
+fi
+
+[[ ! -e ./PKGBUILD ]] && {
+ error "PKGBUILD not found"
+ exit 1
+}
+
+# Source the needed files
+source /etc/makepkg.conf
+[[ -e ~/.makepkg.conf ]] && source ~/.makepkg.conf
+source ./PKGBUILD
+[[ -e ./rePKGBUILD ]] && source ./rePKGBUILD
+
+# Default package location
+PKGDEST=${PKGDEST:-.}
+SRCPKGDEST=${SRCPKGDEST:-.}
+
+PKGEXT=".pkg.tar.?z"
+
+staged=false
+# Copies the packages to the specified repos inside staging
+for _arch in ${ARCHES[@]}; do
+ for pkg in ${pkgname[@]}; do
+
+ pkgpath=$(find ${PKGDEST}/ -type f \
+ -name "${pkg}-$(get_full_version "${pkg}")-${_arch}${PKGEXT}")
+
+ [[ -z ${pkgpath} ]] && continue
+
+ pkgfile=$(basename ${pkgpath})
+
+# TODO refactor this
+ if [ -e "${pkgpath}" ]; then
+ msg "Found ${pkgfile}"
+
+ canonical=""
+ for _repo in ${repos[@]}; do
+
+ if [ ! -d "${WORKDIR}/staging/${_repo}" ]; then
+ warning "[${_repo}] didn't exist, creating..."
+ mkdir -p "${WORKDIR}/staging/${_repo}"
+ fi
+
+ if [ -z "$canonical" ]; then
+ canonical="${WORKDIR}/staging/${_repo}/${pkgfile}"
+
+ cp "${pkgpath}" "${WORKDIR}/staging/${_repo}/" || {
+ error "Can't put ${pkgfile} on [staging]"
+ exit 1
+ } && {
+ msg2 "${pkg} staged on [${_repo}]"
+ staged=true
+ }
+
+ else
+ ln "${canonical}" "${WORKDIR}/staging/${_repo}/${pkgfile}" || {
+ error "Can't put ${pkgfile} on [staging]"
+ exit 1
+ } && {
+ msg2 "${pkg} staged on [${_repo}]"
+ staged=true
+ }
+
+ fi
+ done
+ fi
+ done
+done
+
+if ! $staged ; then
+ error "No package was staged"
+ exit 1
+fi
+
+exit 0