index : devops | |
Archlinux32 devs' convenience-scripts | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-10-15 15:53:29 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-15 15:53:29 +0200 |
commit | c7a69fbf870e0521b02d4c063e7fdcd4d3b5431b (patch) | |
tree | 6f9d721a45df7c6e98a72454108a0c857ecb90f5 /update-kernel-config | |
parent | 1bc454f55ff573486a52390a1d653ba7acd45601 (diff) |
-rwxr-xr-x | update-kernel-config | 116 |
diff --git a/update-kernel-config b/update-kernel-config index 3fed852..e257941 100755 --- a/update-kernel-config +++ b/update-kernel-config @@ -5,12 +5,18 @@ if [ $# -ne 2 ]; then 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 - ' "/usr/src/archlinux32/packages/$1/$2/PKGBUILD" + ' "${git_repo_path}/$1/$2/PKGBUILD" ) if [ -z "${old_revision}" ]; then @@ -20,13 +26,13 @@ if [ -z "${old_revision}" ]; then fi config_names=$( - git -C "/usr/src/archlinux32/packages/$1/$2" archive HEAD -- | \ + git -C "${git_repo_path}/$1/$2" archive HEAD -- | \ tar -t | \ grep '^config\($\|\.\)' ) diff=$( - git -C "/usr/src/archlinux/packages/$2/repos/$1-x86_64" diff "${old_revision}" HEAD -- config | \ + git -C "${upstream_git_path}/$2/repos/$1-x86_64" diff "${old_revision}" HEAD -- config | \ grep '^[+-].' | \ grep -v '^+++\|^---' ) @@ -45,7 +51,7 @@ for config_name in ${config_names}; do T p ' - )" "/usr/src/archlinux32/packages/$1/$2/${config_name}" + )" "${git_repo_path}/$1/$2/${config_name}" printf '%s\n' "${diff}" | \ sed -n ' s/^+// @@ -53,32 +59,104 @@ for config_name in ${config_names}; do p ' } | \ - sponge "/usr/src/archlinux32/packages/$1/$2/${config_name}" + sponge "${git_repo_path}/$1/$2/${config_name}" done sed -i ' 1 s/^#.*$/# upstream git revision: '"$( - git -C "/usr/src/archlinux/packages" rev-parse HEAD + git -C "${upstream_git_path}" rev-parse HEAD )"'/ s/'"$( - git -C "/usr/src/archlinux/packages/$2/repos/$1-x86_64" archive "${old_revision}" -- config | \ + git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive "${old_revision}" -- config | \ tar -Ox | \ sha256sum | \ awk '{print $1}' )"'/'"$( - git -C "/usr/src/archlinux/packages/$2/repos/$1-x86_64" archive HEAD -- config | \ + git -C "${upstream_git_path}/$2/repos/$1-x86_64" archive HEAD -- config | \ tar -Ox | \ sha256sum | \ awk '{print $1}' )"'/g - '"$( - for config_name in ${config_names}; do - printf 's/' - git -C "/usr/src/archlinux32/packages/$1/$2" archive HEAD -- "${config_name}" | \ - tar -Ox | \ - sha256sum | \ - awk '{print $1}' | \ - tr -d '\n' - printf '/SKIP/g\n' - done - )" "/usr/src/archlinux32/packages/$1/$2/PKGBUILD" + ' "${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 arch in i486 i686; do + rm -rf --one-file-system src pkg + CARCH=${arch} makepkg -fcrs --asdeps --noconfirm + mv src/${_srcname}/.config config.${arch} + done +' +for config_name in ${config_names}; do + scp "arch32-test:$2/${config_name}" "${git_repo_path}/$1/$2/" +done +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 |