This commit is contained in:
shenmo 2023-07-21 09:50:17 +08:00
parent f886018e06
commit 7b66181ecb
14 changed files with 210 additions and 0 deletions

5
README.md Normal file

@ -0,0 +1,5 @@
uos-packaging-tools 一共包含了五个工具
可在deepin/UOS上使用
详细介绍见帖子

9
src/DEBIAN/control Normal file

@ -0,0 +1,9 @@
Package: uos-packaging-tools
Version: 1.0.1
Architecture: all
Maintainer: shenmo<shenmo@spark-app.store>
Installed-Size: 10
Depends: libnotify-bin,fakeroot,zstd,store.spark-app.appimage2deb | appimage2deb ,policykit-1
Section: graphics
Priority: optional
Description: uos-packaging-tools

@ -0,0 +1,35 @@
#!/bin/bash
if [ $# -lt 1 ]; then
echo "参数错误请提供至少一个deb文件的目录路径"
exit 1
fi
for deb_file in "$@"
do
cd "$(dirname "$deb_file")"
# 获取deb包的包名和架构
package_name=$(dpkg-deb -f "$deb_file" Package)
architecture=$(dpkg-deb -f "$deb_file" Architecture)
# 创建文件夹
folder_name="$package_name"
mkdir "$folder_name"
cd "$folder_name"
# 创建子文件夹和空文件
mkdir "icons" "screenshot"
touch "info.txt" "author.txt"
# 创建与架构名相同的文件夹并移动deb包
mkdir "$architecture"
mv "$deb_file" "$architecture/"
cp -r /opt/apps/"$package_name"/entries/icons/* icons/
echo "操作完成!"
echo "---------------------------------------------------------------------------"
done

@ -0,0 +1,19 @@
#/bin/bash
TMPDIR="/tmp"
unpack_package() {
DEBPATH="$1"
package_name=$(dpkg-deb -f "$DEBPATH" Package)
OUTPATH=$(dirname "$DEBPATH")
mkdir -p "$OUTPATH/$package_name/DEBIAN/"
dpkg -e "$DEBPATH" "$OUTPATH/$package_name/DEBIAN/"
dpkg -X "$DEBPATH" "$OUTPATH/$package_name/"
notify-send "$package_name 解包已完成" -i /usr/share/icons/uos-packaging-tools.png
echo "---------------------------------------------------------------------------"
}
for arg in "$@"; do
unpack_package "$arg"
done

@ -0,0 +1,44 @@
#!/bin/bash
function notify-send()
{
#Detect the user using such display
local user=$(who | awk '{print $1}' | head -n 1)
#Detect the id of the user
local uid=$(id -u $user)
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send "$@"
}
if [ -e /usr/local/bin/ssaudit ];then
for DEBPATH in "$@"
do
DEBPATH=$(realpath "$DEBPATH")
notify-send "正在使用ssaudit安装 $(dpkg-deb -f "$DEBPATH" Package),请稍候...." -i /usr/share/icons/uos-packaging-tools.png
/usr/local/bin/ssaudit "$DEBPATH"
if [ "$?" = "0" ];then
notify-send "$(dpkg-deb -f "$DEBPATH" Package) 安装已完成" -i /usr/share/icons/uos-packaging-tools.png
else
notify-send "$(dpkg-deb -f "$DEBPATH" Package) 安装出错!请手动安装!" -i /usr/share/icons/uos-packaging-tools.png
fi
echo "---------------------------------------------------------------------------"
done
else
for DEBPATH in "$@"
do
DEBPATH=$(realpath "$DEBPATH")
notify-send "正在使用apt安装 $(dpkg-deb -f "$DEBPATH" Package),请稍候...." -i /usr/share/icons/uos-packaging-tools.png
apt install "$DEBPATH" --reinstall -y
if [ "$?" = "0" ];then
notify-send "$(dpkg-deb -f "$DEBPATH" Package) 安装已完成" -i /usr/share/icons/uos-packaging-tools.png
else
notify-send "$(dpkg-deb -f "$DEBPATH" Package) 安装出错!请手动安装!" -i /usr/share/icons/uos-packaging-tools.png
fi
echo "---------------------------------------------------------------------------"
done
fi

@ -0,0 +1,24 @@
#/bin/bash
TMPDIR=/tmp
OUTPATH=""
for DEBPATH in "$@"
do
rm -rf $TMPDIR/unpack-dir
mkdir -p "$TMPDIR/unpack-dir"
cd "$TMPDIR/unpack-dir"
ar -vx "$DEBPATH"
rm debian-binary
tar -xvf data.tar*
mkdir DEBIAN
tar -xvf control.tar* -C ./DEBIAN
rm data.tar* control.tar*
dpkg-deb -Z xz -b "$TMPDIR/unpack-dir/" "$OUTPATH"
echo "Repack finished for $(dpkg-deb -f $DEBPATH Package). Remove tmp dir."
rm -rf "$TMPDIR/unpack-dir"
notify-send $(dpkg-deb -f "$DEBPATH" Package)重打包已完成 -i /usr/share/icons/uos-packaging-tools.png
done
echo "---------------------------------------------------------------------------"

9
src/usr/bin/pack Executable file

@ -0,0 +1,9 @@
#!/bin/bash
if [ "$1" != "" ];then
opt=$1
else
opt=`pwd`
fi
dpkg-deb -Z xz -b $opt $opt/..
notify-send `basename $opt`打包完成 -i /usr/share/icons/uos-packaging-tools.png
exit

@ -0,0 +1,10 @@
[Desktop Entry]
Categories=Development;
Encoding=UTF-8
Exec=/opt/uos-packaging-tools/directory-create %U
Icon=uos-packaging-tools
MimeType=application/vnd.debian.binary-package;application/x-deb;
Name=
StartupWMClass=
Terminal=false
Type=Application

@ -0,0 +1,10 @@
[Desktop Entry]
Categories=Development;
Encoding=UTF-8
Exec=/opt/uos-packaging-tools/just-X-me %U
Icon=uos-packaging-tools
MimeType=application/vnd.debian.binary-package;application/x-deb;
Name=
StartupWMClass=
Terminal=false
Type=Application

@ -0,0 +1,10 @@
[Desktop Entry]
Categories=Development;
Encoding=UTF-8
Exec=pkexec /opt/uos-packaging-tools/just-install-me %U
Icon=uos-packaging-tools
MimeType=application/vnd.debian.binary-package;application/x-deb;
Name=
StartupWMClass=
Terminal=false
Type=Application

@ -0,0 +1,10 @@
[Desktop Entry]
Categories=Development;
Encoding=UTF-8
Exec=/opt/uos-packaging-tools/just-repack-me %U
Icon=uos-packaging-tools
MimeType=application/vnd.debian.binary-package;application/x-deb;
Name=
StartupWMClass=
Terminal=false
Type=Application

@ -0,0 +1,7 @@
[Desktop Entry]
Exec=/usr/bin/pack %U
Name=Pack Here
Icon=uos-packaging-tools
Type=Application
X-DFM-MenuTypes=SingleDir;SingleFile;MultiFileDirs;
Terminal=true

Binary file not shown.

After

(image error) Size: 58 KiB

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>Spark Store</vendor>
<icon_name>x-package-repository</icon_name>
<action id="store.spark-app.ssinstall">
<description>运行justinstallme需要权限</description>
<message>要使用ssinstall需要权限</message>
<defaults>
<allow_any>yes</allow_any>
<allow_inactive>yes</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/opt/uos-packaging-tools/just-install-me</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>