From 8551ee66b479ef57718c375c9009f4d7e94a2d75 Mon Sep 17 00:00:00 2001 From: hasufell Date: Fri, 14 Aug 2015 22:16:49 +0200 Subject: [PATCH] Initial commit --- etc/portage/check-portdir.sh | 9 +++++++++ etc/portage/postsync.d/sync_cache | 9 +++++++++ etc/portage/postsync.d/sync_dtd | 19 ++++++++++++++++++ etc/portage/postsync.d/sync_glsa | 19 ++++++++++++++++++ etc/portage/postsync.d/sync_herds_xml | 13 +++++++++++++ etc/portage/postsync.d/sync_news | 28 +++++++++++++++++++++++++++ etc/portage/repos.conf/gentoo.conf | 12 ++++++++++++ etc/portage/util-functions.sh | 8 ++++++++ 8 files changed, 117 insertions(+) create mode 100644 etc/portage/check-portdir.sh create mode 100755 etc/portage/postsync.d/sync_cache create mode 100755 etc/portage/postsync.d/sync_dtd create mode 100755 etc/portage/postsync.d/sync_glsa create mode 100755 etc/portage/postsync.d/sync_herds_xml create mode 100755 etc/portage/postsync.d/sync_news create mode 100644 etc/portage/repos.conf/gentoo.conf create mode 100644 etc/portage/util-functions.sh diff --git a/etc/portage/check-portdir.sh b/etc/portage/check-portdir.sh new file mode 100644 index 0000000..7fe1ff6 --- /dev/null +++ b/etc/portage/check-portdir.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +source /etc/portage/util-functions.sh + +if [[ -z ${PORTDIR} || "$(dirname ${PORTDIR})" == "/" ]] ; then + die "PORTDIR empty or pointing to root!" +elif [[ ! -e ${PORTDIR} ]] ; then + die "${PORTDIR} does not exist!" +fi diff --git a/etc/portage/postsync.d/sync_cache b/etc/portage/postsync.d/sync_cache new file mode 100755 index 0000000..3f6694b --- /dev/null +++ b/etc/portage/postsync.d/sync_cache @@ -0,0 +1,9 @@ +#!/bin/bash + +source /etc/portage/check-portdir.sh +source /etc/init.d/functions.sh +source /etc/portage/util-functions.sh + +einfo "syncing metadata cache" +egencache --jobs=8 --repo=gentoo --update --update-use-local-desc || die "egencache failed!" +einfo "done syncing metadata cache" diff --git a/etc/portage/postsync.d/sync_dtd b/etc/portage/postsync.d/sync_dtd new file mode 100755 index 0000000..b804c11 --- /dev/null +++ b/etc/portage/postsync.d/sync_dtd @@ -0,0 +1,19 @@ +#!/bin/bash + +source /etc/portage/check-portdir.sh +source /etc/init.d/functions.sh +source /etc/portage/util-functions.sh + +einfo "updating dtd directory" + +cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" +if [[ -e dtd ]] ; then + einfo "dtd dir already exists, updating..." + cd glsa || die "could not cd into 'dtd'!" + git pull --ff || die "could not pull updates!" +else + einfo "dtd directory does not exist, cloning..." + git clone https://anongit.gentoo.org/git/data/dtd.git || die "could not clone repository!" +fi + +einfo "done updating dtd directory" diff --git a/etc/portage/postsync.d/sync_glsa b/etc/portage/postsync.d/sync_glsa new file mode 100755 index 0000000..27e0fc5 --- /dev/null +++ b/etc/portage/postsync.d/sync_glsa @@ -0,0 +1,19 @@ +#!/bin/bash + +source /etc/portage/check-portdir.sh +source /etc/init.d/functions.sh +source /etc/portage/util-functions.sh + +einfo "updating glsa directory" + +cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" +if [[ -e glsa ]] ; then + einfo "glsa dir already exists, updating..." + cd glsa || die "could not cd into 'glsa'!" + git pull --ff || die "could not pull updates!" +else + einfo "glsa directory does not exist, cloning..." + git clone https://anongit.gentoo.org/git/data/glsa.git || die "could not clone repository!" +fi + +einfo "done updating glsa directory" diff --git a/etc/portage/postsync.d/sync_herds_xml b/etc/portage/postsync.d/sync_herds_xml new file mode 100755 index 0000000..45bc951 --- /dev/null +++ b/etc/portage/postsync.d/sync_herds_xml @@ -0,0 +1,13 @@ +#!/bin/bash + +source /etc/portage/check-portdir.sh +source /etc/init.d/functions.sh +source /etc/portage/util-functions.sh + +einfo "updating herds.xml" + +cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" +[[ -e "${PORTDIR}"/metadata/herds.xml ]] && { rm "${PORTDIR}"/metadata/herds.xml || die "failed to rm herds.xml!" ;} +wget https://gitweb.gentoo.org/proj/api.git/plain/files/packages/herds.xml || die "failed to wget herds.xml" + +einfo "done updating herds.xml" diff --git a/etc/portage/postsync.d/sync_news b/etc/portage/postsync.d/sync_news new file mode 100755 index 0000000..f119df9 --- /dev/null +++ b/etc/portage/postsync.d/sync_news @@ -0,0 +1,28 @@ +#!/bin/bash + +source /etc/portage/check-portdir.sh +source /etc/init.d/functions.sh +source /etc/portage/util-functions.sh + +einfo "updating news items" + +cd "${PORTDIR}"/metadata || die "could not cd into '${PORTDIR}/metadata'!" +if [[ -e news ]] ; then + einfo "news dir already exists, updating..." + cd news || die "could not cd into 'news'!" + git pull --ff || die "could not pull updates!" +else + einfo "glsa directory does not exist, cloning..." + git clone https://anongit.gentoo.org/git/proj/gentoo-news.git news || die "could not clone repository!" +fi + +cd "${PORTDIR}"/metadata/news || die "failed to cd into ${PORTDIR}/metadata/news" +git clean -fdxq || die "failed to clean git repo!" + +if [[ -n "$(find . -mindepth 1 -maxdepth 1 -type d -name "*-*-*")" ]] ; then + die "it seems the repository format of proj/gentoo-news has changed! Update your script!" +else + cp -a */* . || die "could not copy news dirs to base news dir!" +fi + +einfo "done updating news items" diff --git a/etc/portage/repos.conf/gentoo.conf b/etc/portage/repos.conf/gentoo.conf new file mode 100644 index 0000000..dfbe3a1 --- /dev/null +++ b/etc/portage/repos.conf/gentoo.conf @@ -0,0 +1,12 @@ +[DEFAULT] +main-repo = gentoo + +[gentoo] +location = /usr/portage +sync-type = git +sync-uri = https://github.com/gentoo/gentoo.git +auto-sync = yes + +# for daily squashfs snapshots +#sync-type = squashdelta +#sync-uri = mirror://gentoo/../snapshots/squashfs diff --git a/etc/portage/util-functions.sh b/etc/portage/util-functions.sh new file mode 100644 index 0000000..4fbf165 --- /dev/null +++ b/etc/portage/util-functions.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +source /etc/init.d/functions.sh + +die() { + eerror "$*" + exit 1 +}