summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-12-04 10:25:43 +0100
committerErich Eckner <git@eckner.net>2018-12-04 10:25:43 +0100
commit683015b1a3f4ff422c52cc5cdfece725ce665f3b (patch)
treef058b3e203592a1134921ff5806b0cd813a9f608
parent1b479e00f62271940bf22d5e851c890d5ee83b7c (diff)
downloaddevops-683015b1a3f4ff422c52cc5cdfece725ce665f3b.tar.xz
update-kernel-config merged into update-archlinux32-package
update-archlinux32-package is now an egg-laying wool-milk sow
-rwxr-xr-xupdate-archlinux32-package368
-rwxr-xr-xupdate-kernel-config181
2 files changed, 313 insertions, 236 deletions
diff --git a/update-archlinux32-package b/update-archlinux32-package
index ae17d69..891cdf7 100755
--- a/update-archlinux32-package
+++ b/update-archlinux32-package
@@ -1,6 +1,15 @@
#!/bin/bash
-git_repo_path='/usr/src/archlinux32/packages/'
+# update an archlinux32 package
+# devtools
+# linux-pae (no upstream)
+# linux
+# linux-lts
+# linux-zen
+
+git_repo_path='/usr/src/archlinux32/packages'
+upstream_git_path='/usr/src/archlinux/packages'
+archlinuxewe_git_path=~erich/'eigeneSkripte/archPackages'
vagrant_path=$(
readlink -f ~/"virtual-boxes/archlinux32-test"
)
@@ -9,7 +18,44 @@ base_dir=$(
readlink -f "$0"
)"
)
+
+if [ "x$1" = "x-" ]; then
+ shift
+else
+ if ! git -C "${git_repo_path}" pull --ff-only || \
+ ! git -C "${upstream_git_path}" pull --ff-only || \
+ ! git -C "${archlinuxewe_git_path}" pull --ff-only; then
+ >&2 echo 'Your git repos cannot cleanly be updated'
+ exit 1
+ fi
+fi
+
+case $# in
+ 0)
+ >&2 echo "usage: $0 pkg1 pkg2 ..."
+ exit 1
+ ;;
+ 1)
+ ;;
+ *)
+ for param in "$@"; do
+ "$0" - "${param}" || exit $?
+ done
+ exit 0
+ ;;
+esac
+
pkgname="$1"
+repo=$(
+ git -C "${git_repo_path}" archive HEAD -- | \
+ tar -t --wildcards "*/${pkgname}/PKGBUILD" | \
+ cut -d/ -f1
+)
+
+if [ "$(printf '%s\n' "${repo}" | wc -l)" -ne 1 ]; then
+ >&2 printf 'package "%s" does not exist in exactly one repository\n' "${pkgname}"
+ exit 1
+fi
update_checksum() {
checksums=$(
@@ -32,44 +78,28 @@ update_checksum() {
' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
}
-if [ $# -ne 1 ]; then
- >&2 echo 'usage: update-archlinux32-package $pkgname'
- exit
-fi
-
-if [ "${pkgname}" != 'linux-pae' ]; then
- >&2 echo 'sry, this is not yet implemented - I only know "linux-pae".'
- exit
-fi
-
-infos=$(
- "${base_dir}/watch-versions" "${pkgname}"
-)
-
-if [ -z "${infos}" ]; then
- >&2 echo 'Nothing to do.'
- exit
-fi
-
-old_pkgver=$(
- printf '%s\n' "${infos}" | \
- cut -d' ' -f4
-)
-
-new_pkgver=$(
- printf '%s\n' "${infos}" | \
- cut -d' ' -f2
-)
-
-repo=$(
- readlink -f "${git_repo_path}"*"/${pkgname}" | \
- cut -d/ -f6
-)
-
-sed -i '
- s/^pkgver=.*$/pkgver='"'${new_pkgver}'"'/
- s/^pkgrel=.*$/pkgrel='"'1'"'/
-' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+# selecting the "update path"
+case "${pkgname}" in
+ 'devtools')
+ # a package which is in [archlinuxewe] -> mostly upstream, but with
+ # replaced sources, checksums and pkgver (might be identical to
+ # upstream, though)
+ update_path='archlinuxewe'
+ ;;
+ 'linux'|'linux-lts'|'linux-zen')
+ # a kernel which exists upstream -> different config and checksums
+ update_path='kernel with upstream'
+ ;;
+ 'linux-pae')
+ # a kernel which does not exist upstream -> complete package sources
+ # in our repository
+ update_path='kernel without upstream'
+ ;;
+ *)
+ >&2 printf 'I don'"'"'t know how to update package "%s"\n' "${pkgname}"
+ exit 1
+ ;;
+esac
if ssh -o ConnectTimeout=1 arch32-test true; then
vm_is_running=true
@@ -82,34 +112,262 @@ if ! ${vm_is_running}; then
vagrant up
fi
-scp -r "${git_repo_path}/${repo}/${pkgname}" 'arch32-test:'
-update_checksum
+ssh arch32-test 'rm -rf --one-file-system "'"${pkgname}"'"'
-case "${pkgname}" in
- 'linux-pae')
- scp "${git_repo_path}/${repo}/${pkgname}/PKGBUILD" 'arch32-test:'"${pkgname}/"
+case ${update_path} in
+ 'kernel without upstream')
+ infos=$(
+ "${base_dir}/watch-versions" "${pkgname}"
+ )
+ if [ -z "${infos}" ]; then
+ >&2 echo 'Nothing to do.'
+ exit
+ fi
+ old_pkgver=$(
+ printf '%s\n' "${infos}" | \
+ cut -d' ' -f4
+ )
+ new_pkgver=$(
+ printf '%s\n' "${infos}" | \
+ cut -d' ' -f2
+ )
+ sed -i '
+ s/^pkgver=.*$/pkgver='"'${new_pkgver}'"'/
+ s/^pkgrel=.*$/pkgrel='"'1'"'/
+ ' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+ scp -r "${git_repo_path}/${repo}/${pkgname}" 'arch32-test:'
+ update_checksum
+
+ case "${pkgname}" in
+ 'linux-pae')
+ scp "${git_repo_path}/${repo}/${pkgname}/PKGBUILD" 'arch32-test:'"${pkgname}/"
+ ssh arch32-test '
+ cd '"${pkgname}"'
+ sed -i '"'"'
+ /make oldconfig/ s/^\s*#//
+ s/^}$/return 1\n\0/
+ '"'"' PKGBUILD
+ makepkg -fcrs --asdeps --noconfirm
+ cp src/linux-'"${new_pkgver}"'/.config config
+ '
+ update_checksum
+ scp 'arch32-test:'"${pkgname}"'/config' "${git_repo_path}/${repo}/${pkgname}/"
+ git -C "${git_repo_path}/${repo}/${pkgname}" add 'PKGBUILD' 'config'
+ ;;
+ *)
+ >&2 printf 'Whoops, I thought %s should be updated as %s, but I don'"'"'t know the details.\n' \
+ "${pkgname}" "${update_path}"
+ exit 1
+ ;;
+ esac
+
+ git -C "${git_repo_path}" commit -m "${repo}/${pkgname}: ${old_pkgver} -> ${new_pkgver}"
+ ;;
+ 'kernel with upstream')
+ old_revision=$(
+ sed -n '
+ s/^# upstream git\( revision\)\?: *//
+ T
+ p
+ ' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+ )
+ if [ -z "${old_revision}" ]; then
+ >&2 printf 'Cannot determine old upstream git revision of "%s".\n' "${pkgname}"
+ >&2 echo '"# upstream git revision: ..." line is missing.'
+ exit 1
+ fi
+ config_names=$(
+ git -C "${git_repo_path}/${repo}/${pkgname}" archive HEAD -- | \
+ tar -t | \
+ grep '^config\($\|\.\)' | \
+ tr '\n' ' '
+ )
+ diff=$(
+ diff -u <(
+ git -C "${upstream_git_path}/${pkgname}/repos/${repo}-x86_64" archive "${old_revision}" -- config | \
+ tar -Ox | \
+ sort
+ ) \
+ <(
+ git -C "${upstream_git_path}/${pkgname}/repos/${repo}-x86_64" archive HEAD -- config | \
+ tar -Ox | \
+ sort
+ ) | \
+ grep '^[+-].' | \
+ grep -v '^+++\|^---'
+ )
+ if [ -z "${diff}" ]; then
+ >&2 echo 'nothing changed.'
+ exit 0
+ fi
+ for config_name in ${config_names}; do
+ {
+ grep -vxF "$(
+ printf '%s\n' "${diff}" | \
+ sed '
+ s/^-//
+ t
+ d
+ '
+ )" "${git_repo_path}/${repo}/${pkgname}/${config_name}"
+ printf '%s\n' "${diff}" | \
+ sed '
+ s/^+//
+ t
+ d
+ '
+ } | \
+ sponge "${git_repo_path}/${repo}/${pkgname}/${config_name}"
+ done
+ sed -i '
+ 1 s/^#.*$/# upstream git revision: '"$(
+ git -C "${upstream_git_path}" rev-parse HEAD
+ )"'/
+ s/'"$(
+ git -C "${upstream_git_path}/${pkgname}/repos/${repo}-x86_64" archive "${old_revision}" -- config | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}'
+ )"'/'"$(
+ git -C "${upstream_git_path}/${pkgname}/repos/${repo}-x86_64" archive HEAD -- config | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}'
+ )"'/g
+ ' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+ {
+ git -C "${upstream_git_path}/${pkgname}/repos/${repo}-x86_64" archive HEAD --
+ for config_name in ${config_names}; do
+ tar -c -C "${git_repo_path}/${repo}/${pkgname}" "${config_name}"
+ done
+ } | \
+ ssh arch32-test '
+ mkdir "'"${pkgname}"'"
+ tar -xiC "'"${pkgname}"'"
+ '
ssh arch32-test '
- cd '"${pkgname}"'
+ cd "'"${pkgname}"'"
+ cat >> PKGBUILD
sed -i '"'"'
+ '"$(
+ for config_name in ${config_names}; do
+ printf 's/'
+ git -C "${git_repo_path}/${repo}/${pkgname}" archive HEAD -- "${config_name}" | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}' | \
+ tr -d '\n'
+ printf '/SKIP/g\n'
+ done
+ )"'
+ /^arch=[^#]*any/!{
+ /^arch=(/s/(/(i486 i686 pentium3 /
+ }
/make oldconfig/ s/^\s*#//
s/^}$/return 1\n\0/
'"'"' PKGBUILD
- makepkg -fcrs --asdeps --noconfirm
- cp src/linux-'"${new_pkgver}"'/.config config
+ ' < \
+ "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+ ssh arch32-test '
+ cd "'"${pkgname}"'"
+ eval "$(grep '"'"'^_srcname='"'"' PKGBUILD)"
+ for config_name in '"${config_names}"'; do
+ rm -rf --one-file-system src pkg
+ if [ "${config_name}" = "config" ]; then
+ makepkg -fcrs --asdeps --noconfirm
+ else
+ CARCH=${config_name#config.} makepkg -fcrs --asdeps --noconfirm
+ fi
+ mv src/${_srcname}/.config ${config_name}
+ done
'
- update_checksum
- scp 'arch32-test:'"${pkgname}"'/config' "${git_repo_path}/${repo}/${pkgname}/"
- git -C "${git_repo_path}/${repo}/${pkgname}" add 'PKGBUILD' 'config'
+ for config_name in ${config_names}; do
+ scp "arch32-test:${pkgname}/${config_name}" "${git_repo_path}/${repo}/${pkgname}/"
+ done
+ sed -i "$(
+ for config_name in ${config_names}; do
+ printf 's/'
+ git -C "${git_repo_path}/${repo}/${pkgname}" archive HEAD -- "${config_name}" | \
+ tar -Ox | \
+ sha256sum | \
+ awk '{print $1}' | \
+ tr -d '\n'
+ printf '/'
+ sha256sum "${git_repo_path}/${repo}/${pkgname}/${config_name}" | \
+ awk '{print $1}' | \
+ tr -d '\n'
+ printf '/g\n'
+ done
+ )" "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+ git -C "${git_repo_path}/${repo}/${pkgname}" commit PKGBUILD ${config_names} -m "${repo}/${pkgname}: new version => new config => new checksum"
+ ;;
+ 'archlinuxewe')
+ archlinuxewe_PKGBUILD=$(
+ git -C "${archlinuxewe_git_path}" archive HEAD -- "${pkgname}32/PKGBUILD" | \
+ tar -Ox
+ )
+ repo_arch=$(
+ printf '%s\n' "${archlinuxewe_PKGBUILD}" | \
+ grep '^arch=' | \
+ cut -d'=' -f2 | \
+ tr '()"'"'" '\n' | \
+ grep -xF 'x86_64' || \
+ echo any
+ )
+ old_pkgver=$(
+ grep '^pkgver=' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD" | \
+ cut -d'=' -f2
+ )
+ if [ "${old_pkgver}" = "${new_pkgver}" ]; then
+ >&2 echo 'nothing to do'
+ exit
+ fi
+ new_pkgver=$(
+ printf '%s\n' "${archlinuxewe_PKGBUILD}" | \
+ grep '^pkgver=' | \
+ cut -d'=' -f2
+ )
+ sha512sums=$(
+ cd "${archlinuxewe_git_path}/${pkgname}32"
+ makepkg -g | \
+ sed '
+ s/^/\\1/
+ $! s/$/\\n/
+ ' | \
+ tr -d '\n'
+ )
+ sed -i '
+ s/^pkgver=.*/pkgver='"${new_pkgver}"'/
+ s/^pkgrel=.*/pkgrel=1/
+ /^\s*sha512sums=(/ {
+ :sum_loop
+ $b
+ N
+ s/^\(\s*\)sha512sums=(.*)/'"${sha512sums}"'/
+ T sum_loop
+ }
+ ' "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"
+ scp -r "${upstream_git_path}/${pkgname}/repos/${repo}-${repo_arch}" \
+ "arch32-test:${pkgname}"
+ if ! ssh arch32-test '
+ cd "'"${pkgname}"'"
+ cat >> PKGBUILD
+ makepkg --verifysource
+ ' < \
+ "${git_repo_path}/${repo}/${pkgname}/PKGBUILD"; then
+ >&2 echo 'something went wrong'
+ exit 1
+ fi
+ git -C "${git_repo_path}" commit "${repo}/${pkgname}/PKGBUILD" -m "${repo}/${pkgname}: ${old_pkgver} -> ${new_pkgver}"
;;
*)
- >&2 printf 'Whoops, I thought I knew %s, but apparently I don'"'"'t.\n' \
- "${pkgname}"
- exit
+ >&2 printf 'Whoops, I thought I knew how to update %s, but apparently I don'"'"'t.\n' \
+ "${update_path}"
+ exit 1
;;
esac
-ssh arch32-test 'rm -rf --one-file-system '"${pkgname}"
-git -C "${git_repo_path}" commit -m "${repo}/${pkgname}: ${old_pkgver} -> ${new_pkgver}"
+ssh arch32-test 'rm -rf --one-file-system '"${pkgname}"
if ! ${vm_is_running}; then
ssh arch32-test 'sudo poweroff'
diff --git a/update-kernel-config b/update-kernel-config
deleted file mode 100755
index 46b362a..0000000
--- a/update-kernel-config
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/bin/bash
-
-if [ $# -ne 2 ]; then
- >&2 echo 'usage: update-kernel-config [repository] [kernel-name]'
- exit 2
-fi
-
-git_repo_path='/usr/src/archlinux32/packages/'
-upstream_git_path='/usr/src/archlinux/packages'
-vagrant_path=$(
- readlink -f ~/"virtual-boxes/archlinux32-test"
-)
-
-old_revision=$(
- sed -n '
- s/^# upstream git\( revision\)\?: *//
- T
- p
- ' "${git_repo_path}/$1/$2/PKGBUILD"
-)
-
-if [ -z "${old_revision}" ]; then
- >&2 echo 'Cannot determine old upstream git revision.'
- >&2 echo '"# upstream git revision: ..." line is missing.'
- exit 1
-fi
-
-git -C "${git_repo_path}/$1/$2" pull --ff-only
-
-config_names=$(
- git -C "${git_repo_path}/$1/$2" archive HEAD -- | \
- tar -t | \
- grep '^config\($\|\.\)' | \
- tr '\n' ' '
-)
-
-diff=$(
- diff -u <(
- git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive "${old_revision}" -- config | \
- tar -Ox | \
- sort
- ) \
- <(
- git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive HEAD -- config | \
- tar -Ox | \
- sort
- ) | \
- grep '^[+-].' | \
- grep -v '^+++\|^---'
-)
-
-if [ -z "${diff}" ]; then
- >&2 echo 'nothing changed.'
- exit 1
-fi
-
-for config_name in ${config_names}; do
- {
- grep -vxF "$(
- printf '%s\n' "${diff}" | \
- sed '
- s/^-//
- t
- d
- '
- )" "${git_repo_path}/$1/$2/${config_name}"
- printf '%s\n' "${diff}" | \
- sed '
- s/^+//
- t
- d
- '
- } | \
- sponge "${git_repo_path}/$1/$2/${config_name}"
-done
-
-sed -i '
- 1 s/^#.*$/# upstream git revision: '"$(
- git -C "${upstream_git_path}" rev-parse HEAD
- )"'/
- s/'"$(
- git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive "${old_revision}" -- config | \
- tar -Ox | \
- sha256sum | \
- awk '{print $1}'
- )"'/'"$(
- git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive HEAD -- config | \
- tar -Ox | \
- sha256sum | \
- awk '{print $1}'
- )"'/g
- ' "${git_repo_path}/$1/$2/PKGBUILD"
-
-if ssh -o ConnectTimeout=1 arch32-test true; then
- vm_is_running=true
-else
- vm_is_running=false
-fi
-
-if ! ${vm_is_running}; then
- cd "${vagrant_path}"
- vagrant up
-fi
-
-{
- git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive HEAD --
- for config_name in ${config_names}; do
- tar -c -C "${git_repo_path}/$1/$2" "${config_name}"
- done
-} | \
- ssh arch32-test '
- rm -rf --one-file-system "'"$2"'"
- mkdir "'"$2"'"
- tar -xiC "'"$2"'"
- '
-ssh arch32-test '
- cd "'"$2"'"
- cat >> PKGBUILD
- sed -i '"'"'
- '"$(
- for config_name in ${config_names}; do
- printf 's/'
- git -C "${git_repo_path}/$1/$2" archive HEAD -- "${config_name}" | \
- tar -Ox | \
- sha256sum | \
- awk '{print $1}' | \
- tr -d '\n'
- printf '/SKIP/g\n'
- done
- )"'
- /^arch=[^#]*any/!{
- /^arch=(/s/(/(i486 i686 pentium3 /
- }
- /make oldconfig/ s/^\s*#//
- s/^}$/return 1\n\0/
- '"'"' PKGBUILD
-' < \
- "${git_repo_path}/$1/$2/PKGBUILD"
-ssh arch32-test '
- cd "'"$2"'"
- eval "$(grep '"'"'^_srcname='"'"' PKGBUILD)"
- for config_name in '"${config_names}"'; do
- rm -rf --one-file-system src pkg
- if [ "${config_name}" = "config" ]; then
- makepkg -fcrs --asdeps --noconfirm
- else
- CARCH=${config_name#config.} makepkg -fcrs --asdeps --noconfirm
- fi
- mv src/${_srcname}/.config ${config_name}
- done
-'
-for config_name in ${config_names}; do
- scp "arch32-test:$2/${config_name}" "${git_repo_path}/$1/$2/"
-done
-ssh arch32-test '
- rm -rf --one-file-system "'"$2"'"
-'
-sed -i "$(
- for config_name in ${config_names}; do
- printf 's/'
- git -C "${git_repo_path}/$1/$2" archive HEAD -- "${config_name}" | \
- tar -Ox | \
- sha256sum | \
- awk '{print $1}' | \
- tr -d '\n'
- printf '/'
- sha256sum "${git_repo_path}/$1/$2/${config_name}" | \
- awk '{print $1}' | \
- tr -d '\n'
- printf '/g\n'
- done
-)" "${git_repo_path}/$1/$2/PKGBUILD"
-git -C "${git_repo_path}/$1/$2" commit PKGBUILD ${config_names} -m "$1/$2: new version => new config => new checksum"
-if ! ${vm_is_running}; then
- ssh arch32-test 'sudo poweroff'
- err=$?
- if [ ${err} -eq 255 ]; then
- err=0
- fi
- exit ${err}
-fi