21 Commits
Author SHA1 Message Date
wt d1164975e3 Merge pull request 'updated build' (#13) from hot-fixes into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/13
2025-04-15 10:19:35 +07:00
wt dcdd2ea51a updated build 2025-04-11 15:57:19 +07:00
wt b93e6153af Merge pull request 'up' (#12) from up into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/12
2025-04-08 16:22:22 +07:00
wt 0d15808a6f up 2025-04-08 16:25:59 +07:00
wt 2dfdf91528 Merge pull request 'pmbuild' (#10) from pmbuild into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/10
2025-01-23 08:13:42 +03:00
wt 20ca8e49ee updated buildpkg function and hide all in Makefile and buildpkg functions 2025-01-23 15:12:28 +07:00
wt 26b9d8118e updated colors in pm query 2025-01-20 20:13:05 +07:00
wt f14d5866f3 added comments 2025-01-20 15:58:34 +07:00
wt fc2d7e7915 added pmbuild 2025-01-20 18:45:13 +07:00
wt feded5e14e Merge pull request 'updated help' (#9) from update-help into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/9
2025-01-20 10:01:32 +03:00
wt fb463d418d updated help 2025-01-20 17:00:40 +07:00
wt 9f0f903c5e Merge pull request 'updated README.md' (#8) from readme into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/8
2025-01-17 16:27:11 +03:00
wt 106ae39803 updated README.md 2025-01-17 23:26:14 +07:00
wt 758b247438 Merge pull request 'Update Makefile' (#7) from tolamironcenko-patch-1 into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/7
2025-01-15 12:12:12 +03:00
wt 55623e13db Update Makefile 2025-01-15 12:11:53 +03:00
wt f9c7e6b8d6 Merge pull request 'added print deps' (#6) from print-deps into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/6
2025-01-15 12:09:01 +03:00
wt a05836abfd added print deps 2025-01-15 19:08:16 +07:00
wt 256dd28e05 Merge pull request 'added deps and fix delete and add and read query file' (#5) from deps into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/5
2025-01-15 12:03:06 +03:00
wt b75fc8a68a added deps and fix delete and add and read query file 2025-01-15 19:01:58 +07:00
wt db0e243794 Merge pull request 'updated and hot fixes' (#4) from update-and-fixes into main
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/pm/pulls/4
2025-01-14 16:35:22 +03:00
wt 6e8bdba73f updated and hot fixes 2025-01-14 23:33:13 +07:00
5 changed files with 274 additions and 83 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
pm.pkg
pm.pkg.gz
rootfs
rootfs
package
+33 -32
View File
@@ -2,52 +2,53 @@ DESTDIR=/
install:
if [ ! -d ${DESTDIR}/etc/pm ]; then \
mkdir -pv ${DESTDIR}/etc/pm; \
touch ${DESTDIR}/etc/pm/repo; \
@if [ ! -d ${DESTDIR}/etc/pm ]; then \
mkdir -p ${DESTDIR}/etc/pm; \
# touch ${DESTDIR}/etc/pm/repo; \
fi
if [ ! -d ${DESTDIR}/tmp ]; then \
mkdir -pv ${DESTDIR}/tmp; \
@if [ ! -d ${DESTDIR}/tmp ]; then \
mkdir -p ${DESTDIR}/tmp; \
fi
if [ ! -d ${DESTDIR}/usr/bin ]; then \
mkdir -pv ${DESTDIR}/usr/bin; \
@if [ ! -d ${DESTDIR}/usr/bin ]; then \
mkdir -p ${DESTDIR}/usr/bin; \
fi
if [ ! -d ${DESTDIR}/usr/share/pm ]; then \
mkdir -pv ${DESTDIR}/usr/share/pm/{packages,repos}; \
touch ${DESTDIR}/usr/share/pm/query; \
@if [ ! -d ${DESTDIR}/usr/share/pm ]; then \
mkdir -p ${DESTDIR}/usr/share/pm/{packages,repos}; \
# touch ${DESTDIR}/usr/share/pm/query; \
fi
if [ ! -d ${DESTDIR}/var/cache/pm/pkg ]; then \
mkdir -pv ${DESTDIR}/var/cache/pm/pkg; \
@if [ ! -d ${DESTDIR}/var/cache/pm/pkg ]; then \
mkdir -p ${DESTDIR}/var/cache/pm/pkg; \
fi
cp -v src/pm ${DESTDIR}/usr/bin/pm;
@cp src/pm ${DESTDIR}/usr/bin/pm;
uninstall:
if [ -d ${DESTDIR}/etc/pm ]; then \
rm -rv ${DESTDIR}/etc/pm; \
@if [ -d ${DESTDIR}/etc/pm ]; then \
rm -r ${DESTDIR}/etc/pm; \
fi
if [ -d ${DESTDIR}/usr/share/pm ]; then \
rm -rv ${DESTDIR}/usr/share/pm; \
@if [ -d ${DESTDIR}/usr/share/pm ]; then \
rm -r ${DESTDIR}/usr/share/pm; \
fi
if [ -d ${DESTDIR}/var/cache/pm ]; then \
rm -rv ${DESTDIR}/var/cache/pm; \
@if [ -d ${DESTDIR}/var/cache/pm ]; then \
rm -r ${DESTDIR}/var/cache/pm; \
fi
if [ -f ${DESTDIR}/usr/bin/pm ]; then \
rm -v ${DESTDIR}/usr/bin/pm; \
@if [ -f ${DESTDIR}/usr/bin/pm ]; then \
rm ${DESTDIR}/usr/bin/pm; \
fi
package:
mkdir -pv pm.pkg/usr/bin
mkdir -pv pm.pkg/etc/pm
mkdir -pv pm.pkg/var/cache/pm/pkg
mkdir -pv pm.pkg/usr/share/pm/{repos,packages}
echo usr/bin/pm > pm.pkg/list
cp -v src/pm pm.pkg/usr/bin/pm
tar -czvf pm.pkg.gz pm.pkg
@mkdir -p pm.pkg/usr/bin
@mkdir -p pm.pkg/etc/pm
@mkdir -p pm.pkg/var/cache/pm/pkg
@mkdir -p pm.pkg/usr/share/pm/{repos,packages}
@echo usr/bin/pm > pm.pkg/list
@echo busybox > pm.pkg/deps
@cp src/pm pm.pkg/usr/bin/pm
@tar -czf pm.pkg.gz pm.pkg
clean:
if [ -d pm.pkg ]; then \
rm -rv pm.pkg; \
@if [ -d pm.pkg ]; then \
rm -r pm.pkg; \
fi
if [ -f pm.pkg.gz ]; then \
rm -v pm.pkg.gz; \
@if [ -f pm.pkg.gz ]; then \
rm pm.pkg.gz; \
fi
+11
View File
@@ -0,0 +1,11 @@
pkgname=pm
pkgver=1.1
pkgrel=1
# srcdir=/home/tola/Documents/linux/pm
gitsource="https://gitea.home.com:3000/TolaMironcenko/pm.git"
deps="busybox"
package() {
cd $srcdir
make install DESTDIR=$pkgdir
}
+8
View File
@@ -29,6 +29,8 @@
```
pfetch.pkg
├── list
├── deps
├── post_install
└── usr
└── bin
└── pfetch
@@ -38,4 +40,10 @@ pfetch.pkg
```
usr/bin/pfetch
```
## Example deps file (pfetch for example)
```
busybox
```
+220 -50
View File
@@ -49,37 +49,45 @@ checkroot() {
exit 1
fi
}
checkroot
#------------------------------------------------------------------------
#----------------- add(install) package function ------------------------
add() {
shift 1
if [[ "$1" == "" ]]; then
help
exit 0
fi
for i in $*; do
if [[ "$i" == "add" ]]; then
continue
fi
for i in $@; do
case $i in
add|a)
continue
;;
esac
done
for i in $*; do
if [[ "$i" == "add" ]]; then
continue
fi
down $i
for i in $@; do
case $i in
add|a)
continue
;;
*)
down $i
;;
esac
done
for i in $*; do
if [[ "$i" == "add" ]]; then
continue
fi
unpack $cachedpkgdir/$i.pkg.gz
for i in $@; do
case $i in
add|a)
continue
;;
*)
unpack $cachedpkgdir/$i.pkg.gz
;;
esac
done
}
a() {
add $*
add $@
}
#------------------------------------------------------------------------
@@ -93,12 +101,13 @@ down() {
check $? "Read repositories"
for i in $servers; do
serverdir=$(echo $i | sed -e "/http:\/\//s///")
serverdir=$(echo $i | sed -e "/ftp:\/\//s///")
serverdir=$(echo $serverdir | sed -e "/ftp:\/\//s///")
repoquery=$(/usr/bin/cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
for j in $repoquery; do
if [[ $j == $1 ]]; then
if [ ! -f $cachedpkgdir/$1.pkg.gz ]; then
printf "$YELLOW**$RESET Downloading $YELLOW$serverdir: $Bwhite$j\n$RESET"
echo $i/$1.pkg.gz
wget $i/$1.pkg.gz -P $cachedpkgdir
check $? "Download package"
# if [[ "$?" == "0" ]]; then
@@ -112,7 +121,7 @@ down() {
printf "$YELLOW**$GREEN successful downloaded $1\n$RESET"
return
fi
# exit 0
return
fi
done
done
@@ -129,13 +138,42 @@ unpack() {
packagename=$(echo $1 | sed -e "/.gz/s///")
packagename=${packagename#*pkg/}
printf "$YELLOW**$GREEN Installing ${packagename%.pkg*}\n$RESET"
installed=$(/usr/bin/cat $packagesqueryfile | grep ${packagename%.pkg*})
check $? "Read $packagesqueryfile"
if [[ "$installed" != "" ]]; then
if [ ! -f $packagesqueryfile ]; then
printf "$BBLUE**$BWHITE Can't find $packagesqueryfile [$BRED ERROR $BWHITE]\n$RESET"
fi
installed=false
for i in $(/usr/bin/cat $packagesqueryfile); do
if [ "$i" = "${packagename%.pkg*}" ]; then
export installed=true
break
fi
done
if [[ "$installed" == "true" ]]; then
printf "$YELLOW**$RESET Package already installed:$YELLOW reinstalling\n$RESET"
fi
tar -xvf $1 -C $rootdir/tmp &> /dev/null
cd $rootdir/tmp/$packagename
if [ -f deps ]; then
printf "$YELLOW**$GREEN Checking deps\n$RESET"
deps=$(/usr/bin/cat deps)
for dep in $deps; do
have=false
for pack in $(/usr/bin/cat $packagesqueryfile); do
if [ $pack = $dep ]; then
have=yes
break
fi
done
if [ "$have" = "false" ]; then
pkgnow=$packagename
add "" $dep
unpack $cachedpkgdir/$pkgnow.gz
return
fi
done
mkdir $installedpackagesdir/$packagename &> /dev/null
mv -v deps $installedpackagesdir/$packagename &> /dev/null
fi
mkdir $installedpackagesdir/$packagename &> /dev/null
mv -v list $installedpackagesdir/$packagename &> /dev/null
cp -r ./* $rootdir/
@@ -146,7 +184,7 @@ unpack() {
printf "$YELLOW**$GREEN post_install script ${packagename%.pkg*}\n$RESET"
/usr/bin/sh -c $rootdir/tmp/$packagename/post_install &> /dev/null
fi
if [[ "$(/usr/bin/cat $packagesqueryfile | grep ${packagename%.pkg*})" == "" ]]; then
if [[ "$installed" == "false" ]]; then
echo ${packagename%.pkg*} >> $packagesqueryfile
fi
rm -rv $rootdir/tmp/$packagename &> /dev/null
@@ -160,10 +198,8 @@ u() {
#------------------ delete package function -----------------------------
del() {
printf "$YELLOW**$GREEN deleting\n$RESET"
for i in $*; do
if [[ "$i" == "del" ]]; then
continue
fi
shift 1
for i in $@; do
printf "$YELLOW**$GREEN deleting $i\n$RESET"
if [ ! -f $installedpackagesdir/$i.pkg/list ]; then
printf "$BBLUE**$BWHITE package not installed ($i) [$BRED ERROR $BWHITE]\n$RESET"
@@ -174,19 +210,32 @@ del() {
done
# rm -v $rootdir/$(/usr/bin/cat $installedpackagesdir/$i.pkg/list)
rm -rv $installedpackagesdir/$i.pkg &> /dev/null
sed -i "/$i/d" $packagesqueryfile
packs=$(cat $packagesqueryfile)
rm $packagesqueryfile
for pack in $packs; do
if [ "$pack" = "$i" ]; then
continue
fi
echo $pack >> $packagesqueryfile
done
# sed -i "s/$i/d" $packagesqueryfile
printf "$YELLOW**$GREEN delete $i successful\n$RESET"
done
}
d() {
del $*
del $@
}
#------------------------------------------------------------------------
#------------------- list files in package function ---------------------
list() {
if [[ "$1" == "" ]]; then
help
for i in $(/usr/bin/cat $packagesqueryfile); do
filelist=$(/usr/bin/cat $installedpackagesdir/$i.pkg/list)
for j in $filelist; do
printf "$YELLOW$i: $BWHITE$j$RESET\n"
done
done
exit 0
fi
if [[ "$(/usr/bin/cat $packagesqueryfile | grep $1)" == "" ]]; then
@@ -207,10 +256,12 @@ l() {
query() {
packagesquery=$(/usr/bin/cat $packagesqueryfile)
if [[ "$packagesquery" == "" ]]; then
printf "$YELLOW**$BWHITE No installed packages\n"
printf "$YELLOW**$BWHITE No installed packages\n$RESET"
exit 0
fi
printf "$packagesquery\n"
for i in $packagesquery; do
printf "$BWHITE$i\n$RESET"
done
}
q() {
query
@@ -221,16 +272,17 @@ q() {
help() {
printf "
$YELLOW**$GREEN pm usage$RESET :
$BWHITE pm add [package name] - download and install from repository
pm unpack [/path/to/package/archive] - unpack(install) from local package archive
pm down [package name] - download package from repository without install
pm del [package name] - delete package
pm list [package name] - list files in package
pm search [package name] - search package in repository
pm query - show installed packages
pm help - this help message
pm clear - clear all package archives from cached packages directory
pm sync - synchronize repository
$BWHITE add, a [package name] - download and install from repository
unpack, u [/path/to/package/archive] - unpack(install) from local package archive
down, download [package name] - download package from repository without install
del, d [package name] - delete package
list, l [package name] - list files in package
search, ss [package name] - search package in repository
query, q - show installed packages
help - this help message
clear - clear all package archives from cached packages directory
sync, s - synchronize repository
deps [package name] - show package dependencies
$YELLOW**$GREEN examples$RESET :
$BWHITE pm add dnsmasq
@@ -251,12 +303,17 @@ help() {
sync() {
servers=$(/usr/bin/cat $repofile)
for i in $servers; do
printf "$YELLOW**$GREEN Sync $BWHITE$i\n$RESET"
serverdir=$(echo $i | sed -e "/http:\//s///")
serverdir=$(echo $i | sed -e "/ftp:\//s///")
serverdir=$(echo $serverdir | sed -e "/ftp:\//s///")
mkdir -p $reposquerydir/$serverdir &> /dev/null
wget $i/query -O $reposquerydir/$serverdir/query &> /dev/null
check $? "Sync $i"
done
}
s() {
sync
}
#------------------------------------------------------------------------
#----------------- search package in repo function ----------------------
@@ -265,6 +322,7 @@ search() {
if [[ ! $1 ]]; then
for i in $servers; do
serverdir=$(echo $i | sed -e "/http:\/\//s///")
serverdir=$(echo $serverdir | sed -e "/ftp:\/\//s///")
repoquery=$(/usr/bin/cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
for j in $repoquery; do
printf "$YELLOW$serverdir: $BWHITE$j\n$RESET"
@@ -272,18 +330,22 @@ search() {
done
exit 0
fi
found=false
for i in $servers; do
serverdir=$(echo $i | sed -e "/http:\/\//s///")
serverdir=$(echo $serverdir | sed -e "/ftp:\/\//s///")
repoquery=$(/usr/bin/cat $reposquerydir/$serverdir/query | sed -e '/.pkg.gz/s///')
for j in $repoquery; do
if [[ $j == $1 ]]; then
if [[ $j =~ $1 ]]; then
printf "$YELLOW$serverdir: $BWHITE$j\n$RESET"
exit 0
found=true
fi
done
done
printf "$YELLOW**$RED error:$RESET can't find package ($1)\n"
[ "$found" = "false" ] && printf "$YELLOW**$RED error:$RESET can't find package ($1)\n"
}
ss() {
search $1
}
#------------------------------------------------------------------------
@@ -293,14 +355,122 @@ clear() {
}
#------------------------------------------------------------------------
#--- show package dependencies function ---
deps() {
if [ "$1" = "" ]; then
help
exit 1
fi
if [ ! -f $installedpackagesdir/$1.pkg/deps ]; then
printf "$YELLOW**$BWHITE No deps\n$RESET"
exit 0
fi
cat $installedpackagesdir/$1.pkg/deps
}
#------------------------------------------
#--- build package uses PMBUILD file function ---
buildpkg() {
if [ ! -f ./PMBUILD ]; then
if [ "$1" != "" ]; then
source $1
else
printf "$BBLUE**$BWHITE Can't find PMBUILD [$BRED ERROR $BWHITE]\n$RESET"
fi
else
source ./PMBUILD
fi
export buildroot=$(pwd)
if [ -f $buildroot/$pkgname-$pkgver-$pkgrel.pkg.gz ]; then
if [ "$1" != "-r" ]; then
printf "$BBLUE**$BWHITE $pkgname-$pkgver-$pkgrel.pkg.gz already exists please use -r to rebuild [$YELLOW WARNING $BWHITE]\n$RESET"
exit 0
else
[ -d pkg ] && rm -r pkg
[ -d src ] && rm -r src
[ -f $pkgname-$pkgver-$pkgrel.pkg.gz ] && rm -r $pkgname-$pkgver-$pkgrel.pkg.gz
fi
fi
[ ! -d src ] && mkdir -p src
[ ! -d pkg/$pkgname-$pkgver-$pkgrel.pkg ] && mkdir -p pkg/$pkgname-$pkgver-$pkgrel.pkg
export pkgdir=$buildroot/pkg/$pkgname-$pkgver-$pkgrel.pkg
if [ "$srcdir" = "" ]; then
export srcdir=$buildroot/src/$pkgname
fi
if [ "$gitsource" != "" ]; then
printf "$BBLUE**$BWHITE Downloading sources\n$RESET"
git clone $gitsource $srcdir
check $? "Download sources"
fi
if [ "$source" != "" ]; then
printf "$BBLUE**$BWHITE Downloading sources\n$RESET"
[ ! -d $srcdir ] && mkdir -p $srcdir
cd $srcdir
[ ! -f $pkgname-$pkgver.tar.* ] && wget $source
cd -
fi
if [[ $(type -t configure) = function ]]; then
printf "$BBLUE**$BWHITE Configuring package\n$RESET"
configure
check $? "Configure"
fi
if [[ $(type -t build) = function ]]; then
printf "$BBLUE**$BWHITE Building package\n$RESET"
build
check $? "Build"
else
echo "no build"
fi
if [[ $(type -t package) == function ]]; then
printf "$BBLUE**$BWHITE Packaging package\n$RESET"
package
check $? "Package"
else
echo "no package"
fi
printf "$BBLUE**$BWHITE Stripping unneded symbols\n$RESET"
for execfile in $(find $pkgdir -executable -type f); do
strip $execfile
done
printf "$BBLUE**$BWHITE Strip unneded symbols [$BGREEN SUCCESS $BWHITE]\n$RESET"
cd $pkgdir
find -type f > $buildroot/list
find -type l >> $buildroot/list
sed -i "s/.\///" $buildroot/list
sed -i 's/usr\/sbin//g' $buildroot/list
sed -i 's/usr\/lib64//g' $buildroot/list
sed -i 's/usr\/lib32//g' $buildroot/list
cd $buildroot
mv list $pkgdir/list
if [ "$deps" != "" ]; then
for i in $deps; do
echo $i >> $pkgdir/deps
done
fi
cd $pkgdir
printf "$BBLUE**$BWHITE Archiving package\n$RESET"
tar -czf $buildroot/$pkgname-$pkgver-$pkgrel.pkg.gz .. &> /dev/null
check $? "Archive package"
cd $buildroot
unset pkgdir srcdir buildroot
}
#-----------------------------------------------------
#--- main ---
case "$1" in
add|a|del|d)
"$1" $*
checkroot
"$1" $@
;;
query|q|help|sync|clear|search|list|l|unpack|u|down|download)
query|q|s|sync|clear|ss|search|list|l|unpack|u|down|download|deps)
checkroot
"$1" $2
;;
build)
buildpkg $2
;;
*)
help
;;
esac
#------------