larksuite-bin AUR package

larksuite-bin AUR package

3 devlogs
3h 13m
Created by aaronliu

An existing user-generated installation script for Lark, an office collaboration suite that thinks it competes with notion. I maintain this package and make sure it installs and works.

Timeline

Ship 1

aaronliu

about 1 year ago

aaronliu • Covers 3 devlogs and 3h 13m

While updating to 7.50.13, I discovered the license had updated as well. Since the license is currently fetched from their TOS webpage, overcomplicated so as to wrap static HTML as one double-quoted string filled with \n-s in minified JS as a Hera app, I would need to take some time to see what changed in the license. Out of Curiosity, I Endeavor-ed.

Discoveries:
1. There's actually an official version number‽ Who would have thought!
2. The page duplicates its content, which is why it's 1.7kb.

There's data stored as JS vars of two version of the HTML body: the only difference (besides recompiled classnames) is that hereData is the March TOS, while the heraMobileData var stores the latest TOS. With this information, I may finally start my plans for world domination stripping the LICENSE down to just the static portion...

I believe the main problem with corporate culture right now is the lack of MOBILEity and am soooooo glad to see Lark follow that goal with this stupidity!

To be continued with investigations, soon™...

Update attachment

I got to work. It shouldn't be too hard to reverse-engineer how the Lark site served the downloads. Everything you see in the browser is source-available since HTML, CSS, and JS are pretty much interpreted—except for the backend, the logic for how the server decides to send you things. But either way, to download something, the browser needs a link, and there should be either an endpoint or relevant JavaScript function where one can reliably fetch the download link.

Soon enough, I found that the website fetches the latest download link from the JSON returned by a call to https://www.larksuite.com/api/package_info?platform=10 . Replacing the version doesn't allow you to download an older version of a deb, but at least we have a procedure to get the version now. All I need is to extract the link from the API URL. Due to the semantic logic of Arch package files, I opted to do this through a custom DLAGENTS. To avoid requiring an additional dependency—the overqualified jq—I wrote a very simple grep chain, with %u in place of the download link—that I put down as the API endpoint.

/usr/bin/curl -LO $(curl '%u' | grep -oP '(?<="download_link":")[^"]*' --)

However, the DLAGENTS option does not allow piping! It only allows single commands... which means you can just pass the command to sh -c.

That plus the option being enclosed in (either single or double) quotes itself made for a lot of quote-escaping shenanigans that I couldn't figure out until Shuck suggested using printf %q, which escaped everything without using quotes at all. The hassle was finally over!

DLAGENTS=("https::/usr/bin/sh -c curl\ -LO\ \"\$\(curl\ \'%u\'\ \|\ grep\ -oP\ \'\(\?\<=\"download_link\":\"\)\[\^\"\]\*\'\ --\)\"")

...except there was more I had to do. curl gave me a URL with literally \u0026x—the shell-unrecognized UTF-8 escape code for the ampersand &, a special character essential to chaining URL query syntax—which attached all the URL parameter values and names to the first one instead of properly pushing all the buttons on communism's defenses.

The obvious solution would be to fill in the ampersands through sed.

DLAGENTS=("https::/usr/bin/sh -c curl\ -LO\ \"\$\(curl\ \'%u\'\ \|\ grep\ -oP\ \'\(\?\<=\"download_link\":\"\)\[\^\"\]\*\'\ --\ \|\ sed\ \'s/\\\\u0026/\\\&/g\'\ --\)\"")

This finally worked when ran in the shell. Yet makepkg still gave the error screen!

A week of stasis later, a comment on the broken state of the package awoke me from my slumber. I started debugging by having curl give verbose output through... the -v flag.

GET /obj/lark-artifact-storage/3d9dcd0b/Lark-linux_x64-7.46.12.deb?lk3s=fb957577&x-expires=1756144875&x-signature=TmCvXiGbtnGW1HlkB%2Bolz%2FYzjuU%3D HTTP/2

Interestingly, the command had replaced \u0026 with & instead of &, and only when run with makepkg or the related utility updpkgsums. Adding another literal slash fixed the issue. I still have no idea why.

Well, the download works now! From that day on, communism was defeated, and the proletariat lived happily ever after without killing health insurance executives.

⁂

Here's what else you need to know today: The cd to $pkgdir was utilized in its full potential: ${pkgdir}/ prefixes have been stripped from directory names that can now be referenced relatively, such as with usr/share/hello instead of ${pkgdir}/usr/share/hello. Experts estimate future savings of ⏣10 billion in multiple carpal sclerosis.

As the package was a portable directory a little over one gigabyte large, it was moved to the /Usr/Lib Folder for Normal People to Live, away from the /opt space exclusive for the special treatment of FTB App my beloved.

Proper licensing info was added to both the package metadata and files, the latter through downloading the website's term of service. The download would hold an evanescent ad tracking token, which destablized the checksum until the maintainer sadly incurred sed to transform it into 418. It was smooth-sailing reproducible yeet for another two weeks until upstream done rekt us by tralalunging away a space. I think it's fixed now.

The maintainer left the debugging verbosity argument in the package by accident. In the two minutes it took for them to correct this, the AUR had already seen a malware enterprise springamoleover amount of 0.

That's it for today's Unfunny Rambling. Come back next year, whence yoush finally grok what I'm yapping.

Update attachment
aaronliu aaronliu about 1 year ago
I spent the 21m listed by the update doing various things to get demonstration text for this update and fiddling out how to ship the project.
aaronliu aaronliu about 1 year ago
Note that all this work was done before the last update within the 2h! I just accidentally sent the last devlog before I finished writing it.

When the communist upstream starts practicing anti-consumerism

My company uses Lark for its collaboration platform—offering messaging, calendars, meetings, docs, and tasks. Don't ask me why. Sure, it's got all the features, but surely they would want to use something more supported in the US (like Notion), especially when Lark is made by the increasingly-persecuted ByteDance?

Well, I use Arch. With no other takers, it fell upon me to maintain the AUR package. Fortunately, there was an existing package to build on, and all I had to do was bump the version number since last December. I also corrected the homepage and dependencies, and all was happily ever after.

⁂

Early July, I wake up with this email (excerpted and pictured) in my inbox.

Lark's only download sources had gated the links behind a hashed timestamp.

Update attachment