mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-05 08:28:00 +00:00
cleanup repo, move extra scripts to scratchpkg-utils repo
This commit is contained in:
@@ -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}
|
||||
|
||||
128
extra/pkgfix
128
extra/pkgfix
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# 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
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
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
|
||||
@@ -1,85 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
printhelp() {
|
||||
cat << EOF
|
||||
|
||||
Usage:
|
||||
$(basename $0) <newroot> <command>
|
||||
|
||||
(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
|
||||
30
pkgbase
30
pkgbase
@@ -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 $?
|
||||
26
pkgcreate
26
pkgcreate
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
name=${1:-foo}
|
||||
version=${2:-0.1}
|
||||
release=${3:-1}
|
||||
outputdir=${4:-/tmp}
|
||||
target=${5:-PWD}
|
||||
tar -cvJpf $outputdir/$name-$version-$release.spkg.txz *
|
||||
108
pkginfo
108
pkginfo
@@ -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) <option> [arg]
|
||||
|
||||
Options:
|
||||
-i,--installed print all installed ports
|
||||
-p,--ports print all existing ports
|
||||
-d,--diff print outdate ports
|
||||
-l,--listfiles <port> print files for ports
|
||||
-o,--owner <file> print files owner
|
||||
-q,--query <port> print ports details
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
main() {
|
||||
get_repo
|
||||
|
||||
case $1 in
|
||||
-i|--installed) pkg_installed ;;
|
||||
-l|--listfiles) pkg_listfiles $2 ;;
|
||||
-o|--owner) pkg_own $2 ;;
|
||||
-p|--ports) pkg_port ;;
|
||||
-d|--diff) pkg_diff ;;
|
||||
-q|--query) pkg_query $2 ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
}
|
||||
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
REPOFILE="/etc/scratchpkg.repo"
|
||||
CMD=$(basename $0)
|
||||
|
||||
main $@
|
||||
|
||||
exit 0
|
||||
@@ -1,73 +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 <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
|
||||
RED='\e[0;31m' #Red
|
||||
GREEN='\e[0;32m' #Green
|
||||
YELLOW='\e[0;33m' #Yellow
|
||||
CYAN='\e[0;36m' #Cyan
|
||||
CRESET='\e[0m' #Reset color
|
||||
|
||||
msgerr() {
|
||||
echo -e "${RED}==> ERROR:${CRESET} $1"
|
||||
}
|
||||
|
||||
if [ ! $1 ]; then
|
||||
msgerr "This script requires one arguments."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d $INDEX_DIR/$1 ]; then
|
||||
msgerr "Package '$1' not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd / >/dev/null
|
||||
while IFS=' ' read -r LINE; do
|
||||
case "$(file -bi "${LINE}")" in
|
||||
*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
|
||||
NEEDED_LIB=$(objdump -x "$LINE" | grep NEEDED | awk '{print $2}')
|
||||
for i in ${NEEDED_LIB[@]}; do
|
||||
case $i in
|
||||
ld-linux-x86-64.so.2|ld-linux.so.2) continue;;
|
||||
esac
|
||||
libpath=$(ldd "$LINE" | grep -v "not found" | grep -w "$i" | awk '{print $3}')
|
||||
if [ "$libpath" ]; then
|
||||
FILEPATH=$(readlink -f $libpath)
|
||||
FILENAME=$(echo $FILEPATH | sed -e '1s/^.//')
|
||||
PKG_NAME=$(basename $(dirname $(grep -Rx $FILENAME $INDEX_DIR | cut -d ':' -f1)))
|
||||
if [ "$PKG_NAME" != $1 ]; then
|
||||
if ! echo "$deppkg" | grep -qw "$PKG_NAME"; then
|
||||
deppkg="$deppkg $PKG_NAME "
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
unset libpath
|
||||
done
|
||||
esac
|
||||
done < <(tac $INDEX_DIR/$1/.files | grep -E ^"(bin/|lib/|libexec/|sbin/|usr/bin/|usr/lib/|usr/lib32/|usr/libexec/|usr/sbin/|opt/)" | grep -v "/$")
|
||||
popd >/dev/null
|
||||
|
||||
echo $deppkg | tr ' ' '\n'
|
||||
|
||||
exit 0
|
||||
@@ -47,9 +47,11 @@ for file in $spkgnew; do
|
||||
continue
|
||||
fi
|
||||
echo
|
||||
echo "File: $currentfile"
|
||||
echo
|
||||
echo "Choose action:"
|
||||
echo "1) Keep original"
|
||||
echo "2) Replace original with new"
|
||||
echo "1) Discard update"
|
||||
echo "2) Update config"
|
||||
echo "*) Do nothing"
|
||||
echo
|
||||
echo -n "Action: "
|
||||
Reference in New Issue
Block a user