From 4cebf3d7fa36d8706c29554f14015a35f8bcb193 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Sun, 15 Dec 2019 22:49:38 +0800 Subject: [PATCH] cleanup repo, move extra scripts to scratchpkg-utils repo --- BUGS | 0 INSTALL.sh | 3 +- TODO | 1 - extra/pkgfix | 128 --------------------------------- extra/portcreate | 48 ------------- extra/vchroot | 85 ---------------------- pkgbase | 30 -------- pkgcreate | 26 ------- pkginfo | 108 ---------------------------- pkglibdepends | 73 ------------------- extra/updateconf => updateconf | 6 +- 11 files changed, 5 insertions(+), 503 deletions(-) delete mode 100644 BUGS delete mode 100644 TODO delete mode 100755 extra/pkgfix delete mode 100755 extra/portcreate delete mode 100755 extra/vchroot delete mode 100755 pkgbase delete mode 100755 pkgcreate delete mode 100755 pkginfo delete mode 100755 pkglibdepends rename extra/updateconf => updateconf (95%) diff --git a/BUGS b/BUGS deleted file mode 100644 index e69de29..0000000 diff --git a/INSTALL.sh b/INSTALL.sh index d3a8418..cff67d5 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -8,8 +8,7 @@ REVDEPD=/etc/revdep.d REVDEPCONF=/etc/revdep.conf mkdir -pv ${DESTDIR}{${BINDIR},${CONFDIR},${PORT_DIR},${REVDEPD}} -install -m755 revdep pkgadd pkgdel pkgbuild pkgdeplist pkglibdepends scratch pkgbase ${DESTDIR}${BINDIR} +install -m755 revdep pkgadd pkgdel pkgbuild pkgdeplist scratch updateconf ${DESTDIR}${BINDIR} install -m644 scratchpkg.conf scratchpkg.repo ${DESTDIR}${CONFDIR} -install -m755 extra/* ${DESTDIR}${BINDIR} install -dm777 ${DESTDIR}${CACHE_DIR}/{packages,sources,log,work} install -m644 revdep.conf ${DESTDIR}${REVDEPCONF} diff --git a/TODO b/TODO deleted file mode 100644 index 17c36ef..0000000 --- a/TODO +++ /dev/null @@ -1 +0,0 @@ -1. Add no extract function (done) diff --git a/extra/pkgfix b/extra/pkgfix deleted file mode 100755 index 295d7cc..0000000 --- a/extra/pkgfix +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019 by Emmett1 (emmett1.2miligrams@gmail.com) -# -# 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 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 . -# -# -# script to detect broken kernel modules after kernel update -# need to use with 'scratchpkg' -# - -export LANG=C - -get_perlmodules() { - type -p perl &>/dev/null || return - perlpath=$(dirname $(perl -V:sitearch | grep -o "'.*'" | sed "s/'//g")) - for i in $(dirname $perlpath)/*; do - [ "$perlpath" = "$i" ] && continue - ppkg=$(scratch own $i/$ | awk '{print $1}') - done -} - -get_modules() { - [ -f /lib/modules/KERNELVERSION ] || return - KERVER=$(cat /lib/modules/KERNELVERSION) - for i in /lib/modules/*; do - case $i in - /lib/modules/KERNELVERSION|/lib/modules/$KERVER) continue ;; - esac - kpkg=$(scratch own $i/$ | awk '{print $1}') - done -} - -sort_modules() { - for all in $(pkgdeplist -l -i $ppkg $kpkg | cut -d ' ' -f2); do - for r in $ppkg $kpkg; do - if [ $r = $all ]; then - if [ -z "$order" ]; then - order="$all" - else - order="$order $all" - fi - break - fi - done - done -} - -confirm() { - read -r -p "$1 (Y/n) " response - case "$response" in - [Nn][Oo]|[Nn]) echo "$2"; exit 2 ;; - *) : ;; - esac -} - -usage() { - cat << EOF -Usage: - $(basename $0) [options] - -Options: - -r rebuild & reinstall broken package - -y dont ask user confirmation to rebuild package (use with -r) - -h print this help message - -EOF -} - -parse_opt() { - while [ "$1" ]; do - case $1 in - -r) REBUILD=1 ;; - -y) YES=1 ;; - -h) usage; exit 0 ;; - *) echo "Invalid option ($1)"; exit 1 ;; - esac - shift - done -} - -parse_opt $@ - -if [ "$REBUILD" ] && [ "$UID" != 0 ]; then - echo "Rebuild broken packages required root!" - exit 1 -fi - -get_modules -get_perlmodules - -if [ "$ppkg" ] || [ "$kpkg" ]; then - sort_modules -else - echo "No broken packages found." - exit 0 -fi - -if [ "$REBUILD" = 1 ]; then - if [ "$YES" = "" ]; then - echo - echo "Package will be rebuild & reinstall by this order:" - echo " $order" - echo - confirm "Continue rebuild & reinstall broken packages?" "Operation cancelled." - fi - for p in $order; do - scratch build -f $p && scratch install -r $p || exit 1 - done -else - echo "Broken packages:" - for p in $order; do - echo " $p" - done -fi - -exit 0 diff --git a/extra/portcreate b/extra/portcreate deleted file mode 100755 index 86e2281..0000000 --- a/extra/portcreate +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# scratchpkg -# -# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com) -# -# 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 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 . -# - -if [ -d $1 ]; then - echo "ERROR: Directory '$1' already exist!" - exit 1 -else - mkdir $1 - echo "# description : -# homepage : -# depends : - -name=$1 -version= -release=1 -options=() -noextract=() -backup=() -source=() -md5sum=() - -build() { - cd \$name-\$version - ./configure --prefix=/usr - make - make DESTDIR=\$PKG install -}" > $1/spkgbuild - echo "Template port have created for '$1'." -fi - -exit 0 diff --git a/extra/vchroot b/extra/vchroot deleted file mode 100755 index 4f1f15a..0000000 --- a/extra/vchroot +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -printhelp() { - cat << EOF - -Usage: - $(basename $0) - -(omit command to chroot only) - -EOF -} - -msgerr() { - echo -e "ERROR: $@" -} - -if [ "$UID" != "0" ]; then - msgerr "$(basename $0) need root access!" - printhelp - exit 1 -fi - -LFS=$1 - -if [ -z $1 ]; then - msgerr "Please set directory for chroot!" - printhelp - exit 1 -fi - -if [ ! -d $LFS ]; then - msgerr "Directory '$LFS' not exist" - printhelp - exit 1 -fi - -shift - -CMD=$@ -if [ -z $2 ]; then - CMD="/bin/bash --login" -fi - -if [ -e /sys/firmware/efi/systab ]; then - EFI_SYSTEM=1 -fi - -pushd $LFS &>/dev/null - -mount --bind /dev $LFS/dev -mount -t devpts devpts $LFS/dev/pts -o gid=5,mode=620 -mount -t proc proc $LFS/proc -mount -t sysfs sysfs $LFS/sys -if [ -n "$EFI_SYSTEM" ]; then - mount --bind /sys/firmware/efi/efivars $LFS/sys/firmware/efi/efivars -fi -mount -t tmpfs tmpfs $LFS/run - -if [ -h $LFS/dev/shm ]; then - mkdir -p $LFS/$(readlink $LFS/dev/shm) -fi - -cp -L /etc/resolv.conf $LFS/etc - -chroot "$LFS" /usr/bin/env -i \ -HOME=/root \ -TERM="$TERM" \ -PS1='\u:\w\$ ' \ -PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD - -retval=$? - -popd &>/dev/null - -umount $LFS/dev/pts -umount $LFS/dev -umount $LFS/run -umount $LFS/proc -if [ -n "$EFI_SYSTEM" ]; then - umount $LFS/sys/firmware/efi/efivars -fi -umount $LFS/sys - -exit $retval diff --git a/pkgbase b/pkgbase deleted file mode 100755 index 1569c0c..0000000 --- a/pkgbase +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -echo "Calculate keep packages..." -keep=$(pkgdeplist -l base | awk '{print $2}') -if [ "$1" ]; then - echo "Calculate extrakeep packages..." - extrakeep=$(pkgdeplist -l $@ | awk '{print $2}') -fi -keep="$keep $extrakeep" - -echo "Get all installed packages..." -allinstalled=$(scratch listinst | awk '{print $1}') - -echo "Calculate selected packages to remove..." -for pkg in $allinstalled; do - echo $keep | tr ' ' '\n' | grep -qx $pkg - if [ "$?" != 0 ]; then - if [ "$remove" = "" ]; then - remove=$pkg - else - remove="$remove $pkg" - fi - fi -done - -if [ -n "$remove" ]; then - scratch remove -y $remove -fi - -exit $? diff --git a/pkgcreate b/pkgcreate deleted file mode 100755 index a1e3f08..0000000 --- a/pkgcreate +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# scratchpkg -# -# Copyright (c) 2018 by Emmett1 (emmett1.2miligrams@gmail.com) -# -# 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 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 . -# - -name=${1:-foo} -version=${2:-0.1} -release=${3:-1} -outputdir=${4:-/tmp} -target=${5:-PWD} -tar -cvJpf $outputdir/$name-$version-$release.spkg.txz * diff --git a/pkginfo b/pkginfo deleted file mode 100755 index 3ed23c0..0000000 --- a/pkginfo +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash - -msg() { - echo "$CMD: $*" -} - -get_info() { - echo -ne "$1 " - grep -e ^version -e ^release "$INDEX_DIR"/$1/.pkginfo | awk '{print $3}' | tr '\n' '-' | sed 's:\-$::' - echo -} - -pkg_installed() { - for pkg in $(grep ^name "$INDEX_DIR"/*/.pkginfo | awk '{print $3}'); do - get_info $pkg - done -} - -pkg_listfiles() { - [ "$1" ] || return - if [ ! -f "$INDEX_DIR"/$1/.files ]; then - msg "port '$1' not installed." - exit 1 - fi - cat "$INDEX_DIR"/$1/.files -} - -pkg_own() { - [ "$1" ] || return - local arg - arg=$(echo $1 | sed "s/^\///") - grep "$arg" $INDEX_DIR/*/.files | sed "s:$INDEX_DIR/::" | sed "s:/.files::" | tr : " " | column -t -} - -pkg_port() { - find ${PORT_REPO[@]} -name spkgbuild -follow -printf "%h\n" -} - -pkg_diff() { - for pkg in $(pkg_installed | awk '{print $1}'); do - installed_ver=$(grep -e ^version -e ^release /var/lib/scratchpkg/index/$pkg/.pkginfo | awk '{print $3}' | tr '\n' '-' | sed 's/-$//') - port_ver=$(pkg_query $pkg | awk '{print $2,$3}' | tr ' ' '-') - [ "$installed_ver" ] || continue - [ "$port_ver" ] || continue - if [ "$installed_ver" != "$port_ver" ]; then - echo "$pkg: $installed_ver -> $port_ver" - fi - done -} - -pkg_query() { - [ "$1" ] || return - . $(pkg_port | grep "/$1$")/spkgbuild 2>/dev/null && \ - echo "$name $version $release" || \ - return -} - -get_repo() { - if [ ! -f "$REPOFILE" ]; then - msg "repo file not exist. ($REPOFILE)" - exit 1 - else - while read -r repodir repourl junk; do - case $repodir in - ""|"#"*) continue ;; - esac - PORT_REPO+=($repodir) - done < "$REPOFILE" - fi -} - -usage() { - cat << EOF -Usage: - $(basename $0)