rss.xml (26154B)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <rss version="2.0" 3 xmlns:atom="http://www.w3.org/2005/Atom" 4 xmlns:dc="http://purl.org/dc/elements/1.1/" 5 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 6 > 7 <channel> 8 <title>Cem's Website</title> 9 <description>Personal blog/website on Linux/tech/nerdy stuff</description> 10 <link>https://cemkeylan.com</link> 11 <atom:link href="https://cemkeylan.com/rss.xml" rel="self" type="application/rss+xml" /> 12 <lastBuildDate>Tue Oct 19 2021 12:00</lastBuildDate> 13 <item> 14 <title>My thoughts on execline</title> 15 <pubDate>Tue, 12 Oct 2021</pubDate> 16 <dc:creator>Cem Keylan</dc:creator> 17 <link>https://cemkeylan.com/blog/20211012-execline.html</link> 18 <description><h1>My thoughts on execline</h1> 19 20 <p>With the gaining popularity of the <a href="https://www.skarnet.org/software/s6-rc/">s6-rc</a>, I have recently decided to check out 21 <a href="https://www.skarnet.org/software/execline/">execline</a>. It is a shell-like scripting language that is built around chaining 22 commands together. There is no interpreter, there is no &lsquo;built-in&rsquo; functionality 23 even though the docs might make you think there are. Execline is best described 24 as a suite of tools that imitate the functionality of a shell.</p> 25 26 <p>There are a ton of information on the execline&rsquo;s page, especially discussing 27 why skarnet prefers execline instead of <code>/bin/sh</code>. Those points are mostly 28 valid, shells are a nightmare, and they suck at being compliant to the POSIX 29 specification. What I don&rsquo;t agree with the <a href="http://www.skarnet.org/software/execline/dieshdiedie.html">why not sh</a> page, however, is the 30 part on performance. Even though execline does not have an interactive shell 31 implementation of its own, it is still much slower than other shells simply by 32 its design. Since the design of execline is built on process chaining, it 33 requires spawning new processes for things as basic as variable declaration. 34 Variable manipulation is the cheapest operation you would expect from a shell, 35 but in execline, every operation costs the same regardless of how simple it is.</p> 36 37 <p>Throughout my weeks of toying around with execline, I have came to the 38 conclusion that execline is much better in simple scripts only. Execline is 39 as usable as any shell out there, but even with its advantages over <code>sh</code>, 40 execline is only better if it&rsquo;s simple. Execline is really good for certain 41 specific situations such as service scripts (as used in s6-rc), or where you 42 were already meant to chain a couple of commands together. After all, skarnet 43 already presents these limitations on the website of execline.</p> 44 45 <p>Execline can be leveraged as how s6-rc compiles service databases with other 46 utilities, but I don&rsquo;t think it can be used as a shell replacement itself. It&rsquo;s 47 not the next shiny thing to jump on to replace all your shell scripts with 48 (unless you have really basic shell scripts). It does not have the flexibility 49 nor the performance of the shell for scripts that can be considered a little 50 over than the &ldquo;basic&rdquo;.</p></description> 51 </item> 52 <item> 53 <title>Reimplementing `sysmgr` in C</title> 54 <pubDate>Fri, 02 Oct 2020</pubDate> 55 <dc:creator>Cem Keylan</dc:creator> 56 <link>https://cemkeylan.com/blog/20201002-reimplementing-sysmgr-in-c.html</link> 57 <description><h1>Reimplementing <code>sysmgr</code> in C</h1> 58 59 <p>For a while, I have been thinking about implementing <a href="https://git.ckyln.com/sysmgr">sysmgr</a> in C. I started 60 thinking about the inefficiencies of sysmgr. POSIX sh isn&rsquo;t particularly 61 designed to have ultimate control over child processes. There are basic job 62 management features that are <em>just enough</em> for sysmgr to do its job. The 63 biggest pain is having to use tools like <code>sleep(1)</code> and <code>kill(1)</code>. Calling 64 sleep every second, and using the kill command to check whether a process is 65 alive or not is extremely inefficient. Some shells <em>do</em> include these commands 66 built-in, but it isn&rsquo;t specified by POSIX, but one should never take this as 67 granted.</p> 68 69 <p>Lately, I have been adding C utilities to sysmgr to make it more efficient. This 70 defeats the initial purpose of sysmgr, being a service manager in pure POSIX 71 shell. My main purpose, however, is making sysmgr efficient and simplistic. It 72 mostly imitates <code>runit</code> without dealing with all the complexity of the 73 over-thinked <code>supervise</code> directory, nor the logging stuff. Most of these can be 74 handled by the service script itself anyway. That&rsquo;s why instead of this ugly 75 C/POSIX sh hybrid, I decided to implement it all in C.</p> 76 77 <p>I am not a C expert or anything, I am learning a lot as I am writing the 78 program. I want it to be C99 and portable (for BSD). It&rsquo;s currently not 79 functional at all, but, you can see its current state <a href="https://git.ckyln.com/sm">here</a>.</p> 80 81 <p>EDIT Oct 10 2020:</p> 82 83 <p>I did the initial release of this C version of sysmgr, which is more stable, 84 and performant than the POSIX sh version. It still has rough edges, but is 85 completely usable.</p></description> 86 </item> 87 <item> 88 <title>Trust in Distributed Environments</title> 89 <pubDate>Tue, 08 Sep 2020</pubDate> 90 <dc:creator>Cem Keylan</dc:creator> 91 <link>https://cemkeylan.com/blog/20200908-trust-in-distributed-environments.html</link> 92 <description><h1>Trust in Distributed Environments</h1> 93 94 <p>A few days ago, in the <code>#kisslinux</code> IRC channel, jedahan mentioned an 95 implementation for trust in the package manager. While I was intrigued by the 96 idea initially, I decided not to implement this for the upcoming 4.0.0 release. 97 That is because the package manager and the distribution itself is already 98 centered on trust. However, this idea made me think a lot about &ldquo;trust&rdquo; in 99 distributed environments.</p> 100 101 <p>Who and what would you trust? Would you trust Microsoft? Would you trust a 102 binary? Would you only trust a so called &ldquo;reproducible&rdquo; build?</p> 103 104 <p>Jedahan mentioned the possibility that a repository maintainer could create a 105 package that would be normally in the distribution so they could mess your 106 system up. He suggested a &ldquo;source&rdquo; system where you know where each package 107 comes from. This way the package manager can warn you when the source of a 108 package is changed. As I have said this idea intrigued me at the beginning, but 109 here is why it is complex and unnecessary.</p> 110 111 <p>The package manager would warn you every time you fork a package and apply your 112 changes. Both with kiss and CPT, you already see git logs when the repositories 113 are fetched. Those logs address each and every file that has been edited, added, 114 removed, or renamed. CPT also has support for rsync, which is called verbosely. 115 While not as descriptive, rsync also shows what&rsquo;s changed/added and what&rsquo;s 116 deleted.</p> 117 118 <p>Also, back on April, I have added submodule support to my fork of kiss, which 119 Dylan adapted on May 19. I have added this feature because it solves a similar 120 issue. I want to have only some packages from a repository and leave the rest 121 of them. This way I am the one in control of what goes inside my repositories.</p> 122 123 <p>Minor annoyances aside, would this solve the issue of trust? Maybe this evil 124 repository maintainer decides to botch a package that was already in their 125 repository not provided by your distribution. Should we then track the source 126 files, build files as well? But those change all the time.</p> 127 128 <p>I believe that this environment is as trustworthy as it can get, a repository 129 system with package build instructions that easy to read and understand, easy to 130 history check, easy to limit, and easy to allow. KISS and Carbs Linux have a 131 single maintainer. I maintain Carbs and Dylan maintains KISS. You are not 132 trusting an organization, you are trusting individuals that you can easily 133 converse on the internet. The same goes for most community repository 134 maintainers out there. Trying to implement more would be a &ldquo;security theater&rdquo; 135 that would be a hassle for the maintainers, the users and the package manager 136 without a noticeable benefit to any.</p></description> 137 </item> 138 <item> 139 <title>wpa_add script</title> 140 <pubDate>Fri, 28 Aug 2020</pubDate> 141 <dc:creator>Cem Keylan</dc:creator> 142 <link>https://cemkeylan.com/blog/20200828-wpa-add-script.html</link> 143 <description><h1>wpa_add script</h1> 144 145 <p>I have this script named <code>wpa_add</code>, which I use to easily add new WiFi when I 146 am outside, possibly in a cafe. I have written this script because I don&rsquo;t like 147 the way my girlfriend looks at me while thinking that I am an absolute moron for 148 not using Windows 10, and the entirety of Linux is a circlejerk. It is only 149 natural that she thinks this way. I use my own distribution that doesn&rsquo;t have 150 things like <code>dbus</code>, or <code>NetworkManager</code>, or one of those common desktop 151 environments. You could install it by creating a simple package, but I am happy 152 to not have any of those in my system.</p> 153 154 <p>This script uses wpa-supplicant to add a new network and reconfigure. It uses 155 dmenu for input, however you could replace dmenu calls with some command line 156 prompts. I am doing the following assumptions: 157 - You can manipulate <code>wpa_supplicant</code> without root access. 158 - The configuration is on <code>/etc/wpa_supplicant.conf</code>. 159 - You can edit <code>/etc/wpa/supplicant.conf</code>.</p> 160 161 <p>If you want to ensure the above just do the following (as root):</p> 162 163 <pre><code class="sh"># Add yourself to the wheel group if you aren't already. 164 adduser user wheel 165 166 # Change the ownership of /etc/wpa_supplicant.conf 167 chown root:wheel /etc/wpa_supplicant.conf 168 169 # Make sure the configuration can be edited by the wheel group. 170 chmod 664 /etc/wpa_supplicant.conf 171 </code></pre> 172 173 <p>Your <code>wpa_supplicant</code> configuration must include the following line (or something similar):</p> 174 175 <pre><code class="plaintext">ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel 176 </code></pre> 177 178 <p>Here is the script</p> 179 180 <pre><code class="sh">#!/bin/sh 181 # Script to add wpa_supplicant networks through dmenu 182 183 if [ "$1" ]; then 184 name=$1 185 else 186 name=$(dmenu -p "Please enter network name, leave empty if you want to search" &lt;&amp;-) 187 fi 188 189 [ "$name" ] || { 190 wpa_cli scan 191 name=$( 192 wpa_cli scan_results | sed 1,2d | while read -r _ _ _ _ ssid _; do 193 # Hidden wifi are not to be returned 194 [ "$ssid" ] || continue 195 echo "$ssid" 196 done | sort -u | dmenu -l 10 -p "Please choose WiFi") 197 [ "$name" ] || exit 1 198 } 199 200 pass=$(dmenu -P -p "Please enter your password, leave empty if the network has open access.") 201 202 if [ "$pass" ]; then 203 wpa_passphrase "$name" &lt;&lt;EOF&gt;&gt; /etc/wpa_supplicant.conf 204 $pass 205 EOF 206 else 207 printf 'network={\n\tssid="%s"\n\tkey_mgmt=NONE\n\tpriority=-999\n}\n' "$name" &gt;&gt; /etc/wpa_supplicant.conf 208 fi 209 210 wpa_cli reconfigure 211 </code></pre> 212 213 <p>As I have said, you could do something similar in a command-line-only tool as 214 well. This one uses <code>fzf</code> on WiFi selection.</p> 215 216 <pre><code class="sh">#!/bin/sh -e 217 218 stty="$(stty -g)" 219 trap "stty $stty" EXIT INT TERM HUP 220 221 if [ "$1" ]; then 222 name=$1 223 else 224 printf 'Network Name, leave empty if you want to search: ' 225 read -r name 226 fi 227 228 [ "$name" ] || { 229 wpa_cli scan &gt;/dev/null 230 name=$( 231 wpa_cli scan_results | sed 1,2d | while read -r _ _ _ _ ssid _; do 232 # Hidden wifi are not to be returned 233 [ "$ssid" ] || continue 234 echo "$ssid" 235 done | sort -u | fzf --prompt "Please choose WiFi: ") 236 } 237 238 [ "$name" ] || exit 1 239 240 stty -echo 241 printf 'Please enter your password, leave empty if the network has open access.\nPassword: ' 242 read -r pass 243 244 if [ "$pass" ]; then 245 wpa_passphrase "$name" &lt;&lt;EOF&gt;&gt; /etc/wpa_supplicant.conf 246 $pass 247 EOF 248 else 249 printf 'network={\n\tssid="%s"\n\tkey_mgmt=NONE\n\tpriority=-999\n}\n' "$name" &gt;&gt; /etc/wpa_supplicant.conf 250 fi 251 252 wpa_cli reconfigure 253 </code></pre> 254 255 <p>These scripts can be found as a gist <a href="https://git.io/JULL6">here</a></p></description> 256 </item> 257 <item> 258 <title>Static linking</title> 259 <pubDate>Fri, 28 Aug 2020</pubDate> 260 <dc:creator>Cem Keylan</dc:creator> 261 <link>https://cemkeylan.com/blog/20200828-static-linking.html</link> 262 <description><h1>Static linking</h1> 263 264 <p>While I was working on a new initramfs generator for Carbs, I was once again 265 reminded of the advantages of static linking software. Previously, I was using 266 some really dumb script that was just basically using the package manager as a 267 library for building the whole initramfs system from scratch. This system 268 structure was completely statically linked, and the whole thing weighed around 269 1.3MiB.</p> 270 271 <p>Now, while <code>rd</code> (the small script that I had written) was good enough for me, it 272 wouldn&rsquo;t be a fit to distribute with the system. It doesn&rsquo;t deal with dynamic 273 binaries, kernel modules or library installation. So I have written this script 274 that deals with those (kernel modules aren&rsquo;t done yet, though).</p> 275 276 <p>The issue with build systems today are that the binaries are built dynamically 277 unless you build the whole thing static. As long as there are shared libraries, 278 the binaries will be dynamic as well. That&rsquo;s why the core repository of Carbs 279 still contains dynamic binaries for gcc, binutils, util-linux and some other 280 packages.</p> 281 282 <p>The size of the new image with exactly the same binaries is a whopping 1.9MiB. 283 While a size increase of 600KiB might not seem like a huge deal, I just want to 284 tell you that busybox is static in both images, leaving ONLY TWO binaries that 285 I install to my image; fsck and e2fsck. By switching from a static binary to 286 dynamic + lib for only two programs, you require 600 KiB more space, and I have 287 been talking about a gzip compressed cpio archive throughout this whole post.</p></description> 288 </item> 289 <item> 290 <title>Starting X without Xinit</title> 291 <pubDate>Wed, 12 Aug 2020</pubDate> 292 <dc:creator>Cem Keylan</dc:creator> 293 <link>https://cemkeylan.com/blog/20200812-starting-x-without-xinit.html</link> 294 <description><h1>Starting X without Xinit</h1> 295 296 <p>Most people who don&rsquo;t use a desktop environment use the <code>startx</code> command to 297 initialize their X windowing system. Now, <code>startx</code> is a shell script that runs 298 the C program <code>xinit</code> which basically runs <code>xorg-server</code>. Using xinit obviously 299 has some nice perks. It makes some checks and runs your .xinitrc file. We don&rsquo;t 300 need any of that though. Here is my X launcher:</p> 301 302 <pre><code class="sh">#!/bin/sh 303 304 export DISPLAY=${DISPLAY:-:0} 305 trap "$HOME/.xinitrc" USR1 306 307 ( 308 trap '' USR1 309 310 exec X -keeptty :0 vt1 311 ) &amp; 312 313 wait 314 </code></pre> 315 316 <p>You need to keep in mind that your .xinitrc should be an executable.</p></description> 317 </item> 318 <item> 319 <title>Why I dislike Arch and Gentoo</title> 320 <pubDate>Fri, 08 May 2020</pubDate> 321 <dc:creator>Cem Keylan</dc:creator> 322 <link>https://cemkeylan.com/blog/20200508-why-i-dislike-arch-and-gentoo.html</link> 323 <description><h1>Why I dislike Arch and Gentoo</h1> 324 325 <p>Over the years, I have used many many Linux distributions. The reason I am 326 now using a distribution maintained by me, is because I am never truly satisfied 327 about other people&rsquo;s work. Not that they are bad at they do, it&rsquo;s just that 328 they don&rsquo;t share the same vision as me. And I have felt this way with almost 329 every distribution I have used.</p> 330 331 <h2>Arch Linux</h2> 332 333 <p>Arch Linux itself feels like it became a &lsquo;meme distribution&rsquo;. Their user-base 334 is a cult-like community that think they are superior for using Arch Linux. 335 Now, you might be an Arch user, and might not be like this. I used Arch for 336 a long time, and didn&rsquo;t feel this way, ever. I only see this level of cultism 337 for Arch and systemd.</p> 338 339 <p>If you ever call Arch bloated on an online community website, you will get 340 lots of crap for it. But in fact, Arch Linux is bloated. Now this isn&rsquo;t due 341 to having too many packages in the base installation. This is because of their 342 packaging of software.</p> 343 344 <p>Arch enables almost every single option in the package configuration, meaning 345 lots of unnecessary dependencies, and packages with humongous sizes.</p> 346 347 <p>Pacman is a rather slow package manager, and missing alternatives. For me, 348 an alternatives system is a must.</p> 349 350 <p>If you want to use a better binary distribution, use Void Linux. They have 351 saner package configurations, and the environment just feels more UNIXy. xbps 352 is really fast, and has an alternatives system.</p> 353 354 <h2>Gentoo Linux</h2> 355 356 <p>This will be the longer part, because my dislike for Gentoo is bigger than 357 my dislike towards Arch. If you want to see how NOT to maintain a distribution, 358 check out Gentoo.</p> 359 360 <p>I&rsquo;ve used Gentoo for a few months, and I&rsquo;m saying this right out of the 361 gate. Portage is the slowest piece of software that I have ever used on 362 Linux. Maybe that&rsquo;s because I deliberately avoid software using Python, 363 but Portage is most probably the slowest package manager that is being 364 used.</p> 365 366 <p>Portage depends on Bash, Python, and GNU wget. I have got a line count from 367 <code>cloc</code>, doing a <code>find . \( -name '*.sh -o -name '*.py' \) -exec cloc {} +</code>. 368 The source code of just <code>*.sh</code> and <code>*.py</code> files are over 100k lines of code. 369 Then I got curious and runned cloc against the whole repository. Here is 370 the output.</p> 371 372 <pre><code>-------------------------------------------------------------------------------- 373 Language files blank comment code 374 -------------------------------------------------------------------------------- 375 Python 703 20009 21411 102180 376 Bourne Shell 13 643 678 3911 377 Bourne Again Shell 44 583 434 3172 378 diff 17 31 298 574 379 YAML 6 32 80 573 380 XSD 1 27 27 494 381 C 2 56 128 291 382 make 1 7 6 19 383 INI 1 1 0 15 384 reStructuredText 1 5 4 9 385 XSLT 1 0 0 5 386 -------------------------------------------------------------------------------- 387 SUM: 790 21394 23066 111243 388 -------------------------------------------------------------------------------- 389 </code></pre> 390 391 <p>That&rsquo;s quite a lot.</p> 392 393 <p>Portage is a package manager that tries to ease the configuration process of 394 packages, but at the process makes it terribly complex to compose packages, 395 and adds billions of portage configuration options. Configuring your first 396 kernel is literally easier than configuring portage in a way you want. Users 397 just do not know that they would be better off doing an LFS build for a much 398 stabler system. My system was broken countless times while using Gentoo. 399 Maintaining a Gentoo system is honestly harder than maintaining my own 400 distribution.</p> 401 402 <p><strong>EAPI</strong>, probably the worst thing about the Portage ecosystem. It is the most 403 complex, hard to read, hard to learn packaging system ever made. Creating a 404 USE flag system shouldn&rsquo;t have been this hard.</p></description> 405 </item> 406 <item> 407 <title>Editor Wizardry</title> 408 <pubDate>Mon, 13 Apr 2020</pubDate> 409 <dc:creator>Cem Keylan</dc:creator> 410 <link>https://cemkeylan.com/blog/20200413-editor-wizardry.html</link> 411 <description><h1>Editor Wizardry</h1> 412 413 <p>To this day, I have tried lots of IDEs and text editors. Visual Studio, PyCharm, 414 Sublime, Notepad++, Vim, Emacs, Pico, Atom, etc. The list goes on. I have even 415 unironically used ed, and ironically used cat for a while.</p> 416 417 <p>I have settled down after years and years of &ldquo;editor-hopping&rdquo;. I now have 3 418 main editors that I use on a daily basis! Yeah, you have read it correct. I use 419 3 editors on a daily basis. Those are,</p> 420 421 <ul> 422 <li>sed</li> 423 <li>vi (not vim)</li> 424 <li>emacs</li> 425 </ul> 426 427 428 <h2>Emacs</h2> 429 430 <p>Emacs is a beast. Defining Emacs as a text-editor is wrong. It is a lisp 431 interpreter, with text manipulation abilities.</p> 432 433 <p>Now, I do like the concept of Integrated Development Environments. It&rsquo;s a shame 434 that all of them suck. With Emacs I can fine-tune everything according to my 435 taste, install the packages I need, configure them the way I like. With IDEs you 436 get some nice plugins, and a tiny bit of customization, but that&rsquo;s it. You get 437 an environment limited by the vision of someone else. Not to mention that most 438 IDEs are proprietary software.</p> 439 440 <p>I have stopped using Vim, because it is only meant to be a text editor. You can 441 extend its features with plugins, but you can really see the impact with just a 442 few of them. Vimscript is also really primitive, that&rsquo;s why people write plugins 443 with Python, JS, and such. This further affects the speed of Vim. Most Emacs 444 packages I have encountered are written in pure lisp. I have over 70 packages, 445 yet my load time and overall speed is better than when I had Vim with 8 plugins.</p> 446 447 <h3>Cons</h3> 448 449 <ul> 450 <li><strong>It comes with too many unnecessary features</strong> Emacs comes with multiple IRC 451 clients, a mail reader, rss reader etc. I don&rsquo;t think they are badly 452 implemented or anything, I would just prefer building up as I want to instead.</li> 453 <li><strong>The defaults are not intuitive</strong> Now, I haven&rsquo;t actually tried any of them, 454 but there is a reason &ldquo;Emacs distributions&rdquo;, such as &ldquo;Spacemacs&rdquo;, &ldquo;DOOM 455 Emacs&rdquo;, &ldquo;Centaur&rdquo; exist. The base of Emacs, even with its unnecessary 456 features, is unintuitive and complicated.</li> 457 </ul> 458 459 460 <p>Also, let&rsquo;s not forget that Emacs uses an ancient Lisp dialect.</p> 461 462 <h2>Vi</h2> 463 464 <p>I mostly use Emacs when I am dealing with projects. If my aim is to just make 465 simple changes when I am on the terminal, I just pop up vi provided by busybox. 466 I just like that it is fast and featureless. It barely gets the job done, and 467 that&rsquo;s why I like it.</p> 468 469 <h3>Cons</h3> 470 471 <ul> 472 <li><strong>No syntax highlighting</strong> Syntax highlighting is an important feature for me 473 but I have learned to live without it. Since I don&rsquo;t edit large files with it, 474 this is not the biggest con.</li> 475 <li><strong>Hard to configure</strong> Busybox vi only has a limited featureset, which makes 476 it hard to configure. It doesn&rsquo;t read an <code>rc</code> file, it uses the <code>$EXINIT</code> 477 variable instead. Available options are limited. For example, you cannot 478 convert the &ldquo;tab&rdquo; action to use space instead of tabs.</li> 479 <li><strong>No visual selection support</strong> Sadly, <code>v/V</code> isn&rsquo;t implemented in busybox vi.</li> 480 </ul> 481 482 483 <h2>Sed</h2> 484 485 <p>I use sed for when I am making small changes to small files, because it is 486 faster than opening a file, making a change, saving, and exiting. Using regular 487 expressions are much faster and efficient at such things.</p> 488 489 <h3>Cons</h3> 490 491 <ul> 492 <li><strong>Risky unless you know what you are doing</strong> Since sed is operated on regex, 493 you need to be extra careful. You are running that regex on the entire file 494 without an option to &lsquo;undo&rsquo; (unless you have a sed that has a backup 495 implementation).</li> 496 </ul></description> 497 </item> 498 </channel> 499 </rss>