Skip to content

Commit

Permalink
Add: auto add liblol dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
shenmo7192 committed Jun 4, 2024
1 parent 67d730c commit 3b55e82
Showing 1 changed file with 16 additions and 5 deletions.
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

0 comments on commit 3b55e82

Please sign in to comment.