Posted to tcl by dbohdan at Sun Nov 08 14:45:26 GMT 2020view raw
- #! /usr/bin/env tclsh
- #
- # A database of Ubuntu packages I use. To install:
- # $ apt install $(./packages [tag ...])
- # Requires: Tcl 8.6 or later.
- #
- # Copyright (c) 2020 D. Bohdan.
- #
- # Permission to use, copy, modify, and distribute this software for any
- # purpose with or without fee is hereby granted, provided that the above
- # copyright notice and this permission notice appear in all copies.
- #
- # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- set packages {
- apache2-utils benchmark network
- asciidoc converter HTML markup
- audacious audio player
- audacity audio editor
- autoconf dev
- autogen dev
- automake dev
- bat text viewer
- bless GUI editor hex
- borgbackup backup
- bsdgames game rot13 toy
- build-essential C dev
- calibre ebook reader
- cloc dev
- cmake C dev
- cmark converter HTML markup
- cpulimit hardware
- critcl C dev Tcl
- curl client network
- dos2unix converter text
- dosbox emulator
- doublecmd-qt file-manager
- entr automation
- ethtool network hardware
- exiftool image metadata
- expect dev Tcl
- fdupes duplicate
- feh image viewer
- ffmpeg converter multitool video
- findimagedupes duplicate
- flac audio codec
- fonts-open-sans font
- fortune-mod toy
- gdb debugging dev
- geeqie image viewer
- genisoimage filesystem ISO
- gifsicle image optimizer
- gimp editor image
- git dev
- gnupg2 cryptography
- gparted disk
- graphicsmagick automation converter editor image multitool
- gsmartcontrol disk
- gxkb GUI keyboard
- hardinfo GUI hardware system-info
- hddtemp hardware monitoring
- htop monitoring
- hwinfo hardware system-info
- icewm window-manager
- id3 audio editor metadata
- id3v2 audio editor metadata
- imagemagick automation converter editor image multitool
- iotop disk monitoring
- jq interpreter JSON
- keepassx GUI password
- lftp client FTP
- libaugeas-dev dev
- liblz4-tool compression
- lm-sensors monitoring
- lrzip compression
- lxd container
- lz4 compression
- lzop compression
- magic-wormhole network
- mc file-manager
- meld comparison GUI text
- mercurial dev
- minify CSS optimizer
- mosh network remote
- mpv player video
- neovim editor text
- netcat multitool network
- netpbm automation converter editor image multitool
- nfs-common network NFS
- nmap network security
- optipng image optimizer
- opus-tools audio codec
- pcmanfm-qt file-manager GUI
- pep8 dev Python
- pkg-config dev
- pngcrush image optimizer
- pngquant image optimizer
- postfix email server
- postgresql database
- pv monitoring
- pwgen password
- pylint dev Python
- python3-dev dev Python
- python3-more-itertools dev Python
- python3-pip dev Python
- python3-psutil dev Python
- python3-pytest dev Python
- python3-venv dev Python
- python3-wheel dev Python
- qdirstat system-info
- qterminal terminal-emulator
- rar compression
- rclone multitool network
- redis-server database
- remmina GUI remote
- remmina-plugin-vnc GUI remote VNC
- rename file
- rlwrap TUI
- scrot GUI image screenshot
- sed interpreter text
- shellcheck dev
- slugify converter text
- smartmontools disk hardware system-info
- smbclient client network
- sqlite3 database
- squashfs-tools filesystem
- tcl dev Tcl
- tcl-dev C dev Tcl
- tcl-doc dev Tcl
- tcl-itcl4 dev Tcl
- tcl-thread dev Tcl
- tcl-tls dev network Tcl
- tcl-vfs dev Tcl
- tcl8.6-tdbc-postgres dev Tcl
- tcl8.6-tdbc-sqlite3 dev Tcl
- tclcurl dev network Tcl
- tcllib dev Tcl
- tcllib-critcl dev Tcl
- tclx8.4 dev Tcl
- tclx8.4-doc dev Tcl
- tdom dev Tcl
- tesseract-ocr converter image OCR text
- testdisk disk hardware
- thunderbird client email
- tidy converter HTML optimizer
- tk dev Tcl Tk
- tk-doc dev Tcl Tk
- tk-table dev Tcl Tk
- tklib dev Tcl Tk
- transmission network Torrent
- tree file
- ttf-mscorefonts-installer font
- udiskie disk GUI
- unicode-screensaver screensaver
- uptimed monitoring
- upx-ucl compression dev
- valgrind debugging dev
- vim editor text
- webp codec image
- whois network
- wine emulation
- workrave ergonomics GUI
- xclip GUI
- xdotool automation GUI
- xkbset GUI keyboard
- xml2 converter XML
- xscreensaver screensaver
- xscreensaver-data-extra screensaver
- xscreensaver-screensaver-bsod screensaver
- xsensors GUI hardware monitoring
- yacc dev
- zfsutils-linux disk filesystem
- zpaq backup compression
- zstd compression
- zzuf debugging dev
- }
- proc main {packages argv} {
- if {$argv in {-h -help --help -? /?}} {
- set me [file tail [info script]]
- puts stderr "usage: $me"
- puts stderr " $me \"tags\""
- puts stderr " $me tag \[tag ...\]"
- exit 0
- }
- set byTag [parse-pkg-list $packages]
- puts [switch -- $argv {
- tags { lsort -nocase [dict keys $byTag] }
- default { pkgs-with-tags $byTag $argv }
- }]
- }
- proc parse-pkg-list packages {
- set lines [split [string trim $packages] \n]
- foreach line $lines {
- set pkg [lindex $line 0]
- foreach tag [lrange $line 1 end] {
- dict lappend byTag [string tolower $tag] $pkg
- }
- }
- return $byTag
- }
- # $tags must be a list of "tag" or "-tag". The latter removes packages with
- # the tag from the selection.
- proc pkgs-with-tags {byTag tags} {
- set tag [lindex $tags 0]
- set found [if {[llength $tags] == 0 || [regexp ^-(.*)$ $tag _ tag]} {
- lsort [concat {*}[dict values $byTag]]
- } else {
- pkgs-with-tag $byTag $tag
- }]
- foreach tag [lrange $tags 1 end] {
- set op intersection
- if {[regexp ^-(.*)$ $tag _ tag]} {
- set op difference
- }
- set found [set::$op $found [pkgs-with-tag $byTag $tag]]
- }
- return $found
- }
- proc pkgs-with-tag {byTag tag} {
- set tag [string tolower $tag]
- if {![dict exists $byTag $tag]} {
- return {}
- }
- dict get $byTag $tag
- }
- namespace eval set {}
- proc set::intersection {a b} {
- lmap x $a {
- if {$x ni $b} continue
- set x
- }
- }
- proc set::difference {a b} {
- lmap x $a {
- if {$x in $b} continue
- set x
- }
- }
- main $packages $argv