Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: auto add liblol dependency #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions loong64-it/loong64-it.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ abinfo() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
abdbg() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }

_convert_loong64() {
PKG_PATH=$(realpath $1)
PKG_NAME=$(dpkg-deb -f "$PKG_PATH" Package)
VERSION=$(dpkg-deb -f "$PKG_PATH" Version)
HERE=$(basename $1)
abinfo "Examining package information: $1 ..."
dpkg -I "$SRCDIR"/$1 || \
dpkg -I "$PKG_PATH" || \
aberr "Invalid dpkg package: control (metadata) archive not found: $?"
CONTROL_EXT="$(ar t "$SRCDIR"/$1 | grep control.tar* | cut -f3 -d'.')"
CONTROL_EXT="$(ar t "$PKG_PATH" | grep control.tar* | cut -f3 -d'.')"
case "${CONTROL_EXT}" in
gz)
TAR_COMP_FLAG="z"
Expand All @@ -47,7 +51,7 @@ _convert_loong64() {
cd $(mktemp -d) || \
aberr "Failed to create temporary directory to unpack $1: $?."
DEBDIR="$(pwd)"
ar xv "$SRCDIR"/$1 || \
ar xv "$PKG_PATH" || \
aberr "Failed to unpack $1: $?."

abinfo "Unpacking metadata archive: $1 ..."
Expand All @@ -63,14 +67,21 @@ _convert_loong64() {
sed -e 's|^Architecture: loongarch64$|Architecture: loong64|g' \
-i "$DEBDIR"/metadata/control

if grep -q "Depends:" "$DEBDIR"/metadata/control; then
sed -i '/Depends:/ s/$/, liblol/' "$DEBDIR"/metadata/control
else
echo "Depends: liblol" >> "$DEBDIR"/metadata/control
fi


abinfo "Building metadata archive (control.tar.${CONTROL_EXT}): $1 ..."
cd "$DEBDIR"/metadata
tar cvf${TAR_COMP_FLAG} "$DEBDIR"/control.tar."${CONTROL_EXT}" * || \
aberr "Failed to build metadata archive (control.tar.${CONTROL_EXT}) for $1: $?."
cd "$DEBDIR"

abinfo "Rebuilding dpkg package $1: loong64 ..."
ar rv "$SRCDIR"/$1 control.tar.${CONTROL_EXT} || \
ar rv "$PKG_PATH" control.tar.${CONTROL_EXT} || \
aberr "Failed to rebuild dpkg package $1: $?."

#abinfo "Cleaning up: $1 ..."
Expand All @@ -79,7 +90,7 @@ _convert_loong64() {
abinfo """Your requested package:

$1

mv $1 $HERE/${PKG_NAME}_${VERSION}_loong64.deb
Has been successfully converted as a loong64 package!

However, you may still need to install libLoL for old-world applications to
Expand Down