main/scratchpkg: portsync now use git to pull latest port

This commit is contained in:
emmett1
2021-07-24 00:51:04 +08:00
parent a8ead26f0c
commit d40dc75169
4 changed files with 118 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
c6182475cd990fb5c63ceec35394933d c254ac0dc62a037f41bc269f1df291f6f53ab239.tar.gz
d973b8d674eb1a65a1a51e452ff82a2b portsync
e653273a32632805f9493224fd3af227 scratchpkg.conf
ea1fd5e5a7866a32a99c3ee6cef35d29 scratchpkg.repo

View File

@@ -1,4 +1,4 @@
scratchpkg-20210515-1
scratchpkg-20210702-2
drwxr-xr-x root/root etc/
-rw-r--r-- root/root etc/revdep.conf.spkgnew
drwxr-xr-x root/root etc/revdep.d/

111
main/scratchpkg/portsync Executable file
View File

@@ -0,0 +1,111 @@
#!/bin/sh
#
# 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/>.
#
cmp_copy() {
# usage:
# cmp_copy <source dir> <target dir>
#
reponame=${2##*/}
for p in $1/*; do
[ -d $p ] || continue
pname=${p##*/}
if [ ! -d $2/$pname ]; then
mkdir -p $2/$pname
for f in $p/* $p/.pkgfiles $p/.checksums; do
[ -f $f ] || continue
case $f in
*/update) continue;;
esac
fname=${f##*/}
echo " New: $reponame/$pname/$fname"
cp $f $2/$pname/$fname
done
else
for f in $p/* $p/.pkgfiles $p/.checksums; do
[ -f $f ] || continue
case $f in
*/update) continue;;
esac
fname=${f##*/}
cmp -s $f $2/$pname/$fname || {
echo " Edit: $reponame/$pname/$fname"
cp $f $2/$pname/$fname
}
done
fi
done
for p in $2/*; do
[ -d $p ] || continue
pname=${p##*/}
for f in $p/* $p/.pkgfiles $p/.checksums; do
[ -f $f ] || continue
fname=${f##*/}
if [ ! -f $1/$pname/$fname ]; then
echo " Removed: $reponame/$pname/$fname"
rm $2/$pname/$fname
fi
done
if [ ! -d $1/$pname ]; then
rmdir $2/$pname
fi
done
}
github_sync() {
# usage:
# github_sync <github url> <target dir>
#
echo "Updating repo: $2"
dir=$2
repo=${dir##*/}
url=$(echo $1 | cut -d / -f -5)
branch=$(echo $1 | cut -d / -f 7)
tmprepo=/tmp/tmprepo
echo " fetching $1"
rm -fr $tmprepo
git clone -q -b $branch $url $tmprepo
if [ $? != 0 ] || [ ! -d $tmprepo/$repo ]; then
echo " failed sync repo"
return 1
fi
cmp_copy $tmprepo/$repo $dir
rm -fr $tmprepo
echo " repo update completed"
}
REPO_FILE=/etc/scratchpkg.repo
if [ ! -e "$REPO_FILE" ]; then
echo "Repo file not found: $REPO_FILE"
exit 1
fi
if [ "$(id -u)" != 0 ]; then
echo "This operation need root access."
exit 1
fi
grep -Ev '^(#|$)' "$REPO_FILE" | awk '{print $1,$2}' | while read -r repodir repourl; do
if [ "$repodir" ] && [ "$repourl" ]; then
github_sync $repourl $repodir
fi
done
exit 0

View File

@@ -1,9 +1,9 @@
# description : A simple package manager for Linux Distribution
# depends : coreutils libarchive
# depends : coreutils libarchive git
name=scratchpkg
version=20210702
release=1
release=2
backup="etc/scratchpkg.conf
etc/scratchpkg.alias
etc/scratchpkg.repo
@@ -12,7 +12,8 @@ backup="etc/scratchpkg.conf
scratchpkg_url=https://github.com/venomlinux/scratchpkg
source="https://github.com/venomlinux/scratchpkg/archive/c254ac0dc62a037f41bc269f1df291f6f53ab239.tar.gz
$name.repo
$name.conf"
$name.conf
portsync"
build() {
cd $name-c254ac0dc62a037f41bc269f1df291f6f53ab239
@@ -26,4 +27,5 @@ build() {
DESTDIR=$PKG ./INSTALL.sh
install -m644 $SRC/$name.repo $PKG/etc/$name.repo
install -m644 $SRC/$name.conf $PKG/etc/$name.conf
install -m755 $SRC/portsync $PKG/usr/bin/portsync
}