Skip to content

Commit

Permalink
app-editors/pulsar-bin: add 1.106.0
Browse files Browse the repository at this point in the history
Signed-off-by: YiFei Zhu <zhuyifei1999@gmail.com>
  • Loading branch information
zhuyifei1999 committed Jun 16, 2023
1 parent 459f4d1 commit 0789691
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions app-editors/pulsar-bin/Manifest
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DIST pulsar-bin-1.105.0-amd64.tar.gz 228995179 BLAKE2B b4b185a161374590b68e2efbd5b2f37ec59278f71cc30ef519c3a67ae546ea9b73f2e2e50eabd8b07855e291704f4d994428f58dca24e144713e4996fe053b03 SHA512 f2ed05bebe81735c21ac80ff82ec051aebc9ec54e8f2ffce0e4e17f0fc6b221992ca5909271f04334211e494647cfef9f1555f0f439ee77c63488585f255f810
DIST pulsar-bin-1.105.0-arm64.tar.gz 190376758 BLAKE2B 4901f01497f7a015f95f77126f91f7817ffa8bd82d10066f741dd53dd67ec6f43bec1f7a34d949f00f2efed9f36b0f19745fb71abbc6074ca248f08d4159062a SHA512 e201118befcc14308f1383309fd0a7a258f72d1aa31b59da8ffb863ab9a43b821b5285dfe4fde1ccdf8f92121c1898b8022f604362e7415dcf7d8fc05d8de512
DIST pulsar-bin-1.106.0-amd64.tar.gz 230175989 BLAKE2B c26238659ec32918b06563aa14462d2a47f87612d18d0e309ebdeaafb8282c5c2f839264eda7cc3151bb9643b783ac47e0e008eccf59fb8347d7b71995137da5 SHA512 9ce4e1ba0ca375a035863ca955592ebde9e20c16aa06d6ab3bd803d32edbd35d916b5ef94c2072f21f3d9a60546798fa2aaa74608299101713e92cce367fd0f6
110 changes: 110 additions & 0 deletions app-editors/pulsar-bin/pulsar-bin-1.106.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit desktop xdg

DESCRIPTION="A Community-led Hyper-Hackable Text Editor"
HOMEPAGE="https://pulsar-edit.dev/"

# ARM64 build is missing upstream for 1.106.0
# arm64? ( https://github.com/pulsar-edit/pulsar/releases/download/v${PV}/ARM.Linux.pulsar-${PV}-arm64.tar.gz -> ${P}-arm64.tar.gz )
SRC_URI="
amd64? ( https://github.com/pulsar-edit/pulsar/releases/download/v${PV}/Linux.pulsar-${PV}.tar.gz -> ${P}-amd64.tar.gz )
"

LICENSE="MIT"
SLOT="0"
KEYWORDS="-* ~amd64"
RESTRICT="test"

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

Usually RESTRICT=test should have a brief comment stating why


S="${WORKDIR}/pulsar-${PV}"

RDEPEND="
>=app-accessibility/at-spi2-core-2.46.0
app-crypt/libsecret
dev-libs/nss
dev-libs/openssl
dev-libs/openssl-compat
dev-vcs/git
media-libs/alsa-lib
net-print/cups
x11-libs/cairo
x11-libs/gdk-pixbuf
x11-libs/gtk+
x11-libs/libnotify
x11-libs/libX11
x11-libs/libxcb
x11-libs/libXcomposite
x11-libs/libXcursor
x11-libs/libXdamage
x11-libs/libXext
x11-libs/libXfixes
x11-libs/libXi
x11-libs/libxkbcommon
x11-libs/libxkbfile
x11-libs/libXrandr
x11-libs/libXrender
x11-libs/libXScrnSaver
x11-libs/libXtst
x11-libs/pango
"

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

This long RDEPEND should be sanitized. I know binary packages tend to have lots of dependencies, but there are tools that help.

qa-vdb from app-portage/iwdevtools is a good starting point:

 * VDB: detected possibly incorrect RDEPEND (app-editors/pulsar-bin-1.106.0)
 * app-accessibility/at-spi2-core | app-accessibility/at-spi2-core:2
 *                                > dev-libs/expat
 *                                > dev-libs/glib:2
 *                                > dev-libs/nspr
 * dev-libs/openssl               < 
 * dev-libs/openssl-compat        | dev-libs/openssl-compat:1.1.1
 *                                > media-libs/mesa
 *                                > net-misc/curl
 *                                > sys-apps/dbus
 *                                > sys-libs/zlib
 * x11-libs/gdk-pixbuf            | x11-libs/gdk-pixbuf:2
 * x11-libs/gtk+                  | x11-libs/gtk+:3
 * x11-libs/libXScrnSaver         < 
 * x11-libs/libXcursor            < 
 * x11-libs/libXi                 < 
 *                                > x11-libs/libdrm
 * x11-libs/libXrender            < 
 * x11-libs/libXtst               < 
 * x11-libs/libnotify             < 
 *                                > x11-libs/libxshmfence
 * x11-libs/libxkbfile            < 

Packages on the right of > are linked directly, they should be added to RDEPEND. For | you can check if the package has a meaningful subslot. The packages on the left of '<' need more work, they may or may not be needed. They are not linked directly, but can still be needed (dlopen, exec, data files etc).

Also lddtree from app-misc/pax-utils can show direct and indirect dependencies on some libs, so you can remove the indirect ones (the libs not linked directly).

This comment has been minimized.

Copy link
@zhuyifei1999

zhuyifei1999 Jun 17, 2023

Author Contributor

Ok after some fiddling around, first using strace:

strace -zfe openat,execve,execveat -o strace.log /opt/Pulsar/pulsar --no-sandbox
comm -23 <(cat strace.log | grep -vP '132231|132229|[... a bunch more PIDs]|132573' | grep -oP '(?<=").+\.so.*(?=")' | sort -u) <(ldd /opt/Pulsar/pulsar | grep -oP '/\S+' | sort -u)

I see libxkbfile is opened and it's not within DT_NEEDED.

Then I fiddled around and used

ltrace -e dlopen -o ltrace.log -f -s 1024 -w 10 /opt/Pulsar/pulsar --no-sandbox

Most of the dlopens seems not very important, but it dlopens libudev and I don't know why. Also libxkbfile is not part of dlopens...

I think I'll keep libxkbfile, for libudev I don't think that's something I want to pull in explicitly for an editor. I'll adapt the rest

This comment has been minimized.

Copy link
@zhuyifei1999

zhuyifei1999 Jun 17, 2023

Author Contributor

I realize why with libxkbfile. Native node modules are unpacked into /tmp/ and then dlopened. One of which links libxkbfile directly:

$ lddtree /tmp/.org.chromium.Chromium.PS9TVB
/tmp/.org.chromium.Chromium.PS9TVB (interpreter => None)
    libX11.so.6 => /usr/lib64/libX11.so.6
        libxcb.so.1 => /usr/lib64/libxcb.so.1
            libXau.so.6 => /usr/lib64/libXau.so.6
            libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6
    libxkbfile.so.1 => /usr/lib64/libxkbfile.so.1
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6
        ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2
    libm.so.6 => /usr/lib64/libm.so.6
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/13/libgcc_s.so.1
    libpthread.so.0 => /usr/lib64/libpthread.so.0
    libc.so.6 => /usr/lib64/libc.so.6

I really really wish this thing isn't a binary build I can build it without it packed, similar to element-hq/element-desktop#337

This comment has been minimized.

Copy link
@zhuyifei1999

zhuyifei1999 Jun 17, 2023

Author Contributor

ok I did a check for all the shared nodejs native modules in the electron packed archive:
https://gist.github.com/zhuyifei1999/31687ebec33a425e281d871bf836d071

There's nothing missing here. libxkbfile is the only exception.

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

Great work! I like the script too. Only it seems to look only inside packed resources, it does not check /opt/Pulsar/pulsar and the .so files in that directory.

You can look inside the vdb ( /var/db/pkg/app-editors/pulsar-bin-1.106.0/NEEDED ) to see what portage figured out.

This comment has been minimized.

Copy link
@zhuyifei1999

zhuyifei1999 Jun 18, 2023

Author Contributor

Yeah I'm just letting qa-vdb doing that part of the work. :) Since portage won't see into packed resources, the script just supplements it.


QA_PREBUILT="/opt/Pulsar/*"
QA_PRESTRIPPED="/opt/Pulsar/resources/*" # Files are already stripped

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

Both QA_PREBUILT and QA_PRESTRIPPED should be relative to the image directory, i.e., they should not start with /.


src_unpack(){
default

if use arm64; then
mv "pulsar-${PV}-arm64" "pulsar-${PV}" || die
fi
}

src_prepare(){
default

# We do not install licenses
rm resources/LICENSE.md || die "Failed to remove LICENSE"
}

src_install(){
dodir /opt/Pulsar
mv "${S}"/* "${ED}"/opt/Pulsar

dosym ../../opt/Pulsar/resources/pulsar.sh /usr/bin/pulsar

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

In EAPI 8 you can use dosym -r to get rid of ../..


# Bug #906939
if use amd64; then
rm "${ED}"/opt/Pulsar/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

|| die

rmdir "${ED}"/opt/Pulsar/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins

This comment has been minimized.

Copy link
@ceamac

ceamac Jun 17, 2023

Contributor

same

fi

doicon "${ED}"/opt/Pulsar/resources/pulsar.png
make_desktop_entry "/usr/bin/pulsar %F" "Pulsar" "pulsar" \
"GNOME;GTK;Utility;TextEditor;Development;" \
"GenericName=Text Editor\nStartupNotify=true\nStartupWMClass=pulsar\n" \
"MimeType=application/javascript;application/json;application/x-httpd-eruby;" \
"application/x-httpd-php;application/x-httpd-php3;application/x-httpd-php4;" \
"application/x-httpd-php5;application/x-ruby;application/x-bash;application/x-csh;" \
"application/x-sh;application/x-zsh;application/x-shellscript;application/x-sql;" \
"application/x-tcl;application/xhtml+xml;application/xml;application/xml-dtd;" \
"application/xslt+xml;text/coffeescript;text/css;text/html;text/plain;text/xml;" \
"text/xml-dtd;text/x-bash;text/x-c++;text/x-c++hdr;text/x-c++src;text/x-c;text/x-chdr;" \
"text/x-csh;text/x-csrc;text/x-dsrc;text/x-diff;text/x-go;text/x-java;text/x-java-source;" \
"text/x-makefile;text/x-markdown;text/x-objc;text/x-perl;text/x-php;text/x-python;" \
"text/x-ruby;text/x-sh;text/x-zsh;text/yaml;inode/directory"

einstalldocs

find "${ED}" -name '*.la' -delete || die
}

pkg_postinst(){
xdg_desktop_database_update

elog "To migrate configurations & saved state from Atom Editor, execute:"
elog " cp -a \$HOME/.atom \$HOME/.pulsar"
elog " cp -a \$HOME/.config/Atom \$HOME/.config/Pulsar"
}

0 comments on commit 0789691

Please sign in to comment.