From 685741efe0868a3eb08bf03420cc6f01a2392b2e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 17 Jun 2022 17:39:33 +0300 Subject: [PATCH] Code rewritten Signed-off-by: Dimitris Zlatanidis --- AUTHORS | 1 - CHECKSUMS.md5 | 151 --- COMMANDS | 3 - CONTRIBUTING | 11 - ChangeLog.txt | 6 +- EXAMPLES.md | 1322 --------------------- INSTALL.md | 23 - ISSUES | 3 - KNOWN_ISSUES | 1 - LICENSE | 622 ---------- LICENSE.txt | 21 + README.rst | 26 +- REPOSITORIES.md | 56 - THANKS | 26 - bin/__init__.py | 1 - bin/slpkg | 34 +- clean.py | 66 - conf/blacklist | 35 - conf/custom-repositories | 32 - conf/default-repositories | 53 - conf/pkg_security | 34 - conf/repositories.conf | 59 - conf/rlworkman.deps | 35 - conf/slackware-mirrors | 138 --- conf/slpkg.bash-completion | 14 - conf/slpkg.conf | 129 -- conf/slpkg.fish | 18 - config/slpkg.json | 22 + install.sh | 1 - logo.txt | 10 - man/slpkg.1 | 67 ++ man/slpkg.8 | 402 ------- man/slpkg.html | 726 ----------- requirements.txt | 18 +- setup.py | 125 +- slackbuild/README | 7 - slackbuild/doinst.sh | 8 +- slackbuild/slpkg.SlackBuild | 18 +- slpkg/__init__.py | 2 +- slpkg/__metadata__.py | 255 ---- slpkg/arguments.py | 228 ---- slpkg/auto_pkg.py | 89 -- slpkg/binary/__init__.py | 1 - slpkg/binary/check.py | 78 -- slpkg/binary/dependency.py | 70 -- slpkg/binary/greps.py | 284 ----- slpkg/binary/install.py | 403 ------- slpkg/binary/repo_init.py | 163 --- slpkg/binary/search.py | 43 - slpkg/blacklist.py | 115 -- slpkg/checks.py | 150 --- slpkg/checksum.py | 70 -- slpkg/clean.py | 52 - slpkg/clean_logs.py | 34 + slpkg/cli_menu.py | 23 + slpkg/config.py | 98 -- slpkg/create_data.py | 63 + slpkg/dependencies.py | 26 + slpkg/desc.py | 78 -- slpkg/dialog_box.py | 109 -- slpkg/downloader.py | 147 +-- slpkg/file_size.py | 56 - slpkg/graph.py | 120 -- slpkg/grep_md5.py | 56 - slpkg/health.py | 120 -- slpkg/init.py | 940 --------------- slpkg/load.py | 121 -- slpkg/log_deps.py | 52 - slpkg/main.py | 1129 ++---------------- slpkg/md5sum.py | 37 - slpkg/messages.py | 141 --- slpkg/metadata.py | 93 ++ slpkg/models/{__init.py__ => __init__.py} | 0 slpkg/models/data.py | 84 -- slpkg/models/models.py | 65 +- slpkg/new_config.py | 271 ----- slpkg/pkg/__init__.py | 1 - slpkg/pkg/build.py | 229 ---- slpkg/pkg/find.py | 52 - slpkg/pkg/installed.py | 60 - slpkg/pkg/manager.py | 712 ----------- slpkg/pkg_find.py | 96 -- slpkg/queries.py | 90 ++ slpkg/remove.py | 45 - slpkg/remove_packages.py | 79 ++ slpkg/repoenable.py | 167 --- slpkg/repoinfo.py | 141 --- slpkg/repolist.py | 84 -- slpkg/repositories.py | 152 --- slpkg/sbo/__init__.py | 1 - slpkg/sbo/autobuild.py | 76 -- slpkg/sbo/build_num.py | 59 - slpkg/sbo/check.py | 71 -- slpkg/sbo/compressed.py | 32 - slpkg/sbo/dependency.py | 75 -- slpkg/sbo/greps.py | 117 -- slpkg/sbo/network.py | 418 ------- slpkg/sbo/queue.py | 202 ---- slpkg/sbo/read.py | 52 - slpkg/sbo/sbo_arch.py | 47 - slpkg/sbo/search.py | 41 - slpkg/sbo/slack_find.py | 59 - slpkg/sbo/slackbuild.py | 432 ------- slpkg/security.py | 49 - slpkg/sizes.py | 48 - slpkg/slack/__init__.py | 1 - slpkg/slack/mirrors.py | 64 - slpkg/slack/patches.py | 336 ------ slpkg/slack/slack_version.py | 46 - slpkg/slack/slackware_repo.py | 45 - slpkg/slackbuild.py | 204 ++++ slpkg/slpkg_update.py | 112 -- slpkg/splitting.py | 45 - slpkg/status_deps.py | 152 --- slpkg/superuser.py | 41 - slpkg/tracking.py | 244 ---- slpkg/update_repository.py | 44 + slpkg/upgrade_checklist.py | 70 -- slpkg/url_read.py | 55 - slpkg/utilities.py | 32 + slpkg/utils.py | 121 -- slpkg/version.py | 35 - slpkg/views/__init__.py | 0 slpkg/views/views.py | 60 + tests/test_file_size.py | 19 - tests/test_installed.py | 23 - tests/test_md5sum.py | 21 - tests/test_sbo_grep.py | 49 - tests/test_search_package.py | 25 - tests/test_slack_version.py | 15 - tests/test_split_package.py | 26 - tests/test_units.py | 19 - tests/test_utils.py | 34 - tools/gen_repos_files.sh | 945 --------------- 134 files changed, 1069 insertions(+), 15691 deletions(-) delete mode 100644 AUTHORS delete mode 100644 CHECKSUMS.md5 delete mode 100644 COMMANDS delete mode 100644 CONTRIBUTING delete mode 100644 EXAMPLES.md delete mode 100644 INSTALL.md delete mode 100644 ISSUES delete mode 100644 KNOWN_ISSUES delete mode 100644 LICENSE create mode 100644 LICENSE.txt delete mode 100644 REPOSITORIES.md delete mode 100644 THANKS delete mode 100644 bin/__init__.py delete mode 100755 clean.py delete mode 100644 conf/blacklist delete mode 100644 conf/custom-repositories delete mode 100644 conf/default-repositories delete mode 100644 conf/pkg_security delete mode 100644 conf/repositories.conf delete mode 100644 conf/rlworkman.deps delete mode 100644 conf/slackware-mirrors delete mode 100644 conf/slpkg.bash-completion delete mode 100644 conf/slpkg.conf delete mode 100644 conf/slpkg.fish create mode 100644 config/slpkg.json delete mode 100644 logo.txt create mode 100644 man/slpkg.1 delete mode 100644 man/slpkg.8 delete mode 100644 man/slpkg.html delete mode 100644 slpkg/__metadata__.py delete mode 100644 slpkg/arguments.py delete mode 100644 slpkg/auto_pkg.py delete mode 100644 slpkg/binary/__init__.py delete mode 100644 slpkg/binary/check.py delete mode 100644 slpkg/binary/dependency.py delete mode 100644 slpkg/binary/greps.py delete mode 100644 slpkg/binary/install.py delete mode 100644 slpkg/binary/repo_init.py delete mode 100644 slpkg/binary/search.py delete mode 100644 slpkg/blacklist.py delete mode 100644 slpkg/checks.py delete mode 100644 slpkg/checksum.py delete mode 100644 slpkg/clean.py create mode 100644 slpkg/clean_logs.py create mode 100644 slpkg/cli_menu.py delete mode 100644 slpkg/config.py create mode 100644 slpkg/create_data.py create mode 100644 slpkg/dependencies.py delete mode 100644 slpkg/desc.py delete mode 100644 slpkg/dialog_box.py delete mode 100644 slpkg/file_size.py delete mode 100644 slpkg/graph.py delete mode 100644 slpkg/grep_md5.py delete mode 100644 slpkg/health.py delete mode 100644 slpkg/init.py delete mode 100644 slpkg/load.py delete mode 100644 slpkg/log_deps.py delete mode 100644 slpkg/md5sum.py delete mode 100644 slpkg/messages.py create mode 100644 slpkg/metadata.py rename slpkg/models/{__init.py__ => __init__.py} (100%) delete mode 100644 slpkg/models/data.py delete mode 100644 slpkg/new_config.py delete mode 100644 slpkg/pkg/__init__.py delete mode 100644 slpkg/pkg/build.py delete mode 100644 slpkg/pkg/find.py delete mode 100644 slpkg/pkg/installed.py delete mode 100644 slpkg/pkg/manager.py delete mode 100644 slpkg/pkg_find.py create mode 100644 slpkg/queries.py delete mode 100644 slpkg/remove.py create mode 100644 slpkg/remove_packages.py delete mode 100644 slpkg/repoenable.py delete mode 100644 slpkg/repoinfo.py delete mode 100644 slpkg/repolist.py delete mode 100644 slpkg/repositories.py delete mode 100644 slpkg/sbo/__init__.py delete mode 100644 slpkg/sbo/autobuild.py delete mode 100644 slpkg/sbo/build_num.py delete mode 100644 slpkg/sbo/check.py delete mode 100644 slpkg/sbo/compressed.py delete mode 100644 slpkg/sbo/dependency.py delete mode 100644 slpkg/sbo/greps.py delete mode 100644 slpkg/sbo/network.py delete mode 100644 slpkg/sbo/queue.py delete mode 100644 slpkg/sbo/read.py delete mode 100644 slpkg/sbo/sbo_arch.py delete mode 100644 slpkg/sbo/search.py delete mode 100644 slpkg/sbo/slack_find.py delete mode 100644 slpkg/sbo/slackbuild.py delete mode 100644 slpkg/security.py delete mode 100644 slpkg/sizes.py delete mode 100644 slpkg/slack/__init__.py delete mode 100644 slpkg/slack/mirrors.py delete mode 100644 slpkg/slack/patches.py delete mode 100644 slpkg/slack/slack_version.py delete mode 100644 slpkg/slack/slackware_repo.py create mode 100644 slpkg/slackbuild.py delete mode 100644 slpkg/slpkg_update.py delete mode 100644 slpkg/splitting.py delete mode 100644 slpkg/status_deps.py delete mode 100644 slpkg/superuser.py delete mode 100644 slpkg/tracking.py create mode 100644 slpkg/update_repository.py delete mode 100644 slpkg/upgrade_checklist.py delete mode 100644 slpkg/url_read.py create mode 100644 slpkg/utilities.py delete mode 100644 slpkg/utils.py delete mode 100644 slpkg/version.py create mode 100644 slpkg/views/__init__.py create mode 100644 slpkg/views/views.py delete mode 100644 tests/test_file_size.py delete mode 100644 tests/test_installed.py delete mode 100644 tests/test_md5sum.py delete mode 100644 tests/test_sbo_grep.py delete mode 100644 tests/test_search_package.py delete mode 100644 tests/test_slack_version.py delete mode 100644 tests/test_split_package.py delete mode 100644 tests/test_units.py delete mode 100644 tests/test_utils.py delete mode 100644 tools/gen_repos_files.sh diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index e75a569c..00000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Dimitris Zlatanidis diff --git a/CHECKSUMS.md5 b/CHECKSUMS.md5 deleted file mode 100644 index 1d4e7f99..00000000 --- a/CHECKSUMS.md5 +++ /dev/null @@ -1,151 +0,0 @@ -These are the MD5 message digests for the files in this directory. -If you want to test your files, use 'md5sum' and compare the values to -the ones listed here. - -To test all these files, use this command: - -tail +13 CHECKSUMS.md5 | md5sum -c --quiet - | less - -'md5sum' can be found in the GNU coreutils package on ftp.gnu.org in -/pub/gnu, or at any GNU mirror site. - -MD5 message digest Filename -74d79364aef2717c00eae3a37c0e7479 ./slpkg-2.1.5.tar.gz -b37d59524be1ce9ef1c4e13e91ceb763 ./slpkg-2.2.0.tar.gz -3b869056c2309ee3f694b2c11f5533bd ./slpkg-2.2.1.tar.gz -c32bc46bcb2f5a7b4fbc681a6cccc3de ./slpkg-2.2.2.tar.gz -3c7259a18644573e116b4836095aebd8 ./slpkg-2.2.3.tar.gz -246571f3f6489dd98a67df3a2d1acb58 ./slpkg-2.2.5.tar.gz -bc70626560b37398bd66a02cc3c9f5ef ./slpkg-2.2.6.tar.gz -abea645bd382aa47500588631c299bb1 ./slpkg-2.2.7.tar.gz -5aa9870ad189864cfed45a910f5136b9 ./slpkg-2.2.8.tar.gz -cd3c213b4c0da976be970e9fe888e5e3 ./slpkg-2.2.9.tar.gz -08a345549a0a3e1de2103c3b4085b880 ./slpkg-2.3.0.tar.gz -ac61b4952462327f7f06f1d5ea11920d ./slpkg-2.3.1.tar.gz -70175c577672fd0f488cb9f5a715a2c3 ./slpkg-2.3.2.tar.gz -1f7b391e2e3e4f414f58660b094775d8 ./slpkg-2.3.3.tar.gz -141433a4e78e96b4efb0a2e32d75c1be ./slpkg-2.3.4.tar.gz -93b7a0d94695526e1821e3b04685b58f ./slpkg-2.3.5.tar.gz -d0bef671bb8a3f8def08e289f7a84b65 ./slpkg-2.3.6.tar.gz -03f8b36727bf10b46d78c581266670db ./slpkg-2.4.0.tar.gz -9f422c008b25820eb55202989f2871da ./slpkg-2.4.1.tar.gz -ae5ca3128a6ad05b3061541b088f3a1f ./slpkg-2.4.2.tar.gz -8b48e7080bd5363e8752666b9bf583e9 ./slpkg-2.4.3.tar.gz -41552b535b00cd03488d87060e561e05 ./slpkg-2.4.4.tar.gz -4df3325bbf2f67629a41ce498e55f2a6 ./slpkg-2.5.0.tar.gz -e4c638055b82a4590695e5c6b269aa53 ./slpkg-2.5.1.tar.gz -60e6bc9cfa456637112a942a461e6619 ./slpkg-2.5.2.tar.gz -0375ac84e760f51f1d575d96f3ba7fbf ./slpkg-2.5.3.tar.gz -205589985bf31249e6f1ab5c68c18e44 ./slpkg-2.5.4.tar.gz -dff6a5c677311f9c4d17e45088ef2f58 ./slpkg-2.5.5.tar.gz -7936eabe05be9acee42df45f75bc8107 ./slpkg-2.5.6.tar.gz -fd031880db1f60aa90eef0e0fc9a106b ./slpkg-2.5.7.tar.gz -9f8f748ab7ab99799a9e55891b11130c ./slpkg-2.5.8.tar.gz -cbc5213680f8db5c1283923ff07b066f ./slpkg-2.5.9.tar.gz -f6cb268e56051a958538c4182870f241 ./slpkg-2.6.0.tar.gz -8c7fde89ba7658d3505c88d5b7dd1b40 ./slpkg-2.6.1.tar.gz -1f0cca089df4d157201730f27afa4765 ./slpkg-2.6.2.tar.gz -95ccc27545a259087e0dd0b666cbb686 ./slpkg-2.6.3.tar.gz -8584d7d9d3666a93f6d14f5e42e4cb41 ./slpkg-2.6.4.tar.gz -2240d34cc28c69846ad47bea473f25e4 ./slpkg-2.6.5.tar.gz -e6ed625b553fd2f24f149162e4fa735f ./slpkg-2.6.6.tar.gz -48a3941cd990a1a037f11d989d2e5be0 ./slpkg-2.6.7.tar.gz -4f2df9ad3ffc303373e26200544d4af4 ./slpkg-2.6.8.tar.gz -f348ca49b0d8419f170f2211399a0851 ./slpkg-2.6.9.tar.gz -a41dbb2b95c34bd31319addcae0f1e49 ./slpkg-2.7.0.tar.gz -28ec4b26e87188f1ebf1eb0a8fcb64e2 ./slpkg-2.7.1.tar.gz -4a110faf3df50c336678b410736295e3 ./slpkg-2.7.2.tar.gz -18cb0f66a8a5fb27e9170efd59a7e1df ./slpkg-2.7.3.tar.gz -86579033c8789b5896a36b377508d367 ./slpkg-2.7.4.tar.gz -12dd03c8ed172eebc41f9ed84993780b ./slpkg-2.7.5.tar.gz -4484ede82d667badb6dd22873d2da785 ./slpkg-2.7.6.tar.gz -3bb2cb5f2427fa9024af8df9e6a6d51d ./slpkg-2.8.0.tar.gz -7545f9dbce24deb9b4b69d7303c00f28 ./slpkg-2.8.1.tar.gz -8158ab7fe2555a24553c9efa6d6f8ac9 ./slpkg-2.8.2.tar.gz -d6842f77b159a9f9db8183c10abcb83f ./slpkg-2.8.3.tar.gz -5247eb52e9864a1dd4d134893227a7a4 ./slpkg-2.8.4.tar.gz -64a22e9fbf7a6bc04b6f544609322434 ./slpkg-2.8.5.tar.gz -5e4ccdb74fe3abde188994a362de1d67 ./slpkg-2.8.6.tar.gz -cac1f51618665cebd8ed778f78a8d2fe ./slpkg-2.8.7.tar.gz -f65b1525da801a7cc2e460cf1eb5d4be ./slpkg-2.8.8.tar.gz -1a311e132d3b7957f3ab3d128072a10f ./slpkg-2.8.9.tar.gz -737b6a59dcb103708c4aeab4a96b517d ./slpkg-2.9.0.tar.gz -2ba8c1f63d05f368d9c7a6f12f4df387 ./slpkg-2.9.1.tar.gz -8970a287eafc773bc87905204fea35f6 ./slpkg-2.9.2.tar.gz -8d749508937faf31ee2432a05f64a46e ./slpkg-2.9.3.tar.gz -6616d6612e6eed897fd723777f5fb273 ./slpkg-2.9.4.tar.gz -f645936c1b143e4e1fa7c1637a4ea03f ./slpkg-2.9.5.tar.gz -d30ee37dbab0b113e6493fc61ee2f0b2 ./slpkg-2.9.6.tar.gz -a3a9e3768fc1ba3da91503b49325fee3 ./slpkg-2.9.7.tar.gz -96b1e1262a410e385f21e5413329ce18 ./slpkg-3.0.0.tar.gz -fab52c1b84e988cd5ec4b5ddbc95277c ./slpkg-3.0.1.tar.gz -4dd94caee2ef25501a5b70546ee0e3a4 ./slpkg-3.0.2.tar.gz -b88c991b2d29934f9f69104144a97e26 ./slpkg-3.0.3.tar.gz -1d50725d7bd271533442ca61bdf989fd ./slpkg-3.0.4.tar.gz -36a0b209ec8f194b86870112a3baa5b2 ./slpkg-3.0.5.tar.gz -101233e422a193f16d9056cf9f9d7b75 ./slpkg-3.0.6.tar.gz -9ec6024d77cd0e42292358ab1520973e ./slpkg-3.0.7.tar.gz -3e20b6d9ac4f36719ea76555910f6fe3 ./slpkg-3.0.8.tar.gz -44865cf611fc9a8d6425ce40f65d24f3 ./slpkg-3.0.9.tar.gz -fb2c0fedd2af291195faccfd304087be ./slpkg-3.1.0.tar.gz -e2b106a786a889c26385bf6ef266f09b ./slpkg-3.1.1.tar.gz -d9652f8d1ed42cb35084fdea88a8e483 ./slpkg-3.1.2.tar.gz -bb1ecf5cee734126f28241e810b77db3 ./slpkg-3.1.3.tar.gz -7b575cb93f3d2203fa2d3c41bd20f922 ./slpkg-3.1.4.tar.gz -f31a256221c02efbe4d356829d2a85e4 ./slpkg-3.1.5.tar.gz -9fbe32bd1f22e1784e2bb1ae7a288a4f ./slpkg-3.1.6.tar.gz -c3704b344c426151786a9760c4c62c4a ./slpkg-3.1.7.tar.gz -85df62558734a4113827e3b7f461c56e ./slpkg-3.1.8.tar.gz -9dc7d81d758a98ce3ad9c94364f33850 ./slpkg-3.1.9.tar.gz -1a006b491e0d3cb5613f37bdf1847c6c ./slpkg-3.2.0.tar.gz -88812d9fe483f30635f35ec8d19b74d1 ./slpkg-3.2.1.tar.gz -137a121ff3dc9f37abd3af6e2a6ae6c4 ./slpkg-3.2.2.tar.gz -33dddeeea7eb50420455a82bd32bce7c ./slpkg-3.2.3.tar.gz -57ba5c20050411095f2ae732e5012576 ./slpkg-3.2.4.tar.gz -ce4657f7e644ad58adb21eddfcea495a ./slpkg-3.2.5.tar.gz -95b595479e7fb6e0ed934f33a74c267c ./slpkg-3.2.6.tar.gz -a937c14f0d728ba36c1afd91a6800282 ./slpkg-3.2.7.tar.gz -9f10d66105681d304edb130d7948d92f ./slpkg-3.2.8.tar.gz -bd1ac24393c5cfdc8c7546fe9e9d0ff2 ./slpkg-3.2.9.tar.gz -d9b3a3a2903f2e3637b6f7d324f979b3 ./slpkg-3.3.0.tar.gz -65acf0561ba00fce3a012c0b76383292 ./slpkg-3.3.1.tar.gz -7eb3f0cd2d78fcd073420a5152ec14cd ./slpkg-3.3.2.tar.gz -da0c65f15f8c8b53edd964a703560e79 ./slpkg-3.3.3.tar.gz -0c08eaac7f40fd9d8304aed8c3e69050 ./slpkg-3.3.4.tar.gz -01c779d3f22439c2a8903015bc4d14b1 ./slpkg-3.3.5.tar.gz -e2e5c91996d68c248416c90127347233 ./slpkg-3.3.6.tar.gz -3fe4ca75b734a7880cf13a07d6e1b441 ./slpkg-3.3.7.tar.gz -86024e707ff696ebecf8de77da14500e ./slpkg-3.3.8.tar.gz -049284f54ea21e8443226dbb92f61095 ./slpkg-3.3.9.tar.gz -976baf5c4b98ecae3d2336de801e8906 ./slpkg-3.4.0.tar.gz -25c697d6039ddda6c0a79a0d28fe6145 ./slpkg-3.4.1.tar.gz -14ba9c085dea13238e39fd476ed299c8 ./slpkg-3.4.2.tar.gz -2f62cfc87b130310490ff0b76eb17b74 ./slpkg-3.4.3.tar.gz -deb10f0e2597ef8b201c039af2bd9c36 ./slpkg-3.7.0.tar.gz -04a0e87c5ed0a70b4aa9682b9d2a8cc9 ./slpkg-3.7.1.tar.gz -6740e8213bbaa8f8d674144f61954366 ./slpkg-3.7.2.tar.gz -dd97a05ee9ba37e0262f7e1c60d0eb61 ./slpkg-3.7.3.tar.gz -31d0c6aa7558bdc77d4eed4d4d5eb3f8 ./slpkg-3.7.4.tar.gz -a8298533001b4537939339dc6970e140 ./slpkg-3.8.0.tar.gz -4c2c7aecc7c08f2acf63ee154f1fe090 ./slpkg-3.8.1.tar.gz -e3215b66237bc6615da823725ad3ba66 ./slpkg-3.8.2.tar.gz -ad77a79f0fe059818d905d959df85064 ./slpkg-3.8.3.tar.gz -5a622c35ad6c8bd5a0a6bce2ea73d1dc ./slpkg-3.8.4.tar.gz -030bc3e2c9a82c95cbd8647872979652 ./slpkg-3.8.5.tar.gz -79019bd09837370c92fc301822da2c8b ./slpkg-3.8.6.tar.gz -2b41c1d3c21ff61d62cc119ee7def256 ./slpkg-3.8.7.tar.gz -e35b8a1b5bd51a6bf1a223f82f733af7 ./slpkg-3.8.8.tar.gz -d485c552637b510d2d3b7ff5be093ada ./slpkg-3.8.9.tar.gz -c23fcaeee005bdd7858f8269d7532f1f ./slpkg-3.9.0.tar.gz -19d4b05df424482d8532892fc6271666 ./slpkg-3.9.1.tar.gz -4fb0c6c100299d0a05aa2df3cd639c2f ./slpkg-3.9.2.tar.gz -784dbeb6f3dfa6f5825c58b8a4be6b27 ./slpkg-3.9.3.tar.gz -7f8053f4a6147e7c82ef981d61d34c66 ./slpkg-3.9.4.tar.gz -98c5079212e39d92144fc3805f93408a ./slpkg-3.9.5.tar.gz -4f4c6dc84a9834fc8b65a820ec52fa19 ./slpkg-3.9.6.tar.gz -63be7458372cdcfba46654c7423379ac ./slpkg-3.9.7.tar.gz -41b3f4f0f8fb8270e3b03abd2c73be2c ./slpkg-3.9.8.tar.gz -9c0ac9e08ae39c56a17c0aaf63dd94bb ./slpkg-3.9.9.tar.gz -7ad1bee7fc1db400aeb925485ed76b76 ./slpkg-4.0.0.tar.gz -5b1f9eb4738b5b578fea41cde6dcdddc ./slpkg-4.0.1.tar.gz -9beb1b86eece6c26a9153d0894aadda0 ./slpkg-4.0.2.tar.gz diff --git a/COMMANDS b/COMMANDS deleted file mode 100644 index ec31ff47..00000000 --- a/COMMANDS +++ /dev/null @@ -1,3 +0,0 @@ -sed -i "s/2014-2021/2014-2022/g" {} \; # Update the Copyright year -sed -i 's/^/# /' slackware-mirrors # Add first char (#) per line -sed -i 's/ *$//' slackware-mirrors # Remove spaces the end of line diff --git a/CONTRIBUTING b/CONTRIBUTING deleted file mode 100644 index f23faf4c..00000000 --- a/CONTRIBUTING +++ /dev/null @@ -1,11 +0,0 @@ -Contributions are very much appreciated !!! - -Pull requests should be based on and submitted to the "develop" branch - -It would be preferable to have a basic knowledge about the distribution Slackware, -as important how a package is build. - -Small changes in the code each time more appreciated. -Keep the style code applicable items. - -Please ensure your changes work in Python >= 3.7 diff --git a/ChangeLog.txt b/ChangeLog.txt index abadae38..b0ceecf9 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,6 @@ -4.0.3 - 13/06/2022 -Removed: -- Unused flags --resolve-off, --download-prefix, --download-only +4.1.0 - 20/06/2022 +Updated: +- slpkg code re-written from the beginning and currently supports only the SBo repository 4.0.2 - 13/06/2022 Fixed: diff --git a/EXAMPLES.md b/EXAMPLES.md deleted file mode 100644 index 2c2858f2..00000000 --- a/EXAMPLES.md +++ /dev/null @@ -1,1322 +0,0 @@ -# Slpkg - -##### Slpkg Examples - -Enable or disable default repositories, edit '`/etc/slpkg/repositories.conf`' file or with the command. -(require pythondialog, install with '`slpkg -s sbo python3-pythondialog`'): - -``` -$ slpkg repo-enable -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/repo_enable.png) - - -If you use slpkg for the first time, you will have to create and update the packages -lists. This command must be executed to update the packages lists: - -``` -$ slpkg update - -Update repository [slack] ... Done -Update repository [sbo] ... Done -Update repository [alien] ... Done -Update repository [slacky] ... Done -Update repository [conrad] ... Done -Update repository [slonly] ... Done -Update repository [ktown] ... Done -Update repository [salix] ... Done -Update repository [slacke] ... Done -Update repository [slackl] ... Done -Update repository [multi] ... Done -Update repository [msb] ... Done - -``` -Update specifically repositories: - -``` -$ slpkg update --repositories=sbo,msb,slacky -``` - -Also you can check ChangeLog.txt for changes, like: - -``` -$ slpkg -c sbo - -+============================================================================== -| Repository Status -+============================================================================== - sbo News in ChangeLog.txt - -Summary -=============================================================================== -From 1 repositories need 1 updating. Run the command 'slpkg update'. - - -$ slpkg --check - -+============================================================================== -| Repository Status -+============================================================================== - slack No changes in ChangeLog.txt - sbo News in ChangeLog.txt - slacky News in ChangeLog.txt - alien No changes in ChangeLog.txt - rlw No changes in ChangeLog.txt - -Summary -=============================================================================== -From 5 repositories need 2 updating. Run the command 'slpkg update'. -``` - -Add and remove custom repositories: - -``` -$ slpkg repo-add ponce http://ponce.cc/slackware/slackware64-14.2/packages/ - -Repository 'ponce' successfully added - -$ slpkg repo-add repo1 file:///home/user1/repos/alien/ - -Repository 'repo1' successfully added - -$ slpkg repo-remove ponce - -Repository 'ponce' successfully removed - -``` - -View information about the repositories: - -``` -$ slpkg repo-list - -+============================================================================== -| Repo id Repo URL Default Status -+============================================================================== - alien http://www.slackware.com/~alien/slackbuilds/ yes disabled - ktown http://alien.slackbook.org/ktown/ yes disabled - msb http://slackware.org.uk/msb/ yes enabled - multi http://www.slackware.com/~alien/multilib/ yes disabled - ponce http://ponce.cc/slackware/slackware64-14.2/packa~ no enabled - rested http://taper.alienbase.nl/mirrors/people/alien/r~ yes disabled - rlw http://rlworkman.net/pkgs/ yes disabled - salix http://download.salixos.org/ yes disabled - sbo http://slackbuilds.org/slackbuilds/ yes enabled - slack http://ftp.cc.uoc.gr/mirrors/linux/slackware/ yes enabled - slacke http://ngc891.blogdns.net/pub/ yes disabled - slackl http://www.slackel.gr/repo/ yes disabled - conrad http://slack.conraid.net/repository/slackware64-~ yes disabled - slacky http://repository.slacky.eu/ yes disabled - slonly https://slackonly.com/pub/packages/ yes disabled - -Repositories summary -=============================================================================== -3/14 enabled default repositories and 1 custom. -For enable or disable default repositories edit '/etc/slpkg/repositories.conf' -file. - -$ slpkg repo-info alien - -Default: yes -Last updated: Tue Dec 23 11:48:31 UTC 2014 -Number of packages: 3149 -Repo id: alien -Repo url: http://www.slackware.com/~alien/slackbuilds/ -Status: enabled -Total compressed packages: 9.3 Gb -Total uncompressed packages: 36.31 Gb -``` - -Installing packages from the repositories (supporting multi packages): - -``` -$ slpkg -s sbo brasero -Reading package lists... Done -Resolving dependencies... Done - -The following packages will be automatically installed or upgraded -with new version: - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Installing: - brasero 3.12.1 x86_64 SBo -Installing for dependencies: - orc 0.4.23 x86_64 SBo - gstreamer1 1.4.5 x86_64 SBo - gst1-plugins-base 1.4.5 x86_64 SBo - gst1-plugins-bad 1.4.5 x86_64 SBo - -Installing summary -=============================================================================== -Total 5 packages. -5 packages will be installed, 0 already installed and 0 package -will be upgraded. - -Would you like to continue [y/N]? -``` - -Example install multi packages: - -``` -$ slpkg -s sbo brasero pylint atkmm -Reading package lists... Done -Resolving dependencies... Done - -The following packages will be automatically installed or upgraded -with new version: - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Installing: - brasero 3.12.1 x86_64 SBo - pylint-1.3.1 1.3.1 x86_64 SBo - atkmm 2.22.7 x86_64 SBo -Installing for dependencies: - libsigc++ 2.2.11 x86_64 SBo - glibmm 2.36.2 x86_64 SBo - cairomm 1.10.0 x86_64 SBo - pangomm 2.34.0 x86_64 SBo - six-1.8.0 1.8.0 x86_64 SBo - pysetuptools-17.0 17.0 x86_64 SBo - logilab-common-0.63.2 0.63.2 x86_64 SBo - astroid-1.3.6 1.3.6 x86_64 SBo - orc 0.4.23 x86_64 SBo - gstreamer1 1.4.5 x86_64 SBo - gst1-plugins-base 1.4.5 x86_64 SBo - gst1-plugins-bad 1.4.5 x86_64 SBo - -Installing summary -=============================================================================== -Total 15 packages. -10 packages will be installed, 5 already installed and 0 package -will be upgraded. - -Would you like to continue [y/N]? -``` - -Example from 'alien' repository: - -``` -$ slpkg -s alien atkmm -Reading package lists... Done -Resolving dependencies... Done - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Installing: - atkmm 2.22.6 x86_64 1 alien 124 K -Installing for dependencies: - libsigc++ 2.2.10 x86_64 2 alien 128 K - glibmm 2.32.1 x86_64 1 alien 1012 K - cairomm 1.10.0 x86_64 2 alien 124 K - pangomm 2.28.4 x86_64 1 alien 124 K - -Installing summary -=============================================================================== -Total 5 packages. -5 packages will be installed, 0 will be upgraded and 0 will be reinstalled. -Need to get 124 Kb of archives. -After this process, 620 Kb of additional disk space will be used. - -Would you like to continue [y/N]? -``` - -Close auto resolve dependencies: - -``` -$ slpkg -s alien atkm --resolve-off -Reading package lists... Done - -The following packages will be automatically installed or upgraded -with new version: - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Installing: - atkmm 2.22.6 x86_64 1 alien 124 K - -Installing summary -=============================================================================== -Total 1 package. -1 package will be installed, 0 will be upgraded and 0 will be reinstalled. -Need to get 124 Kb of archives. -After this process, 620 Kb of additional disk space will be used. - -Would you like to continue [y/N]? -``` - -Build packages and passing variables to the script: - - -First export variable(s) like: - -``` -$ export FFMPEG_ASS=yes FFMPEG_X264=yes -``` - -And then run as you know: - -``` -$ slpkg -s sbo ffmpeg - -``` - -or - -``` -$ slpkg -n ffmpeg -``` - -or if already script and source donwloaded: - -``` -$ slpkg -a ffmpeg.tar.gz ffmpeg-2.1.5.tar.bz2 -``` - -Tracking all the dependencies of packages, and also displays the installed packages: - -``` -$ slpkg -t sbo brasero -Resolving dependencies... Done - -+========================= -| brasero dependencies : -+========================= -\ - +---[ Tree of dependencies ] - | - +--1 orc - | - +--2 gstreamer1 - | - +--3 gst1-plugins-base - | - +--4 gst1-plugins-bad - | - +--5 libunique -``` - -Check if the dependencies used: - -``` -$ slpkg -t sbo Flask --check-deps -Resolving dependencies... Done - -+============================= -| Package Flask dependencies : -+============================= -\ - +---[ Tree of dependencies ] - | - +--1: pysetuptools is dependence on --> Flask, bpython, pip, pylint - | - +--2: MarkupSafe is dependence on --> Flask - | - +--3: itsdangerous is dependence on --> Flask - | - +--4: Jinja2 is dependence on --> Flask - | - +--5: werkzeug is dependence on --> Flask -``` - -Drawing the dependencies diagram: - -``` -$ slpkg -t sbo flexget --graph=image.x11 -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/deps2.png) - -``` -$ slpkg -t sbo Flask --check-deps --graph=image.x11 -Resolving dependencies... Done - -+============================= -| Package Flask dependencies : -+============================= -\ - +---[ Tree of dependencies ] - | - +--1: pysetuptools is dependence on --> APScheduler, Flask, Jinja2, MarkupSafe, astroid, autopep8, blessings, bpython, cffi, cryptography, curtsies, itsdangerous, monty, ndg_httpsclient, pip, pyOpenSSL, pylint, wcwidth - | - +--2: MarkupSafe is dependence on --> Flask, Jinja2 - | - +--3: itsdangerous is dependence on --> Flask - | - +--4: Jinja2 is dependence on --> Flask - | - +--5: werkzeug is dependence on --> Flask -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/deps3.png) - - -Drawing the dependencies ascii diagram: - -``` -$ slpkg -t sbo botocore --graph=ascii - - +---------------------------------+ - | | - | | - | +---------+ | - | | | | - | | | | - +----------------+----+----+ | | - | | | | | | -+--------------+ | +--------------------+ | +-----------------+ | -| jmespath | -+- | botocore | +- | python-dateutil | | -+--------------+ | +--------------------+ +-----------------+ | - | | | | | | | - | | | | | | | - | | | | | | | -+--------------+ | +----------+ | | +-----------------+ | -| pysetuptools | -+ | bcdoc | -+----+------ | six | -+ -+--------------+ +----------+ | | +-----------------+ - | | | | - | | | | - | | | | - | +----------+ | | - | | docutils | -+ | - | +----------+ | - | | - +-------------------------------------+ -``` - -Print the dependencies status used by packages: - -``` -$ slpkg deps-status - -+============================================================================== -| Dependencies Packages -+============================================================================== - astroid pylint - logilab-common pylint - werkzeug Flask - cryptography bpython - ndg_httpsclient bpython - enum34 bpython - pyOpenSSL bpython - curtsies bpython - six bpython, pylint - cffi bpython - python-requests bpython - pysetuptools Flask, bpython, pip, pylint - MarkupSafe Flask - Pygments bpython - Jinja2 Flask - pycparser bpython - blessings bpython - greenlet bpython - pyasn1 bpython - -Summary -=============================================================================== -Found 19 dependencies in 4 packages. -``` - -Use the additional option '`--graph=[image]`' to drawing the dependencies diagram: - -``` -$ slpkg deps-status --graph=image.x11 -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/deps.png) - - -Check if your packages is up to date or they have changes in ChangeLog.txt: - -``` -$ slpkg -c sbo - -+============================================================================== -| Repository Status -+============================================================================== - sbo News in ChangeLog.txt - -Summary -=============================================================================== -From 1 repositories need 1 updating. Run the command 'slpkg update'. -``` - -Check for new versions: - -``` -$ slpkg -c sbo --upgrade -Checking... Done -Reading package lists... Done -Resolving dependencies... Done - -The following packages will be automatically installed or upgraded -with new version: - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Upgrading: - astroid-1.3.2 1.3.4 x86_64 SBo - jdk-7u51 8u31 x86_64 SBo -Installing for dependencies: - six-1.7.3 1.8.0 x86_64 SBo - logilab-common-0.60.1 0.63.2 x86_64 SBo - pysetuptools-6.1 7.0 x86_64 SBo - -Installing summary -=============================================================================== -Total 5 packages. -0 package will be installed, 2 already installed and 3 packages -will be upgraded. - -Would you like to continue [y/N]? - - -$ slpkg -c slacky --upgrade -Checking... Done -Reading package lists... Done -Resolving dependencies... Done - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Upgrading: - gstreamer1-1.4.1 1.4.4 x86_64 1 slacky 1563 K - -Installing summary -=============================================================================== -Total 1 package. -0 package will be installed, 1 will be upgraded and 0 will be reinstalled. -Need to get 1.53 Mb of archives. -After this process, 14.55 Mb of additional disk space will be used. - -Would you like to continue [y/N]? -``` - -Check if your Slackware distribution is up to date. -This option works independently of the others i.e you don't need before you updating the -packages lists: - -``` -$ slpkg -c slack --upgrade -Reading package lists... Done - -These packages need upgrading: - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Upgrading: - dhcpcd-6.0.5 6.0.5 x86_64 3 Slack 92 K - samba-4.1.0 4.1.11 x86_64 1 Slack 9928 K - xscreensaver-5.22 5.29 x86_64 1 Slack 3896 K - -Installing summary -=============================================================================== -Total 3 package will be upgrading and 0 will be installed. -Need to get 13.58 Mb of archives. -After this process, 76.10 Mb of additional disk space will be used. - -Would you like to continue [y/N]? -``` - -Upgrade only distribution: - -``` -$ slpkg -c slack --upgrade --skip="multi:*multilib*,ktown:*" // This upgrade -Checking... Done // distribution - // and skip all -Slackware64 'stable' v14.2 distribution is up to date // packages from - // ktown repository - // and multilib - // from multi. -``` - -Skip packages when upgrading: - -``` -$ slpkg -c sbo --upgrade --skip=pip,jdk // Available options: -Checking... Done // repository:*string* -Reading package lists... Done // repository:string* -Resolving dependencies... Done // repository:*string - -The following packages will be automatically installed or upgraded -with new version: - -+============================================================================== -| Package New version Arch Build Repos Size -+============================================================================== -Upgrading: - cffi-1.0.1 1.1.0 x86_64 SBo -Installing for dependencies: - pysetuptools-17.0 17.0 x86_64 SBo - pycparser-2.12 2.13 x86_64 SBo - -Installing summary -=============================================================================== -Total 3 packages. -0 package will be installed, 1 already installed and 2 packages -will be upgraded. - -Would you like to continue [y/N]? -``` - -View slackbuilds.org site in your terminal. Read files, download, build or install: - -``` -$ slpkg -n bitfighter -Reading package lists... Done - -+============================================================================== -| SlackBuilds Repository -+============================================================================== -| 14.2 > Games > bitfighter -+=============================================================================== -| Package url: http://slackbuilds.org/repository/14.2/games/bitfighter/ -+=============================================================================== -| Description: multi-player combat game -| SlackBuild: bitfighter.tar.gz -| Sources: bitfighter-019c.tar.gz, classic_level_pack.zip -| Requirements: OpenAL, SDL2, speex, libmodplug -+=============================================================================== -| README View the README file -| SlackBuild View the .SlackBuild file -| Info View the .info file -| Doinst.sh View the doinst.sh file -| Download Download this package -| Build Download and build this package -| Install Download/Build/Install -| Clear Clear screen - Quit Quit -+================================================================================ - Choose an option > _ -``` - -Use the dialog utility to help you find the packages: - -``` -$ slpkg -n --checklist -Reading package lists... -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/pythondialog5.png) - -``` -$ slpkg -n perl --checklist -Reading package lists... -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/pythondialog6.png) - - -Auto tool to build a package: -Two files termcolor.tar.gz and termcolor-1.1.0.tar.gz must be in the same directory. -(slackbuild script & source code or extra sources if needed) - -``` -$ slpkg -a termcolor.tar.gz termcolor-1.1.0.tar.gz - -termcolor/ -termcolor/slack-desc -termcolor/termcolor.info -termcolor/README -termcolor/termcolor.SlackBuild -termcolor-1.1.0/ -termcolor-1.1.0/CHANGES.rst -termcolor-1.1.0/COPYING.txt -termcolor-1.1.0/README.rst -termcolor-1.1.0/setup.py -termcolor-1.1.0/termcolor.py -termcolor-1.1.0/PKG-INFO -running install -running build -running build_py -creating build -creating build/lib -copying termcolor.py -> build/lib -running install_lib -creating /tmp/SBo/package-termcolor/usr -creating /tmp/SBo/package-termcolor/usr/lib64 -creating /tmp/SBo/package-termcolor/usr/lib64/python2.7 -creating /tmp/SBo/package-termcolor/usr/lib64/python2.7/site-packages -copying build/lib/termcolor.py -> -/tmp/SBo/package-termcolor/usr/lib64/python2.7/site-packages -byte-compiling /tmp/SBo/package-termcolor/usr/lib64/python2.7/site-packages/termcolor.py -to termcolor.pyc -running install_egg_info -Writing -/tmp/SBo/package-termcolor/usr/lib64/python2.7/site-packages/termcolor-1.1.0-py2.7.egg-info - -Slackware package maker, version 3.14159. - -Searching for symbolic links: - -No symbolic links were found, so we wont make an installation script. -You can make your own later in ./install/doinst.sh and rebuild the -package if you like. - -This next step is optional - you can set the directories in your package -to some sane permissions. If any of the directories in your package have -special permissions, then DO NOT reset them here! - -Would you like to reset all directory permissions to 755 (drwxr-xr-x) and -directory ownerships to root.root ([y]es, [n]o)? n - -Creating Slackware package: /tmp/termcolor-1.1.0-x86_64-1_SBo.tgz - -./ -usr/ -usr/lib64/ -usr/lib64/python2.7/ -usr/lib64/python2.7/site-packages/ -usr/lib64/python2.7/site-packages/termcolor.py -usr/lib64/python2.7/site-packages/termcolor.pyc -usr/lib64/python2.7/site-packages/termcolor-1.1.0-py2.7.egg-info -usr/doc/ -usr/doc/termcolor-1.1.0/ -usr/doc/termcolor-1.1.0/termcolor.SlackBuild -usr/doc/termcolor-1.1.0/README.rst -usr/doc/termcolor-1.1.0/CHANGES.rst -usr/doc/termcolor-1.1.0/PKG-INFO -usr/doc/termcolor-1.1.0/COPYING.txt -install/ -install/slack-desc - -Slackware package /tmp/termcolor-1.1.0-x86_64-1_SBo.tgz created. - -Total build time for package termcolor : 1 Sec -``` - -Upgrade, install the packages like Slackware command '`upgradepkg --install-new`': - -``` -$ slpkg -u --install-new /tmp/termcolor-1.1.0-x86_64-1_SBo.tgz - -+============================================================================== -| Installing new package ./termcolor-1.1.0-x86_64-1_SBo.tgz -+============================================================================== - -Verifying package termcolor-1.1.0-x86_64-1_SBo.tgz. -Installing package termcolor-1.1.0-x86_64-1_SBo.tgz: -PACKAGE DESCRIPTION: -# termcolor (ANSII Color formatting for output in terminal) -# -# termcolor allows you to format your output in terminal. -# -# Project URL: https://pypi.python.org/pypi/termcolor -# -Package termcolor-1.1.0-x86_64-1_SBo.tgz installed. -``` - -Install mass-packages: - -``` -$ slpkg -u --install-new *.t?z -``` - -or - -``` -$ slpkg -i *.t?z -``` - -Slpkg auto detect Slackware binary packages (.tgz, .txz, .tlz and .tbz) for installation: - -``` -$ slpkg pysed-0.7.8-x86_64-1_SBo.tgz - -pysed-0.7.8-x86_64-1_SBo.tgz - -+============================================================================== -| Choose a Slackware command: -+============================================================================== -| i) installpkg -| r) upgradepkg --reinstall -| u) upgradepkg --install-new -+============================================================================== - > _ -``` - -Search packages from the enabled repositories: - -``` -$ slpkg -F aria2 - -Packages with name matching [ aria2 ] - -+============================================================================== -| Repository Package Size -+============================================================================== - sbo aria2-1.18.10 0 K - slonly aria2-1.18.10-x86_64-1_slack.txz 1124 K - salix aria2-1.18.1-x86_64-1rl.txz 1052 K - conrad aria2-1.18.10-x86_64-1cf.txz 1140 K - -Found summary -=============================================================================== -Total found 4 packages in 4 repositories. - - -$ slpkg -F pyqt5 AAA --case-ins - -Packages with name matching [ pyqt5, AAA ] - -+============================================================================== -| Repository Package Size -+============================================================================== - slack aaa_base-14.2-x86_64-1.txz 12 K - slack aaa_elflibs-14.2-x86_64-3.txz 4316 K - slack aaa_terminfo-5.8-x86_64-1.txz 44 K - sbo jaaa-0.8.4 0 K - sbo python3-PyQt5-5.5 0 K - slonly jaaa-0.8.4-x86_64-1_slack.txz 40 K - slonly python3-PyQt5-5.5-x86_64-1_slack.txz 3088 K - -Found summary -=============================================================================== -Total found 7 packages in 3 repositories. -``` - -Find the installed packages: - -``` -$ slpkg -f apr - -Sckages with matching name [ apr ] - -[ installed ] [ 1.1M ] - apr-1.5.2-x86_64-1 -[ installed ] [ 530K ] - apr-util-1.5.4-x86_64-2 -[ installed ] [ 40K ] - xf86dgaproto-2.1-noarch-1 -[ installed ] [ 50K ] - xineramaproto-1.2.1-noarch-1 - -Found summary -=============================================================================== -Total found 4 matching packages. -Size of installed packages 1.71 Mb. - - -$ slpkg -f python --third-party - -Packages with matching name [ python ] - -[ installed ] [ 1.4M ] - bpython-0.17.1-x86_64-1_SBo -[ installed ] [ 590K ] - python-certifi-2018.11.29-x86_64-1_SBo -[ installed ] [ 1.9M ] - python-chardet-3.0.4-x86_64-1_SBo -[ installed ] [ 220K ] - python-libtmux-0.8.0-x86_64-1_SBo -[ installed ] [ 50K ] - python-notify2-0.3.1-x86_64-1_SBo -[ installed ] [ 1.5M ] - python-requests-2.20.1-x86_64-1_SBo -[ installed ] [ 110K ] - python-scandir-1.8-x86_64-1_SBo -[ installed ] [ 1.5M ] - python-urllib3-1.23-x86_64-1_SBo -[ installed ] [ 440K ] - python2-pythondialog-3.4.0-x86_64-1_SBo -[ installed ] [ 120M ] - python3-3.6.7-x86_64-1_SBo - -Found summary -=============================================================================== -Total found 10 matching packages. -Size of installed packages 127.68 Mb. -``` - -Display the contents of the packages: - -``` -$ slpkg -d termcolor lua - -PACKAGE NAME: termcolor-1.1.0-x86_64-1_SBo -COMPRESSED PACKAGE SIZE: 8.0K -UNCOMPRESSED PACKAGE SIZE: 60K -PACKAGE LOCATION: ./termcolor-1.1.0-x86_64-1_SBo.tgz -PACKAGE DESCRIPTION: -termcolor: termcolor (ANSII Color formatting for output in terminal) -termcolor: -termcolor: termcolor allows you to format your output in terminal. -termcolor: -termcolor: -termcolor: Project URL: https://pypi.python.org/pypi/termcolor -termcolor: -termcolor: -termcolor: -termcolor: -FILE LIST: -./ -usr/ -usr/lib64/ -usr/lib64/python2.7/ -usr/lib64/python2.7/site-packages/ -usr/lib64/python2.7/site-packages/termcolor.py -usr/lib64/python2.7/site-packages/termcolor.pyc -usr/lib64/python2.7/site-packages/termcolor-1.1.0-py2.7.egg-info -usr/lib64/python3.3/ -usr/lib64/python3.3/site-packages/ -usr/lib64/python3.3/site-packages/termcolor-1.1.0-py3.3.egg-info -usr/lib64/python3.3/site-packages/__pycache__/ -usr/lib64/python3.3/site-packages/__pycache__/termcolor.cpython-33.pyc -usr/lib64/python3.3/site-packages/termcolor.py -usr/doc/ -usr/doc/termcolor-1.1.0/ -usr/doc/termcolor-1.1.0/termcolor.SlackBuild -usr/doc/termcolor-1.1.0/README.rst -usr/doc/termcolor-1.1.0/CHANGES.rst -usr/doc/termcolor-1.1.0/PKG-INFO -usr/doc/termcolor-1.1.0/COPYING.txt -install/ -install/slack-desc - -No such package lua: Cant find -``` - -Removes a previously installed Slackware binary package: - -``` -$ slpkg -r termcolor - -Packages with name matching [ termcolor ] - -[ delete ] --> termcolor-1.1.0-x86_64-1_SBo - -Removed summary -=============================================================================== -Size of removed packages 50.0 Kb. - -Are you sure to remove 1 package(s) [y/N]? y - -Package: termcolor-1.1.0-x86_64-1_SBo - Removing... - -Removing package /var/log/packages/termcolor-1.1.0-x86_64-1_SBo... - Removing files: ---> Deleting /usr/doc/termcolor-1.1.0/CHANGES.rst ---> Deleting /usr/doc/termcolor-1.1.0/COPYING.txt ---> Deleting /usr/doc/termcolor-1.1.0/PKG-INFO ---> Deleting /usr/doc/termcolor-1.1.0/README.rst ---> Deleting /usr/doc/termcolor-1.1.0/termcolor.SlackBuild ---> Deleting /usr/lib64/python2.7/site-packages/termcolor-1.1.0-py2.7.egg-info ---> Deleting /usr/lib64/python2.7/site-packages/termcolor.py ---> Deleting /usr/lib64/python2.7/site-packages/termcolor.pyc ---> Deleting /usr/lib64/python3.3/site-packages/__pycache__/termcolor.cpython-33.pyc ---> Deleting /usr/lib64/python3.3/site-packages/termcolor-1.1.0-py3.3.egg-info ---> Deleting /usr/lib64/python3.3/site-packages/termcolor.py ---> Deleting empty directory /usr/lib64/python3.3/site-packages/__pycache__/ -WARNING: Unique directory /usr/lib64/python3.3/site-packages/ contains new files -WARNING: Unique directory /usr/lib64/python3.3/ contains new files ---> Deleting empty directory /usr/doc/termcolor-1.1.0/ - -+============================================================================== -| Package: termcolor-1.1.0 removed -+============================================================================== -``` - -Remove packages with all dependencies and check if used as dependency: -(Presupposes install with the option '`slpkg -s `') - -``` -$ slpkg -r Flask --check-deps - -Packages with name matching [ Flask ] - -[ delete ] --> Flask-0.10.1-x86_64-1_SBo - -Removed summary -=============================================================================== -Size of removed packages 1.2 Mb. - -Are you sure to remove 1 package [y/N]? y - -+============================================================================== -| Found dependencies for package Flask: -+============================================================================== -| pysetuptools-18.0.1 -| MarkupSafe-0.23 -| werkzeug-0.9.4 -| Jinja2-2.7.3 -| itsdangerous-0.24 -+============================================================================== -| Size of removed dependencies 5.52 Mb -+============================================================================== - -Remove dependencies (maybe used by other packages) [y/N]? y - - -+============================================================================== -| !!! WARNING !!! -+============================================================================== -| pysetuptools is dependency of the package --> Flask -| MarkupSafe is dependency of the package --> Flask -| werkzeug is dependency of the package --> Flask -| Jinja2 is dependency of the package --> Flask -| itsdangerous is dependency of the package --> Flask -| pysetuptools is dependency of the package --> flake8 -| pysetuptools is dependency of the package --> pip -| pysetuptools is dependency of the package --> pipstat -| pysetuptools is dependency of the package --> pylint -| pysetuptools is dependency of the package --> wcwidth -+============================================================================== -+============================================================================== -| Insert packages to exception remove: -+============================================================================== - > pysetuptools - -. -. -. -+============================================================================== -| Total 5 packages removed -+============================================================================== -| Package Flask-0.10.1 removed -| Package MarkupSafe-0.23 removed -| Package itsdangerous-0.24 removed -| Package Jinja2-2.7.3 removed -| Package werkzeug-0.9.4 removed -+============================================================================== -``` - -Remove the packages with by TAG: - -``` -$ slpkg -r _SBo --tag - -Packages with name matching [ _SBo ] - -[ delete ] --> Jinja2-2.7.3-x86_64-1_SBo -[ delete ] --> MarkupSafe-0.23-x86_64-1_SBo -[ delete ] --> Pafy-0.3.72-x86_64-1_SBo -[ delete ] --> Pulse-Glass-1.02-x86_64-1_SBo -[ delete ] --> Pygments-1.6-x86_64-2_SBo -[ delete ] --> asciinema-1.1.1-x86_64-1_SBo -[ delete ] --> astroid-1.3.8-x86_64-1_SBo -[ delete ] --> autopep8-1.2-x86_64-1_SBo -[ delete ] --> blessings-1.6-x86_64-1_SBo -[ delete ] --> bpython-0.14.2-x86_64-1_SBo -[ delete ] --> cffi-1.1.2-x86_64-1_SBo -[ delete ] --> cryptography-0.8.2-x86_64-1_SBo -[ delete ] --> curtsies-0.1.19-x86_64-1_SBo -[ delete ] --> enum34-1.0.4-x86_64-1_SBo - -Removed summary -=============================================================================== -Size of removed packages 24.61 Mb. - -Are you sure to remove 14 packages [y/N]? -``` - -Remove the packages using dialog utility: - -``` -$ slpkg -r _SBo --tag --checklist -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/pythondialog.png) - -``` -$ slpkg -r Flask --check-deps --checklist -``` - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/pythondialog2.png) - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/pythondialog3.png) - -![alt text](https://gitlab.com/dslackw/images/raw/master/slpkg/pythondialog4.png) - - -Remove only the third-party packages: - -``` -$ slpkg -r python --third-party - -Packages with name matching [ python ] - -[ delete ] --> bpython-0.17.1-x86_64-1_SBo -[ delete ] --> python-certifi-2018.11.29-x86_64-1_SBo -[ delete ] --> python-chardet-3.0.4-x86_64-1_SBo -[ delete ] --> python-libtmux-0.8.0-x86_64-1_SBo -[ delete ] --> python-notify2-0.3.1-x86_64-1_SBo -[ delete ] --> python-requests-2.20.1-x86_64-1_SBo -[ delete ] --> python-scandir-1.8-x86_64-1_SBo -[ delete ] --> python-urllib3-1.23-x86_64-1_SBo -[ delete ] --> python2-pythondialog-3.4.0-x86_64-1_SBo -[ delete ] --> python3-3.6.7-x86_64-1_SBo - -Removed summary -=============================================================================== -Size of removed packages 127.68 Mb. - - -+============================================================================== -| *** WARNING *** -| Before you use third-party option, be sure you have updated the package -| lists. Run the command 'slpkg update' and 'slpkg -c slack --upgrade' -+============================================================================== - -Are you sure to remove 10 packages [y/N]? -``` - -Build and install the packages that have added to the queue: - -``` -$ slpkg -q roxterm SDL2 CEGUI --add - -Add packages in queue: - -roxterm -SDL2 -CEGUI - - -$ slpkg -q roxterm --remove (or '`slpkg -q --remove`' remove all packages) - -Remove packages from queue: - -roxterm - - -$ slpkg -q list - -Packages in queue: - -SDL2 -CEGUI - - -$ slpkg -q build (build only packages from queue) - -$ slpkg -q install (install packages from queue) - -$ slpkg -q build-install (build and install) -``` - -Add or remove packages in blacklist file manually from the '`/etc/slpkg/blacklist`' file or with the following options: - -``` -$ slpkg -b live555 speex faac --add - -Add packages in blacklist: - -live555 -speex -faac - - -$ slpkg -b speex --remove (or 'slpkg -b --remove' remove all packages) - -Remove packages from blacklist: - -speex - - -$ slpkg -b list - -Packages in blacklist: - -live555 -faac - - -``` - -Print a package description: - -``` -$ slpkg -p alien vlc --color=green - -vlc (multimedia player for various audio and video formats) - -VLC media player is a highly portable multimedia player for various -audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, ...) -as well as DVDs, VCDs, and various streaming protocols. -It can also be used as a server to stream in unicast or multicast in -IPv4 or IPv6 on a high-bandwidth network. - - -vlc home: http://www.videolan.org/vlc/ -``` - -Man page it is available for full support: - -``` -$ man slpkg -``` - - -##### Python modules - - -Slpkg has been designed it to work as cli tool however you can use some modules in your -own python code. - -Get the package dependencies from the sbo repository: - -``` ->>> from slpkg.sbo.dependency import Requires ->>> Requires(flag="").sbo("vlc") -[['libass', 'libdc1394', 'libdvbpsi', 'libmpeg2', 'libupnp', 'lua', 'portaudio', -'twolame', 'opus', 'ffmpeg', 'libwebp', 'gsm', 'opencv', 'libtar', 'libkate', ' -faac', 'libdca', 'libmatroska', 'libshout', 'speex', 'avahi', 'projectM', 'jack- -audio-connection-kit', 'libsidplay2', 'zvbi', 'faad2', 'libavc1394', 'libmodplug -', 'musepack-tools', 'vcdimager', 'dirac', 'gnome-vfs', 'live555', 'qt5', 'rtmpd -ump', 'libdvdcss', 'fluidsynth', 'schroedinger', 'libminizip', 'chromaprint', 'x -264', 'x265', 'libbluray'], ['libmp4v2'], ['libebml'], ['libdaemon'], ['ftgl'], -['libcuefile', 'libreplaygain'], ['gnome-mime-data', 'libbonobo'], ['ORBit2'], [ -'libxkbcommon', 'libinput'], ['libwacom']] -``` - -Example from binary repository: - -``` ->>> from slpkg.binary.dependency import Dependencies ->>> Dependencies(repo="slonly", black="").binary(name="Flask", flag="") -[['Jinja2', 'click', 'itsdangerous', 'werkzeug'], ['MarkupSafe']] -``` - -Grab packages from the sbo repository: - -``` ->>> from slpkg.sbo.greps import SBoGrep ->>> SBoGrep(name="").names() -... -``` - -Grab the package sources links: - -``` ->>> SBoGrep(name="jdk").source() -'http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe7 -8cdb6d0/jdk-8u152-linux-x64.tar.gz' -``` - -Grap a package requires: - -``` ->>> SBoGrep(name="Flask").requires() -['werkzeug', 'Jinja2', 'itsdangerous', 'click'] -``` - -Grap a package checksum: - -``` ->>> SBoGrep(name="Flask").checksum() -['97278dfdafda98ba7902e890b0289177'] -``` - -Grap a package description: - -``` ->>> SBoGrep(name="Flask").description() -'Flask (Microframework for Python)' -``` - -Grap the package files: - -``` ->>> SBoGrep(name="Flask").files() -'Flask.SlackBuild Flask.info README slack-desc' -``` - -Grab the packages for binary repository: - -``` ->>> from slpkg.binary.greps import repo_data ->>> from slpkg.binary.repo_init import RepoInit ->>> PACKAGES_TXT, mirror = RepoInit("slonly").fetch() ->>> name, location, size, unsize = repo_data(PACKAGES_TXT, repo="slonly", flag="") -``` - -Find a package url from the sbo repository: - -``` -from slpkg.sbo.search import sbo_search_pkg ->>> sbo_search_pkg(name="Flask") -'http://slackbuilds.org/slackbuilds/14.2/python/Flask/' -``` - -Check if the package exist in the binary repository: - -``` ->>> from slpkg.binary.search import search_pkg ->>> search_pkg(name="vlc", repo="alien") -'vlc' -``` - -Read files from the sbo repository: - -``` ->>> from slpkg.sbo.search import sbo_search_pkg ->>> from slpkg.sbo.read import ReadSBo ->>> url = sbo_search_pkg(name="libreoffice") ->>> ReadSBo(url).readme("README") -'LibreOffice is a productivity suite that is compatible with other major\noffice - suites, and available on a variety of platforms. It is free\nsoftware and there -fore free to download, use and distribute.\n\nThis script builds a Slackware pac -kage from the official binary (RPM\'s)\ndistributed by The Document Foundation. - Everything needed by the\napplication should be built statically into it, so th -ere aren\'t any\ndependencies not satisfied by a normal installation.\n\nBe sure - to look at the script for some optional things you can do when\nbuilding.\n\nNO -TE: See the separate SlackBuild script for the language packs.\n\nNOTE2: To keep - LibreOffice installed concurrently with OpenOffice, run the\n included "o -pen-libre-together.sh" script saved in the documentation\n directory of th -is package to patch the .desktop menu files.\n\nNOTE3: LibreOffice versions chan -ge quite often. If the version for which\n this script was written is no l -onger available, look for it at:\n http://download.documentfoundation.org/ -libreoffice/old/stable/\n It will go there after the next release.\n - You can also try building the newer version using:\n # VERSION="x.y.z" ./ -libreoffice.SlackBuild\n This *might* work, but upstream has a habit of ch -anging the naming\n and structure of the files, etc. between versions, so: - YMMV.\n' - ->>> ReadSBo(url).slackbuild("libreoffice", ".SlackBuild") -... - ->>> ReadSBo(url).info("libreoffice", ".info") -'PRGNAM="libreoffice"\nVERSION="5.4.3"\nHOMEPAGE="http://www.libreoffice.org"\nD -OWNLOAD="http://download.documentfoundation.org/libreoffice/stable/5.4.3/rpm/x86 -/LibreOffice_5.4.3_Linux_x86_rpm.tar.gz"\nMD5SUM="bada10945a979537ff42268462fc8b -de"\nDOWNLOAD_x86_64="http://download.documentfoundation.org/libreoffice/stable/ -5.4.3/rpm/x86_64/LibreOffice_5.4.3_Linux_x86-64_rpm.tar.gz"\nMD5SUM_x86_64="4b0b -46a6d2df74a1446837ba76af07fd"\nREQUIRES="jdk"\nMAINTAINER="Willy Sudiarto Raharj -o"\nEMAIL="willysr@slackbuilds.org"\n' - - ->>> ReadSBo(url).doinst("doinst.sh") -'if [ -x /usr/bin/update-desktop-database ]; then\n /usr/bin/update-desktop-dat -abase -q usr/share/applications\nfi\n\nif [ -x /usr/bin/update-mime-database ]; -then\n /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1\nfi\n\nif [ --x /usr/bin/gtk-update-icon-cache ]; then\n for theme in gnome locolor hicolor -; do\n if [ -e usr/share/icons/$theme/icon-theme.cache ]; then\n /usr/b -in/gtk-update-icon-cache -f usr/share/icons/$theme >/dev/null 2>&1\n fi\n do -ne\nfi\' -``` - -Get the Slackware version: - -``` ->>> from slpkg.slack.slack_version import slack_ver ->>> slack_ver() -'14.2' -``` - -Find a Slackware package: - -``` ->>> from slpkg.pkg.find import find_package ->>> find_package(find_pkg="vlc", directory="/var/log/packages/") -['vlc-2.2.6-x86_64-1alien'] -``` - -Check for the installed packages: - -``` ->>> from slpkg.pkg.installed import GetFromInstalled ->>> GetFromInstalled(package="ffmpeg").name() -'ffmpeg' ->>> GetFromInstalled(package="ffmpeg").version() -'3.2.4' -``` - -##### Copyright - -- Copyright 2014-2018 © Dimitris Zlatanidis -- Slackware® is a Registered Trademark of Patrick Volkerding. -- Linux is a Registered Trademark of Linus Torvalds. diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index b4f7ce56..00000000 --- a/INSTALL.md +++ /dev/null @@ -1,23 +0,0 @@ -### Installation - - -##### Python & OS Support - -Slpkg works with Python versions 3.7+ . - -Slpkg works on Slackware distribution and possibly in some Slackware based -distribution like SalixOS, Slackel etc. - - -##### Install slpkg - -There are mainly 2 ways: - -1. Suggested method, download latest slpkg version from: - '`https://gitlab.com/dslackw/slpkg/releases`' - Untar or unzip the archive, change directory in '`slpkg-`' - and run '`./install.sh`'. - slpkg auto-installed as Slackware package (root privileges are required). - -2. Download binary package from '`https://sourceforge.net/projects/slpkg/files/binary/`' - and use Slackware command '`upgradepkg --install-new `' \ No newline at end of file diff --git a/ISSUES b/ISSUES deleted file mode 100644 index 4ae2021a..00000000 --- a/ISSUES +++ /dev/null @@ -1,3 +0,0 @@ -Please report issues: - -https://gitlab.com/dslackw/slpkg/issues diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES deleted file mode 100644 index 68789eb2..00000000 --- a/KNOWN_ISSUES +++ /dev/null @@ -1 +0,0 @@ -Known issues: diff --git a/LICENSE b/LICENSE deleted file mode 100644 index e06c3e15..00000000 --- a/LICENSE +++ /dev/null @@ -1,622 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..903514ed --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Dimitris Zlatanidis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.rst b/README.rst index 8d3053e5..8bee51c5 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,8 @@ *********** -slpkg 4.0.2 +slpkg 4.1.0 *********** -Slpkg is a powerful software package manager that installs, updates, and removes packages on +Slpkg is a software package manager that installs, updates, and removes packages on `Slackware `_ based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. @@ -11,12 +11,6 @@ Slpkg works in accordance with the standards of the organization `SlackBuilds.or to build packages. Also uses the Slackware Linux instructions for installation, upgrading or removing packages. -What makes slpkg distinguish from the other tools; The user-friendliness it's a primary -target as well as easy to understand and use, also uses colours to highlight packages and -display warning messages, etc. - -Look in the `EXAMPLES.md `_ file to explore some examples. - Install ------- @@ -26,9 +20,9 @@ Install from the official third party `SBo repository + $ slpkg install $ slpkg --help Copyright --------- -Copyright 2014-2022 © Dimitris Zlatanidis. - -Slackware® is a Registered Trademark of Patrick Volkerding. - -Linux is a Registered Trademark of Linus Torvalds. +- Copyright 2014-2022 © Dimitris Zlatanidis. +- Slackware® is a Registered Trademark of Patrick Volkerding. +- Linux is a Registered Trademark of Linus Torvalds. diff --git a/REPOSITORIES.md b/REPOSITORIES.md deleted file mode 100644 index f174c58e..00000000 --- a/REPOSITORIES.md +++ /dev/null @@ -1,56 +0,0 @@ -## This file was created to explain some peculiarities of repositories used by the slpkg. - - -*NOTE: For more informations, refer directly to the repositories* - - -## Default repositories: - -For the -current users who they use the sbo repository: - SlackBuilds.org (sbo) FAQ(15): - Slackware current is not supported, but as a general rule, the scripts - should work on it as well. - -Rworkman's (rlw) repository use dependencies where displayed in a central site - '`http://rlworkman.net/pkgs/`' and only those. Unfortunately there is no fixed reference - dependencies in the file PACKAGES.TXT. You can make changes in '`/etc/slpkg/rlworkman.deps`' - file. - -Conraid's (conrad) repository must be used only from Slackware64 current users and it has no - reference dependencies. - -Slackel.gr (slackl) repository must be used only from Slackware{x86, x86_64} -current users. - -MSB (msb) repository has one ChangeLog.txt file for three sub-repositories {1.14, 1.16, latest}. - So if you have updated the list of packages with the version 1.14 and you want to switch to - version 1.16 you must run '`slpkg upgrade`' instead of '`slpkg update`'. MSB (msb) repository - has no reference to the dependencies. Similarly apply and for the repository Cinnamon (csb) - but with the different versions. Both repositories Mate and Cinnamon support Slackware -current - x86_64 but not x86. - -Slonly repository don't support -current for x86 arch. - -Alien's ktown (ktown), Alien's multilib (multi), Slacke E17 and E18, slack-n-free, csb, - mles and Alien's restricted repository has no reference dependencies. - -IMPORTANT: For Alien's (Eric Hameleers) repositories (alien, multi and ktown) should run - '`slpkg upgrade`' instant '`slpkg update`', if you want to spend from -stable in -current or - not, because there is no different file '`ChangeLog.txt`' for each version. - - -## Custom repositories: - -There is the possibility of adding the repository directly from the user enough to address - the '`PACKAGES.TXT`' files and '`CHECKSUMS.md5`' at least. If not is there file '`ChangeLog.txt`' - will get warning messages that the '`ChangeLog.txt`' file can not be read but not worry, the process - is completed normally have each time you run the command '`slpkg update`' the package lists for such - a repository will be recreated from start automatically. - -Sometimes you may experience some problems with these repositories such as the not correctly - resolve dependencies, and this may happen some specificities separate list which unfortunately - can not be calculated, good is the report these problems. - - -## Slackware ARM repositories: - -Slackware ARM users will must use only two repositories at the moment slack and sbo. diff --git a/THANKS b/THANKS deleted file mode 100644 index 9c1816a3..00000000 --- a/THANKS +++ /dev/null @@ -1,26 +0,0 @@ -I want to Thank: - -Dave Reese - https://github.com/wvragga - - For your interest in the project and the small changes in the code. - -Willy Sudiarto Raharjo - https://github.com/willysr - - For the interesting and valuable advice around the systems of Slackware - and SBo packages. - -Kostas Nikiforakis - Tester - - For the tests in his system. - -LinuxQuestions.org - http://www.linuxquestions.org - - In all members of the community of Slackware forum linuxquestions.org. - -OSarena - http://osarena.net/ - - Many thanks to OSarena website for reporting: - http://osarena.net/slpkg-dnamikos-kai-pio-filikos-package-manager-gia-slackware-kai-paragoges-dianomes - - -Special Thanks at Brenton Earl and Thomas Szteliga for their continuous references. diff --git a/bin/__init__.py b/bin/__init__.py deleted file mode 100644 index 1b592e2e..00000000 --- a/bin/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# [ bin ] directory diff --git a/bin/slpkg b/bin/slpkg index 93bd0158..86d68ec4 100755 --- a/bin/slpkg +++ b/bin/slpkg @@ -1,44 +1,12 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# slpkg file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -""" - _ _ - ___| |_ __ | | ____ _ -/ __| | '_ \| |/ / _` | -\__ \ | |_) | < (_| | -|___/_| .__/|_|\_\__, | - |_| |___/ - -Slpkg is a user-friendly package manager for Slackware installations -""" from slpkg.main import main -from slpkg.superuser import s_user, virtual_env + if __name__ == "__main__": try: - s_user() - virtual_env() main() except KeyboardInterrupt as err: raise SystemExit(err) diff --git a/clean.py b/clean.py deleted file mode 100755 index 3f2f4f0c..00000000 --- a/clean.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# clean.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import shutil - - -class Clean: - """Clean all data like man page, log files, PACKAGES.TXT and - configuration files. This is useful if "slpkg" installed via - "pip" because pip uninstalls only Python packages and script - and not data. So if uninstall with "# pip uninstall slpkg" after - run "# python clean.py" to remove all data and configuration files. - NOTE: Run this script as root.""" - def __init__(self): - self.files = [ - "/usr/man/man8/slpkg.8.gz", - "/etc/bash_completion.d/slpkg.bash-completion", - "/etc/fish/completions/slpkg.fish" - ] - - self.dirs = [ - "/etc/slpkg/", - "/var/log/slpkg/", - "/var/lib/slpkg/", - "/tmp/slpkg/" - ] - - def start(self): - for f in self.files: - - if os.path.isfile(f): - print(f"Remove file --> {f}") - os.remove(f) - - for d in self.dirs: - - if os.path.exists(d): - print(f"Remove directory --> {d}") - shutil.rmtree(d) - - -if __name__ == "__main__": - clean = Clean() - clean.start() diff --git a/conf/blacklist b/conf/blacklist deleted file mode 100644 index 8615a8d1..00000000 --- a/conf/blacklist +++ /dev/null @@ -1,35 +0,0 @@ -# List of blacklist packages: -# -# blacklist file is part of slpkg. -# -# ---------------------------------------------------------------------------- -# This is the blacklist file. Each package listed here may not be -# installed be upgraded be find or deleted. -# NOTE: The settings here affect all repositories. -# -# To blacklist the package 'wicd-1.7.2.4-x86_64-4.txz' the line will be: -# wicd -# -# To blacklist packages that start with name add * the end of the name: -# kernel* -# -# -# Sometimes the automatic kernel update creates problems because you -# may need to file intervention 'lilo'. The slpkg automatically detects -# if the core has been upgraded and running 'lilo'. If you want to avoid -# any problems uncomment the lines below. -# ---------------------------------------------------------------------------- -# -# kernel-firmware -# kernel-generic -# kernel-generic-smp -# kernel-headers -# kernel-huge -# kernel-huge-smp -# kernel-modules -# kernel-modules-smp -# kernel-source -# -# -# aaa_elflibs should NOT be blacklisted! -# diff --git a/conf/custom-repositories b/conf/custom-repositories deleted file mode 100644 index f8e64118..00000000 --- a/conf/custom-repositories +++ /dev/null @@ -1,32 +0,0 @@ -# List File Repositories: -# -# custom-repositories file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# This file is used to read, write and remove custom repositories by -# the user. The repositories will be added here should have a different -# name from existing repositories and the default. Also the URL must have -# contained the PACKAGES.TXT, CHECKSUMS.md5 and optional ChangeLog.txt files. -# ---------------------------------------------------------------------------- -# -# NAME URL diff --git a/conf/default-repositories b/conf/default-repositories deleted file mode 100644 index 5457fb22..00000000 --- a/conf/default-repositories +++ /dev/null @@ -1,53 +0,0 @@ -# List File Repositories: -# -# default-repositories file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# This file provide the URLs from repositories. Change only the URL -# if necessary finishing with "/". For local repository start with -# "file:///" avoid end path with "/". Do NOT change the name of the -# repository. -# -# Default repositories names: -# sbo, slack, rlw, alien, slacky, conrad, slonly, ktown, multi, slacke, salix, -# slackl, rested, msb, csb, connos, mles -# NOTE: Slackware repository (slack) served from file slackware-mirros -# ----------------------------------------------------------------------------- -# -# NAME URL - sbo http://slackbuilds.org/slackbuilds/ - rlw http://slackware.uk/people/rlworkman/ - alien http://bear.alienbase.nl/mirrors/people/alien/sbrepos/ - slacky http://repository.slacky.eu/ - conrad http://slack.conraid.net/repository/slackware64-current/ - slonly https://slackonly.com/pub/packages/ - ktown http://alien.slackbook.org/ktown/ - multi http://bear.alienbase.nl/mirrors/people/alien/multilib/ - slacke http://ngc891.blogdns.net/pub/ - salix http://download.salixos.org/ - slackl http://www.slackel.gr/repo/ - rested http://bear.alienbase.nl/mirrors/people/alien/restricted_slackbuilds/ - msb http://slackware.org.uk/msb/ - csb http://slackware.uk/csb/ - connos https://connochaetos.org/slack-n-free/ - mles http://slackware.uk/microlinux/ diff --git a/conf/pkg_security b/conf/pkg_security deleted file mode 100644 index 8d8fd09b..00000000 --- a/conf/pkg_security +++ /dev/null @@ -1,34 +0,0 @@ -# Security file: -# -# pkg_security file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# For some reasons some packages need extra management and attention before -# build, install or upgrade. So this list of packages will produce one warning -# message before action. -# You can add the packages you that believe need attention or please mention -# to me in the email dslackw@gmail.com -# ---------------------------------------------------------------------------- -# -nvidia-kernel -nvidia-driver diff --git a/conf/repositories.conf b/conf/repositories.conf deleted file mode 100644 index 81c47fc0..00000000 --- a/conf/repositories.conf +++ /dev/null @@ -1,59 +0,0 @@ -# Repositories configuration file for slpkg -# -# repositories.conf file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# conrad (Conraid's) repository must used from Slackware64 current. -# ktown (Alien"s ktown: 4.14.3 and latest) repository. Default ktown{latest}. -# slacke (Enlightenment: E17 and E18) repository. Default slacke{18}. -# msb (Mate: 1.14, 1.16, 1,18, latest) repository. Default msb{1.18} -# mles (Microlinux: desktop, extras, server) repository. Default mles{desktop} -# -# Slackware ARM users will must use only two repositories at the moment slack and sbo. -# -# Slpkg uses by default slack (Slackware) and sbo (SlackBuilds.org) repositories. -# Read the REPOSITORIES file for more instructions. -# -# -# KEEP FILE CLEAN AND UNCOMMENT ONLY REPOSITORIES -# Uncomment (remove the '#' character) to choose repositories: -# Do NOT change the name of the repository. -# ---------------------------------------------------------------------------- -[REPOSITORIES] -slack -sbo -# alien -# rlw -# slacky -# conrad -# slonly -# ktown{latest} -# multi -# slacke{18} -# salix -# slackl -# rested -# msb{1.18} -# csb -# connos -# mles{desktop} diff --git a/conf/rlworkman.deps b/conf/rlworkman.deps deleted file mode 100644 index 45f88cbe..00000000 --- a/conf/rlworkman.deps +++ /dev/null @@ -1,35 +0,0 @@ -# Rworkman's dependencies: -# -# rlworkman.deps file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# Some notes about package dependencies (all deps are also found here): -# Rworkman's repository dependencies as shown in the central page -# http://rlworkman.net/pkgs/ -# ---------------------------------------------------------------------------- -# -# PACKAGE: DEPENDENCIES -abiword: wv -claws-mail: libetpan -inkscape: lxml numpy BeautifulSoup -xfburn: libburn libisofs diff --git a/conf/slackware-mirrors b/conf/slackware-mirrors deleted file mode 100644 index 255e2263..00000000 --- a/conf/slackware-mirrors +++ /dev/null @@ -1,138 +0,0 @@ -# List of Slackware Mirrors copy from: -# http://mirrors.slackware.com/mirrorlist/ -# -# slackware-mirrors file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# Slpkg uses the central mirror "http://mirrors.slackware.com/slackware/" -# to find the nearest one. If however for some reason this troublesome -# please uncomment (remove the '#' character) only one mirror from -# the list available below. You can also add a new mirror in the list -# below. Be careful with the template. -# ---------------------------------------------------------------------------- -# -# -# st Updated: Sun Feb 6 15:54:02 UTC 2022 -# -# Available https mirrors: -# -# ar https://mirrors.eze.sysarmy.com/slackware/ -# ar https://slackware.zero.com.ar/slackware/ -# au https://slackware.mirror.digitalpacific.com.au/ -# au https://syd.mirror.rackspace.com/slackware/ -# bg https://mirror.telepoint.bg/slackware/ -# bg https://mirrors.linux-bulgaria.org/slackware/ -# bg https://mirrors.netix.net/slackware/ -# br https://slackjeff.com.br/slackware/ -# ca https://mirror.csclub.uwaterloo.ca/slackware/ -# ca https://mirror.its.dal.ca/slackware/ -# cn https://mirrors.bfsu.edu.cn/slackware/ -# cr https://mirrors.ucr.ac.cr/slackware/ -# de https://ftp6.gwdg.de/pub/linux/slackware/ -# de https://linux.rz.rub.de/slackware/ -# de https://mirror.de.leaseweb.net/slackware/ -# de https://mirror.netcologne.de/slackware/ -# dk https://mirrors.dotsrc.org/slackware/ -# ec https://mirror.cedia.org.ec/slackware/ -# gb https://lon.mirror.rackspace.com/slackware/ -# gb https://mirror.bytemark.co.uk/slackware/ -# gb https://www.mirrorservice.org/sites/ftp.slackware.com/pub/slackware/ -# gr https://ftp.cc.uoc.gr/mirrors/linux/slackware/ -# hk https://hkg.mirror.rackspace.com/slackware/ -# hkg https://mirror-hk.koddos.net/slackware/ -# hu https://quantum-mirror.hu/mirrors/pub/slackware/ -# id https://iso.ukdw.ac.id/slackware/ -# id https://repo.ukdw.ac.id/slackware/ -# its https://slackware.mirror.garr.it/slackware/ -# lt https://mirrors.atviras.lt/slackware/ -# md https://mirror.ihost.md/slackware/ -# nc https://mirror.lagoon.nc/slackware/ -# nl https://ftp.nluug.nl/os/Linux/distr/slackware/ -# nl https://mirror.koddos.net/slackware/ -# nl https://mirror.nl.leaseweb.net/slackware/ -# pl https://ftp.slackware.pl/pub/slackware/ -# pl https://sunsite.icm.edu.pl/pub/Linux/slackware/ -# pt https://ftp.rnl.tecnico.ulisboa.pt/pub/slackware/ -# ro https://mirrors.nxthost.com/slackware/ -# rub https://mirror.yandex.ru/slackware/ -# sa https://mirror.lyrahosting.com/slackware/ -# se https://ftp.acc.umu.se/mirror/slackware.com/ -# se https://ftpmirror.infania.net/slackware/ -# sk https://mirror.wheel.sk/slackware/ -# tw https://ftp.yzu.edu.tw/Linux/Slackware/ -# ua https://ifconfig.com.ua/slackware/ -# ua https://mirrors.nix.org.ua/linux/slackware/ -# us https://dfw.mirror.rackspace.com/slackware/ -# us https://ftp.ussg.indiana.edu/linux/slackware/ -# ussg https://mirror.cs.princeton.edu/pub/mirrors/slackware/ -# ussg https://mirror.slackbuilds.org/slackware/ -# ussg https://mirrors.kernel.org/slackware/ -# ussg https://mirrors.syringanetworks.net/slackware/ -# ussg https://mirrors.xmission.com/slackware/ -# ussg https://plug-mirror.rcac.purdue.edu/slackware/ -# ussg https://slackware.absolutehosting.net/pub/slackware/ -# -# -# Available http mirrors: -# -# au http://ftp.cc.swin.edu.au/slackware/ -# au http://ftp.swin.edu.au/slackware/ -# au http://mirror.as24220.net/pub/slackware/slackware64-14.2/ -# au http://mirror.internode.on.net/pub/slackware/ -# bg http://mirrors.slackware.bg/slackware/ -# bg http://mirrors.unixsol.org/slackware/ -# bg http://slackware.telecoms.bg/slackware/ -# br http://ftp.slackware-brasil.com.br/ -# br http://linorg.usp.br/slackware/ -# bytemark http://mirror.datacenter.by/pub/slackware/ -# cz http://ftp.linux.cz/pub/linux/slackware/ -# de http://download.dlackware.com/slackware/ -# de http://ftp.tu-chemnitz.de/pub/linux/slackware/ -# de http://mirrors.nav.ro/slackware/ -# fr http://nephtys.lip6.fr/pub/linux/distributions/slackware/ -# fr http://nephtys.lip6.fr/pub/linux/distributions/slackware/ -# fr http://slackware.mirrors.ovh.net/ftp.slackware.com/ -# gb http://slackware.uk/slackware/ -# gr http://ftp.ntua.gr/pub/linux/slackware/ -# hr http://mirror.slackware.hr/slackware/ -# jp http://ftp.nara.wide.ad.jp/pub/Linux/slackware/ -# jp http://ftp.riken.jp/Linux/slackware/ -# lt http://slackware.laukas.lt -# mc http://slackware.qontinuum.space/slackware/ -# nl http://bear.alienbase.nl/mirrors/slackware/ -# nz http://ftp.slackware.org.nz/slackware/ -# ph http://mirror.rise.ph/slackware/ -# plug http://mirror.onet.pl/pub/mirrors/slackware/ -# ru http://slackware.tsu.ru/slackware/ -# sg http://download.nus.edu.sg/mirror/slackware/ -# tr http://ftp.linux.org.tr/slackware/ -# tw http://ftp.isu.edu.tw/pub/Linux/Slackware/ -# ua http://slackware.ip-connect.info/ -# usp http://ftp.slackware.com/pub/slackware/ -# usp http://mirror.lug.udel.edu/pub/slackware/ -# usp http://slackblog.com/slackware/ -# usp http://slackware.cs.utah.edu/pub/slackware/ -# usp http://slackware.mirrors.tds.net/pub/slackware/ -# za http://ftp.is.co.za/mirror/ftp.slackware.com/pub/ -# za http://ftp.wa.co.za/pub/slackware/ -# za http://slackware.mirror.ac.za/ diff --git a/conf/slpkg.bash-completion b/conf/slpkg.bash-completion deleted file mode 100644 index 1ad16262..00000000 --- a/conf/slpkg.bash-completion +++ /dev/null @@ -1,14 +0,0 @@ -_slpkg() -{ - local cur - cur=${COMP_WORDS[COMP_CWORD]} - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W "--autobuild --blacklist --queue --list --check --sync --tracking --print --network --FIND --find --installpkg --upgradepkg --removepkg --display" -- $cur )) - - else - _filedir - fi -} - -complete -F _slpkg slpkg diff --git a/conf/slpkg.conf b/conf/slpkg.conf deleted file mode 100644 index 4cec339a..00000000 --- a/conf/slpkg.conf +++ /dev/null @@ -1,129 +0,0 @@ -# Configuration file for slpkg -# -# slpkg.conf file is part of slpkg. -# -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. -# -# Slpkg is a user-friendly package manager for Slackware installations. -# -# https://gitlab.com/dslackw/slpkg -# -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# END OF LEGAL NOTICE -# -# ---------------------------------------------------------------------------- -# Set Slackware release "stable" or "current". Default is "stable". -RELEASE=stable - -# Set Slackware version if it's necessary. Default is "off". -SLACKWARE_VERSION=off - -# Set computer architecture if it's necessary. Default is "off". -COMP_ARCH=off - -# Build directory for repository "sbo" slackbuilds.org. In this -# directory downloaded sources and scripts for building. -# Default is "/tmp/slpkg/build/". -BUILD_PATH=/tmp/slpkg/build/ - -# Alternative source downloads for the "sbo" repository. Default is "off". -SBOSRCARCH=off -SBOSRCARCH_LINK=http://slackware.uk/sbosrcarch/by-name/ - -# Download directory for others repositories that use binaries files -# for installation. Default is "/tmp/slpkg/packages/" -PACKAGES=/tmp/slpkg/packages/ - -# Download directory for Slackware patches file. -PATCHES=/tmp/slpkg/patches/ - -# If CHECKMD5 is "on" the system will check all downloaded -# sources and Slackware packages. Default is "on". -CHECKMD5=on - -# Delete all downloaded files if DEL_ALL is "on". Default is "on". -DEL_ALL=on - -# Delete build directory after each process if DEL_BUILD is "on". -# Settings for the repository "sbo" slackbuilds.org. Default is "off". -DEL_BUILD=off - -# Keep build log file if SBO_BUILD_LOG is "on". Default is "on". -SBO_BUILD_LOG=off - -# Speed up SlackBuild scripts. If "on" slpkg auto detect the numbers of -# processor and apply into MAKEFLAGS variable. Some SlackBuilds fail if -# MAKEFLAGS is declared or the number of processors (-j ) is greater -# than one. Default if "off". -MAKEFLAGS=off - -# Define default answer to slpkg questions. -# Choose "y" if you do not want to questions. Default is "n". -DEFAULT_ANSWER=n - -# Define default answer for the removal of dependencies. -# Choose "y" if you do not want to question. Default is "n". -REMOVE_DEPS_ANSWER=n - -# If you want build UNSUPPORTED or UNTESTED packages choose "y". -# Settings for the repository "sbo" slackbuilds.org. Default is "n". -SKIP_UNST=n - -# If you want to disable automatic resovle dependencies choose "off". -# Default is "on". -RSL_DEPS=on - -# Delete package dependencies if DEL_DEPS is on. -# You must be careful if you enable this option because it can remove -# packages related to distribution. Default is "off". -DEL_DEPS=off - -# Use colors for highlighting. Choose "on" or "off". Default is "on". -USE_COLORS=on - -# Downloader utility. Four options are supported "wget", "aria2c", -# "curl" and "http" (HTTPie). Default is "wget". -DOWNDER=wget - -# Downloader [OPTION]. Pass downloader options, for curl use "-L -o" as -# using to download in specific directory and support any redirects -# such as from sourceforge repository. aria2c recommended "--allow-overwrite" -# options by default. Http recommended "-d -c -o" options by default. -# Default for wget is "-c -N". -DOWNDER_OPTIONS=-c -N - -# Update slackpkg ChangeLog.txt file if SLACKPKG_LOG is "on". -# Automatically synchronizes the command "slackpkg update" with -# "slpkg -c slack --upgrade". Default is "on". -SLACKPKG_LOG=on - -# This option applies only to the distribution upgrade and repository -# slack (Slackware). If you want to update only packages that are installed -# choose "on". Default is "off". -# NOTE: This option is not recommended at "on" because it can leave out -# packages required for distribution. -ONLY_INSTALLED=off - -# Register a text editor that uses the slpkg in a few options. -# Default is "nano". -EDITOR=nano - -# If you don't want slpkg downgrade packages, setting this variable to "on". -# Warning: Possible failure building packages or running applications after -# install. Default is "off". -NOT_DOWNGRADE=off - -# If you are working under a proxy server you need to set -# your proxy server here. Default is null. -HTTP_PROXY= diff --git a/conf/slpkg.fish b/conf/slpkg.fish deleted file mode 100644 index 3bcaa55f..00000000 --- a/conf/slpkg.fish +++ /dev/null @@ -1,18 +0,0 @@ -complete --command slpkg --long-option help --short-option h --description 'Print this help message and exit.' -complete --command slpkg --long-option version --short-option v --description 'Print program version and exit.' -complete --command slpkg --long-option autobuild --short-option a --description 'Auto build SBo packages. If you already have downloaded the script and the source code you can build a new package with this command.' -complete --command slpkg --long-option blacklist --short-option b --description 'Manage packages in the blacklist. Add or remove packages and print the list. Each package is added here will not be accessible by the program.' -complete --command slpkg --long-option queue --short-option q --description 'Manage SBo packages in the queue. Add or remove and print the list build-install of packages. Build and then install the packages from the queue.' -complete --command slpkg --long-option config --short-option g --description 'Configuration file management. Print the configuration file or edit.' -complete --command slpkg --long-option list --short-option l --description 'Print a list of all available packages repository index or print only packages installed on the system.' -complete --command slpkg --long-option check --short-option c --description 'Check view and install updated packages from repositories.' -complete --command slpkg --long-option sync --short-option s --description 'Sync packages. Install packages directly from remote repositories with all dependencies.' -complete --command slpkg --long-option tracking --short-option t --description 'Tracking package dependencies and print package dependenies tree with highlight if packages is installed.' -complete --command slpkg --long-option print --short-option p --description 'Print description of a package directly from the repository and change color text.' -complete --command slpkg --long-option network --short-option n --description 'View a standard of SBo page in terminal and manage multiple options like reading downloading building installation etc.' -complete --command slpkg --long-option find --short-option f --description 'Find and print installed packages reporting the size and the sum.' -complete --command slpkg --long-option FIND --short-option F --description 'Find packages from repositories and search at each enabled repository and prints results.' -complete --command slpkg --long-option installpkg --short-option i --description 'Installs single or multiple Slackware binary packages.' -complete --command slpkg --long-option upgradepkg --short-option u --description 'Upgrade single or multiple Slackware binary packages from a older to a newer one.' -complete --command slpkg --long-option removepkg --short-option r --description 'Removes a previously installed Slackware binary packages.' -complete --command slpkg --long-option display --short-option d --description 'Display the installed packages contents and file list.' diff --git a/config/slpkg.json b/config/slpkg.json new file mode 100644 index 00000000..a69ed454 --- /dev/null +++ b/config/slpkg.json @@ -0,0 +1,22 @@ +{ + "os_arch": "x86_64", + "tmp_path": "/tmp", + "tmp_slpkg": "/tmp/slpkg", + "build_path": "/tmp/slpkg/build", + "lib_path": "/var/lib/slpkg", + "log_path": "/var/log/slpkg", + "db_path": "/var/lib/slpkg/database", + "sbo_repo_path": "/var/lib/slpkg/repository", + "log_packages": "/var/log/packages", + "database": "database.slpkg", + "repo_version": "15.0", + "sbo_url": "http://slackbuilds.org/slackbuilds/15.0", + "sbo_txt": "SLACKBUILDS.TXT", + "tar_suffix": ".tar.gz", + "pkg_suffix": ".tgz", + "repo_tag": "_SBo", + "installpkg": "upgradepkg --install-new", + "removepkg": "removepkg", + "colors": "on", + "wget_options": "-c -N" +} diff --git a/install.sh b/install.sh index 7851ab93..fc542700 100755 --- a/install.sh +++ b/install.sh @@ -33,7 +33,6 @@ VERSION=${VERSION:-$(__version)} # Installation script. # With this script allows you to install the slpkg as a Slackware package binary file. -# Support wget download. ARCHIVES="$PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION.zip v$VERSION.tar.gz v$VERSION.zip \ $PRGNAM-$VERSION.tar.bz2" cd .. diff --git a/logo.txt b/logo.txt deleted file mode 100644 index 582d7fbe..00000000 --- a/logo.txt +++ /dev/null @@ -1,10 +0,0 @@ - __ __ - ____| |__ ___ | | ______ __ - / | | ' \ | | / / ` | - / ___| | __ \| |/ / __ | - \ \ | |__) | < (__| | - \____ \ | /| |\ \ | - | / | .___/ |__| \__\___, | - |____/__| | | | - |__| |_____/ - ____________ Slackware package manager _________________________ diff --git a/man/slpkg.1 b/man/slpkg.1 new file mode 100644 index 00000000..5b5c395c --- /dev/null +++ b/man/slpkg.1 @@ -0,0 +1,67 @@ +.TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.0" dslackw +.SH NAME +.P +slpkg - [OPTIONS] [packages] +.SH SYNAPSES +.P +slpkg [-h|-v] [update] [build] [install] [remove] [clean-logs] --yes --resolve-off +.SH DESCRIPTION +.P +Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. +.P +Slpkg works in accordance with the standards of the organization SlackBuilds.org to build packages. Also uses the Slackware Linux instructions for installation, upgrading or removing packages. +.SH OPTIONS +.P +-h |--help +.RS +Show help informatio and exit. +.RE +.P +-v |--version +.RS +Print version and exit. +.RE +.P +update +.RS +Updates the data packages and the database. +.RE +.P +build +.RS +Builds and creates only the scripts and puts them in the /tmp directory. +.RE +.P +install +.RS +Builds, creates and installs the packages in the correct order and also logs the packages with dependencies to use for removal. +.RE +.P +remove +.RS +Removes packages with dependencies if the packages was installed with slpkg install method. +.RE +.P +clean-logs +.RS +Purge logs of dependencies. +.RE +.P +--yes +.RS +Answer Yes to all questions. +.RE +.P +--resolve-off +.RS +Turns off dependency resolving. +.RE +.SH CONFIGURATION FILE +.P +Configuration file in the /etc/slpkg/slpkg.json file. +.SH REPORT BUGS +.P +Please report any found to https://gitlab.com/dslackw/slpkg/-/issues. +.SH AUTHORS +.P +Dimitris Zlatanidis diff --git a/man/slpkg.8 b/man/slpkg.8 deleted file mode 100644 index 64f36cf8..00000000 --- a/man/slpkg.8 +++ /dev/null @@ -1,402 +0,0 @@ -.\" -*- nroff -*- -.\" Copyright (C) 2014-2022 Dimitris Zlatanidis -.\" -.\" This program is free software: you can redistribute it and/or modify -.\" it under the terms of the GNU General Public License as published by -.\" the Free Software Foundation, either version 3 of the License, or -.\" (at your option) any later version. -.\" -.\" This program is distributed in the hope that it will be useful, -.\" but WITHOUT ANY WARRANTY; without even the implied warranty of -.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -.\" GNU General Public License for more details. -.\" -.TH Slpkg "11" "05" 2022" "slpkg" -.SH NAME -Slpkg is a user-friendly package manager for Slackware installations -.SH SYNOPSIS -slpkg [COMMANDS|OPTIONS] {repository|package...} - -.SH DESCRIPTION -Slpkg is a powerful software package manager that installs, updates, and -removes packages on Slackware based systems. It automatically computes -dependencies and figures out what things should occur to install packages. -Slpkg makes it easier to maintain groups of machines without having to -manually update. - -.SH GLOBAL OPTIONS -\fB\-v\fP, \fB\-\-version\fP -.PP -Print the version of program and exit. - -.SH COMMANDS -.PP -The following commands are available. - -.SS update, create and update packages list -\fBslpkg\fP \fBupdate\fP, \fB--repos=[repositories...]\fP -.PP -Used to re-synchronize the package lists and create some important files. -This command must run every new repository is added or new updates is available. -.PP -Additional options: -.PP -\fB--repos=[repositories...]\fP : Update at specifically repositories separate by comma. - -.SS upgrade, recreate packages list -\fBslpkg\fP \fBupgrade\fP, \fB--repos=[repositories...]\fP -.PP -It is sometimes useful to create all of the base file from the beginning so this -command delete all the package lists and recreated. -.PP -Additional options: -.PP -\fB--repos=[repositories...]\fP : Update at specifically repositories separate by comma. - -.SS repo-add, add custom repository -\fBslpkg\fP \fBrepo-add\fP <\fIrepository name\fP> <\fIURL\fP> -.PP -Add custom binary repository. The repositories will be added to this command should -contain at least the files "PACKAGES.TXT" and "CHECKSUMS.md5" and optional file -"ChangeLog.txt" used to control changes. - -.SS repo-remove, remove custom repository -\fBslpkg\fP \fBrepo-remove\fP <\fIrepository\fP> -.PP -Remove custom repository by name. - -.SS repo-enable, enable or disable repositories -\fBslpkg\fP \fBrepo-enable\fP -.PP -Enable or disable repositories via dialog utility (require python3-pythondialog) - -.SS repo-list, repositories list -\fBslpkg\fP \fBrepo-list\fP -.PP -Lists all enabled or disabled repositories. - -.SS repo-info, repository information -\fBslpkg\fP \fBrepo-info\fP <\fIrepository\fP> -.PP -View repository information. - -.SS update slpkg, update slpkg itself -\fBslpkg\fP \fBupdate\fP \fBslpkg\fP -.PP -You can check for new versions and update slpkg itself. - -.SS health, health check installed packages -\fBslpkg\fP \fBhealth\fP, \fB--silent\fP -.PP -Check file list from packages of files installed. -.PP -Additional options: -.PP -\fB--silent\fP : Print only errors. - -.SS deps-status, print dependencies status -\fBslpkg\fP \fBdeps-status\fP \fB--graph=[type]\fP -.PP -Print dependencies status used by packages. Prerequisite packages have been installed -with the option "# slpkg -s ". -.PP -Additional options: -.PP -\fB--graph=[type]\fP : Drawing dependencies diagram. (example for type: ascii, image.x11, image.png etc. Require pygraphviz) -.PP -\fB--tree\fP : Switch to tree view. - -.SS new-config, manage .new configuration files -\fBslpkg\fP \fBnew-config\fP -.PP -This command searches for .new configuration files in /etc/ path and ask the user what todo with those -files. - -.SS clean-tmp, clean the tmp/ directory -\fBslpkg\fP \fBclean-tmp\fP -.PP -Clean the /tmp/slpkg/ directory from downloaded packages and sources. - -.SH OPTIONS -.PP -The following arguments are available. - -.SS -a, --autobuild, auto build packages -\fBslpkg\fP \fB-a\fP <\fIscript.tar.gz\fP> <\fIsources\fP> -.PP -If you already have download the script and source with this argument you can build Slackware -package from source quickly and easy. Slpkg will grab checksum from the .info file to make control -if he does not agree with the versions you will get the wrong message. If you want switch off -checksum from the configuration file. - -.SS -b, --blacklist, add, remove, view packages in blacklist -\fBslpkg\fP \fB-b\fP <\fIname of packages\fP> \fB--add\fP, \fB--remove\fP, \fBlist\fP -.PP -Add, remove or listed packages from blacklist file. The settings here affect -all repositories. Remove all packages from blacklist use argument like -"# slpkg -b --remove". Use asterisk "*" to match pagkages like "# slpkg -b -py* --add", this add all installed packages with starts string "py" or "# slpkg -b -multi:*multilib* --add", this add all multilib packages from repository "multi". - -.SS -q, --queue, add, remove, view packages in queue -\fBslpkg\fP \fB-q\fP <\fInames of packages\fP> \fB--add\fP, \fB--remove\fP -.TP -\fBslpkg\fP \fB-q\fP \fBlist\fP, \fBbuild\fP, \fBinstall\fP, \fBbuild-install\fP -.PP -Add, remove and listed sbo packages from queue. This argument is very useful if you want -to build and install multiple packages together. Note the correct order if there are -dependencies. If you want to remove all the packages from the list run "# slpkg -q --remove". -(these arguments only working for the sbo repository) -Build or install or build and install packages are queued. - -.SS -g, --config, configuration file management -\fBslpkg\fP \fB-g\fP \fBprint\fP, \fBedit\fP, \fBreset\fP -.PP -Print, reset or edit configuration file. - -.SS -l, --list, list of installed packages -\fBslpkg\fP \fB-l\fP <\fIrepository\fP>, \fB--index\fP, \fB--installed\fP, \fB--name\fP -.PP -Print a list of all available packages from repository, index or print only packages installed on the -system. Support command "grep" like "# slpkg -l sbo | grep python". -.PP -Additional options: -.PP -\fB--index\fP : Count packages per page. -.PP -\fB--installed\fP : Highlight installed packages. -.PP -\fB--name\fP : Print package name only. - -.SS -c, --check, check if your packages is up to date -\fBslpkg\fP \fB-c\fP <\fIrepository\fP> \fB--upgrade\fP \fB--rebuild\fP \fB--skip=[packages...]\fP, \fB--checklist\fP -.PP -Check your packages if up to date. Slackware patches repository works independently of the -others i.e not need before updating the list of packages by choosing "# slpkg update", works -directly with the official repository and so always you can have updated your system. -.PP -Additional options: -.PP -\fB-c \fP : Check ChangeLog.txt files for changes. -.PP -\fB--upgrade\fP : Check and install packages for upgrade. -.PP -\fB--rebuild\fP : Rebuild packages from sbo repository. -.PP -\fB--skip=[packages...]\fP : Skip packages from upgrade separate by comma like "# slpkg -c sbo --skip=jdk,pep8,pip" (See REGEX). -.PP -\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog) - -.SS -s, --sync, synchronize packages, download, build and install package with all dependencies -\fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fInames of packages\fP>, \fB--case-ins\fP, \fB--patches\fP -.PP -Installs or upgrade packages from the repositories with automatically resolving all -dependencies of the package. -.PP -Additional options: -.PP -\fB--rebuild\fP : Rebuild packages from sbo repository. -.PP -\fB--reinstall\fP : Reinstall binary packages from repositories. -.PP -\fB--case-ins\fP : Search package name in repository with case insensitive. -.PP -\fB--patches\fP : Switch to patches\ directory, only for slack repository. - -.SS -t, --tracking, tracking dependencies -\fBslpkg\fP \fB-t\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--check-deps\fP, \fB--graph=[type]\fP \fB--case-ins\fP -.PP -Tracking all dependencies of that package. -The sequence shown is that you must follow to correctly install package. -Also you can check if the installed package has all the required dependencies. -.PP -Additional options: -.PP -\fB--check-deps\fP : Check if installed packages used by other packages. -.PP -\fB--graph=[type]\fP : Drawing dependencies graph. (example for type: ascii, image.x11, image.png etc. Require pygraphviz) -.PP -\fB--case-ins\fP : Search package name in repository with case insensitive. - -.SS -p, --desc, print packages description -\fBslpkg\fP \fB-p\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--color=[]\fP -.PP -Print package description from remote repository with color. Available colors: -red, green, yellow, cyan, grey -.PP -Additional options: -.PP -\fB--color=[]\fP : Change color print. - -.SS -F, --FIND, find packages from repositories -\fBslpkg\fP \fB-F\fP <\fInames of packages\fP>, \fI--case-ins\fP -.PP -Find packages from all repositories are enabled. Useful command to find all available -packages per repository. -.PP -Additional options: -.PP -\fB--case-ins\fP : Search package name in repository with case insensitive. - -.SS -f, --find, find installed packages -\fBslpkg\fP \fB-f\fP <\fInames of packages\fP>, \fB--case-ins\fP, \fB--third-party\fP -.PP -Find installed packages with view total file size. -Example you can view all installed sbo packages like "# slpkg -f _SBo". -.PP -Additional options: -.PP -\fB--case-ins\fP : Search package name with case insensitive. -.PP -\fB--third-party\fP : View all the third-party packages. - -.SS -n, --network, view SBo packages -\fBslpkg\fP \fB-n\fP <\fIname of package\fP>, <\fI[pattern], --checklist\fP>, \fB--case-ins\fP -.PP -View complete slackbuilds.org site in your terminal. Read file, download, -build or install etc. Use "--checklist" additional option to load all repository, example: -"# slpkg -n --checklist". -.PP -Additional options: -.PP -\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog) -.PP -\fB--case-ins\fP : Search package name in repository with case insensitive. - -.SS -i, --installpkg, install Slackware binary packages -\fBslpkg\fP \fB-i\fP \fB[--warn, --md5sum, --root /otherroot, --infobox, --menu, --terse, ---ask, --priority ADD|REC|OPT|SKP, --tagfile /somedir/tagfile]\fP <\fIpackages.t?z\fP> -.PP -Installs single binary packages designed for use with the Slackware Linux -distribution into your system. More information please read "man installpkg". - -.SS -u, --upgradepkg, install-upgrade Slackware binary packages with new -\fBslpkg\fP \fB-u\fP \fB[--dry-run, --install-new, --reinstall, --verbose]\fP <\fIpackages.t?z\fP> -.PP -Normally upgrade only upgrades packages that are already installed on the system, -and will skip any packages that do not already have a version installed. -More information please read "man upgradepkg". - -.SS -r, --removepkg, remove previously installed Slackware binary packages -\fBslpkg\fP \fB-r\fP \fB[-copy, -keep, -preserve, -warn]\fP <\fInames of packages\fP>, \fB--deps\fP, \fB--check-deps\fP, \fB--tag\fP, \fB--checklist\fP, \fB--third-party\fP -.PP -Removes a previously installed Slackware package, while writing a progress report to -the standard output. A package may be specified either by the full package name (as -you'd see listed in /var/log/packages/), or by the base package name. If installed -packages with command "# slpkg -s " then write a file in /var/log/slpkg/dep/ -with all dependencies and it allows you can remove them all together. -More information please read "man removepkg". -.PP -Additional options: -.PP -\fB--deps\fP : Remove packages with dependencies. -.PP -\fB--check-deps\fP : Check if installed packages used by other packages. -.PP -\fB--tag\fP : Remove packages with by TAG. -.PP -\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog) -.PP -\fB--third-party\fP : Remove all the third-party packages. (Be sure update the package lists before) - -.SS -d, --display, display the installed packages contents and file list -\fBslpkg\fP \fB-d\fP <\fInames of packages\fP> -.PP -Display the installed Slackware packages contents and file list with all descriptions. - -.SH HELP OPTION -Specifying the help option displays help for slpkg itself, or a -command. -.br -For example: - \fBslpkg \-\-help\fP - display help for slpkg - -.SH DEFAULT REPOSITORIES - slackware.com = "slack" - SlackBuilds.org = "sbo" - Alien's = "alien" - slacky.eu = "slacky" - rworkman's = "rlw" - Conraid's = "conrad" - slackonly.com = "slonly" - Alien's ktown = "ktown{latest}" - Alien's multilib = "multi" - Slacke E17 and E18 = "slacke{18}" - SalixOS = "salix" - Slackel.gr = "slackel" - Alien's restricted = "rested" - MATE Desktop Environment = "msb{1.18}" - Cinnamon Desktop Environment = "csb" - Connochaetos slack-n-free = "connos" - Microlinux mles = "mles" - - Default enable repository is "slack" and "sbo". - Add or remove default repository in configuration file "/etc/slpkg/repositories.conf". - Read REPOSITORIES file for particularities. - -.SH COLORS - red, green, yellow, cyan, grey - -.SH REGEX - For options "--skip=" and blacklist file. - - All packages starts with: "string*" - All packages ends with: "*string" - All packages include: "*string*" - -.SH PASS VARIABLES TO THE SCRIPT - If you want to pass variables to the script exported as: - Usage: - - Example: - "# export FFMPEG_X264=yes FFMPEG_LAME=yes" - -.SH FILES -/etc/slpkg/slpkg.conf - General configuration of slpkg - -/etc/slpkg/repositories.conf - Configuration file for repositories - -/etc/slpkg/blacklist - List of packages to skip - -/etc/slpkg/slackware-mirrors - List of Slackware Mirrors - -/etc/slpkg/default-repositories - List of default repositories - -/etc/slpkg/custom-repositories - List of custom repositories - -/etc/slpkg/rlworkman.deps - Rworkman's repository dependencies - -/etc/slpkg/pkg_security - List of packages for security reasons - -/var/log/slpkg - ChangeLog.txt repositories files - SlackBuilds logs and dependencies files - -/var/lib/slpkg - PACKAGES.TXT files - SLACKBUILDS.TXT files - CHECKSUMS.md5 files - FILELIST.TXT files - -/tmp/slpkg - Slpkg temporary downloaded files and build packages - - -.SH AUTHOR -Dimitris Zlatanidis -.SH HOMEPAGE -https://dslackw.gitlab.io/slpkg/ -.SH COPYRIGHT -Copyright \(co 2014-2022 Dimitris Zlatanidis - -.SH SEE ALSO -installpkg(8), upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8), explodepkg(8), -makepkg(8). diff --git a/man/slpkg.html b/man/slpkg.html deleted file mode 100644 index f8294d6a..00000000 --- a/man/slpkg.html +++ /dev/null @@ -1,726 +0,0 @@ - - - - - - - - - -Slpkg - - - - -

Slpkg

- -NAME
-SYNOPSIS
-DESCRIPTION
-GLOBAL OPTIONS
-COMMANDS
-OPTIONS
-HELP OPTION
-DEFAULT REPOSITORIES
-COLORS
-REGEX
-PASS VARIABLES TO THE SCRIPT
-FILES
-AUTHOR
-HOMEPAGE
-COPYRIGHT
-SEE ALSO
- -
- - -

NAME - -

- - -

Slpkg is a -user-friendly package manager for Slackware -installations

- -

SYNOPSIS - -

- - -

slpkg -[COMMANDS|OPTIONS] {repository|package...}

- -

DESCRIPTION - -

- - -

Slpkg is a -powerful software package manager that installs, updates, -and removes packages on Slackware based systems. It -automatically computes dependencies and figures out what -things should occur to install packages. Slpkg makes it -easier to maintain groups of machines without having to -manually update.

- -

GLOBAL OPTIONS - -

- - - -

−v, -−−version

- -

Print the -version of program and exit.

- -

COMMANDS - -

- - -

The following -commands are available.

- -

update, -create and update packages list
-slpkg update
, ---repos=[repositories...]

- -

Used to -re-synchronize the package lists and create some important -files. This command must run every new repository is added -or new updates is available.

- -

Additional -options:

- - -

--repos=[repositories...] -: Update at specifically repositories separate by comma.

- -

upgrade, -recreate packages list
-slpkg upgrade
, ---repos=[repositories...]

- -

It is sometimes -useful to create all of the base file from the beginning so -this command delete all the package lists and recreated.

- -

Additional -options:

- - -

--repos=[repositories...] -: Update at specifically repositories separate by comma.

- -

repo-add, -add custom repository
-slpkg repo-add
<repository name> -<URL>

- -

Add custom -binary repository. The repositories will be added to this -command should contain at least the files -"PACKAGES.TXT" and "CHECKSUMS.md5" and -optional file "ChangeLog.txt" used to control -changes.

- - -

repo-remove, -remove custom repository
-slpkg repo-remove
<repository>

- -

Remove custom -repository by name.

- - -

repo-enable, -enable or disable repositories
-slpkg repo-enable

- -

Enable or -disable repositories via dialog utility (require -python3-pythondialog)

- -

repo-list, -repositories list
-slpkg repo-list

- -

Lists all -enabled or disabled repositories.

- -

repo-info, -repository information
-slpkg repo-info
<repository>

- -

View repository -information.

- -

update -slpkg, update slpkg itself
-slpkg update slpkg

- -

You can check -for new versions and update slpkg itself.

- -

health, -health check installed packages
-slpkg health
, --silent

- -

Check file list -from packages of files installed.

- -

Additional -options:

- - -

--silent -: Print only errors.

- - -

deps-status, -print dependencies status
-slpkg deps-status --graph=[type]

- -

Print -dependencies status used by packages. Prerequisite packages -have been installed with the option "# slpkg -s -<repository> <packages>".

- -

Additional -options:

- - -

--graph=[type] -: Drawing dependencies diagram. (example for type: ascii, -image.x11, image.png etc. Require pygraphviz)

- -

--tree : -Switch to tree view.

- -

new-config, -manage .new configuration files
-slpkg new-config

- -

This command -searches for .new configuration files in /etc/ path and ask -the user what todo with those files.

- -

clean-tmp, -clean the tmp/ directory
-slpkg clean-tmp

- -

Clean the -/tmp/slpkg/ directory from downloaded packages and -sources.

- -

OPTIONS - -

- - -

The following -arguments are available.

- -

-a, ---autobuild, auto build packages
-slpkg -a
<script.tar.gz> -<sources>

- -

If you already -have download the script and source with this argument you -can build Slackware package from source quickly and easy. -Slpkg will grab checksum from the .info file to make control -if he does not agree with the versions you will get the -wrong message. If you want switch off checksum from the -configuration file.

- -

-b, ---blacklist, add, remove, view packages in blacklist
-slpkg -b
<name of packages> --add, ---remove, list

- -

Add, remove or -listed packages from blacklist file. The settings here -affect all repositories. Remove all packages from blacklist -use argument like "# slpkg -b --remove". Use -asterisk "*" to match pagkages like "# slpkg --b py* --add", this add all installed packages with -starts string "py" or "# slpkg -b -multi:*multilib* --add", this add all multilib packages -from repository "multi".

- -

-q, --queue, -add, remove, view packages in queue
-slpkg -q
<names of packages> --add, ---remove
-slpkg -q list
, build, install, -build-install

- -

Add, remove and -listed sbo packages from queue. This argument is very useful -if you want to build and install multiple packages together. -Note the correct order if there are dependencies. If you -want to remove all the packages from the list run "# -slpkg -q --remove". (these arguments only working for -the sbo repository) Build or install or build and install -packages are queued.

- -

-g, ---config, configuration file management
-slpkg -g print
, edit, reset

- -

Print, reset or -edit configuration file.

- -

-l, --list, -list of installed packages
-slpkg -l
<repository>, --index, ---installed, --name

- -

Print a list of -all available packages from repository, index or print only -packages installed on the system. Support command -"grep" like "# slpkg -l sbo | grep -python".

- -

Additional -options:

- -

--index -: Count packages per page.

- - -

--installed -: Highlight installed packages.

- -

--name : -Print package name only.

- -

-c, --check, -check if your packages is up to date
-slpkg -c
<repository> --upgrade ---rebuild --skip=[packages...], --checklist

- -

Check your -packages if up to date. Slackware patches repository works -independently of the others i.e not need before updating the -list of packages by choosing "# slpkg update", -works directly with the official repository and so always -you can have updated your system.

- -

Additional -options:

- -

-c : -Check ChangeLog.txt files for changes.

- - -

--upgrade -: Check and install packages for upgrade.

- - -

--rebuild -: Rebuild packages from sbo repository.

- - -

--skip=[packages...] -: Skip packages from upgrade separate by comma like "# -slpkg -c sbo --skip=jdk,pep8,pip" (See REGEX).

- - -

--checklist -: Enable dialog utility and checklist option. (Require -python3-pythondialog)

- -

-s, --sync, -synchronize packages, download, build and install package -with all dependencies
-slpkg -s
<repository> <names of -packages>, --case-ins, ---patches

- -

Installs or -upgrade packages from the repositories with automatically -resolving all dependencies of the package.

- -

Additional -options:

- - -

--rebuild -: Rebuild packages from sbo repository.

- - -

--reinstall -: Reinstall binary packages from repositories.

- - -

--case-ins -: Search package name in repository with case -insensitive.

- - -

--patches -: Switch to patches directory, only for slack -repository.

- -

-t, ---tracking, tracking dependencies
-slpkg -t
<repository> <name of -package>, --check-deps, --graph=[type] ---case-ins

- -

Tracking all -dependencies of that package. The sequence shown is that you -must follow to correctly install package. Also you can check -if the installed package has all the required -dependencies.

- -

Additional -options:

- - -

--check-deps -: Check if installed packages used by other packages.

- - -

--graph=[type] -: Drawing dependencies graph. (example for type: ascii, -image.x11, image.png etc. Require pygraphviz)

- - -

--case-ins -: Search package name in repository with case -insensitive.

- -

-p, --desc, -print packages description
-slpkg -p
<repository> <name of -package>, --color=[]

- -

Print package -description from remote repository with color. Available -colors: red, green, yellow, cyan, grey

- -

Additional -options:

- - -

--color=[] -: Change color print.

- -

-F, --FIND, -find packages from repositories
-slpkg -F
<names of packages>, ---case-ins

- -

Find packages -from all repositories are enabled. Useful command to find -all available packages per repository.

- -

Additional -options:

- - -

--case-ins -: Search package name in repository with case -insensitive.

- -

-f, --find, -find installed packages
-slpkg -f
<names of packages>, ---case-ins, --third-party

- -

Find installed -packages with view total file size. Example you can view all -installed sbo packages like "# slpkg -f _SBo".

- -

Additional -options:

- - -

--case-ins -: Search package name with case insensitive.

- - -

--third-party -: View all the third-party packages.

- -

-n, ---network, view SBo packages
-slpkg -n
<name of package>, -<[pattern], --checklist>, --case-ins

- -

View complete -slackbuilds.org site in your terminal. Read file, download, -build or install etc. Use "--checklist" additional -option to load all repository, example: "# slpkg -n ---checklist".

- -

Additional -options:

- - -

--checklist -: Enable dialog utility and checklist option. (Require -python3-pythondialog)

- - -

--case-ins -: Search package name in repository with case -insensitive.

- -

-i, ---installpkg, install Slackware binary packages
-slpkg -i [--warn, --md5sum, --root /otherroot, --infobox, ---menu, --terse, --ask, --priority ADD|REC|OPT|SKP, ---tagfile /somedir/tagfile]
-<packages.t?z>

- -

Installs single -binary packages designed for use with the Slackware Linux -distribution into your system. More information please read -"man installpkg".

- -

-u, ---upgradepkg, install-upgrade Slackware binary packages with -new
-slpkg -u [--dry-run, --install-new, --reinstall, ---verbose]
<packages.t?z>

- -

Normally -upgrade only upgrades packages that are already installed on -the system, and will skip any packages that do not already -have a version installed. More information please read -"man upgradepkg".

- -

-r, ---removepkg, remove previously installed Slackware binary -packages
-slpkg -r [-copy, -keep, -preserve, -warn]
<names -of packages>, --deps, --check-deps, ---tag, --checklist, --third-party

- -

Removes a -previously installed Slackware package, while writing a -progress report to the standard output. A package may be -specified either by the full package name (as you’d -see listed in /var/log/packages/), or by the base package -name. If installed packages with command "# slpkg -s -<repo> <packages>" then write a file in -/var/log/slpkg/dep/ with all dependencies and it allows you -can remove them all together. More information please read -"man removepkg".

- -

Additional -options:

- -

--deps : -Remove packages with dependencies.

- - -

--check-deps -: Check if installed packages used by other packages.

- -

--tag : -Remove packages with by TAG.

- - -

--checklist -: Enable dialog utility and checklist option. (Require -python3-pythondialog)

- - -

--third-party -: Remove all the third-party packages. (Be sure update the -package lists before)

- -

-d, ---display, display the installed packages contents and file -list
-slpkg -d
<names of packages>

- -

Display the -installed Slackware packages contents and file list with all -descriptions.

- -

HELP OPTION - -

- - -

Specifying the -help option displays help for slpkg itself, or a command. -
-For example:
-slpkg −−help
- display help for slpkg

- -

DEFAULT REPOSITORIES - -

- - -

slackware.com = -"slack"
-SlackBuilds.org = "sbo"
-Alien’s = "alien"
-slacky.eu = "slacky"
-rworkman’s = "rlw"
-Conraid’s = "conrad"
-slackonly.com = "slonly"
-Alien’s ktown = "ktown{latest}"
-Alien’s multilib = "multi"
-Slacke E17 and E18 = "slacke{18}"
-SalixOS = "salix"
-Slackel.gr = "slackel"
-Alien’s restricted = "rested"
-MATE Desktop Environment = "msb{1.18}"
-Cinnamon Desktop Environment = "csb"
-Connochaetos slack-n-free = "connos"
-Microlinux mles = "mles"

- -

Default enable -repository is "slack" and "sbo".
-Add or remove default repository in configuration file -"/etc/slpkg/repositories.conf".
-Read REPOSITORIES file for particularities.

- -

COLORS - -

- - -

red, green, -yellow, cyan, grey

- -

REGEX - -

- - -

For options -"--skip=" and blacklist file.

- -

All packages -starts with: "string*"
-All packages ends with: "*string"
-All packages include: "*string*"

- -

PASS VARIABLES TO THE SCRIPT - -

- - -

If you want to -pass variables to the script exported as:
-Usage: <NAME_VARIABLE=value>

- -

Example:
-"# export FFMPEG_X264=yes FFMPEG_LAME=yes"

- -

FILES - -

- - - -

/etc/slpkg/slpkg.conf -
-General configuration of slpkg

- - -

/etc/slpkg/repositories.conf -
-Configuration file for repositories

- - -

/etc/slpkg/blacklist -
-List of packages to skip

- - -

/etc/slpkg/slackware-mirrors -
-List of Slackware Mirrors

- - -

/etc/slpkg/default-repositories -
-List of default repositories

- - -

/etc/slpkg/custom-repositories -
-List of custom repositories

- - -

/etc/slpkg/rlworkman.deps -
-Rworkman’s repository dependencies

- - -

/etc/slpkg/pkg_security -
-List of packages for security reasons

- -

/var/log/slpkg -
-ChangeLog.txt repositories files
-SlackBuilds logs and dependencies files

- -

/var/lib/slpkg -
-PACKAGES.TXT files
-SLACKBUILDS.TXT files
-CHECKSUMS.md5 files
-FILELIST.TXT files

- -

/tmp/slpkg
-Slpkg temporary downloaded files and build packages

- -

AUTHOR - -

- - -

Dimitris -Zlatanidis <d.zlatanidis@gmail.com>

- -

HOMEPAGE - -

- - - -

https://dslackw.gitlab.io/slpkg/

- -

COPYRIGHT - -

- - -

Copyright -© 2014-2022 Dimitris Zlatanidis

- -

SEE ALSO - -

- - -

installpkg(8), -upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8), -explodepkg(8), makepkg(8).

-
- - diff --git a/requirements.txt b/requirements.txt index d4f26dd4..e6e2854c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,2 @@ -# Slackware Linux (based) -# Python 3.7+ -# GNU wget -# GNU coreutils -# sqlite3 -# progress -# SQLAlchemy -# -# [OPTIONAL] -# aria2 (alternative downloader) -# curl (alternative downloader) -# httpie (alternative downloader) -# pygraphviz >= 1.3.1 (drawing dependencies diagram) -# perl 5 language and graph-easy >= 0.75 (drawing dependencies ascii diagram) -# python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility) -# flake8 >= 3.5.0 +SQLAlchemy>=1.4.36 + diff --git a/setup.py b/setup.py index 52fbaa27..3e532880 100755 --- a/setup.py +++ b/setup.py @@ -1,102 +1,47 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# setup.py file is part of slpkg. -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +from setuptools import setup +from slpkg.metadata import Metadata -import os -import time -from slpkg.__metadata__ import MetaData as _meta_ - -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - -docs_requires = [] -tests_requires = [] -install_requires = [ - "SQLAlchemy>=1.4.36", - "progress>=1.6" -] -optional_requires = [ - "pythondialog>=3.5.1", - "pygraphviz>=1.3.1" -] - -# Non-Python/non-PyPI optional dependencies: -# ascii diagram: graph-easy (available from SBo repository) - - -def print_logo(): - """print slpkg logo""" - logo_fname = os.path.join(os.path.dirname(__file__), 'logo.txt') - with open(logo_fname, 'rb') as f: - logo = f.read().decode('utf-8') - print(logo) - time.sleep(0.5) - - -print_logo() +install_requires = ['SQLAlchemy>=1.4.36'] setup( - name="slpkg", - packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack", - "slpkg/binary", "slpkg/models"], - scripts=["bin/slpkg"], - version=_meta_.__version__, - description="Package manager for Slackware installations", - long_description=open("README.rst").read(), - keywords=["slackware", "slpkg", "upgrade", "install", "remove", - "view", "slackpkg", "tool", "build"], - author=_meta_.__author__, - author_email=_meta_.__email__, - url="https://dslackw.gitlab.io/slpkg/", - package_data={"": ["LICENSE", "README.rst", "CHANGELOG"]}, - data_files=[("man/man8", ["man/slpkg.8"]), - ("/etc/bash_completion.d", ["conf/slpkg.bash-completion"]), - ("/etc/fish/completions", ["conf/slpkg.fish"]), - ("/var/lib/slpkg/database", [])], + name='slpkg', + packages=['slpkg', 'slpkg/models', 'slpkg/views'], + scripts=['bin/slpkg'], + version=Metadata.version, + description='Package manager for Slackware installations', + long_description=open('README.rst').read(), + keywords=['slackware', 'slpkg', 'update', 'build', 'install', 'remove', + 'slackpkg', 'tool'], + author=Metadata.author, + author_email=Metadata.email, + url='https://dslackw.gitlab.io/slpkg/', + package_data={'': ['LICENSE', 'README.rst', 'ChangeLog.txt']}, + data_files=[('/etc/slpkg', ['config/slpkg.json']), + ('/var/lib/slpkg/database', []), + ('/var/lib/slpkg/repository', []), + ('/tmp/slpkg/build', [])], install_requires=install_requires, - extras_require={ - "optional": optional_requires, - "docs": docs_requires, - "tests": tests_requires, - }, classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Operating System :: POSIX :: Linux", - "Operating System :: Unix", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Unix Shell", - "Topic :: Software Development :: Build Tools", - "Topic :: System :: Archiving :: Packaging", - "Topic :: System :: Software Distribution", - "Topic :: System :: Installation/Setup", - "Topic :: System :: Systems Administration", - "Topic :: System :: Software Distribution", - "Topic :: Utilities"], - python_requires=">=3.7" + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX :: Linux', + 'Operating System :: Unix', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Unix Shell', + 'Topic :: Software Development :: Build Tools', + 'Topic :: System :: Archiving :: Packaging', + 'Topic :: System :: Software Distribution', + 'Topic :: System :: Installation/Setup', + 'Topic :: System :: Systems Administration', + 'Topic :: System :: Software Distribution', + 'Topic :: Utilities'], + python_requires='>=3.9' ) diff --git a/slackbuild/README b/slackbuild/README index ef10d2b7..b4665f85 100644 --- a/slackbuild/README +++ b/slackbuild/README @@ -3,10 +3,3 @@ and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. - -Optional dependencies: - python3-pythondialog (for dialog box interface) - pygraphviz (for drawing dependencies diagram) - graph-easy (for drawing ascii dependencies diagram) - aria2 (alternative downloader) - httpie (alternative downloader) diff --git a/slackbuild/doinst.sh b/slackbuild/doinst.sh index 8eb6acd1..095e2b41 100644 --- a/slackbuild/doinst.sh +++ b/slackbuild/doinst.sh @@ -8,12 +8,8 @@ config() { fi } -CONFIGS="slpkg.conf repositories.conf blacklist slackware-mirrors default-repositories \ - custom-repositories rlworkman.deps pkg_security" -for file in $CONFIGS; do - config etc/slpkg/${file}.new -done +config etc/slpkg/slpkg.json.new if [ -x /usr/bin/update-desktop-database ]; then /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 -fi \ No newline at end of file +fi diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index f54decc8..5126f27d 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -90,26 +90,18 @@ find -L . \ python3 setup.py install --root=$PKG +mkdir -p $PKG/usr/sbin +cp bin/slpkg $PKG/usr/sbin/slpkg + find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true # install configuration files mkdir -p $PKG/etc/slpkg -CONFIGS="slpkg.conf repositories.conf blacklist slackware-mirrors \ - default-repositories custom-repositories rlworkman.deps pkg_security" -for file in $CONFIGS; do - install -D -m0644 conf/$file $PKG/etc/slpkg/${file}.new -done - -# keep original configuration file for reset -cp -p conf/slpkg.conf $PKG/etc/slpkg/slpkg.conf.orig - -find $PKG/usr/man -type f -exec gzip -9 {} \; -for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done +install -D -m0644 conf/slpkg.json $PKG/etc/slpkg/slpkg.json.new mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION -cp -a README.rst ChangeLog.txt LICENSE ISSUES KNOWN_ISSUES REPOSITORIES.md \ - INSTALL.md requirements.txt $PKG/usr/doc/$PRGNAM-$VERSION +cp -a README.rst ChangeLog.txt LICENSE requirements.txt $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mkdir -p $PKG/install diff --git a/slpkg/__init__.py b/slpkg/__init__.py index ee3482ea..2ec89ad5 100644 --- a/slpkg/__init__.py +++ b/slpkg/__init__.py @@ -1 +1 @@ -# [ slpkg ] directory +from main import Flags diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py deleted file mode 100644 index d2a2bebf..00000000 --- a/slpkg/__metadata__.py +++ /dev/null @@ -1,255 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# __metadata__.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - - -# Slackware distribution branches -STABLE = "stable" -CURRENT = "current" - - -def remove_repositories(repositories, default_repositories): - """Removes no default repositories - """ - for repo in repositories: - if repo in default_repositories: - yield repo - - -def update_repositories(repositories, conf_path): - """Upadate with user custom repositories - """ - repo_file = f"{conf_path}custom-repositories" - if os.path.isfile(repo_file): - f = open(repo_file, "r") - repositories_list = f.read() - f.close() - for line in repositories_list.splitlines(): - line = line.lstrip() - if line and not line.startswith("#"): - repositories.append(line.split()[0]) - return repositories - - -def grab_sub_repo(repositories, repos): - """Grabs SUB_REPOSITORY - """ - for i, repo in enumerate(repositories): - if repos in repo: - sub = repositories[i].replace(repos, "") - repositories[i] = repos - return sub - return "" - - -def select_slack_release(slack_rel): - """Warning message if Slackware release not defined or - defined wrong - """ - if slack_rel not in [STABLE, CURRENT]: - return "FAULT" - return slack_rel - - -class MetaData: - - __all__ = "slpkg" - __author__ = "dslackw" - __version_info__ = (4, 0, 2) - __version__ = "{0}.{1}.{2}".format(*__version_info__) - __license__ = "GNU General Public License v3 (GPLv3)" - __email__ = "d.zlatanidis@gmail.com" - __maintainer__ = "Dimitris Zlatanidis (dslackw)" - __homepage__ = "https://dslackw.gitlab.io/slpkg/" - - # Default Slackware release - slack_rel = STABLE - - # Configuration path - conf_path = f"/etc/{__all__}/" - - # tmp paths - tmp = "/tmp/" - tmp_path = f"{tmp}{__all__}/" - - # Default configuration values - _conf_slpkg = { - "RELEASE": STABLE, - "SLACKWARE_VERSION": "off", - "COMP_ARCH": "off", - "REPOSITORIES": ["slack", "sbo", "rlw", "alien", - "slacky", "conrad", "slonly", - "ktown{latest}", "multi", "slacke{18}", - "salix", "slackl", "rested", "msb{1.18}", - "csb", "connos", "mles{desktop}"], - "BUILD_PATH": "/tmp/slpkg/build/", - "SBOSRCARCH": "off", - "SBOSRCARCH_LINK": "http://slackware.uk/sbosrcarch/by-name/", - "PACKAGES": "/tmp/slpkg/packages/", - "PATCHES": "/tmp/slpkg/patches/", - "CHECKMD5": "on", - "DEL_ALL": "on", - "DEL_BUILD": "off", - "SBO_BUILD_LOG": "on", - "MAKEFLAGS": "off", - "DEFAULT_ANSWER": "n", - "REMOVE_DEPS_ANSWER": "n", - "SKIP_UNST": "n", - "RSL_DEPS": "on", - "DEL_DEPS": "off", - "USE_COLORS": "on", - "DOWNDER": "wget", - "DOWNDER_OPTIONS": "-c -N", - "SLACKPKG_LOG": "on", - "ONLY_INSTALLED": "off", - "EDITOR": "nano", - "NOT_DOWNGRADE": "off", - "HTTP_PROXY": "", - } - - default_repositories = ["slack", "sbo", "rlw", "alien", "slacky", "conrad", - "slonly", "ktown", "multi", "slacke", "salix", - "slackl", "rested", "msb", "csb", "connos", "mles"] - - # reads values from the configuration file - repositories = [] - for files in ["slpkg.conf", "repositories.conf"]: - if os.path.isfile(f"{conf_path}{files}"): - f = open(f"{conf_path}{files}", "r") - conf = f.read() - f.close() - for line in conf.splitlines(): - line = line.lstrip() - if line and not line.startswith("#"): - if files == "slpkg.conf": - _conf_slpkg[line.split("=")[0]] = line.split("=")[1] - elif files == "repositories.conf": - repositories.append(line) - - # Sets values from the configuration file - slack_rel = _conf_slpkg["RELEASE"] - slackware_version = _conf_slpkg["SLACKWARE_VERSION"] - comp_arch = _conf_slpkg["COMP_ARCH"] - build_path = _conf_slpkg["BUILD_PATH"] - sbosrcarch = _conf_slpkg["SBOSRCARCH"] - sbosrcarch_link = _conf_slpkg["SBOSRCARCH_LINK"] - slpkg_tmp_packages = _conf_slpkg["PACKAGES"] - slpkg_tmp_patches = _conf_slpkg["PATCHES"] - checkmd5 = _conf_slpkg["CHECKMD5"] - del_all = _conf_slpkg["DEL_ALL"] - del_folder = _conf_slpkg["DEL_BUILD"] - sbo_build_log = _conf_slpkg["SBO_BUILD_LOG"] - makeflags = _conf_slpkg["MAKEFLAGS"] - default_answer = _conf_slpkg["DEFAULT_ANSWER"] - remove_deps_answer = _conf_slpkg["REMOVE_DEPS_ANSWER"] - skip_unst = _conf_slpkg["SKIP_UNST"] - rsl_deps = _conf_slpkg["RSL_DEPS"] - del_deps = _conf_slpkg["DEL_DEPS"] - use_colors = _conf_slpkg["USE_COLORS"] - downder = _conf_slpkg["DOWNDER"] - downder_options = _conf_slpkg["DOWNDER_OPTIONS"] - slackpkg_log = _conf_slpkg["SLACKPKG_LOG"] - only_installed = _conf_slpkg["ONLY_INSTALLED"] - editor = _conf_slpkg["EDITOR"] - not_downgrade = _conf_slpkg["NOT_DOWNGRADE"] - http_proxy = _conf_slpkg["HTTP_PROXY"] - - # SBo downloading sources path - SBo_SOURCES = build_path + "_SOURCES/" - - # Removes any gaps - repositories = [repo.strip() for repo in repositories] - - # Checks Slackware release - slack_rel = select_slack_release(slack_rel) - - # Grabs sub repositories - ktown_kde_repo = grab_sub_repo(repositories, "ktown") - slacke_sub_repo = grab_sub_repo(repositories, "slacke") - msb_sub_repo = grab_sub_repo(repositories, "msb") - mles_sub_repo = grab_sub_repo(repositories, "mles") - - # removes no default repositories - repositories = list(remove_repositories(repositories, - default_repositories)) - # adds custom repositories - update_repositories(repositories, conf_path) - - color = { - "RED": "\x1b[31m", - "GREEN": "\x1b[32m", - "YELLOW": "\x1b[33m", - "CYAN": "\x1b[36m", - "GREY": "\x1b[38;5;247m", - "ENDC": "\x1b[0m" - } - - if use_colors in ["off", "OFF"]: - color = { - "RED": "", - "GREEN": "", - "YELLOW": "", - "CYAN": "", - "GREY": "", - "ENDC": "" - } - - CHECKSUMS_link = (f"https://gitlab.com/{__author__}/{__all__}/raw/" - "master/CHECKSUMS.md5") - - # current path - try: - path = os.getcwd() + "/" - except OSError: - path = tmp_path - - # library path - lib_path = "/var/lib/slpkg/" - - # log path - log_path = "/var/log/slpkg/" - - # packages log files path - pkg_path = "/var/log/packages/" - - # slackpkg lib path - slackpkg_lib_path = "/var/lib/slackpkg/" - - # database name - db = "database/database.slpkg" - - # computer architecture - if comp_arch in ["off", "OFF"]: - arch = os.uname()[4] - else: - arch = comp_arch - - # gets sbo OUTPUT enviroment variable - try: - output = os.environ["OUTPUT"] - except KeyError: - output = tmp - if not output.endswith("/"): - output += "/" diff --git a/slpkg/arguments.py b/slpkg/arguments.py deleted file mode 100644 index c5a00e44..00000000 --- a/slpkg/arguments.py +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# arguments.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.repolist import RepoList -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.slack.slack_version import slack_ver - - -def header(): - """help header message""" - print(f"slpkg - version {_meta_.__version__} | Slackware release: " - f"{_meta_.slack_rel} - {slack_ver()}\n") - - -def options(): - """Slpkg is a user-friendly package manager for Slackware installations - -Usage: slpkg [COMMANDS|OPTIONS] {repository|package...} - - _ _ - ___| |_ __ | | ____ _ - / __| | '_ \| |/ / _` | - \__ \ | |_) | < (_| | - |___/_| .__/|_|\_\__, | - |_| |___/ - _Slackware package manager_______ - -Commands: - update, --repos=[...] Run this command to update all - the packages lists. - - upgrade, --repos=[...] Delete and recreate all packages - lists. - - repo-add [repository name] [URL] Add custom repository. - - repo-remove [repository] Remove custom repository. - - repo-enable Enable or disable default - repositories via dialog utility. - - repo-list Print a list of all the - repositories. - - repo-info [repository] Get information about a - repository. - - update slpkg Upgrade the program directly from - repository. - - health, --silent Health check installed packages. - - deps-status, --tree, --graph=[type] Print dependencies status used by - packages or drawing dependencies - diagram. - - new-config Manage .new configuration files. - - clean-tmp Clean the tmp/ directory from - downloaded packages and sources. -Optional arguments: - -h | --help Print this help message and exit. - - -v | --version Print program version and exit. - - -a | --autobuild, [script] [source...] Auto build SBo packages. - If you have already downloaded the - script and the source code you can - build a new package with this - command. - - -b | --blacklist, [package...] --add, Manage packages in the blacklist. - --remove, list Add or remove packages and print - the list. Each package is added - here will not be accessible by the - program. - - -q | --queue, [package...] --add, Manage SBo packages in the queue. - --remove, list, build, install, Add or remove and print the list - build-install of packages. Build and then - install the packages from the - queue. - - -g | --config, print, edit, reset Configuration file management. - Print, edit the configuration file - or reset in the default values. - - -l | --list, [repository], --index, Print a list of all available - --installed, --name packages from repository, index or - print only packages installed on - the system. - - -c | --check, [repository], --upgrade, Check for updated packages from - --rebuild --skip=[...], the repositories and upgrade or - --resolve-off, --checklist install with all dependencies. - - -s | --sync, [repository] [package...], Sync packages. Install packages - --rebuild, --reinstall, directly from remote repositories - --case-ins, --patches with all dependencies. - - -t | --tracking, [repository] [package], Tracking package dependencies and - --check-deps, --graph=[type], print package dependencies tree - --case-ins with highlight if packages is - installed. Also check if - dependencies used or drawing - dependencies diagram. - - -p | --desc, [repository] [package], Print description of a package - --color=[] directly from the repository and - change color text. - - -n | --network, [package], --checklist, View a standard of SBo page in - --case-ins terminal and manage multiple - options like reading, downloading, - building, installation, etc. - - -F | --FIND, [package...], --case-ins Find packages from each enabled - repository and view results. - - -f | --find, [package...], --case-ins, Find and print installed packages - --third-party reporting the size and the sum. - - -i | --installpkg, [options] [package...] Installs single or multiple *.tgz - options=[--warn, --md5sum, --root, (or .tbz, .tlz, .txz) Slackware - --infobox, --menu, --terse, --ask, binary packages designed for use - --priority, --tagfile] with the Slackware Linux - distribution onto your system. - - -u | --upgradepkg, [options] [package...] Upgrade single or multiple - options=[--dry-run, --install-new, Slackware binary packages from - --reinstall, --verbose] an older version to a newer one. - - -r | --removepkg, [options] [package...], Removes a previously installed - --deps, --check-deps, --tag, Slackware binary packages, - --checklist, --third-party while writing a progress report - options=[-warn, -preserve, -copy, to the standard output. - -keep] Use only package name. - - -d | --display, [package...] Display the contents of installed - packages and file list. - -You can read more about slpkg from manpage or see examples from readme file. -Issues: https://gitlab.com/dslackw/slpkg/issues -Homepage: https://dslackw.gitlab.io/slpkg/ -""" - header() - print(options.__doc__) - - -def usage(repo, stderr): - """Usage: slpkg [COMMANDS|OPTIONS] {repository|package...} - - Commands: - [update, --repos=[...]] - [upgrade, --repos=[...]] - [repo-add [repository name] [URL]] - [repo-remove [repository]] - [repo-enable] - [repo-list] - [repo-info [repository]] - [update [slpkg]] - [health, --silent] - [deps-status, --tree, --graph=[type]] - [new-config] - [clean-tmp] - - Optional arguments: - [-h] [-v] - [-a [script] [sources...]] - [-b [package...] --add, --remove, - [list]] - [-q [package...] --add, --remove, - [list, build, install, build-install]] - [-g [print, edit, reset]] - [-l [repository], --index, --installed, --name] - [-c [repository], --upgrade, --rebuild, --skip=[...], - --resolve-off, --checklist] - [-s [repository] [package...], --rebuild, --reinstall, - --case-ins, --patches] - [-t [repository] [package], --check-deps, --graph=[type], - --case-ins] - [-p [repository] [package], --color=[]] - [-n [SBo package], --checklist, --case-ins] - [-F [package...], --case-ins] - [-f [package...], --case-ins, --third-party] - [-i [options] [package...]] - [-u [options] [package...]] - [-r [options] [package...], --deps, --check-deps, --tag, - --checklist, --third-party] - [-d [package...]] - """ - if repo and repo not in _meta_.repositories: - error_repo = "" - all_repos = RepoList().all_repos.keys() - del RepoList().all_repos - if repo in all_repos: - error_repo = (f"slpkg: Error: Repository '{repo}' is not activated" - "\n") - else: - error_repo = (f"slpkg: Error: Repository '{repo}' does not exist" - "\n") - raise SystemExit(f"\n{error_repo}") - print(usage.__doc__) - print("For more information try 'slpkg -h, --help' or view manpage\n") - if stderr == 1: - raise SystemExit(stderr) diff --git a/slpkg/auto_pkg.py b/slpkg/auto_pkg.py deleted file mode 100644 index 8c19bcd8..00000000 --- a/slpkg/auto_pkg.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# auto_pkg.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.messages import Msg -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.manager import PackageManager - - -class AutoInstall: - """Select the Slackware command to install packages - """ - def __init__(self, packages): - self.packages = packages - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.cyan = _meta_.color["CYAN"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.commands = { - "i": "installpkg", - "u": "upgradepkg --install-new", - "r": "upgradepkg --reinstall" - } - - def select(self): - """Select Slackware command - """ - print("\nDetected Slackware binary package for installation:\n") - - for pkg in self.packages: - print(" " + pkg.split("/")[-1]) - - print() - - self.msg.template(78) - print("| Choose a Slackware command:") - self.msg.template(78) - - for com in sorted(self.commands): - print(f"| {self.red}{com}{self.endc}) {self.green}" - f"{self.commands[com]}{self.endc}") - - self.msg.template(78) - - try: - self.choice = input(" > ") - except EOFError: - raise SystemExit("\n") - - if self.choice in self.commands.keys(): - print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}" - f"{self.endc}", end="\n\n") - print(end="", flush=True) - - self.execute() - - def execute(self): - """Executes Slackware command - """ - if self.choice in self.commands.keys(): - - if self.choice == "i": - PackageManager(self.packages).install("") - - elif self.choice in ["u", "r"]: - PackageManager(self.packages).upgrade( - self.commands[self.choice][11:]) diff --git a/slpkg/binary/__init__.py b/slpkg/binary/__init__.py deleted file mode 100644 index 508f2ef0..00000000 --- a/slpkg/binary/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# [ binarys ] directory diff --git a/slpkg/binary/check.py b/slpkg/binary/check.py deleted file mode 100644 index 2d64a64c..00000000 --- a/slpkg/binary/check.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# check.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from pkg_resources import parse_version - -from slpkg.messages import Msg -from slpkg.splitting import split_package -from slpkg.upgrade_checklist import choose_upg -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - -from slpkg.binary.greps import repo_data -from slpkg.binary.repo_init import RepoInit - - -def pkg_upgrade(repo, skip, flag): - """Checking packages for upgrade - """ - msg = Msg() - msg.checking() - PACKAGES_TXT = RepoInit(repo).fetch()[0] - pkgs_for_upgrade = [] - - # name = data[0] - # location = data[1] - # size = data[2] - # unsize = data[3] - data = repo_data(PACKAGES_TXT, repo, flag="") - - for pkg in installed(): - inst_pkg = split_package(pkg) - - for name in data[0]: - - if name: # this tips because some pkg_name is empty - repo_pkg = split_package(name[:-4]) - - if (repo_pkg[0] == inst_pkg[0] and - parse_version(repo_pkg[1]) > parse_version(inst_pkg[1]) and - repo_pkg[3] >= inst_pkg[3] and - inst_pkg[0] not in skip and - repo_pkg[1] != "blacklist"): - pkgs_for_upgrade.append(repo_pkg[0]) - - msg.done() - - if "--checklist" in flag: - pkgs_for_upgrade = choose_upg(pkgs_for_upgrade) - - return pkgs_for_upgrade - - -def installed(): - """Returns all installed packages - """ - return find_package("", _meta_.pkg_path) diff --git a/slpkg/binary/dependency.py b/slpkg/binary/dependency.py deleted file mode 100644 index 3045e208..00000000 --- a/slpkg/binary/dependency.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# dependency.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import sys -from functools import lru_cache - -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.binary.greps import Requires - - -class Dependencies: - """Resolving binary dependencies - """ - def __init__(self, repo, black): - self.repo = repo - self.black = black - self.dep_results = [] - self.meta = _meta_ - - def binary(self, name, flag): - """Builds all dependencies of a package - """ - if self.meta.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag: - sys.setrecursionlimit(10000) - dependencies = [] - requires = Requires(name, self.repo).get_deps() - - if requires: - - for req in requires: - - if req and req not in self.black: - dependencies.append(req) - - self.deep_check(tuple(dependencies), tuple(flag)) - - return self.dep_results - - else: - return [] - - @lru_cache - def deep_check(self, dependencies, flag): - """Checking if dependencies are finnished - """ - if dependencies: - self.dep_results.append(dependencies) - [self.binary(dep, flag) for dep in dependencies] diff --git a/slpkg/binary/greps.py b/slpkg/binary/greps.py deleted file mode 100644 index 125560a5..00000000 --- a/slpkg/binary/greps.py +++ /dev/null @@ -1,284 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# greps.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from functools import lru_cache -from slpkg.utils import Utils -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.slack.slack_version import slack_ver - - -def repo_data(PACKAGES_TXT, repo, flag): - """Grabs data packages - """ - (name, location, size, unsize, - rname, rlocation, rsize, runsize) = ([] for i in range(8)) - - for line in PACKAGES_TXT.splitlines(): - - if line.startswith("PACKAGE NAME:"): - name.append(line[15:].strip()) - - if line.startswith("PACKAGE LOCATION:"): - location.append(line[21:].strip()) - - if line.startswith("PACKAGE SIZE (compressed):"): - size.append(line[28:-2].strip()) - - if line.startswith("PACKAGE SIZE (uncompressed):"): - unsize.append(line[30:-2].strip()) - - if repo == "slack" and "--upgrade" not in flag: - (rname, - rlocation, - rsize, - runsize - ) = slack_filter(name, location, size, unsize, flag) - - elif repo == "rlw": - (rname, - rlocation, - rsize, - runsize - ) = rlw_filter(name, location, size, unsize) - - elif repo == "alien": - (rname, - rlocation, - rsize, - runsize - ) = alien_filter(name, location, size, unsize) - - elif repo == "rested": - (rname, - rlocation, - rsize, - runsize - ) = rested_filter(name, location, size, unsize) - - elif repo == "ktown": - (rname, - rlocation, - rsize, - runsize - ) = ktown_filter(name, location, size, unsize) - - else: - rname, rlocation, rsize, runsize = name, location, size, unsize - - return [rname, rlocation, rsize, runsize] - - -def slack_filter(name, location, size, unsize, flag): - """Slackware filter seperate packages from patches/ directory - """ - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - - if "--patches" not in flag: - - for n, l, s, u in zip(name, location, size, unsize): - - if f"_slack{slack_ver()}" not in n: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - - if "--patches" in flag: - - for n, l, s, u in zip(name, location, size, unsize): - - if f"_slack{slack_ver()}" in n: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - - return [fname, flocation, fsize, funsize] - - -def rlw_filter(name, location, size, unsize): - """Filter rlw repository data - """ - arch = _meta_.arch - - if arch.startswith("i") and arch.endswith("86"): - arch = "i486" - - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - - for n, l, s, u in zip(name, location, size, unsize): - - loc = l.split("/") - - if arch == loc[-1]: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - - return [fname, flocation, fsize, funsize] - - -def alien_filter(name, location, size, unsize): - """Fix to avoid packages include in slackbuilds folder - """ - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - - for n, l, s, u in zip(name, location, size, unsize): - - if "slackbuilds" != l: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - - return [fname, flocation, fsize, funsize] - - -def rested_filter(name, location, size, unsize): - """Filter Alien"s repository data - """ - ver = slack_ver() - if _meta_.slack_rel == "current": - ver = "current" - - path_pkg = "pkg" - - if _meta_.arch == "x86_64": - path_pkg = "pkg64" - - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - - for n, l, s, u in zip(name, location, size, unsize): - - if path_pkg == l.split("/")[-2] and ver == l.split("/")[-1]: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - - return [fname, flocation, fsize, funsize] - - -def ktown_filter(name, location, size, unsize): - """Filter Alien"s ktown repository data - """ - ver = slack_ver() - - if _meta_.slack_rel == "current": - ver = "current" - - path_pkg = "x86" - - if _meta_.arch == "x86_64": - path_pkg = _meta_.arch - - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - - for n, l, s, u in zip(name, location, size, unsize): - - if (path_pkg in l and _meta_.ktown_kde_repo[1:-1] in l and - l.startswith(ver)): - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - - return [fname, flocation, fsize, funsize] - - -class Requires: - - def __init__(self, name, repo): - self.name = name - self.repo = repo - - def get_deps(self): - """Grabs package requirements from repositories - """ - if self.repo == "rlw": - - dependencies = {} - rlw_deps = Utils().read_file(_meta_.conf_path + "rlworkman.deps") - - for line in rlw_deps.splitlines(): - - if line and not line.startswith("#"): - pkgs = line.split(":") - dependencies[pkgs[0]] = pkgs[1] - - if self.name in dependencies.keys(): - return dependencies[self.name].split() - - else: - return "" - - else: - PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}" - f"{self.repo}_repo/PACKAGES.TXT") - - for line in PACKAGES_TXT.splitlines(): - - if line.startswith("PACKAGE NAME:"): - pkg_name = split_package(line[14:].strip())[0] - - if line.startswith("PACKAGE REQUIRED:"): - - if pkg_name == self.name: - - if line[18:].strip(): - return self._req_fix(line) - - @lru_cache - def _req_fix(self, line): - """Fix slacky and salix requirements because many dependencies - splitting with "," and others with "|" - """ - deps = [] - - for dep in line[18:].strip().split(","): - dep = dep.split("|") - - if self.repo == "slacky": - - if len(dep) > 1: - - for d in dep: - deps.append(d.split()[0]) - - dep = "".join(dep) - deps.append(dep.split()[0]) - - else: - - if len(dep) > 1: - - for d in dep: - deps.append(d) - - deps.append(dep[0]) - - return deps diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py deleted file mode 100644 index f60de9cc..00000000 --- a/slpkg/binary/install.py +++ /dev/null @@ -1,403 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# install.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from itertools import zip_longest -from pkg_resources import parse_version - -from slpkg.utils import Utils -from slpkg.sizes import units -from slpkg.messages import Msg -from slpkg.checksum import check_md5 -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.log_deps import write_deps -from slpkg.grep_md5 import pkg_checksum -from slpkg.remove import delete_package -from slpkg.security import pkg_security -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package -from slpkg.pkg.manager import PackageManager -from slpkg.pkg.installed import GetFromInstalled - -from slpkg.binary.greps import repo_data -from slpkg.binary.repo_init import RepoInit -from slpkg.binary.dependency import Dependencies - - -class BinaryInstall(BlackList, Utils): - """Installs binaries packages with all dependencies from - repository - """ - def __init__(self, packages, repo, flag): - super().__init__() - self.packages = packages - pkg_security(packages) - self.repo = repo - self.flag = flag - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.grey = _meta_.color["GREY"] - self.yellow = _meta_.color['YELLOW'] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.version = self.meta.slack_rel - self.tmp_path = self.meta.slpkg_tmp_packages - self.dwn, self.dep_dwn = [], [] - self.install, self.dep_install = [], [] - self.comp_sum, self.dep_comp_sum = [], [] - self.uncomp_sum, self.dep_uncomp_sum = [], [] - self.dependencies = [] - self.deps_dict = {} - self.answer = "" - self.msg.reading() - self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch() - self.data = repo_data(self.PACKAGES_TXT, self.repo, self.flag) - self.repo_pkg_names = [] - - for name in self.data[0]: - self.repo_pkg_names.append(split_package(name)[0]) - - self.blacklist = list(self.get_black()) - self.matching = False - - def start(self, is_upgrade): - """Installs packages from official Slackware distribution - """ - self.case_insensitive() - # fix if packages is for upgrade - self.is_upgrade = is_upgrade - mas_sum = dep_sum = sums = 0, 0, 0, 0 - self.msg.done() - self.dependencies = self.resolving_deps() - self.update_deps() - - (self.dep_dwn, self.dep_install, self.dep_comp_sum, - self.dep_uncomp_sum) = self.store(self.dependencies) - - self.clear_masters() - - (self.dwn, self.install, self.comp_sum, - self.uncomp_sum) = self.store(self.packages) - - if self.meta.rsl_deps in ["on", "ON"]: - self.msg.done() - - if self.install: - - if self.matching and [""] != self.packages: - self.msg.matching(self.packages) - - else: - print("\nThe following packages will be automatically " - "installed or upgraded \nwith new version:\n") - self.top_view() - - self.msg.upg_inst(self.is_upgrade) - - mas_sum = self.views(self.install, self.comp_sum) - - if self.dependencies: - print("Installing for dependencies:") - dep_sum = self.views(self.dep_install, self.dep_comp_sum) - - # sums[0] --> total packages - # sums[1] --> reinstall - # sums[2] --> upgraded - # sums[3] --> uninstall - - sums = [sum(s) for s in zip_longest(mas_sum, dep_sum)] - unit, size = units(self.comp_sum + self.dep_comp_sum, - self.uncomp_sum + self.dep_uncomp_sum) - - if self.matching and [""] != self.packages: - print("\nMatching summary") - print("=" * 79) - raise SystemExit(f"Total {sums[0]} matching packages\n") - - print("\nInstalling summary") - print("=" * 79) - print(f"{self.grey}Total {sums[0]} {self.msg.pkg(sums[0])}.") - print(f"{sums[3]} {self.msg.pkg(sums[3])} will be installed, " - f"{sums[2]} will be upgraded and " - f"{sums[1]} will be reinstalled.") - print(f"Need to get {size[0]} {unit[0]} of archives.") - print(f"After this process, {size[1]} {unit[1]} of additional " - f"disk space will be used.{self.endc}") - - print() - - self.if_all_installed() - - if self.msg.answer() in ["y", "Y"]: - - for inst, dwn in zip(self.dep_install + self.install, - self.dep_dwn + self.dwn): - - if (self.meta.not_downgrade == "on" and - self.not_downgrade(inst) is True): - continue - - if (not os.path.isfile(self.meta.pkg_path + inst[:-4]) or - "--reinstall" in self.flag): - Download(self.tmp_path, dwn.split(), self.repo).start() - - else: - self.msg.template(78) - self.msg.pkg_found(inst) - self.msg.template(78) - - self.dep_install = list(self.check_downloaded( - self.tmp_path, self.dep_install)) - - self.install = list(self.check_downloaded( - self.tmp_path, self.install)) - - ins, upg = self.install_packages() - - self.msg.reference(ins, upg) - - write_deps(self.deps_dict) - delete_package(self.tmp_path, self.dep_install + self.install) - - else: - self.msg.not_found(self.is_upgrade) - raise SystemExit(1) - - def if_all_installed(self): - """Checks if all packages is already installed - """ - count_inst = 0 - - for inst in (self.dep_install + self.install): - - if (os.path.isfile(self.meta.pkg_path + inst[:-4])): - count_inst += 1 - - if (count_inst == len(self.dep_install + self.install) and - "--reinstall" not in self.flag): - raise SystemExit() - - def case_insensitive(self): - """Matching packages distinguish between uppercase and - lowercase - """ - if "--case-ins" in self.flag: - data = list(self.package_name(self.PACKAGES_TXT)) - data_dict = self.case_sensitive(data) - - for pkg in self.packages: - index = self.packages.index(pkg) - - for key, value in data_dict.items(): - - if key == pkg.lower(): - self.packages[index] = value - - def update_deps(self): - """Updates dependencies dictionary with all package - """ - for dep in self.dependencies: - deps = self.dimensional_list(Dependencies( - self.repo, self.blacklist).binary( - dep, self.flag)) - - self.deps_dict[dep] = deps - - def clear_masters(self): - """Clear master packages if already exist in dependencies - or if added to install two or more times - """ - packages = [] - for mas in self.remove_dbs(self.packages): - - if mas not in self.dependencies: - packages.append(mas) - - self.packages = packages - - def install_packages(self): - """Installs or upgrades packages - """ - installs, upgraded = [], [] - for inst in (self.dep_install + self.install): - package = (self.tmp_path + inst).split() - pkg_ver = f"{split_package(inst)[0]}-{split_package(inst)[1]}" - self.checksums(inst) - - if GetFromInstalled(split_package(inst)[0]).name(): - print(f"[ {self.yellow}upgrading{self.endc} ] --> {inst}") - upgraded.append(pkg_ver) - - if "--reinstall" in self.flag: - PackageManager(package).upgrade("--reinstall") - - else: - PackageManager(package).upgrade("--install-new") - - else: - print(f"[ {self.green}installing{self.endc} ] --> {inst}") - installs.append(pkg_ver) - PackageManager(package).upgrade("--install-new") - - return [installs, upgraded] - - def not_downgrade(self, package): - """Don't downgrade packages if repository version is lower than - installed""" - name = split_package(package)[0] - rep_ver = split_package(package)[1] - ins_ver = GetFromInstalled(name).version() - - if not ins_ver: - ins_ver = "0" - - if parse_version(rep_ver) < parse_version(ins_ver): - self.msg.template(78) - print(f"| Package {name} does not downgrade, setting by user") - self.msg.template(78) - return True - - def checksums(self, install): - """Checksums before install - """ - check_md5(pkg_checksum(install, self.repo), self.tmp_path + install) - - def resolving_deps(self): - """Returns package dependencies - """ - requires = [] - - if self.meta.rsl_deps in ["on", "ON"]: - self.msg.resolving() - - for dep in self.packages: - dependencies = [] - dependencies = self.dimensional_list(Dependencies( - self.repo, self.blacklist).binary(dep, self.flag)) - requires += list(self._fix_deps_repos(dependencies)) - self.deps_dict[dep] = self.remove_dbs(requires) - - return self.remove_dbs(requires) - - def _fix_deps_repos(self, dependencies): - """Fixes store deps include in the repository - """ - for dep in dependencies: - - if dep in self.repo_pkg_names: - yield dep - - def views(self, install, comp_sum): - """Views packages - """ - pkg_sum = uni_sum = upg_sum = res_sum = 0 - - # fix repositories align - repo = self.repo + (" " * (6 - (len(self.repo)))) - for pkg, comp in zip(install, comp_sum): - pkg_sum += 1 - pkg_repo = split_package(pkg[:-4]) - - if find_package(pkg[:-4], self.meta.pkg_path): - - if "--reinstall" in self.flag: - res_sum += 1 - COLOR = self.meta.color["GREEN"] - - elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name(): - COLOR = self.meta.color["YELLOW"] - upg_sum += 1 - - else: - COLOR = self.meta.color["RED"] - uni_sum += 1 - - ver = GetFromInstalled(pkg_repo[0]).version() - - if ver: - ver = f"-{ver}" - - print(f" {COLOR}{pkg_repo[0] + ver}{self.endc}" - f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}" - f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}" - f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}" - f"{' ' * (7-len(pkg_repo[3]))}{repo}{comp:>11}{' K'}") - - return [pkg_sum, res_sum, upg_sum, uni_sum] - - def top_view(self): - """Prints packages status bar - """ - self.msg.template(78) - print(f"| Package{' ' * 17}New Version{' ' * 8}Arch{' ' * 4}" - f"Build{' ' * 2}Repos{' ' * 10}Size") - self.msg.template(78) - - def store(self, packages): - """Stores and returns packages for install - """ - dwn, install, comp_sum, uncomp_sum = ([] for i in range(4)) - - # name = data[0] - # location = data[1] - # size = data[2] - # unsize = data[3] - - for pkg in packages: - - for pk, loc, comp, uncomp in zip(self.data[0], self.data[1], - self.data[2], self.data[3]): - - if (pk and pkg == split_package(pk)[0] and - pk not in install and - split_package(pk)[0] not in self.blacklist): - dwn.append(f"{self.mirror}{loc}/{pk}") - install.append(pk) - comp_sum.append(comp) - uncomp_sum.append(uncomp) - - if not install: - - for pkg in packages: - - for pk, loc, comp, uncomp in zip(self.data[0], self.data[1], - self.data[2], self.data[3]): - name = split_package(pk)[0] - - if (pk and pkg in name and name not in self.blacklist): - self.matching = True - dwn.append(f"{self.mirror}{loc}/{pk}") - install.append(pk) - comp_sum.append(comp) - uncomp_sum.append(uncomp) - dwn.reverse() - install.reverse() - comp_sum.reverse() - uncomp_sum.reverse() - - return [dwn, install, comp_sum, uncomp_sum] diff --git a/slpkg/binary/repo_init.py b/slpkg/binary/repo_init.py deleted file mode 100644 index 56a1d9cf..00000000 --- a/slpkg/binary/repo_init.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# repo_init.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.utils import Utils -from slpkg.repositories import Repo -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.slack.mirrors import mirrors -from slpkg.slack.slack_version import slack_ver - - -class RepoInit(Utils): - """Returns PACKAGES.TXT and mirror by repository - """ - def __init__(self, repo): - self.repo = repo - self.meta = _meta_ - self.def_repo_dict = Repo().default_repository() - self.mirror = "" - - def fetch(self): - if self.repo in self.meta.default_repositories: - getattr(self, f"_init_{self.repo}")() - - else: - self._init_custom() - - self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT" - PACKAGES_TXT = self.read_file(self.lib) - return PACKAGES_TXT, self.mirror - - def _init_custom(self): - repo = Repo() - self.mirror = repo.custom_repository()[self.repo] - - def _init_slack(self): - self.mirror = mirrors(name="", location="") - - def _init_rlw(self): - self.mirror = f"{self.def_repo_dict}{slack_ver()}/" - - def _init_alien(self): - ver = slack_ver() - arch = "x86" - if self.meta.arch == "x86_64": - arch = "x86_64" - - if self.meta.slack_rel == "current": - ver = self.meta.slack_rel - - self.mirror = f"{self.def_repo_dict['alien']}{ver}/{arch}/" - - def _init_slacky(self): - arch = "" - if self.meta.arch == "x86_64": - arch = "64" - - self.mirror = f"{self.def_repo_dict}slackware{arch}-{slack_ver()}/" - - def _init_conrad(self): - self.mirror = self.def_repo_dict["conrad"] - - def _init_slonly(self): - ver = slack_ver() - arch = f"{ver}-x86" - if self.meta.arch == "x86_64": - arch = f"{ver}-x86_64" - - if self.meta.slack_rel == "current": - - if self.meta.arch == "x86_64": - arch = f"{self.meta.slack_rel}-x86_64" - - else: - arch = f"{self.meat.slack_rel}-x86" - - self.mirror = f"{self.def_repo_dict['slonly']}{arch}/" - - def _init_ktown(self): - self.mirror = self.def_repo_dict["ktown"] - - def _init_multi(self): - ver = slack_ver() - if self.meta.slack_rel == "current": - ver = self.meta.slack_rel - - self.mirror = self.def_repo_dict["multi"] + ver + "/" - - def _init_slacke(self): - arch = "" - if self.meta.arch == "x86_64": - arch = "64" - - self.mirror = (f"{self.def_repo_dict['slacke']}" - f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware" - f"{arch}-{slack_ver()}/") - - def _init_salix(self): - arch = "i486" - if self.meta.arch == "x86_64": - arch = "x86_64" - - self.mirror = f"{self.def_repo_dict['salix']}{arch}/{slack_ver()}/" - - def _init_slackl(self): - arch = "i486" - if self.meta.arch == "x86_64": - arch = "x86_64" - - self.mirror = f"{self.def_repo_dict['slackl']}{arch}/current/" - - def _init_rested(self): - self.mirror = self.def_repo_dict["rested"] - - def _init_msb(self): - arch = "x86" - if self.meta.arch == "x86_64": - arch = "x86_64" - self.mirror = (f"{self.def_repo_dict['msb']}{slack_ver()}/" - f"{self.meta.msb_sub_repo[1:-1]}/{arch}/") - - def _init_csb(self): - arch = "x86" - if self.meta.arch == "x86_64": - arch = "x86_64" - - self.mirror = f"{self.def_repo_dict['csb']}{slack_ver()}/{arch}" - - def _init_connos(self): - arch = "" - if self.meta.arch == "x86_64": - arch = "64" - self.mirror = (f"{self.def_repo_dict['connos']}slack-n-free" - f"{arch}-{slack_ver()}/") - - def _init_mles(self): - arch = "32" - if self.meta.arch == "x86_64": - arch = "64" - self.mirror = (f"{self.def_repo_dict['mles']}" - f"{self.meta.mles_sub_repo[1:-1]}-" - f"{slack_ver()}-{arch}bit/") diff --git a/slpkg/binary/search.py b/slpkg/binary/search.py deleted file mode 100644 index 31f24b2b..00000000 --- a/slpkg/binary/search.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# search.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.utils import Utils -from slpkg.blacklist import BlackList -from slpkg.__metadata__ import MetaData as _meta_ - - -def search_pkg(name, repo): - """Searching if the package exists in PACKAGES.TXT file - and return the name. - """ - utils = Utils() - black = BlackList() - - text = utils.read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") - - PACKAGES_TXT = list(utils.package_name(text)) - blacklist = list(black.get_black()) - - if name in PACKAGES_TXT and name not in blacklist: - return name diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py deleted file mode 100644 index e22f2d13..00000000 --- a/slpkg/blacklist.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# blacklist.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.utils import Utils -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - - -class BlackList(Utils): - """Blacklist class to add, remove or list packages - in blacklist file.""" - - def __init__(self): - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.endc = _meta_.color["ENDC"] - self.blackfile = "/etc/slpkg/blacklist" - self.black_conf = "" - - if os.path.isfile(self.blackfile): - self.black_conf = self.read_file(self.blackfile) - - def get_black(self): - """Return blacklist packages from /etc/slpkg/blacklist - configuration file.""" - blacklist = list(self.black_filter()) - installed = os.listdir("/var/log/packages/") - - for black in blacklist: - - if black.endswith("*"): - - for inst in installed: - - if inst.startswith(black[:-1]): - yield split_package(inst)[0] - - else: - yield black - - def black_filter(self): - """Returns all the installed files that start - by the name - """ - for read in self.black_conf.splitlines(): - - read = read.lstrip() - - if not read.startswith("#"): - yield read.replace("\n", "") - - def black_listed(self): - """Prints blacklist packages - """ - print("Packages in the blacklist:") - for black in list(self.black_filter()): - if black: - print(f"{self.green}{black}{self.endc}") - print() - - def black_add(self, pkgs): - """Adds blacklist packages if not exist - """ - blacklist = list(self.black_filter()) - pkgs = set(pkgs) - - print("Add packages in the blacklist:") - - with open(self.blackfile, "a") as black_conf: - - for pkg in pkgs: - - if pkg not in blacklist: - print(f"{self.green}{pkg}{self.endc}") - black_conf.write(pkg + "\n") - print() - - def black_remove(self, pkgs): - """Removes packages from blacklist - """ - print("Remove packages from the blacklist:") - - with open(self.blackfile, "w") as remove: - - for line in self.black_conf.splitlines(): - - if line not in pkgs: - remove.write(line + "\n") - - else: - print(f"{self.red}{line}{self.endc}") - print() diff --git a/slpkg/checks.py b/slpkg/checks.py deleted file mode 100644 index aaa10025..00000000 --- a/slpkg/checks.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# checks.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.messages import Msg -from slpkg.arguments import usage -from slpkg.init import Init -from slpkg.__metadata__ import MetaData as _meta_ - - -class Updates: - """Checking for news in ChangeLog.txt - """ - def __init__(self, repo): - self.repo = repo - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.check = 2 - self.st = "" - self.count_repo = 0 - self.count_news = 0 - self._init = Init(True) - - self.all_repos = { - "slack": self._init.slack, - "sbo": self._init.sbo, - "rlw": self._init.rlw, - "alien": self._init.alien, - "slacky": self._init.slacky, - "conrad": self._init.conrad, - "slonly": self._init.slonly, - "ktown": self._init.ktown, - "multi": self._init.multi, - "slacke": self._init.slacke, - "salix": self._init.salix, - "slackl": self._init.slackl, - "rested": self._init.rested, - "msb": self._init.msb, - "csb": self._init.csb, - "connos": self._init.msb, - "mles": self._init.mles - } - - def status_bar(self): - """Top view bar status - """ - self.msg.template(78) - print("| Repository Status") - self.msg.template(78) - - def run(self): - """Run and check if new in ChangeLog.txt - """ - if (self.repo in self.meta.default_repositories and - self.repo in self.meta.repositories): - - try: - self.check = self.all_repos[self.repo]() - except OSError: - usage(self.repo, 1) - - elif self.repo in self.meta.repositories: - self.check = self._init.custom(self.repo) - - else: - usage(self.repo, 1) - - self.status_bar() - self.status() - self.print_status(self.repo) - self.summary() - - def ALL(self): - """Check ALL enabled repositories ChangeLogs - """ - self.status_bar() - - for repo in self.meta.repositories: - - if repo in self.meta.default_repositories: - - try: - self.check = self.all_repos[repo]() - - except OSError: - usage(self.repo, 1) - - elif repo in self.meta.repositories: - self.check = self._init.custom(repo) - - self.status() - self.print_status(repo) - - self.summary() - - def status(self): - """Set messages - """ - self.count_repo += 1 - - if self.check == 1: - self.count_news += 1 - self.st = f"{self.green}News in ChangeLog.txt{self.endc}" - - elif self.check == 0: - self.st = "No changes in ChangeLog.txt" - - def print_status(self, repo): - """Print status - """ - print(f" {repo}{' ' * (19 - len(repo))}{self.st}") - - def summary(self): - """Print summary - """ - print("\nSummary") - print("=" * 79) - - cmd = "All repositories are updated." - - if self.count_repo == 1: - cmd = "Repository is updated." - - if self.count_news > 0: - cmd = "Run the command 'slpkg update'." - - print(f"From {self.count_repo} repositories need" - f" {self.count_news} updating. {cmd}", end="\n") diff --git a/slpkg/checksum.py b/slpkg/checksum.py deleted file mode 100644 index 948f1192..00000000 --- a/slpkg/checksum.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# checksum.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.md5sum import md5 -from slpkg.messages import Msg -from slpkg.__metadata__ import MetaData as _meta_ - - -def check_md5(pkg_md5, src_file): - """MD5 Checksum - """ - msg = Msg() - red = _meta_.color["RED"] - green = _meta_.color["GREEN"] - endc = _meta_.color["ENDC"] - - if _meta_.checkmd5 in ["on", "ON"]: - - print() - - md5s = md5(src_file) - - if pkg_md5 != md5s: - - msg.template(78) - - print(f"| MD5SUM check for {src_file.split('/')[-1]}" - f" [ {red}FAILED{endc} ]") - - msg.template(78) - - print(f"| Expected: {pkg_md5}") - print(f"| Found: {md5s}") - - msg.template(78) - - print() - - if not msg.answer() in ["y", "Y"]: - raise SystemExit() - else: - msg.template(78) - - print(f"| MD5SUM check for {src_file.split('/')[-1]}" - f" [ {green}PASSED{endc} ]") - - msg.template(78) - - print() # new line after pass checksum diff --git a/slpkg/clean.py b/slpkg/clean.py deleted file mode 100644 index ab530912..00000000 --- a/slpkg/clean.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# clean.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import shutil - -from slpkg.__metadata__ import MetaData as _meta_ - - -def clean_tmp(): - """Deletes packages and sources from tmp/ directory - """ - tmps = [_meta_.tmp_path, # /tmp/slpkg/ - _meta_.build_path, # /tmp/slpkg/build/ - _meta_.slpkg_tmp_packages, # /tmp/slpkg/packages/ - _meta_.slpkg_tmp_patches # /tmp/slpkg/patches/ - ] - - # Delete a whole slpkg folder from the tmp directory - if os.path.exists(tmps[0]): - shutil.rmtree(tmps[0]) - print(f"All packages and sources were deleted from: {tmps[0]}") - - # Recreate the paths again - if not os.path.exists(tmps[0]): - - for tmp in tmps: - os.mkdir(tmp) - print(f"Created directory: {tmp}") - - print("Done!") diff --git a/slpkg/clean_logs.py b/slpkg/clean_logs.py new file mode 100644 index 00000000..ae4f25b9 --- /dev/null +++ b/slpkg/clean_logs.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +from dataclasses import dataclass + +from views.views import ViewMessage +from models.models import LogsDependencies +from models.models import session as Session + + +@dataclass +class CleanLogsDependencies: + flags: str + session: str = Session + + @classmethod + def clean(cls): + deps = cls.session.query( + LogsDependencies.name, LogsDependencies.requires).all() + + if deps: + print('The following logs will be removed:\n') + + for dep in deps: + print(f'{dep[0]} -> Dependencies: {dep[1]}') + + view = ViewMessage() + view.question(cls.flags) + + cls.session.query(LogsDependencies).delete() + cls.session.commit() + else: + print('Nothing to clean.') diff --git a/slpkg/cli_menu.py b/slpkg/cli_menu.py new file mode 100644 index 00000000..82fbe578 --- /dev/null +++ b/slpkg/cli_menu.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +from metadata import Metadata + + +def usage(status): + args = [f'Usage: {Metadata.proj_name} [OPTIONS] [packages]\n', + ' Tool that interact with the SBo repository.\n', + 'Options:', + ' update Update the data packages.', + ' build Build only the packages.', + ' install Build and install the packages.', + ' remove Remove installed packages.', + ' clean-logs Purge logs of dependencies.', + ' --yes Answer Yes to all questions.', + ' --resolve-off Turns off dependency resolving.', + ' -h, --help Show this message and exit.', + ' -v, --version Print version and exit.\n', + 'If you need more information try to use slpkg manpage.'] + for opt in args: + print(opt) + raise SystemExit(status) diff --git a/slpkg/config.py b/slpkg/config.py deleted file mode 100644 index 5a8241f1..00000000 --- a/slpkg/config.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# config.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import shutil -import filecmp -import subprocess - -from slpkg.utils import Utils -from slpkg.__metadata__ import MetaData as _meta_ - - -class Config(Utils): - """Print or edit slpkg configuration file - """ - def __init__(self): - self.config_file = "/etc/slpkg/slpkg.conf" - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.cyan = _meta_.color["CYAN"] - self.endc = _meta_.color["ENDC"] - - def view(self): - """View slpkg config file - """ - conf_args = [ - "RELEASE", - "SLACKWARE_VERSION", - "COMP_ARCH", - "BUILD_PATH", - "PACKAGES", - "PATCHES", - "CHECKMD5", - "DEL_ALL", - "DEL_BUILD", - "SBO_BUILD_LOG", - "MAKEFLAGS", - "DEFAULT_ANSWER", - "REMOVE_DEPS_ANSWER", - "SKIP_UNST", - "RSL_DEPS", - "DEL_DEPS", - "USE_COLORS", - "DOWNDER", - "DOWNDER_OPTIONS", - "SLACKPKG_LOG", - "ONLY_INSTALLED", - "EDITOR", - "NOT_DOWNGRADE", - "HTTP_PROXY", - ] - - read_conf = self.read_file(self.config_file) - - for line in read_conf.splitlines(): - - if not line.startswith("#") and line.split("=")[0] in conf_args: - print(line) - - else: - print(f"{self.cyan}{line}{self.endc}", end="\n") - - def edit(self): - """Edit configuration file - """ - subprocess.call(f"{self.meta.editor} {self.config_file}", shell=True) - - def reset(self): - """Reset slpkg.conf file with default values - """ - shutil.copy2(f"{self.config_file}.orig", self.config_file) - - if filecmp.cmp(f"{self.config_file}.orig", self.config_file): - print(f"{self.green}The reset was done{self.endc}") - - else: - print(f"{self.red}Reset failed{self.endc}") diff --git a/slpkg/create_data.py b/slpkg/create_data.py new file mode 100644 index 00000000..6f0e8e50 --- /dev/null +++ b/slpkg/create_data.py @@ -0,0 +1,63 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +from dataclasses import dataclass + +from metadata import Metadata +from models.models import SBoTable +from models.models import session as Session + + +@dataclass +class CreateData: + + db_path: str = Metadata.db_path + sbo_txt: str = Metadata.sbo_txt + sbo_repo_path: str = Metadata.sbo_repo_path + session: str = Session + + def insert_sbo_table(self): + sbo_tags = [ + "SLACKBUILD NAME:", + "SLACKBUILD LOCATION:", + "SLACKBUILD FILES:", + "SLACKBUILD VERSION:", + "SLACKBUILD DOWNLOAD:", + "SLACKBUILD DOWNLOAD_x86_64:", + "SLACKBUILD MD5SUM:", + "SLACKBUILD MD5SUM_x86_64:", + "SLACKBUILD REQUIRES:", + "SLACKBUILD SHORT DESCRIPTION:" + ] + + sbo_file = self.read_file(f"{self.sbo_repo_path}/SLACKBUILDS.TXT") + + cache = [] # init cache + + print('Creating the database... ', end='', flush=True) + + for i, line in enumerate(sbo_file, 1): + + for s in sbo_tags: + if line.startswith(s): + line = line.replace(s, "").strip() + cache.append(line) + + if (i % 11) == 0: + data = SBoTable(name=cache[0], location=cache[1].split('/')[1], + files=cache[2], version=cache[3], + download=cache[4], download64=cache[5], + md5sum=cache[6], md5sum64=cache[7], + requires=cache[8], short_description=cache[9]) + self.session.add(data) + + cache = [] # reset cache after 11 lines + + print('Done') + + self.session.commit() + + def read_file(self, file): + with open(file, "r", encoding="utf-8") as f: + return f.readlines() diff --git a/slpkg/dependencies.py b/slpkg/dependencies.py new file mode 100644 index 00000000..1fe556de --- /dev/null +++ b/slpkg/dependencies.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +from queries import SBoQueries +from dataclasses import dataclass + + +@dataclass +class Requires: + ''' Creates a list of dependencies with + the right order to install ''' + name: str + + def resolve(self) -> list: + requires = SBoQueries(self.name).requires() + + for r in requires: + if r and r != "%README%": + sub = SBoQueries(r).requires() + for s in sub: + requires.append(s) + + requires.reverse() + + return list(dict.fromkeys(requires)) diff --git a/slpkg/desc.py b/slpkg/desc.py deleted file mode 100644 index 97e4a6f8..00000000 --- a/slpkg/desc.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# desc.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.sbo.greps import SBoGrep - - -class PkgDesc(Utils): - """Prints package description from the repository - """ - def __init__(self, name, repo, paint): - self.name = name - self.repo = repo - self.paint = paint - self.meta = _meta_ - self.msg = Msg() - self.lib = "" - self.color = { - "red": self.meta.color["RED"], - "green": self.meta.color["GREEN"], - "yellow": self.meta.color["YELLOW"], - "cyan": self.meta.color["CYAN"], - "grey": self.meta.color["GREY"], - "": "" - }[self.paint] - - if self.repo in self.meta.repositories and self.repo != "sbo": - self.lib = f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT" - - def view(self): - """Prints package description by repository - """ - description, count = "", 0 - - if self.repo == "sbo": - description = SBoGrep(self.name).description() - - else: - PACKAGES_TXT = self.read_file(self.lib) - - for line in PACKAGES_TXT.splitlines(): - - if line.startswith(self.name + ":"): - description += f"{line[len(self.name) + 2:]}\n" - count += 1 - - if count == 11: - break - - if description: - print(f"{self.color}{description}{self.meta.color['ENDC']}") - - else: - self.msg.pkg_not_found("", self.name, "No matching", "") diff --git a/slpkg/dialog_box.py b/slpkg/dialog_box.py deleted file mode 100644 index fbaa397d..00000000 --- a/slpkg/dialog_box.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# dialog_box.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from __future__ import unicode_literals - -import os - - -class DialogUtil: - """Creates dialog checklist - """ - def __init__(self, *args): - self.imp_dialog() - self.data = args[0] - self.text = args[1] - self.title = args[2] - self.backtitle = args[3] - self.status = args[4] - self.ununicode = [] - self.tags = [] - - def imp_dialog(self): - try: - from dialog import Dialog - except ImportError as er: - raise SystemExit(er) - - self.d = Dialog(dialog="dialog", autowidgetsize=True) - - def checklist(self): - """Runs dialog checklist - """ - choice = [] - - for item in self.data: - choice.append((item, "", self.status)) - - code, self.tags = self.d.checklist( - text=self.text, height=20, width=65, list_height=13, - choices=choice, title=self.title, backtitle=self.backtitle) - - if code == "ok": - self.unicode_to_string() - return self.ununicode - - if code in ["cancel", "esc"]: - self.exit() - - def buildlist(self, enabled): - """Runs dialog buildlist - """ - choice = [] - - for item in self.data: - choice.append((item, False)) - - for item in enabled: - choice.append((item, True)) - - items = [(tag, tag, sta) for (tag, sta) in choice] - - code, self.tags = self.d.buildlist( - text=self.text, items=items, visit_items=True, item_help=False, - title=self.title) - - if code == "ok": - self.unicode_to_string() - return self.ununicode - - if code in ["cancel", "esc"]: - self.exit() - - def exit(self): - """Exits from dialog - """ - self.clear_screen() - raise SystemExit() - - def clear_screen(self): - """Clear screen - """ - os.system("clear") - - def unicode_to_string(self): - """Converts unicode in string - """ - for tag in self.tags: - self.ununicode.append(str(tag)) diff --git a/slpkg/downloader.py b/slpkg/downloader.py index f693af84..b4bf4bb5 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -1,147 +1,16 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# downloader.py file is part of slpkg. -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import tarfile import subprocess - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.slack.slack_version import slack_ver -from slpkg.__metadata__ import MetaData as _meta_ +from dataclasses import dataclass +from metadata import Metadata -class Download(Utils): - """Downloader manager. Slpkg use wget by default but support - curl, aria2 and httpie - """ - def __init__(self, path, url, repo): - self.path = path - self.url = url - self.repo = repo - self.file_name = "" - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.dir_prefix = "" - self.downder = self.meta.downder - self.downder_options = self.meta.downder_options +@dataclass +class Wget: + wget_options: str = Metadata.wget_options - def start(self): - """Download files using wget or other downloaders. - Optional curl, aria2c and httpie - """ - dwn_count = 1 - - self._directory_prefix() - - for dwn in self.url: - - self.file_name = self.fix_file_name(dwn.split("/")[-1]) - - if dwn.startswith("file:///"): - source_dir = dwn[7:-7].replace(slack_ver(), "") - self._make_tarfile(self.file_name, source_dir) - - self._check_certificate() - - print(f"\n[{dwn_count}/{len(self.url)}][ {self.green}" - f"Download{self.endc} ] --> {self.file_name}\n") - - if self.downder in ["wget"]: - subprocess.call(f"{self.downder} {self.downder_options}" - f" {self.dir_prefix}{self.path} {dwn}", - shell=True) - - if self.downder in ["aria2c"]: - subprocess.call(f"{self.downder} {self.downder_options}" - f" {self.dir_prefix}{self.path[:-1]} {dwn}", - shell=True) - - elif self.downder in ["curl", "http"]: - subprocess.call(f"{self.downder} {self.downder_options}" - f" {self.path}{self.file_name} {dwn}", - shell=True) - - self._check_if_downloaded() - - dwn_count += 1 - - def _make_tarfile(self, output_filename, source_dir): - """Creates .tar.gz file - """ - with tarfile.open(output_filename, "w:gz") as tar: - tar.add(source_dir, arcname=os.path.basename(source_dir)) - - def _directory_prefix(self): - """Downloader options for specific directory - """ - if self.downder == "wget": - self.dir_prefix = "--directory-prefix=" - - elif self.downder == "aria2c": - self.dir_prefix = "--dir=" - - def _check_if_downloaded(self): - """Checks if file downloaded - """ - if not os.path.isfile(self.path + self.file_name): - - print() - - self.msg.template(78) - - print(f"| Download '{self.file_name}' file" - f" [ {self.red}FAILED{self.endc} ]") - - self.msg.template(78) - - print() - - if not self.msg.answer() in ["y", "Y"]: - raise SystemExit() - - def _check_certificate(self): - """Checks for certificates options for wget - """ - if (self.file_name.startswith("jdk-") and self.repo == "sbo" and - self.downder == "wget"): - certificate = (' --no-check-certificate --header="Cookie: ' - 'oraclelicense=accept-securebackup-cookie"') - - self.msg.template(78) - - print(f"| '{certificate[:23].strip()}' need to go" - f" ahead downloading") - - self.msg.template(78) - - print() - - self.downder_options += certificate - - if not self.msg.answer() in ["y", "Y"]: - raise SystemExit() + def download(self, path: str, url: str): + subprocess.call(f'wget {self.wget_options} --directory-prefix={path}' + f' {url}', shell=True) diff --git a/slpkg/file_size.py b/slpkg/file_size.py deleted file mode 100644 index 750f8698..00000000 --- a/slpkg/file_size.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -* - -# file_size.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import urllib3 - -from slpkg.__metadata__ import MetaData as _meta_ - - -class FileSize: - """Checks local or remote file size - """ - def __init__(self, registry): - self.meta = _meta_ - self.registry = registry - - if self.meta.http_proxy: - self.http = urllib3.ProxyManager(self.meta.http_proxy) - - else: - self.http = urllib3.PoolManager() - - def server(self): - """Returns the size of remote files - """ - try: - r = self.http.request("GET", self.registry) - return int(r.headers["Content-Length"]) - except urllib3.exceptions.NewConnectionError: - return " " - - def local(self): - """Returns the size of local files - """ - return os.path.getsize(self.registry) diff --git a/slpkg/graph.py b/slpkg/graph.py deleted file mode 100644 index 4fb28ad5..00000000 --- a/slpkg/graph.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# graph.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import subprocess - - -# class ImportErrorGraphEasy(Exception): -# def __init__(self, GraphEasyImportError): -# Exception.__init__(self, "graph-easy required") -# self.GraphEasyImportError = GraphEasyImportError - - -class Graph: - """Drawing dependencies diagram - """ - def __init__(self, image): - self.image = image - self.file_format = [ - ".bmp", ".canon", ".cmap", ".cmapx", ".cmapx_np", ".dot", - ".eps", ".fig", ".gd", ".gd2", ".gif", ".gtk", ".gv", ".ico", - ".imap", ".imap_np", ".ismap", ".jpe", ".jpeg", ".jpg", ".pdf", - ".pic", ".plain", ".plain-ext", ".png", ".pov", ".ps", ".ps2", - ".svg", ".svgz", ".tif", ".tiff", ".tk", ".vml", ".vmlz", - ".vrml", ".wbmp", ".x11", ".xdot", ".xlib" - ] - - def dependencies(self, deps_dict): - """Generates graph file with dependencies map tree - """ - try: - import pygraphviz as pgv - except ImportError: - - if (self.image == "ascii" - and not os.path.isfile("/usr/bin/graph-easy")): - print("Require 'grap_easy': " - "Install with 'slpkg -s sbo graph-easy'") - - else: - raise SystemExit("Require 'pygraphviz: " - "Install with 'slpkg -s sbo pygraphviz'") - - if self.image != "ascii": - self.check_file() - - try: - G = pgv.AGraph(deps_dict) - - G.layout(prog="fdp") - - if self.image == "ascii": - G.write(f"{self.image}.dot") - self.graph_easy() - - G.draw(self.image) - - except IOError: - raise SystemExit(1) - - if os.path.isfile(self.image): - print(f"Graph image file '{self.image}' created") - raise SystemExit() - - def check_file(self): - """Checks for file format and type - """ - try: - image_type = f".{self.image.split('.')[1]}" - - if image_type not in self.file_format: - raise SystemExit(f"Format: '{self.image.split('.')[1]}' not " - f"recognized. Use one of them:\n" - f"{', '.join(self.file_format)}") - except IndexError: - raise SystemExit("slpkg: Error: Image file suffix missing") - - def graph_easy(self): - """Drawing ascii diagram. graph-easy perl module requires - """ - if not os.path.isfile("/usr/bin/graph-easy"): - - print("Require 'graph-easy': Install with 'slpkg -s sbo" - " graph-easy'") - self.remove_dot() - - raise SystemExit(1) - - subprocess.call(f"graph-easy {self.image}.dot", shell=True) - - self.remove_dot() - - raise SystemExit(1) - - def remove_dot(self): - """Removes .dot files - """ - if os.path.isfile(f"{self.image}.dot"): - os.remove(f"{self.image}.dot") diff --git a/slpkg/grep_md5.py b/slpkg/grep_md5.py deleted file mode 100644 index 6a7870b1..00000000 --- a/slpkg/grep_md5.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# grep_md5.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.slack.mirrors import mirrors - -from slpkg.url_read import URL -from slpkg.__metadata__ import MetaData as _meta_ - - -def pkg_checksum(binary, repo): - """Returns checksum from CHECKSUMS.md5 file by repository - """ - md5 = "None" - - if repo == "slack_patches" and _meta_.slack_rel == "stable": - CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).get_request() - - elif repo == "slack_patches" and _meta_.slack_rel == "current": - CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).get_request() - - elif repo == "slpkg": - CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).get_request() - - else: - lib = f"{_meta_.lib_path}{repo}_repo/CHECKSUMS.md5" - f = open(lib, "r") - CHECKSUMS_md5 = f.read() - f.close() - - for line in CHECKSUMS_md5.splitlines(): - - if line.endswith(f"/{binary}"): - md5 = line.split()[0] - - return md5 diff --git a/slpkg/health.py b/slpkg/health.py deleted file mode 100644 index bdbdd4cd..00000000 --- a/slpkg/health.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# health.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.messages import Msg -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - - -class PackageHealth: - """Health check for the installed packages - """ - def __init__(self, mode): - self.mode = mode - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.yellow = _meta_.color["YELLOW"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.pkg_path = _meta_.pkg_path - self.installed = [] - self.cn = 0 - - def packages(self): - """Gets all installed packages from /var/log/packages/ path - """ - self.installed = find_package("", self.pkg_path) - - def check(self, line, pkg): - line = line.replace("\n", "") - try: - - if (not line.endswith("/") and - not line.endswith(".new") and - not line.startswith("dev/") and - not line.startswith("install/") and - "/incoming/" not in line): - - if not os.path.isfile(r"/" + line): - self.cn += 1 - print(f"Not installed: {self.red}/{line}{self.endc} --> {pkg}") - - elif not self.mode: - print(line) - - except IOError: - raise SystemExit("\n") - - def test(self): - """Starts testing each package and reading the file list - """ - self.packages() - self.cf = 0 - - for pkg in self.installed: - - if os.path.isfile(f"{self.meta.pkg_path}{pkg}"): - self.lf = 0 - - with open(self.pkg_path + pkg, "r") as fopen: - - for line in fopen: - - if "\0" in line: - print(f"Null: {line}") - break - - self.cf += 1 # count all files - self.lf += 1 # count each package files - - if self.lf > 19: - self.check(line, pkg) - self.results() - - def results(self): - """Prints results - """ - print() - per = int(round((float(self.cf) / (self.cf + self.cn)) * 100)) - - if per > 90: - color = self.green - - elif per < 90 and per > 60: - color = self.yellow - - elif per < 60: - color = self.red - - health = f"{color}{str(per)}%{self.endc}" - - self.msg.template(78) - print(f"| Total files{' ' * 7}Not installed{' ' * 40}Health") - self.msg.template(78) - print(f"| {self.cf}{' ' * (18-len(str(self.cf)))}{self.cn}{' ' * (55-len(str(self.cn)))}{health:>4}") - self.msg.template(78) diff --git a/slpkg/init.py b/slpkg/init.py deleted file mode 100644 index fdb479a8..00000000 --- a/slpkg/init.py +++ /dev/null @@ -1,940 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# init.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import shutil - -from slpkg.utils import Utils -from slpkg.repositories import Repo -from slpkg.file_size import FileSize -from slpkg.downloader import Download -from slpkg.models.data import Database -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.slack.mirrors import mirrors -from slpkg.slack.slack_version import slack_ver -from slpkg.models.models import SBoTable, session - - -class Init(Utils): - """Slpkg initialization starts all from here. - Creates local package lists and updates or upgrades these. - """ - def __init__(self, check): - self.check = check - self.meta = _meta_ - self.arch = _meta_.arch - self.session = session - self.conf_path = self.meta.conf_path - self.log_path = self.meta.log_path - self.lib_path = self.meta.lib_path - self.tmp_path = self.meta.tmp_path - self.build_path = self.meta.build_path - self._SOURCES = self.meta.SBo_SOURCES - self.slpkg_tmp_packages = self.meta.slpkg_tmp_packages - self.slpkg_tmp_patches = self.meta.slpkg_tmp_patches - self.slack_ver = slack_ver() - self.def_repos_dict = Repo().default_repository() - self.constructing() - - def constructing(self): - """Creating the all necessary directories - """ - paths_basic = [ - self.conf_path, - self.log_path, - self.lib_path, - self.tmp_path - ] - - paths_extra = [ - self.build_path, - self._SOURCES, - self.slpkg_tmp_packages, - self.slpkg_tmp_patches - ] - - self.make_dir(paths_basic) - self.make_dirs(paths_extra) - - def make_dir(self, path: list): - for p in path: - if not os.path.exists(p): - os.mkdir(p) - - def make_dirs(self, path: list): - for p in path: - if not os.path.exists(p): - os.makedirs(p) - - def custom(self, name): - """Creating user custom repository local library - """ - repo = Repo().custom_repository()[name] - log = self.log_path + name + "/" - lib = self.lib_path + f"{name}_repo/" - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - PACKAGES_TXT = f"{repo}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, name) - self.down(lib, CHECKSUMS_MD5, name) - self.down(log, ChangeLog_txt, name) - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, name) - - def slack(self): - """Creating slack local libraries - """ - log = self.log_path + "slack/" - lib = self.lib_path + "slack_repo/" - repo_name = Init.slack.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - dirs = ["core/", "extra/", "patches/"] - - self.make_dir([log, lib]) - self.make_dir([f"{lib}{dirs[0]}", - f"{lib}{dirs[1]}", - f"{lib}{dirs[2]}"]) - - PACKAGES_TXT = mirrors(lib_file, "") - FILELIST_TXT = "" - CHECKSUMS_MD5 = mirrors(md5_file, "") - - self.EXTRA = mirrors(lib_file, dirs[1]) - self.EXT_CHECKSUMS = mirrors(md5_file, dirs[1]) - self.PATCHES = mirrors(lib_file, dirs[2]) - self.PAT_CHECKSUMS = mirrors(md5_file, dirs[2]) - ChangeLog_txt = mirrors(log_file, "") - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib + dirs[0], PACKAGES_TXT, repo_name) - self.down(lib + dirs[0], CHECKSUMS_MD5, repo_name) - self.down(lib + dirs[1], self.EXTRA, repo_name) - self.down(lib + dirs[1], self.EXT_CHECKSUMS, repo_name) - self.down(lib + dirs[2], self.PATCHES, repo_name) - self.down(lib + dirs[2], self.PAT_CHECKSUMS, repo_name) - self.down(log, ChangeLog_txt, repo_name) - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - self.merge(lib, "PACKAGES.TXT", ["core/PACKAGES.TXT", - "extra/PACKAGES.TXT", - "patches/PACKAGES.TXT"]) - self.merge(lib, "CHECKSUMS.md5", ["core/CHECKSUMS.md5", - "extra/CHECKSUMS.md5", - "patches/CHECKSUMS_md5"]) - - def sbo(self): - """Creating sbo local library - """ - repo = self.def_repos_dict["sbo"] - log = self.log_path + "sbo/" - lib = self.lib_path + "sbo_repo/" - repo_name = Init.sbo.__name__ - - lib_file = "SLACKBUILDS.TXT" - # lst_file = "" - # md5_file = "" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - SLACKBUILDS_TXT = f"{repo}{self.slack_ver}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = "" - ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, SLACKBUILDS_TXT, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, SLACKBUILDS_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def rlw(self): - """Creating rlw local library - """ - repo = self.def_repos_dict["rlw"] - log = self.log_path + "rlw/" - lib = self.lib_path + "rlw_repo/" - repo_name = Init.rlw.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - PACKAGES_TXT = f"{repo}{self.slack_ver}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{self.slack_ver}/{md5_file}" - ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def alien(self): - """Creating alien local library - """ - ar = "x86" - ver = self.slack_ver - repo = self.def_repos_dict["alien"] - log = self.log_path + "alien/" - lib = self.lib_path + "alien_repo/" - repo_name = Init.alien.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = self.arch - - if self.meta.slack_rel == "current": - ver = self.meta.slack_rel - - PACKAGES_TXT = f"{repo}/{ver}/{ar}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}/{ver}/{ar}/{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def slacky(self): - """Creating slacky.eu local library - """ - ar = "" - repo = self.def_repos_dict["slacky"] - log = self.log_path + "slacky/" - lib = self.lib_path + "slacky_repo/" - repo_name = Init.slacky.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "64" - - PACKAGES_TXT = f"{repo}slackware{ar}-{self.slack_ver}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}slackware{ar}-{self.slack_ver}/{md5_file}" - - ChangeLog_txt = f"{repo}slackware{ar}-{self.slack_ver}/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def conrad(self): - """Creating slackers local library - """ - repo = self.def_repos_dict["conrad"] - log = self.log_path + "conrad/" - lib = self.lib_path + "conrad_repo/" - repo_name = Init.conrad.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - PACKAGES_TXT = f"{repo}{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def slonly(self): - """Creating slackers local library - """ - ar = f"{self.slack_ver}-x86" - repo = self.def_repos_dict["slonly"] - log = self.log_path + "slonly/" - lib = self.lib_path + "slonly_repo/" - repo_name = Init.slonly.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = f"{self.slack_ver}-x86_64" - - if self.meta.slack_rel == "current": - ar = f"{self.meta.slack_rel}-x86" - - if self.meta.slack_rel == "current" and self.arch == "x86_64": - ar = f"{self.meta.slack_rel}-x86_64" - - PACKAGES_TXT = f"{repo}{ar}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{ar}/{md5_file}" - ChangeLog_txt = f"{repo}{ar}/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def ktown(self): - """Creating alien ktown local library - """ - repo = self.def_repos_dict["ktown"] - log = self.log_path + "ktown/" - lib = self.lib_path + "ktown_repo/" - repo_name = Init.ktown.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - PACKAGES_TXT = f"{repo}{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def multi(self): - """Creating alien multilib local library - """ - ver = self.slack_ver - repo = self.def_repos_dict["multi"] - log = self.log_path + "multi/" - lib = self.lib_path + "multi_repo/" - repo_name = Init.multi.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.meta.slack_rel == "current": - ver = self.meta.slack_rel - - PACKAGES_TXT = f"{repo}{ver}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{ver}/{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def slacke(self): - """Creating Slacke local library - """ - ar = "" - repo = self.def_repos_dict["slacke"] - log = self.log_path + "slacke/" - lib = self.lib_path + "slacke_repo/" - repo_name = Init.slacke.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "64" - - version = self.meta.slacke_sub_repo[1:-1] - PACKAGES_TXT = (f"{repo}slacke{version}/slackware{ar}-" - f"{self.slack_ver}/{lib_file}") - FILELIST_TXT = "" - CHECKSUMS_MD5 = (f"{repo}slacke{version}/slackware{ar}-" - f"{self.slack_ver}/{md5_file}") - ChangeLog_txt = (f"{repo}slacke{version}/slackware{ar}-" - f"{self.slack_ver}/{log_file}") - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def salix(self): - """Creating SalixOS local library - """ - ar = "i486" - repo = self.def_repos_dict["salix"] - log = self.log_path + "salix/" - lib = self.lib_path + "salix_repo/" - repo_name = Init.salix.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "x86_64" - - PACKAGES_TXT = f"{repo}{ar}/{self.slack_ver}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{ar}/{self.slack_ver}/{md5_file}" - ChangeLog_txt = f"{repo}{ar}/{self.slack_ver}/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def slackl(self): - """Creating slackel.gr local library - """ - ar = "i486" - repo = self.def_repos_dict["slackl"] - log = self.log_path + "slackl/" - lib = self.lib_path + "slackl_repo/" - repo_name = Init.slackl.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "x86_64" - - PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{ar}/current/{md5_file}" - ChangeLog_txt = f"{repo}{ar}/current/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def rested(self): - """Creating alien restricted local library - """ - repo = self.def_repos_dict["rested"] - log = self.log_path + "rested/" - lib = self.lib_path + "rested_repo/" - repo_name = Init.rested.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - PACKAGES_TXT = f"{repo}{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def msb(self): - """Creating MATE local library - """ - ar = "x86" - ver_slack = self.slack_ver - repo = self.def_repos_dict["msb"] - log = self.log_path + "msb/" - lib = self.lib_path + "msb_repo/" - repo_name = Init.msb.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "x86_64" - - version = self.meta.msb_sub_repo[1:-1] - - if self.meta.slack_rel == "current": - ver_slack = self.meta.slack_rel - - PACKAGES_TXT = f"{repo}{ver_slack}/{version}/{ar}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{ver_slack}/{version}/{ar}/{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def csb(self): - """Creating Cinnamon local library - """ - ar = "x86" - ver_slack = self.slack_ver - repo = self.def_repos_dict["csb"] - log = self.log_path + "csb/" - lib = self.lib_path + "csb_repo/" - repo_name = Init.csb.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "x86_64" - - if self.meta.slack_rel == "current": - ver_slack = self.meta.slack_rel - - PACKAGES_TXT = f"{repo}{ver_slack}/{ar}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{ver_slack}/{ar}/{md5_file}" - ChangeLog_txt = f"{repo}{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def connos(self): - """Creating connochaetos (slack-n-free) local library - """ - nickname = "slack-n-free" - ar = "" - repo = self.def_repos_dict["connos"] - log = self.log_path + "connos/" - lib = self.lib_path + "connos_repo/" - repo_name = Init.connos.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "64" - - PACKAGES_TXT = f"{repo}{nickname}{ar}-{self.slack_ver}/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{self.slack_ver}/{md5_file}" - ChangeLog_txt = f"{repo}{nickname}{ar}-{self.slack_ver}/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def mles(self): - """Creating Microlinux local library - """ - ar = "32" - repo = self.def_repos_dict["mles"] - log = self.log_path + "mles/" - lib = self.lib_path + "mles_repo/" - repo_name = Init.mles.__name__ - - lib_file = "PACKAGES.TXT" - # lst_file = "" - md5_file = "CHECKSUMS.md5" - log_file = "ChangeLog.txt" - - self.make_dir([log, lib]) - - if self.arch == "x86_64": - ar = "64" - - version = self.meta.mles_sub_repo[1:-1] - PACKAGES_TXT = f"{repo}{version}-{self.slack_ver}-{ar}bit/{lib_file}" - FILELIST_TXT = "" - CHECKSUMS_MD5 = f"{repo}{version}-{self.slack_ver}-{ar}bit/{md5_file}" - ChangeLog_txt = f"{repo}{version}-{self.slack_ver}-{ar}bit/{log_file}" - - if self.check: - return self.checks_logs(log, ChangeLog_txt) - - self.down(lib, PACKAGES_TXT, repo_name) - self.down(lib, CHECKSUMS_MD5, repo_name) - self.down(log, ChangeLog_txt, repo_name) - - self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, - FILELIST_TXT, repo_name) - - def down(self, path, link, repo): - """Downloads files - """ - filename = link.split("/")[-1] - if not os.path.isfile(path + filename): - Download(path, link.split(), repo).start() - - def remote(self, *args): - """Removes and recreates files - """ - log_path = args[0] - ChangeLog_txt = args[1] - lib_path = args[2] - PACKAGES_TXT = args[3] - CHECKSUMS_MD5 = args[4] - FILELIST_TXT = args[5] - repo = args[6] - - if self.checks_logs(log_path, ChangeLog_txt): - # remove old files - self.file_remove(log_path, ChangeLog_txt.split("/")[-1]) - self.file_remove(lib_path, PACKAGES_TXT.split("/")[-1]) - self.file_remove(lib_path, CHECKSUMS_MD5.split("/")[-1]) - self.file_remove(lib_path, FILELIST_TXT.split("/")[-1]) - - if repo == "slack": - - dirs = ["core/", "extra/"] - - for d in dirs: - self.file_remove(lib_path + d, "PACKAGES.TXT") - self.file_remove(lib_path + d, "CHECKSUMS.md5") - - self.down(lib_path + "core/", PACKAGES_TXT, repo) - self.down(lib_path + "core/", CHECKSUMS_MD5, repo) - self.down(lib_path + "extra/", self.EXTRA, repo) - self.down(lib_path + "extra/", self.EXT_CHECKSUMS, repo) - - # download new files - if repo != "slack": - self.down(lib_path, PACKAGES_TXT, repo) - self.down(lib_path, CHECKSUMS_MD5, repo) - - self.down(lib_path, FILELIST_TXT, repo) - self.down(log_path, ChangeLog_txt, repo) - - if repo == 'sbo': - self.session.query(SBoTable).delete() # delete all data - self.session.commit() - - def merge(self, path, outfile, infiles): - """Merging files - """ - code = "utf-8" - - with open(path + outfile, 'w', encoding=code) as out_f: - - for f in infiles: - - if os.path.isfile(f"{path}{f}"): - - # checking the encoding before read the file - code = self.check_encoding(path, f) - - with open(path + f, "r", encoding=code) as in_f: - - for line in in_f: - out_f.write(line) - - def file_remove(self, path, filename): - """Checks if filename exists and removes - """ - if os.path.isfile(path + filename): - os.remove(path + filename) - - def checks_logs(self, log_path, url): - """Checks ChangeLog.txt for changes - """ - local = "" - filename = url.split("/")[-1] - server = FileSize(url).server() - - if os.path.isfile(log_path + filename): - local = FileSize(log_path + filename).local() - - if server != local: - return True - - return False - - -class Upgrade: - - def __init__(self): - self.meta = _meta_ - self.log_path = self.meta.log_path - self.lib_path = self.meta.lib_path - self.session = session - - def run(self, repos): - """Removing and creating the packages lists - """ - repositories = self.meta.repositories - - # Replace the enabled repositories from user defined - if repos: - repositories = repos - - for repo in repositories: - - changelogs = f"{self.log_path}{repo}/ChangeLog.txt" - - self.del_tables(repo) - - if os.path.isfile(changelogs): - os.remove(changelogs) - - if os.path.isdir(f"{self.lib_path}{repo}_repo/"): - - for f in os.listdir(f"{self.lib_path}{repo}_repo/"): - - files = f"{self.lib_path}{repo}_repo/{f}" - - if os.path.isfile(files): - os.remove(files) - - elif os.path.isdir(files): - shutil.rmtree(files) - - update = Update() - update.run(repos) - - def del_tables(self, repo): - if repo == 'sbo': - self.session.query(SBoTable).delete() # delete all data - self.session.commit() - - -class Update: - - def __init__(self): - self.meta = _meta_ - self.grey = _meta_.color["GREY"] - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.cyan = _meta_.color["CYAN"] - self.endc = _meta_.color["ENDC"] - self.done = f"{self.green}Done{self.endc}\n" - self.error = f"{self.red}Error{self.endc}\n" - self.session = session - - def run(self, repos): - """Updates repositories lists - """ - print("\nCheck and update repositories:\n") - default = self.meta.default_repositories - enabled = self.meta.repositories - custom = Repo().custom_repository() - - # Replace the enabled repositories from user defined - if repos: - enabled = repos - - for repo in enabled: - - if check_for_local_repos(repo) is True: - continue - - self.done_msg(repo) - - if repo in default: - getattr(Init(False), repo)() - print(self.done, end="") - - elif repo in custom: - Init(False).custom(repo) - print(self.done, end="") - - else: - print(self.error, end="") - - print() # new line at end - - self.check_db() - - raise SystemExit() - - def check_db(self): - """Checking if the table is empty - """ - db = Database() - - if self.session.query(SBoTable).first() is None: - db.insert_sbo_table() - - def done_msg(self, repo): - print(f"{self.grey}Checking repository " - f"[{self.cyan}{repo}{self.grey}] ... " - f"{self.endc}", end="", flush=True) - - -def check_exists_repositories(repo): - """Checking if repositories exists by PACKAGES.TXT file - """ - pkg_list = "PACKAGES.TXT" - - if repo == "sbo": - pkg_list = "SLACKBUILDS.TXT" - - elif check_for_local_repos(repo) is True: - pkg_list = "PACKAGES.TXT" - - if not os.path.isfile(f"{_meta_.lib_path}{repo}_repo/{pkg_list}"): - return False - - -def check_for_local_repos(repo): - """Checks if repository is local - """ - repos_dict = Repo().default_repository() - if repo in repos_dict: - - repo_url = repos_dict[repo] - - if repo_url.startswith("file:///"): - return True diff --git a/slpkg/load.py b/slpkg/load.py deleted file mode 100644 index 15fa0122..00000000 --- a/slpkg/load.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# load.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.utils import Utils -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - - -def library(repo): - """Loads packages from slpkg library and from local - """ - utils = Utils() - pkg_list, packages = [], "" - - if repo == "sbo": - - if (os.path.isfile( - f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")): - packages = utils.read_file( - f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT") - - else: - - if (os.path.isfile( - f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")): - packages = utils.read_file( - f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT") - - for line in packages.splitlines(): - - if repo == "sbo": - - if line.startswith("SLACKBUILD NAME: "): - pkg_list.append(line[17:].strip()) - - elif "local" not in repo: - - if line.startswith("PACKAGE NAME: "): - pkg_list.append(line[15:].strip()) - - if repo == "local": - pkg_list = find_package("", _meta_.pkg_path) - - return pkg_list - - -class Regex: - """Graps packages with simple regex using asterisk * - with options: starts with string* - ends with *string - include *string* - """ - def __init__(self, pkgs): - self.pkgs = pkgs - - def get(self): - lib, data = [], [] - - for pkg in self.pkgs.split(","): - pr = pkg.split(":") # priotity by repository - data = library(pr[0]) # load data - - if len(pr) > 1: - - for d in data: - - if pr[1].startswith("*") and pr[1].endswith("*"): - - if pr[1][1:-1] in d: - lib.append(self.add(pr[0], d)) - - elif pr[1].endswith("*"): - - if d.startswith(pr[1][:-1]): - lib.append(self.add(pr[0], d)) - - elif pr[1].startswith("*"): - - if d.endswith(pr[1][1:]): - lib.append(self.add(pr[0], d)) - - else: - lib.append(self.add(pr[0], d)) - - else: - lib += pkg.split() - return lib - - def add(self, repo, pkg): - """Splits packages by repository - """ - if repo == "sbo": - return pkg - - else: - return split_package(pkg)[0] diff --git a/slpkg/log_deps.py b/slpkg/log_deps.py deleted file mode 100644 index 7d0fb2ec..00000000 --- a/slpkg/log_deps.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# log_deps.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - - -def write_deps(deps_dict): - """Writes dependencies in a log file - into the directory `/var/log/slpkg/dep/` - """ - for name, dependencies in deps_dict.items(): - - if find_package(f"{name}-", _meta_.pkg_path): - dep_path = f"{_meta_.log_path}dep/" - - if not os.path.exists(dep_path): - os.mkdir(dep_path) - - if os.path.isfile(f"{dep_path}{name}"): - os.remove(f"{dep_path}{name}") - - if len(dependencies) >= 1: - - with open(f"{dep_path}{name}", "w") as f: - - for dep in dependencies: - f.write(f"{dep}\n") diff --git a/slpkg/main.py b/slpkg/main.py index 9c189db6..e100a293 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -1,1038 +1,141 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# main.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - import os import sys - -from slpkg.load import Regex -from slpkg.desc import PkgDesc -from slpkg.messages import Msg -from slpkg.config import Config -from slpkg.checks import Updates -from slpkg.clean import clean_tmp -from slpkg.repoinfo import RepoInfo -from slpkg.repolist import RepoList -from slpkg.repositories import Repo -from slpkg.blacklist import BlackList -from slpkg.version import prog_version -from slpkg.auto_pkg import AutoInstall -from slpkg.health import PackageHealth -from slpkg.new_config import NewConfig -from slpkg.tracking import TrackingDeps -from slpkg.repoenable import RepoEnable -from slpkg.pkg_find import FindFromRepos -from slpkg.arguments import options, usage -from slpkg.slpkg_update import it_self_update -from slpkg.status_deps import DependenciesStatus - -from slpkg.init import ( - Update, - Upgrade, - check_exists_repositories -) -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.manager import PackageManager - -from slpkg.sbo.queue import QueuePkgs -from slpkg.sbo.check import sbo_upgrade -from slpkg.sbo.network import SBoNetwork -from slpkg.sbo.autobuild import AutoBuild -from slpkg.sbo.slackbuild import SBoInstall - -from slpkg.slack.patches import Patches -from slpkg.binary.check import pkg_upgrade -from slpkg.binary.install import BinaryInstall - - -class ArgParse(BlackList): - - def __init__(self, args): - super().__init__() - self.args = args - self.meta = _meta_ - self.msg = Msg() - self.commands = [ - "update", - "upgrade", - "repo-add", - "repo-remove", - "repo-enable", - "repo-list", - "repo-info", - "update-slpkg", - "health", - "deps-status", - "new-config", - "clean" - ] - - options = [ - "-c", "--check", - "-l", "--list", - "-c", "--check", - "-s", "--sync", - "-t", "--tracking", - "-p", "--desc", - "-F", "--FIND", - "-f", "--find" - ] - - # checking if the repositories exist - enabled_repos = _meta_.repositories - - if len(self.args) > 1: - repo = self.args[1] - check = check_exists_repositories(repo) - - if (len(self.args) > 1 and self.args[0] in options - and check is False and repo in enabled_repos): - - print("\n Please update the packages lists. Run 'slpkg update'.\n" - " This command should be used to synchronize the packages\n" - " lists from the repositories that are enabled.\n") - - raise SystemExit(1) - - def help_version(self): - """Help and version info - """ - if (len(self.args) == 1 and self.args[0] in ["-h", "--help"] and - self.args[1:] == []): - options() - - elif (len(self.args) == 1 and self.args[0] in ["-v", "--version"] and - self.args[1:] == []): - prog_version() - - else: - usage("", 1) - - def command_update(self): - """Updates package lists repositories - """ - update = Update() - - if len(self.args) == 1 and self.args[0] == "update": - update.run(repos="") - - elif (len(self.args) == 2 and self.args[0] == "update" and - self.args[1].startswith("--repos=")): - - repos = self.args[1].split("=")[-1].split(",") - - for rp in repos: - if rp not in self.meta.repositories: - usage(rp, 1) - - update.run(repos) - - else: - usage("", 1) - - def command_upgrade(self): - """Recreates repositories package lists - """ - upgrade = Upgrade() - - if len(self.args) == 1 and self.args[0] == "upgrade": - upgrade.run(repos="") - - elif (len(self.args) == 2 and self.args[0] == "upgrade" and - self.args[1].startswith("--repos=")): - - repos = self.args[1].split("=")[-1].split(",") - - for rp in repos: - - if rp not in self.meta.repositories: - usage(rp, 1) - - upgrade.run(repos) - - else: - usage("", 1) - - def command_update_slpkg(self): - """Slpkg it self update - """ - if len(self.args) == 2 and self.args[0] == "update-slpkg": - it_self_update() - - else: - usage("", 1) - - def command_repo_enable(self): - """Repositories enable/disable - """ - self.if_checklist() - if len(self.args) == 1 and self.args[0] == "repo-enable": - RepoEnable().choose() - - else: - usage("", 1) - - def command_repo_list(self): - """Repositories list - """ - if len(self.args) == 1 and self.args[0] == "repo-list": - RepoList().repos() - - else: - usage("", 1) - - def command_repo_add(self): - """Adds custom repositories - """ - if len(self.args) == 3 and self.args[0] == "repo-add": - Repo().add(self.args[1], self.args[2]) - - else: - usage("", 1) - - def command_repo_remove(self): - """Removes custom repositories - """ - if len(self.args) == 2 and self.args[0] == "repo-remove": - Repo().remove(self.args[1]) - - else: - usage("", 1) - - def command_repo_info(self): - """Repositories informations - """ - if (len(self.args) == 2 and self.args[0] == "repo-info" and - self.args[1] in RepoList().all_repos): - del RepoList().all_repos - RepoInfo().view(self.args[1]) - - elif (len(self.args) > 1 and self.args[0] == "repo-info" and - self.args[1] not in RepoList().all_repos): - usage(self.args[1], 1) - - else: - usage("", 1) - - def command_health(self): - """Checks package health - """ - if len(self.args) == 1 and self.args[0] == "health": - PackageHealth(mode="").test() - - elif (len(self.args) == 2 and self.args[0] == "health" and - self.args[1] == "--silent"): - PackageHealth(mode=self.args[1]).test() - - else: - usage("", 1) - - def command_deps_status(self): - """Prints dependencies status - """ - image = "" - - for arg in self.args: - - if arg.startswith("--graph="): - image = arg.split("=")[1] - - if len(self.args) == 1 and self.args[0] == "deps-status": - DependenciesStatus(image).show() - - elif len(self.args) == 2 and self.args[0] == "deps-status" and image: - DependenciesStatus(image).show() - - elif (len(self.args) == 2 and self.args[0] == "deps-status" and - "--tree" in self.args): - DependenciesStatus(image).tree() - - elif (len(self.args) == 3 and self.args[0] == "deps-status" and - "--tree" in self.args and image): - DependenciesStatus(image).tree() - - else: - usage("", 1) - - def command_new_config(self): - """Manages .new configuration files - """ - if len(self.args) == 1 and self.args[0] == "new-config": - NewConfig().run() - - else: - usage("", 1) - - def command_clean_tmp(self): - """Clean all downloaded packages and sources""" - if len(self.args) == 1 and self.args[0] == "clean-tmp": - clean_tmp() - - else: - usage("", 1) - - def auto_build(self): - """Auto built tool - """ - options = [ - "-a", - "--autobuild" - ] - - if len(self.args) >= 3 and self.args[0] in options: - AutoBuild(self.args[1], self.args[2:], self.meta.path).run() - - else: - usage("", 1) - - def pkg_list(self): - """List of packages by repository - """ - options = [ - "-l", - "--list" - ] - - flag = ["--index", "--installed", "--name"] - name = INDEX = installed = False - - for arg in self.args[2:]: - - if flag[0] == arg: - INDEX = True - - if flag[1] in arg: - installed = True - - if flag[2] == arg: - name = True - - if arg not in flag: - usage("", 1) - - if (len(self.args) > 1 and len(self.args) <= 5 and - self.args[0] in options): - - if self.args[1] in self.meta.repositories: - PackageManager(binary=None).package_list(self.args[1], - name, - INDEX, - installed) - - else: - usage(self.args[1], 1) - - else: - usage("", 1) - - def pkg_upgrade(self): - """Checks and upgrade packages by repository - """ - options = [ - "-c", - "--check" - ] - flags = [ - "--upgrade", - "--skip=", - "--resolve-off", - "--checklist", - "--rebuild" - ] - flag, skip = self.__pkg_upgrade_flags(flags) - - # Removes --checklist flag from args so that works with - # both conditions - # if flags[3] in self.args: - # self.args.remove(flags[3]) - - if (len(self.args) >= 3 and self.args[0] in options and - self.args[2] == flags[0] and - self.args[1] in self.meta.repositories): - - if self.args[1] not in ["slack", "sbo"]: - BinaryInstall(pkg_upgrade(self.args[1], skip, flag), - self.args[1], flag).start(is_upgrade=True) - - elif self.args[1] == "slack": - Patches(skip, flag).start() - - elif self.args[1] == "sbo": - SBoInstall(sbo_upgrade(skip, flag), flag).start( - is_upgrade=True) - - else: - usage(self.args[1], 1) - - elif len(self.args) == 1 and self.args[0] in options: - Updates(repo="").ALL() - - elif len(self.args) == 2 and self.args[0] in options: - Updates(self.args[1]).run() - - elif (len(self.args) >= 2 and self.args[0] in options and - self.args[1] not in self.meta.repositories): - usage(self.args[1], 1) - - else: - usage("", 1) - - def __pkg_upgrade_flags(self, flags): - """Manages flags for the package upgrade option - """ - # Check for typos or unssuported flags - for arg in self.args[2:]: - - if arg not in flags: - usage("", 1) - - flag, skip = [], "" - if flags[0] in self.args: - - for arg in self.args: - - if arg.startswith(flags[1]): - skip = Regex(arg.split("=")[1]).get() - self.args.remove(arg) - - if arg in flags: - flag.append(arg) - - if arg not in self.args: - self.args.remove(arg) - if "--checklist" in flag: - self.if_checklist() - - return flag, skip - - def pkg_install(self): - """Installs packages by repository - """ - flag = [] - options = [ - "-s", - "--sync" - ] - additional_options = [ - "--case-ins", - "--rebuild", - "--reinstall", - "--patches" - ] - - for arg in self.args: - - if arg.startswith(additional_options[2]): - flag.append(arg) - arg = "" - - if arg in additional_options: - flag.append(arg) - - # clean from flags - for ar in flag: - - if ar in self.args: - self.args.remove(ar) - - if len(self.args) >= 3 and self.args[0] in options: - - if (self.args[1] in self.meta.repositories and - self.args[1] not in ["sbo"]): - BinaryInstall(self.args[2:], self.args[1], flag).start( - is_upgrade=False) - - elif (self.args[1] == "sbo" and - self.args[1] in self.meta.repositories): - SBoInstall(self.args[2:], flag).start(is_upgrade=False) - - else: - usage(self.args[1], 1) - - else: - usage("", 1) - - def pkg_tracking(self): - """Tracking package dependencies - """ - flag = [] - options = [ - "-t", - "--tracking" - ] - additional_options = [ - "--check-deps", - "--graph=", - "--case-ins" - ] - for arg in self.args[2:]: - - if arg.startswith(additional_options[1]): - flag.append(arg) - self.args.remove(arg) - - if arg in additional_options: - flag.append(arg) - - # clean additional options from args - for f in flag: - - if f in self.args: - self.args.remove(f) - - # print usage message if wrong additional option - for arg in self.args: - - if arg.startswith("--"): - - if arg not in additional_options: - usage("", 1) - - if (len(self.args) >= 3 and len(self.args) <= 3 and - self.args[0] in options and - self.args[1] in self.meta.repositories): - TrackingDeps(self.args[2], self.args[1], flag).run() - - elif (len(self.args) >= 2 and - self.args[1] not in self.meta.repositories): - usage(self.args[1], 1) - - else: - usage("", 1) - - def sbo_network(self): - """Views slackbuilds packages - """ - flag = [] - options = [ - "-n", - "--network" - ] - additional_options = [ - "--checklist", - "--case-ins" - ] - - for add in additional_options: - - if add in self.args: - flag.append(add) - self.args.remove(add) - - if "--checklist" in flag: - self.if_checklist() - - if (len(self.args) == 2 and self.args[0] in options and - "sbo" in self.meta.repositories): - SBoNetwork(self.args[1], flag).view() - - elif (len(self.args) == 1 and self.args[0] in options and - "sbo" in self.meta.repositories and - additional_options[0] in flag): - SBoNetwork("", flag).view() - - else: - usage("sbo", 1) - - def pkg_blacklist(self): - """Manages blacklist packages - """ - options = [ - "-b", - "--blacklist" - ] - flag = [ - "--add", - "--remove" - ] - - command = ["list"] - - if (len(self.args) == 2 and self.args[0] in options and - self.args[1] == command[0]): - self.black_listed() - - elif (len(self.args) > 2 and self.args[0] in options and - flag[0] in self.args): - self.args.remove(flag[0]) - self.black_add(self.args[1:]) - - elif (len(self.args) == 2 and self.args[0] in options and - flag[1] in self.args): - self.args.remove(flag[1]) - self.black_remove(list(self.get_black())) - - elif (len(self.args) > 2 and self.args[0] in options and - flag[1] in self.args): - self.args.remove(flag[1]) - self.black_remove(self.args[1:]) - - else: - usage("", 1) - - def pkg_queue(self): - """Manages packages in queue - """ - queue = QueuePkgs() - options = [ - "-q", - "--queue" - ] - - flag = [ - "--add", - "--remove" - ] - - command = [ - "list", - "build", - "install", - "build-install" - ] - - if (len(self.args) > 2 and self.args[0] in options and - flag[0] in self.args): - self.args.remove(flag[0]) - queue.add(self.args[1:]) - - elif (len(self.args) == 2 and self.args[0] in options and - flag[1] in self.args): - self.args.remove(flag[1]) - queue.remove(queue.packages()) - - elif (len(self.args) > 2 and self.args[0] in options and - flag[1] in self.args): - self.args.remove(flag[1]) - queue.remove(self.args[1:]) - - elif (len(self.args) == 2 and self.args[0] in options and - self.args[1] == command[0]): - queue.listed() - - elif (len(self.args) == 2 and self.args[0] in options and - self.args[1] == command[1]): - queue.build() - - elif (len(self.args) == 2 and self.args[0] in options and - self.args[1] == command[2]): - queue.install() - - elif (len(self.args) == 2 and self.args[0] in options and - self.args[1] == command[3]): - queue.build() - queue.install() - - else: - usage("", 1) - - def bin_install(self): - """Installs Slackware binary packages - """ - packages = self.args[1:] - - options = [ - "-i", - "--installpkg" - ] - - flag = "" - - flags = [ - "--warn", - "--md5sum", - "--root", - "--infobox", - "--menu", - "--terse", - "--ask", - "--priority", - "--tagfile" - ] - - if len(self.args) > 1 and self.args[0] in options: - - if self.args[1] in flags: - flag = self.args[1] - packages = self.args[2:] - - PackageManager(packages).install(flag) - - else: - usage("", 1) - - def bin_upgrade(self): - """Installs, upgrades Slackware binary packages - """ - packages = self.args[1:] - - options = [ - "-u", - "--upgradepkg" - ] - - flag = "" - - flags = [ - "--dry-run", - "--install-new", - "--reinstall", - "--verbose" - ] - - if len(self.args) > 1 and self.args[0] in options: - - if self.args[1] in flags: - flag = self.args[1] - packages = self.args[2:] - - PackageManager(packages).upgrade(flag) - - else: - usage("", 1) - - def bin_remove(self): - """Remove Slackware packages - """ - packages = self.args[1:] - - options = [ - "-r", - "--removepkg" - ] - - additional_options = [ - "--deps", - "--check-deps", - "--tag", - "--checklist", - "--third-party" - ] - - flag, extra = "", [] - - flags = [ - "-warn", - "-preserve", - "-copy", - "-keep" - ] - - # merge --check-deps and --deps options - if (additional_options[1] in self.args and - additional_options[0] not in self.args): - self.args.append(additional_options[0]) - - if len(self.args) > 1 and self.args[0] in options: - - for additional in additional_options: - - if additional in self.args: - extra.append(additional) - self.args.remove(additional) - +from dataclasses import dataclass + +from cli_menu import usage +from metadata import Metadata +from queries import SBoQueries +from slackbuild import Slackbuilds +from remove_packages import RemovePackages +from update_repository import UpdateRepository +from clean_logs import CleanLogsDependencies + + +@dataclass +class Check: + slackbuilds: list + log_packages: str = Metadata.log_packages + repo_tag: str = Metadata.repo_tag + + def exists(self): + ''' Checking if the slackbuild exists in the repository. ''' + for sbo in self.slackbuilds: + if not SBoQueries(sbo).slackbuild(): + raise SystemExit(f'Error: Slackbuild {sbo} does not exists.') + + def unsupported(self): + ''' Checking for unsupported slackbuilds. ''' + for sbo in self.slackbuilds: + sources = SBoQueries(sbo).sources() + if 'UNSUPPORTED' in sources: + raise SystemExit(f'Error: Slackbuild {sbo} ' + 'unsupported by arch.') + + def installed(self): + ''' Checking for installed packages. ''' + installed = os.listdir(self.log_packages) + for package in installed: + for sbo in self.slackbuilds: + if sbo + '-' in package and self.repo_tag in package: + return + raise SystemExit('Error: Not found packages for remove.') + + +@dataclass +class Argparse: + args: list + + def flags(self): + self.flags = [] + resolve_off = '--resolve-off' + yes = '--yes' + + if resolve_off in self.args: + self.args.remove(resolve_off) + self.flags.append(resolve_off) + + if yes in self.args: + self.args.remove(yes) + self.flags.append(yes) + + def command(self): + + self.flags() + + if len(self.args) <= 0: + usage(1) + + if len(self.args) == 1: + if self.args[0] in ['--help', '-h']: + usage(0) + + if self.args[0] in ['--version', '-v']: + print(f'{Metadata.proj_name}: {Metadata.version}') + raise SystemExit(0) + + if self.args[0] == 'clean-logs': + logs = CleanLogsDependencies(self.flags) + logs.clean() + raise SystemExit(0) + + # Update repository + if self.args[0] == 'update': + update = UpdateRepository() + update.sbo() + raise SystemExit(0) + + usage(1) + + if len(self.args) >= 2: + # Build slackbuilds + if self.args[0] == 'build': packages = self.args[1:] - for fl in flags: + check = Check(packages) + check.exists() + check.unsupported() - if fl in self.args: - flag = self.args[1] - packages = self.args[2:] + build = Slackbuilds(packages, self.flags, False) + build.execute() + raise SystemExit() - if "--checklist" in extra: - self.if_checklist() + # Install packages + if self.args[0] == 'install': + packages = self.args[1:] - if not packages: - packages = [""] - PackageManager(packages).remove(flag, extra) + check = Check(packages) + check.exists() + check.unsupported() - else: - usage("", 1) + install = Slackbuilds(packages, self.flags, True) + install.execute() + raise SystemExit() - def bin_find(self): - """Finds installed packages - """ - flag = [] - options = [ - "-f", - "--find" - ] + # Remove packages + if self.args[0] == 'remove': + packages = self.args[1:] - additional_options = [ - "--case-ins", - "--third-party" - ] + check = Check(packages) + check.installed() - for add in additional_options: + remove = RemovePackages(packages, self.flags) + remove.remove() + raise SystemExit() - if add in self.args: - flag.append(add) - self.args.remove(add) - - packages = self.args[1:] - - if not packages: - packages = [""] - - if len(self.args) == 1 and self.args[0] in options: - PackageManager(packages).find(flag) - - elif len(self.args) > 1 and self.args[0] in options: - PackageManager(packages).find(flag) - - else: - usage("", 1) - - def pkg_desc(self): - """Prints slack-desc by repository - """ - options = [ - "-p", - "--desc" - ] - - flag = ["--color="] - - colors = [ - "red", - "green", - "yellow", - "cyan", - "grey" - ] - - tag = "" - - for arg in self.args: - - if arg.startswith(flag[0]): - tag = arg[len(flag[0]):] - self.args.remove(arg) - break - - if tag and tag not in colors: - raise SystemExit(f"\nslpkg: Error: Available colors {colors}\n") - - if (len(self.args) == 3 and self.args[0] in options and - self.args[1] in self.meta.repositories and tag in colors): - PkgDesc(self.args[2], self.args[1], tag).view() - - elif (len(self.args) == 3 and self.args[0] in options and - self.args[1] in self.meta.repositories): - PkgDesc(self.args[2], self.args[1], paint="").view() - - elif (len(self.args) > 1 and self.args[0] in options and - self.args[1] not in self.meta.repositories): - usage(self.args[1], 1) - - else: - usage("", 1) - - def pkg_find(self): - """Finds packages from all the enabled repositories - """ - flag = [] - options = [ - "-F", - "--FIND" - ] - - additional_options = ["--case-ins"] - - for arg in self.args: - - if arg in additional_options: - flag.append(arg) - self.args.remove(arg) - - packages = self.args[1:] - - if len(self.args) > 1 and self.args[0] in options: - FindFromRepos().find(packages, flag) - - else: - usage("", 1) - - def pkg_contents(self): - """Prints packages contents - """ - packages = self.args[1:] - - options = [ - "-d", - "--display" - ] - - if len(self.args) > 1 and self.args[0] in options: - PackageManager(packages).display() - - else: - usage("", 1) - - def congiguration(self): - """Manages slpkg configuration file - """ - options = [ - "-g", - "--config" - ] - - command = [ - "print", - "edit", - "reset" - ] - - conf = Config() - - if (len(self.args) == 2 and self.args[0] in options - and self.args[1] in command): - - if self.args[1] == command[0]: - conf.view() - - if self.args[1] == command[1]: - conf.edit() - - if self.args[1] == command[2]: - conf.reset() - - else: - usage("", 1) - - def auto_detect(self, args): - """Checks for already Slackware binary packages - """ - suffixes = [ - ".tgz", - ".txz", - ".tbz", - ".tlz" - ] - - if (not args[0].startswith("-") and args[0] not in self.commands and - args[0].endswith(tuple(suffixes))): - packages, not_found = [], [] - - for pkg in args: - - if pkg.endswith(tuple(suffixes)): - - if os.path.isfile(pkg): - packages.append(pkg) - - else: - not_found.append(pkg) - - if packages: - AutoInstall(packages).select() - - if not_found: - - for ntf in not_found: - self.msg.pkg_not_found("", ntf, "Not installed", "") - - raise SystemExit(0) - - def if_checklist(self): - try: - from dialog import Dialog - except ImportError: - raise SystemExit("Require 'pythondialog': Install with 'slpkg " - "-s sbo python3-pythondialog'") + usage(1) def main(): - args = sys.argv args.pop(0) - argparse = ArgParse(args) - - if len(args) == 0: - usage("", 1) - - argparse.auto_detect(args) - - if len(args) == 2 and args[0] == "update" and args[1] == "slpkg": - args[0] = "update-slpkg" - - arguments = { - "-h": argparse.help_version, - "--help": argparse.help_version, - "-v": argparse.help_version, - "--version": argparse.help_version, - "update": argparse.command_update, - "upgrade": argparse.command_upgrade, - "update-slpkg": argparse.command_update_slpkg, - "repo-enable": argparse.command_repo_enable, - "repo-list": argparse.command_repo_list, - "repo-add": argparse.command_repo_add, - "repo-remove": argparse.command_repo_remove, - "repo-info": argparse.command_repo_info, - "health": argparse.command_health, - "deps-status": argparse.command_deps_status, - "new-config": argparse.command_new_config, - "clean-tmp": argparse.command_clean_tmp, - "-a": argparse.auto_build, - "--autobuild": argparse.auto_build, - "-l": argparse.pkg_list, - "--list": argparse.pkg_list, - "-c": argparse.pkg_upgrade, - "--check": argparse.pkg_upgrade, - "-s": argparse.pkg_install, - "--sync": argparse.pkg_install, - "-t": argparse.pkg_tracking, - "--tracking": argparse.pkg_tracking, - "-n": argparse.sbo_network, - "--netwotk": argparse.sbo_network, - "-b": argparse.pkg_blacklist, - "--blacklist": argparse.pkg_blacklist, - "-q": argparse.pkg_queue, - "--queue": argparse.pkg_queue, - "-i": argparse.bin_install, - "--installpkg": argparse.bin_install, - "-u": argparse.bin_upgrade, - "--upgradepkg": argparse.bin_upgrade, - "-r": argparse.bin_remove, - "--removepkg": argparse.bin_remove, - "-f": argparse.bin_find, - "--find": argparse.bin_find, - "-F": argparse.pkg_find, - "--FIND": argparse.pkg_find, - "-p": argparse.pkg_desc, - "--desc": argparse.pkg_desc, - "-d": argparse.pkg_contents, - "--display": argparse.pkg_contents, - "-g": argparse.congiguration, - "--config": argparse.congiguration - } - try: - arguments[args[0]]() - except KeyError: - usage("", 1) + argparse = Argparse(args) + argparse.command() -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/slpkg/md5sum.py b/slpkg/md5sum.py deleted file mode 100644 index 49ec35f2..00000000 --- a/slpkg/md5sum.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# md5sum.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import hashlib - - -def md5(source): - """Return MD5 Checksum - """ - # fix passing char '+' from source - source = source.replace("%2B", "+") - - with open(source, "rb") as file_to_check: - data = file_to_check.read() - - return hashlib.md5(data).hexdigest() diff --git a/slpkg/messages.py b/slpkg/messages.py deleted file mode 100644 index 486b750c..00000000 --- a/slpkg/messages.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# messages.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import itertools - -from slpkg.__metadata__ import MetaData as _meta_ - - -class Msg: - """Messages control - """ - def __init__(self): - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.grey = _meta_.color["GREY"] - self.red = _meta_.color["RED"] - self.cyan = _meta_.color["CYAN"] - self.endc = _meta_.color["ENDC"] - - def pkg_not_found(self, bol, pkg, message, eol): - print(f"{bol}No such package {pkg}: {message}{eol}") - - def pkg_found(self, prgnam): - print(f"| Package {prgnam} is already installed") - - def pkg_installed(self, pkg): - print(f"| Package {pkg} installed") - - def build_FAILED(self, prgnam): - self.template(78) - print(f"| Some error on the package {prgnam} " - f"[ {self.red}FAILED{self.endc} ]") - self.template(78) - print(f"| See the log file in '{self.cyan}" - f"/var/log/slpkg/sbo/build_logs{self.endc}' " - f"directory or read the README file") - self.template(78) - print() # new line at end - - def template(self, max_len): - print("+" + "=" * max_len) - - def checking(self): - print(f"{self.grey}Checking...{self.endc} ", end="", flush=True) - - def reading(self): - print(f"{self.grey}Reading package lists...{self.endc} ", - end="", flush=True) - - def resolving(self): - print(f"{self.grey}Resolving dependencies...{self.endc} ", - end="", flush=True) - - def done(self): - print(f"\b{self.green}Done{self.endc}\n", end="") - - def pkg(self, count): - message = "package" - if count > 1: - message = message + "s" - - return message - - def not_found(self, if_upgrade): - if if_upgrade: - print("\nNot found packages for upgrade\n") - - else: - print("\nNot found packages for installation\n") - - def upg_inst(self, if_upgrade): - if not if_upgrade: - print("Installing:") - - else: - print("Upgrading:") - - def answer(self): - if self.meta.default_answer in ["y", "Y"]: - answer = self.meta.default_answer - - else: - try: - answer = input("Would you like to continue [y/N]? ") - except EOFError: - raise SystemExit("\n") - return answer - - def security_pkg(self, pkg): - print() - self.template(78) - print(f"| {' ' * 27}{self.red}*** WARNING ***{self.endc}") - self.template(78) - print(f"| Before proceed with the package '{pkg}' will you must read\n" - f"| the README file. You can use the command " - f"'slpkg -n {pkg}'") - self.template(78) - print() - - def reference(self, install, upgrade): - self.template(78) - print(f"| Total {len(install)} {self.pkg(len(install))} installed and " - f"{len(upgrade)} {self.pkg(len(upgrade))} upgraded") - self.template(78) - - for installed, upgraded in itertools.zip_longest(install, upgrade): - - if upgraded: - print(f"| Package {upgraded} upgraded successfully") - - if installed: - print(f"| Package {installed} installed successfully") - - self.template(78) - print() - - def matching(self, packages): - print(f"\nNot found package with the name " - f"[ {self.cyan}{''.join(packages)}{self.endc} ]. " - "Matching packages:\nNOTE: Not dependencies are resolved\n") diff --git a/slpkg/metadata.py b/slpkg/metadata.py new file mode 100644 index 00000000..675cd426 --- /dev/null +++ b/slpkg/metadata.py @@ -0,0 +1,93 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +# import json +from dataclasses import dataclass + + +@dataclass +class Metadata: + + # Project info + prog_name: str = 'slpkg' + version_info: tuple = (4, 1, 0) + version: str = '{0}.{1}.{2}'.format(*version_info) + license: str = 'MIT' + author: str = 'dslackw' + + ''' Default configurations. ''' + # OS architecture by default + os_arch: str = 'x86_64' + # All necessary paths + tmp_path: str = '/tmp' + tmp_slpkg: str = f'{tmp_path}/{prog_name}' + build_path: str = f'/tmp/{prog_name}/build' + lib_path: str = f'/var/lib/{prog_name}' + log_path: str = f'/var/log/{prog_name}' + db_path: str = f'/var/lib/{prog_name}/database' + sbo_repo_path: str = f'/var/lib/{prog_name}/repository' + log_packages: str = '/var/log/packages' + # Database name + database: str = f'database.{prog_name}' + # Repository details + repo_version: str = '15.0' + sbo_url: str = f'http://slackbuilds.org/slackbuilds/{repo_version}' + sbo_txt: str = 'SLACKBUILDS.TXT' + tar_suffix: str = '.tar.gz' + pkg_suffix: str = '.tgz' + repo_tag: str = '_SBo' + # Slackware commands + installpkg: str = 'upgradepkg --install-new' + removepkg: str = 'removepkg' + # Other configs + colors: str = 'on' + wget_options = '-c -N' + + @classmethod + def colour(cls): + color = { + 'RED': '', + 'GREEN': '', + 'YELLOW': '', + 'CYAN': '', + 'GREY': '', + 'ENDC': '' + } + + if cls.colors in ['on', 'ON']: + color = { + 'RED': '\x1b[31m', + 'GREEN': '\x1b[32m', + 'YELLOW': '\x1b[93m', + 'CYAN': '\x1b[36m', + 'GREY': '\x1b[38;5;247m', + 'ENDC': '\x1b[0m' + } + + return color + + ''' User configuration in /etc/slpkg/ folder. ''' + # with open(f'/etc/{prog_name}/{prog_name}.json', 'r') as conf: + # config = json.load(conf) + + # tmp_path: str = config['tmp_path'] + # tmp_slpkg: str = config['tmp_slpkg'] + # build_path: str = config['build_path'] + # lib_path: str = config['lib_path'] + # log_path: str = config['log_path'] + # db_path: str = config['db_path'] + # sbo_repo_path: str = config['sbo_repo_path'] + # log_packages: str = config['log_packages'] + # # Database name + # database: str = config['database'] + # # Repository details + # repo_version: str = config['repo_version'] + # sbo_url: str = config['sbo_url'] + # sbo_txt: str = config['sbo_txt'] + # tar_suffix: str = config['tar_suffix'] + # pkg_suffix: str = config['pkg_suffix'] + # repo_tag: str = config['repo_tag'] + # # Slackware commands + # upgradepkg: str = config['upgradepkg'] + # removepkg: str = config['removepkg'] diff --git a/slpkg/models/__init.py__ b/slpkg/models/__init__.py similarity index 100% rename from slpkg/models/__init.py__ rename to slpkg/models/__init__.py diff --git a/slpkg/models/data.py b/slpkg/models/data.py deleted file mode 100644 index b406012b..00000000 --- a/slpkg/models/data.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# data.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from progress.bar import Bar -from slpkg.__metadata__ import MetaData as _meta_ -from slpkg.models.models import SBoTable, session - - -class Database: - - def __init__(self): - self.lib_path = _meta_.lib_path - self.session = session - - def insert_sbo_table(self): - """Grabbing data line by line and inserting them into the database - """ - - sbo_tags = [ - "SLACKBUILD NAME:", - "SLACKBUILD LOCATION:", - "SLACKBUILD FILES:", - "SLACKBUILD VERSION:", - "SLACKBUILD DOWNLOAD:", - "SLACKBUILD DOWNLOAD_x86_64:", - "SLACKBUILD MD5SUM:", - "SLACKBUILD MD5SUM_x86_64:", - "SLACKBUILD REQUIRES:", - "SLACKBUILD SHORT DESCRIPTION:" - ] - - sbo_file = self.open_file(f"{self.lib_path}sbo_repo/SLACKBUILDS.TXT") - - bar = Bar("Creating sbo database", max=len(sbo_file), - suffix="%(percent)d%% - %(eta)ds") - - cache = [] # init cache - - for i, line in enumerate(sbo_file, 1): - - for s in sbo_tags: - if line.startswith(s): - line = line.replace(s, "").strip() - cache.append(line) - - if (i % 11) == 0: - data = SBoTable(name=cache[0], location=cache[1], - files=cache[2], version=cache[3], - download=cache[4], download64=cache[5], - md5sum=cache[6], md5sum64=cache[7], - requires=cache[8], short_description=cache[9]) - self.session.add(data) - - cache = [] # reset cache after 11 lines - - bar.next() - bar.finish() - - self.session.commit() - - def open_file(self, file): - with open(file, "r", encoding="utf-8") as f: - return f.readlines() diff --git a/slpkg/models/models.py b/slpkg/models/models.py index 5dfd0958..31100e45 100644 --- a/slpkg/models/models.py +++ b/slpkg/models/models.py @@ -1,58 +1,51 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -# models.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - +from metadata import Metadata +from dataclasses import dataclass from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import create_engine, Column, Integer, Text -from slpkg.__metadata__ import MetaData as _meta_ -lib_path = _meta_.lib_path -db = _meta_.db +db_path = Metadata.db_path +database = Metadata.database -DATABASE_URI = f"sqlite:///{lib_path}{db}" +DATABASE_URI = f"sqlite:///{db_path}/{database}" engine = create_engine(DATABASE_URI) session = sessionmaker(engine)() Base = declarative_base() +@dataclass class SBoTable(Base): + ''' The main table for the SBo repository. ''' __tablename__ = "sbotable" - id = Column(Integer, primary_key=True) - name = Column(Text) - location = Column(Text) - files = Column(Text) - version = Column(Text) - download = Column(Text) - download64 = Column(Text) - md5sum = Column(Text) - md5sum64 = Column(Text) - requires = Column(Text) - short_description = Column(Text) + id: int = Column(Integer, primary_key=True) + name: str = Column(Text) + location: str = Column(Text) + files: str = Column(Text) + version: str = Column(Text) + download: str = Column(Text) + download64: str = Column(Text) + md5sum: str = Column(Text) + md5sum64: str = Column(Text) + requires: str = Column(Text) + short_description: str = Column(Text) + + +@dataclass +class LogsDependencies(Base): + ''' The table that stores the dependencies after installing a package. ''' + + __tablename__ = 'logsdependencies' + + id: int = Column(Integer, primary_key=True) + name: str = Column(Text) + requires: str = Column(Text) Base.metadata.create_all(engine) diff --git a/slpkg/new_config.py b/slpkg/new_config.py deleted file mode 100644 index dea9ddd9..00000000 --- a/slpkg/new_config.py +++ /dev/null @@ -1,271 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# new_config.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import shutil -import itertools - -from slpkg.messages import Msg -from slpkg.utils import Utils -from slpkg.__metadata__ import MetaData as _meta_ - - -class NewConfig(Utils): - """Manages .new configuration files - """ - def __init__(self): - self.meta = _meta_ - self.msg = Msg() - self.red = self.meta.color["RED"] - self.green = self.meta.color["GREEN"] - self.endc = self.meta.color["ENDC"] - self.br = "" - - if self.meta.use_colors in ["off", "OFF"]: - self.br = ")" - - self.etc = "/etc/" - self.news = [] - - def run(self): - """prints .new configuration files - """ - self.find_new() - - for n in self.news: - print(n) - - print() - self.msg.template(78) - print(f"| Installed {len(self.news)} new configuration files:") - - self.msg.template(78) - self.choices() - - def find_new(self): - """Finds all '.new' files from /etc/ folder - and subfolders - """ - print("Search for .new configuration files:\n") - - for path, dirs, files in os.walk(self.etc): - del dirs # delete unsed - - for f in files: - - if f.endswith(".new"): - self.news.append(os.path.join(path, f)) - - if not self.news: - print(" No new configuration files\n") - raise SystemExit() - - def choices(self): - """Menu options for new configuration files - """ - print(f"| {self.red}K{self.endc}{self.br}eep the old and .new files, no changes") - print(f"| {self.red}O{self.endc}{self.br}verwrite all old configuration files with new ones") - print("| The old files will be saved with suffix .old") - print(f"| {self.red}R{self.endc}{self.br}emove all .new files") - print(f"| {self.red}P{self.endc}{self.br}rompt K, O, R, D, M option for each single file") - print(f"| {self.red}Q{self.endc}{self.br}uit from menu") - self.msg.template(78) - - try: - choose = input("\nWhat would you like to do [K/O/R/P/Q]? ") - except EOFError: - raise SystemExit("\n") - - print() - - if choose in ("K", "k"): - self.keep() - - elif choose in ("O", "o"): - self.overwrite_all() - - elif choose in ("R", "r"): - self.remove_all() - - elif choose in ("P", "p"): - self.prompt() - - def overwrite_all(self): - """Overwrites all .new files and keep - old with suffix .old - """ - for n in self.news: - self._overwrite(n) - - def remove_all(self): - """Removes all .new files - """ - for n in self.news: - self._remove(n) - print() - - def prompt(self): - """Select file - """ - self.msg.template(78) - print("| Choose what to do file by file:") - print("| {0}K{1}{2}eep, {3}O{4}{5}verwrite, {6}R{7}{8}emove, " - "{9}D{10}{11}iff, {12}M{13}{14}erge, {15}Q{16}{17}uit".format( - self.red, self.endc, self.br, self.red, self.endc, self.br, - self.red, self.endc, self.br, self.red, self.endc, self.br, - self.red, self.endc, self.br, self.red, self.endc, self.br)) - self.msg.template(78) - print() - - self.i = 0 - - try: - while self.i < len(self.news): - self.question(self.news[self.i]) - self.i += 1 - except EOFError: - raise SystemExit("\n") - - def question(self, n): - """Chooses what do to file by file - """ - print() - prompt_ask = input(f"{n} [K/O/R/D/M/Q]? ") - print() - - if prompt_ask in ("K", "k"): - self.keep() - - elif prompt_ask in ("O", "o"): - self._overwrite(n) - - elif prompt_ask in ("R", "r"): - self._remove(n) - - elif prompt_ask in ("D", "d"): - self.diff(n) - self.i -= 1 - - elif prompt_ask in ("M", "m"): - self.merge(n) - - elif prompt_ask in ("Q", "q", "quit"): - self.quit() - - def _remove(self, n): - """Removes one single file - """ - if os.path.isfile(n): - os.remove(n) - - if not os.path.isfile(n): - print(f"File '{n}' removed") - - def _overwrite(self, n): - """Overwrites old file with new and keep file with suffix .old - """ - if os.path.isfile(n[:-4]): - shutil.copy2(n[:-4], n[:-4] + ".old") - print("Old file {0} saved as {1}.old".format( - n[:-4].split("/")[-1], n[:-4].split("/")[-1])) - - if os.path.isfile(n): - shutil.move(n, n[:-4]) - print("New file {0} overwrite as {1}".format( - n.split("/")[-1], n[:-4].split("/")[-1])) - - def keep(self): - pass - - def diff(self, n): - """Prints the differences between the two files - """ - if os.path.isfile(n[:-4]): - diff1 = self.read_file(n[:-4]).splitlines() - - if os.path.isfile(n): - diff2 = self.read_file(n).splitlines() - - lines, ln, c = [], 0, 0 - - for a, b in itertools.izip_longest(diff1, diff2): - ln += 1 - - if a != b: - - for s1, s2 in itertools.izip_longest(str(a), str(b)): - c += 1 - - if s1 != s2: - break - print(f"@@ -{ln},{c} +{ln},{c} @@\n") - - for line in lines[-3:]: - print(f"{line}") - - if a is None: - a = "" - - print(f"{self.red}-{self.endc}{a}") - - if b is None: - b = "" - - print(f"{self.green}+{self.endc}{b}") - lines = [] - c = 0 - - else: - lines.append(a) - - def merge(self, n): - """Merges new file into old - """ - if os.path.isfile(n[:-4]): - old = self.read_file(n[:-4]).splitlines() - - if os.path.isfile(n): - new = self.read_file(n).splitlines() - - with open(n[:-4], "w") as out: - - for l1, l2 in itertools.izip_longest(old, new): - - if l1 is None: - l1 = "" - - if l2 is None: - l2 = "" - - if l1 != l2: - out.write(l2 + "\n") - - else: - out.write(l1 + "\n") - - print("The file {0} merged in file {1}".format( - n.split("/")[-1], n[:-4].split("/")[-1])) - - def quit(self): - raise SystemExit() diff --git a/slpkg/pkg/__init__.py b/slpkg/pkg/__init__.py deleted file mode 100644 index 1c43f989..00000000 --- a/slpkg/pkg/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# [ packages ] directory diff --git a/slpkg/pkg/build.py b/slpkg/pkg/build.py deleted file mode 100644 index 6bbfe032..00000000 --- a/slpkg/pkg/build.py +++ /dev/null @@ -1,229 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# build.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import re -import sys -import time -import shutil -import tarfile -import itertools -import subprocess -import multiprocessing - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.checksum import check_md5 -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.sbo.greps import SBoGrep - - -class BuildPackage(Utils): - """Builds SBo packages from source - """ - def __init__(self, script, sources, path, auto): - self.script = script - self.sources = sources - self._check_sources() - self.path = path - self.auto = auto - self.meta = _meta_ - self.msg = Msg() - self._SOURCES = self.meta.SBo_SOURCES - self.prgnam = self.script[:-7] - self.log_file = f"build_{self.prgnam}_log" - self.sbo_logs = self.meta.log_path + "sbo/" - self.build_logs = self.sbo_logs + "build_logs/" - self.start_log_time = time.strftime("%H:%M:%S") - self.start_time = time.time() - - if not os.path.exists(self.meta.log_path): - os.mkdir(self.meta.log_path) - - if not os.path.exists(self.sbo_logs): - os.mkdir(self.sbo_logs) - - if not os.path.exists(self.build_logs): - os.mkdir(self.build_logs) - - def build(self): - """Builds package from source and creates log - file in path /var/log/slpkg/sbo/build_logs/. - Also checks the md5sum calculation. - """ - try: - self._delete_dir() - - try: - tar = tarfile.open(self.script) - except Exception as err: - raise SystemExit(err) - - tar.extractall() - tar.close() - - self._makeflags() - self._delete_sbo_tar_gz() - self._create_md5_dict() - - if not self.auto: - os.chdir(self._SOURCES) - - for src in self.sources: - - if not os.path.isfile(src): - continue - # fix build sources with spaces - src = src.replace("%20", " ") - check_md5(self.sbo_md5[src], src) - # copy source and fix passing char '+' from file name - shutil.copy2(src, self.path + self.prgnam) - - os.chdir(self.path + self.prgnam) - - # change permissions - subprocess.call(f"chmod +x {self.prgnam}.SlackBuild", shell=True) - - pass_var = self._pass_variable() - - if self.meta.sbo_build_log in ["on", "ON"]: - - if os.path.isfile(self.build_logs + self.log_file): - os.remove(self.build_logs + self.log_file) - - # start log write - log_head(self.build_logs, self.log_file, self.start_log_time) - subprocess.Popen(f"{' '.join(pass_var)} ./{self.prgnam}.SlackBuild 2>&1 | tee -a " - f"{self.build_logs}{self.log_file}", shell=True, stdout=sys.stdout).communicate() - - sum_time = build_time(self.start_time) - - # write end in log file - log_end(self.build_logs, self.log_file, sum_time) - print(f"Total build time for the package {self.prgnam} : {sum_time}\n") - - else: - subprocess.call(f"{' '.join(pass_var)} ./{self.prgnam}.SlackBuild", shell=True) - os.chdir(self.path) - - except (KeyboardInterrupt, KeyError) as e: - print(e) # (OSError, IOError, KeyError): - self.msg.pkg_not_found("\n", self.prgnam, "Wrong file", "\n") - - def _check_sources(self): - """Fixes filenames with char + - """ - new_sources = [] - for src in self.sources: - new_sources.append(self.fix_file_name(src)) - - self.sources = new_sources - - def _create_md5_dict(self): - """Creates md5 dictionary per source - """ - self.sbo_md5 = {} - - md5_lists = SBoGrep(self.prgnam).checksum() - - for src, md5 in itertools.zip_longest(self.sources, md5_lists): - self.sbo_md5[src] = md5 - - def _makeflags(self): - """Sets variable MAKEFLAGS with the numbers of - processors - """ - if self.meta.makeflags in ["on", "ON"]: - cpus = multiprocessing.cpu_count() - os.environ["MAKEFLAGS"] = f"-j{cpus}" - - def _pass_variable(self): - """Returns enviroment variables - """ - pass_var = [] - - for var in os.environ.keys(): - expVAR = var.split("_") - - if expVAR[0] == self.prgnam.upper() and expVAR[1] != "PATH": - pass_var.append(f"{expVAR[1]}={os.environ[var]}") - - return pass_var - - def _delete_sbo_tar_gz(self): - """Deletes slackbuild tar.gz file after untar - """ - if not self.auto and os.path.isfile(self.meta.build_path + self.script): - os.remove(self.meta.build_path + self.script) - - def _delete_dir(self): - """Deletes old folder if exists before start build - """ - if not self.auto and os.path.isdir(self.meta.build_path + self.prgnam): - shutil.rmtree(self.meta.build_path + self.prgnam) - - -def log_head(path, log_file, log_time): - """Writes headers to log file - """ - with open(path + log_file, "w") as log: - log.write("#" * 79 + "\n\n") - log.write("File : " + log_file + "\n") - log.write("Path : " + path + "\n") - log.write("Date : " + time.strftime("%d/%m/%Y") + "\n") - log.write("Time : " + log_time + "\n\n") - log.write("#" * 79 + "\n\n") - - -def log_end(path, log_file, sum_time): - """Appends END tag to a log file - """ - with open(path + log_file, "a") as log: - log.seek(2) - log.write("#" * 79 + "\n\n") - log.write("Time : " + time.strftime("%H:%M:%S") + "\n") - log.write(f"Total build time : {sum_time}\n") - log.write(" " * 38 + "E N D\n\n") - log.write("#" * 79 + "\n\n") - - -def build_time(start_time): - """Calculates build time per package - """ - diff_time = round(time.time() - start_time, 2) - if diff_time <= 59.99: - sum_time = str(diff_time) + " Sec" - - elif diff_time > 59.99 and diff_time <= 3599.99: - sum_time = round(diff_time / 60, 2) - sum_time_list = re.findall(r"\d+", str(sum_time)) - sum_time = (f"{sum_time_list[0]} Min {sum_time_list[1]} Sec") - - elif diff_time > 3599.99: - sum_time = round(diff_time / 3600, 2) - sum_time_list = re.findall(r"\d+", str(sum_time)) - sum_time = (f"{sum_time_list[0]} Hours {sum_time_list[1]} Min") - - return sum_time diff --git a/slpkg/pkg/find.py b/slpkg/pkg/find.py deleted file mode 100644 index 8c4bd149..00000000 --- a/slpkg/pkg/find.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# find.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from slpkg.blacklist import BlackList -from slpkg.splitting import split_package - - -def searching(find_pkg, directory): - """Find packages - """ - black = BlackList() - - if os.path.isdir(directory): - installed = os.listdir(directory) - blacklist = list(black.get_black()) - - if os.path.exists(directory): - - for pkg in installed: - - if (not pkg.startswith(".") and pkg.startswith(find_pkg) and - split_package(pkg)[0] not in blacklist): - - yield pkg - - -def find_package(pkg, path): - """Generator allias - """ - return list(searching(pkg, path)) diff --git a/slpkg/pkg/installed.py b/slpkg/pkg/installed.py deleted file mode 100644 index b3744047..00000000 --- a/slpkg/pkg/installed.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -* - -# installed.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.pkg.find import find_package - -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - - -class GetFromInstalled: - """Finds and returns version and package name from - already installed packages - """ - def __init__(self, package): - self.package = package - self.meta = _meta_ - self.files = find_package(f"{self.package}-", self.meta.pkg_path) - self.find = "" - - for file in self.files: - - if split_package(file)[0] == self.package: - self.find = file - - def version(self): - """Returns version from installed packages - """ - if self.find: - return split_package(self.find)[1] - - return self.find - - def name(self): - """Returns installed package name - """ - if self.find: - return self.package - - return self.find diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py deleted file mode 100644 index 0ddbefb0..00000000 --- a/slpkg/pkg/manager.py +++ /dev/null @@ -1,712 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# manager.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import re -import subprocess - - -from slpkg.pkg.find import find_package -from slpkg.pkg.installed import GetFromInstalled - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.dialog_box import DialogUtil -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.slack.slackware_repo import slackware_repository - - -class PackageManager(Utils): - """Package manager class for install, upgrade, - reinstall, remove, find and display packages""" - def __init__(self, binary): - self.binary = binary - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.yellow = _meta_.color["YELLOW"] - self.cyan = _meta_.color["CYAN"] - self.grey = _meta_.color["GREY"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.skip = [] - self.size = 0 - self.file_size = 0 - self.unit = "Kb" - - def install(self, flag): - """Installs Slackware binary packages - """ - for pkg in self.binary: - try: - subprocess.call(f"installpkg {flag} {pkg}", shell=True) - - check = pkg[:-4].split("/")[-1] - - if os.path.isfile(self.meta.pkg_path + check): - print("Completed!\n") - - else: - raise SystemExit(1) - - except subprocess.CalledProcessError: - self._not_found("Can't install", self.binary, pkg) - raise SystemExit(1) - - def upgrade(self, flag): - """Upgrades Slackware binary packages with new - """ - for pkg in self.binary: - try: - subprocess.call(f"upgradepkg {flag} {pkg}", shell=True) - - check = pkg[:-4].split("/")[-1] - - if os.path.isfile(self.meta.pkg_path + check): - print("Completed!\n") - - else: - raise SystemExit(1) - - except subprocess.CalledProcessError: - self._not_found("Can't upgrade", self.binary, pkg) - raise SystemExit(1) - - def _not_found(self, message, binary, pkg): - if len(binary) > 1: - bol = eol = "" - - else: - bol = eol = "\n" - - self.msg.pkg_not_found(bol, pkg, message, eol) - - def remove(self, flag, extra): - """Removes Slackware binary packages - """ - self.flag = flag - self.extra = extra - self.dep_path = self.meta.log_path + "dep/" - dependencies, rmv_list = [], [] - self.removed = self._view_removed() - - if not self.removed: - print() # new line at end - - else: - msg = "package" - - if len(self.removed) > 1: - msg = msg + "s" - - try: - if self.meta.default_answer in ["y", "Y"]: - remove_pkg = self.meta.default_answer - - else: - remove_pkg = input( - "\nAre you sure to remove {0} {1} [y/N]? ".format( - str(len(self.removed)), msg)) - - except EOFError: - raise SystemExit(1) - - if remove_pkg in ["y", "Y"]: - self._check_if_used(self.binary) - - for rmv in self.removed: - '''If package build and install with "slpkg -s sbo " - then looks in the log file for dependencies "/var/log/slpkg/dep", - reads and removes all but remove only the package. - ''' - - if (os.path.isfile(self.dep_path + rmv) and - self.meta.del_deps in ["on", "ON"] or - os.path.isfile(self.dep_path + rmv) and - "--deps" in self.extra): - dependencies = self._view_deps(self.dep_path, rmv) - - if dependencies and self._rmv_deps_answer() in ["y", - "Y"]: - rmv_list += self._rmv_deps(dependencies, rmv) - - else: - rmv_list += self._rmv_pkg(rmv) - - else: - rmv_list += self._rmv_pkg(rmv) - - # Prints all removed packages - self._reference_rmvs(rmv_list) - - def _rmv_deps_answer(self): - """Removes dependencies answer - """ - if self.meta.remove_deps_answer in ["y", "Y"]: - remove_dep = self.meta.remove_deps_answer - - else: - try: - remove_dep = input( - "\nRemove dependencies (maybe used by " - "other packages) [y/N]? ") - print() - except EOFError: - raise SystemExit("\n") - - return remove_dep - - def _get_removed(self): - """Manages removed packages by extra options - """ - extra = self.extra - removed, packages, pkg = [], [], "" - - if "--tag" in extra: - - for pkg in find_package("", self.meta.pkg_path): - - for tag in self.binary: - - if pkg.endswith(tag): - removed.append(split_package(pkg)[0]) - packages.append(pkg) - pkg = "" - extra = "" - - elif "--third-party" in extra: - slack_packages, slack_names = slackware_repository() - slpkg_pkg = self.meta.__all__ + "-" + self.meta.__version__ - binary = self.binary - - for pkg in find_package("", self.meta.pkg_path): - slack_name = split_package(pkg)[0] - - for tag in binary: - - if (slack_name not in slack_names and - slpkg_pkg not in pkg and tag in pkg): - removed.append(split_package(pkg)[0]) - packages.append(pkg) - pkg = "" - extra = "" - - else: - for pkg in self.binary: - name = GetFromInstalled(pkg).name() - ver = GetFromInstalled(pkg).version() - package = find_package(f"{name}-{ver}-", self.meta.pkg_path) - - if pkg and name == pkg: - removed.append(pkg) - packages.append(package[0]) - - if not removed: - self.msg.pkg_not_found("", pkg, "Can't remove", "\n") - raise SystemExit(1) - - return removed, packages - - def _view_removed(self): - """Views packages before removed - """ - print("Packages with name matching [ {0}{1}{2} ]\n".format( - self.cyan, ", ".join(self.binary), self.endc)) - removed, packages = self._get_removed() - - if packages and "--checklist" in self.extra: - removed = [] - text = "Press 'spacebar' to unchoose packages from the remove" - backtitle = f"{self.meta.__all__} {self.meta.__version__}" - status = True - pkgs = DialogUtil(packages, text, " Remove ", backtitle, - status).checklist() - if pkgs: - for rmv in pkgs: - removed.append(split_package(rmv)[0]) - self.meta.default_answer = "y" - - else: - for rmv, pkg in zip(removed, packages): - self._sizes(pkg) - print(f"[ {self.red}delete{self.endc} ] --> " - f"[ {self.file_size} ] - {pkg}") - - self._calc_sizes() - self._remove_summary() - - if "--third-party" in self.extra: - print() - self.msg.template(78) - print(f"| {' ' * 27}{self.red}*** WARNING ***{self.endc}") - print("| Before you use third-party option, be sure you have" - " updated the packages \n| lists. Run the command" - " 'slpkg update' and 'slpkg -c slack --upgrade'") - self.msg.template(78) - - return removed - - def _calc_sizes(self): - """Package size calculation - """ - if self.size > 1024: - self.unit = "Mb" - self.size = (self.size / 1024) - - if self.size > 1024: - self.unit = "Gb" - self.size = (self.size / 1024) - - def _remove_summary(self): - """Removed packge size summary - """ - if self.size > 0: - print("\nRemoved summary") - print("=" * 79) - print("{0}Size of removed packages {1} {2}.{3}".format( - self.grey, round(self.size, 2), self.unit, self.endc)) - - def _view_deps(self, path, package): - """Views dependencies before remove - """ - self.size = 0 - packages = [] - dependencies = (self.read_file(path + package)).splitlines() - - for dep in dependencies: - - if GetFromInstalled(dep).name(): - ver = GetFromInstalled(dep).version() - packages.append(f"{dep}-{ver}") - - else: - dependencies.remove(dep) - - if packages: - - if "--checklist" in self.extra: - deps, dependencies = [], [] - text = "Found dependencies for the package {0}".format(package) - backtitle = f"{self.meta.__all__} {self.meta.__version__}" - status = True - deps = DialogUtil(packages, text, " Remove ", backtitle, - status).checklist() - for d in deps: - dependencies.append("-".join(d.split("-")[:-1])) - self.meta.remove_deps_answer = "y" - - else: - print() # new line at start - self.msg.template(78) - print(f"| Found dependencies for the package {package}:") - self.msg.template(78) - for pkg in packages: - find = find_package(f"{pkg}-", self.meta.pkg_path) - self._sizes(find[0]) - print(f"| {self.red}{pkg}{self.endc}") - self.msg.template(78) - self._calc_sizes() - print("| {0}Size of removed dependencies {1} {2}{3}".format( - self.grey, round(self.size, 2), self.unit, self.endc)) - self.msg.template(78) - - return dependencies - - def _removepkg(self, package): - """removepkg Slackware command - """ - try: - subprocess.call(f"removepkg {self.flag} {package}", shell=True) - - if os.path.isfile(self.dep_path + package): - os.remove(self.dep_path + package) # remove log - - except subprocess.CalledProcessError as er: - raise SystemExit(er) - - def _rmv_deps(self, dependencies, package): - """Removes dependencies - """ - removes = [] - dependencies.append(package) - - self._check_if_used(dependencies) - - for dep in dependencies: - - if dep not in self.skip and GetFromInstalled(dep).name(): - ver = GetFromInstalled(dep).version() - removes.append(f"{dep}-{ver}") - self._removepkg(dep) - - return removes - - def _rmv_pkg(self, package): - """Removes one signle package - """ - removes = [] - - if GetFromInstalled(package).name() and package not in self.skip: - ver = GetFromInstalled(package).version() - removes.append(f"{package}-{ver}") - self._removepkg(package) - - return removes - - def _skip_remove(self): - """Skip packages from remove - """ - if "--checklist" not in self.extra: - self.msg.template(78) - print("| Insert packages to exception remove:") - self.msg.template(78) - try: - self.skip = input(" > ").split() - except EOFError: - raise SystemExit("\n") - - for s in self.skip: - - if s in self.removed: - self.removed.remove(s) - - def _check_if_used(self, removes): - """Checks package if dependencies for another package - before removed""" - if "--check-deps" in self.extra: - package, dependency, pkg_dep = [], [], [] - - for pkg in find_package("", self.dep_path): - deps = self.read_file(self.dep_path + pkg) - - for rmv in removes: - - if GetFromInstalled(rmv).name() and rmv in deps.split(): - pkg_dep.append(f"{rmv} is dependency of the " - f"package --> {pkg}") - package.append(pkg) - dependency.append(rmv) - - if package: - - if "--checklist" in self.extra: - text = ("Press 'spacebar' to choose packages for the" - " remove exception") - backtitle = f"{self.meta.__all__} {self.meta.__version__}" - status = False - choose = DialogUtil(pkg_dep, text, " !!! WARNING !!! ", - backtitle, status).checklist() - - for pkg in choose: - self.skip.append(pkg.split()[0]) - - else: - self.msg.template(78) - print("| {0}{1}{2}".format( - self.red, " " * 30 + "!!! WARNING !!!", self.endc)) - self.msg.template(78) - - for p, d in zip(package, dependency): - print(f"| {self.yellow}{d}{self.endc} is dependency " - f"of the package --> {self.green}{p}{self.endc}") - self.msg.template(78) - self._skip_remove() - - def _reference_rmvs(self, removes): - """Prints all removed packages - """ - print() - self.msg.template(78) - msg_pkg = "package" - - if len(removes) > 1: - msg_pkg = "packages" - - print(f"| Total {len(removes)} {msg_pkg} removed") - self.msg.template(78) - - for pkg in removes: - - if not GetFromInstalled(pkg).name(): - print(f"| Package {pkg} removed") - - else: - print(f"| Package {pkg} not found") - - self.msg.template(78) - print() # new line at end - - def find(self, flag): - """Finds installed Slackware packages - """ - matching, packages = 0, [] - pkg_cache, match_cache = "", "" - slack_packages, slack_names = slackware_repository() - - print("Packages with matching name [ {0}{1}{2} ]\n".format( - self.cyan, ", ".join(self.binary), self.endc)) - - for pkg in self.binary: - - for match in find_package("", self.meta.pkg_path): - pkg_cache = pkg - match_cache = match - split_name = split_package(match)[0] - - if "--case-ins" in flag: - pkg_cache = pkg.lower() - match_cache = match.lower() - - if ("--third-party" in flag and not self.binary and - split_name not in slack_names): - packages.append(match) - - if ("--third-party" in flag and pkg_cache in match_cache and - split_name not in slack_names): - packages.append(match) - - if pkg_cache in match_cache and not flag: - packages.append(match) - - if ("--case-ins" in flag and "--third-party" not in flag and - pkg_cache in match_cache): - packages.append(match) - - for pkgs in packages: - matching += 1 - self._sizes(pkgs) - print(f"[ {self.green}installed{self.endc} ] " - f"[ {self.file_size} ] - {pkgs}") - - if matching == 0: - message = "Can't find" - self.msg.pkg_not_found("", ", ".join(self.binary), message, "\n") - raise SystemExit(1) - - else: - self._calc_sizes() - print("\nFound summary") - print("=" * 79) - print("{0}Total found {1} matching packages.{2}".format( - self.grey, matching, self.endc)) - print("{0}Size of installed packages {1} {2}.{3}\n".format( - self.grey, round(self.size, 2), self.unit, self.endc)) - - def _sizes(self, package): - """Package size summary - """ - data = self.read_file(self.meta.pkg_path + package) - for line in data.splitlines(): - - if line.startswith("UNCOMPRESSED PACKAGE SIZE:"): - digit = float((''.join(re.findall( - r"[-+]?\d+[\.]?\d*[eE]?[-+]?\d*", line[26:])))) - self.file_size = line[26:].strip() - - if "M" in line[26:]: - self.size += digit * 1024 - - else: - self.size += digit - break - - def display(self): - """Prints the Slackware packages contents - """ - for pkg in self.binary: - name = GetFromInstalled(pkg).name() - ver = GetFromInstalled(pkg).version() - find = find_package(f"{name}-{ver}-", self.meta.pkg_path) - - if find: - package = self.read_file( - self.meta.pkg_path + "".join(find)) - print(package) - - else: - message = "Can't dislpay" - - if len(self.binary) > 1: - bol = eol = "" - - else: - bol = eol = "\n" - - self.msg.pkg_not_found(bol, pkg, message, eol) - raise SystemExit(1) - - def package_list(self, repo, name, INDEX, installed): - """List with the installed packages - """ - tty_size = os.popen("stty size", "r").read().split() - row = int(tty_size[0]) - 2 - - try: - all_installed_names = [] - index, page, pkg_list = 0, row, [] - r = self.list_lib(repo) - pkg_list = self.list_greps(repo, r)[0] - all_installed_names = self.list_of_installed(repo, name) - - print() - - for pkg in sorted(pkg_list): - pkg = self._splitting_packages(pkg, repo, name) - - if installed and repo: - - if pkg in all_installed_names: - pkg = f"{self.green}{pkg}{self.endc}" - - if INDEX: - index += 1 - pkg = self.list_color_tag(pkg) - print(f"{self.grey}{index}:{self.endc} {pkg}") - - if index == page: - read = input(f"\nPress {self.cyan}Enter{self.endc} to " - f"continue... ") - - if read in ["Q", "q"]: - break - print() # new line after page - page += row - - else: - print(pkg) - print() # new line at end - - except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError): - raise SystemExit(1) - - def _splitting_packages(self, pkg, repo, name): - """Returns package name from repositories - """ - if name and repo != "sbo": - pkg = split_package(pkg)[0] - - elif not name and repo != "sbo": - pkg = pkg[:-4] - - return pkg - - def list_greps(self, repo, packages): - """Grabs packages - """ - pkg_list, pkg_size = [], [] - for line in packages.splitlines(): - - if repo == "sbo": - - if line.startswith("SLACKBUILD NAME: "): - pkg_list.append(line[17:].strip()) - pkg_size.append("0 K") - - else: - - if line.startswith("PACKAGE NAME: "): - pkg_list.append(line[15:].strip()) - - if line.startswith("PACKAGE SIZE (compressed): "): - pkg_size.append(line[26:].strip()) - - if repo == "alien" or repo == "ktown": - return alien_filter(pkg_list, pkg_size) - - return pkg_list, pkg_size - - def list_lib(self, repo): - """Returns package lists - """ - packages = "" - - if repo == "sbo": - - if (os.path.isfile( - self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")): - packages = self.read_file(f"{self.meta.lib_path}" - "sbo_repo/SLACKBUILDS.TXT") - - else: - - if (os.path.isfile( - self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")): - packages = self.read_file(f"{self.meta.lib_path}" - f"{repo}_repo/PACKAGES.TXT") - return packages - - def list_color_tag(self, pkg): - """Tag with colour installed packages - """ - name = GetFromInstalled(pkg).name() - find = f"{name}-" - - if pkg.endswith(".txz") or pkg.endswith(".tgz"): - find = pkg[:-4] - - if find_package(find, self.meta.pkg_path): - pkg = f"{self.green}{pkg}{self.endc}" - - return pkg - - def list_of_installed(self, repo, name): - """Returns installed packages - """ - all_installed_names = [] - all_installed_packages = find_package("", self.meta.pkg_path) - - for inst in all_installed_packages: - - if repo == "sbo" and inst.endswith("_SBo"): - name = split_package(inst)[0] - all_installed_names.append(name) - - else: - - if name: - all_installed_names.append(split_package(inst)[0]) - - else: - all_installed_names.append(inst) - - return all_installed_names - - -def alien_filter(packages, sizes): - """This filter avoids listing double packages from - alien repository - """ - cache, npkg, nsize = [], [], [] - - for p, s in zip(packages, sizes): - name = split_package(p)[0] - - if name not in cache: - cache.append(name) - npkg.append(p) - nsize.append(s) - - return npkg, nsize diff --git a/slpkg/pkg_find.py b/slpkg/pkg_find.py deleted file mode 100644 index 7b21d32a..00000000 --- a/slpkg/pkg_find.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# pkg_find.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.messages import Msg -from slpkg.sbo.greps import SBoGrep -from slpkg.pkg.manager import PackageManager -from slpkg.__metadata__ import MetaData as _meta_ - - -class FindFromRepos: - """Finds packages from all enabled repositories - """ - def __init__(self): - self.cache = "" - self.p_cache = "" - self.find_cache = "" - self.count_pkg = 0 - self.count_repo = 0 - self.meta = _meta_ - self.msg = Msg() - self.cyan = self.meta.color["CYAN"] - self.grey = self.meta.color["GREY"] - self.endc = self.meta.color["ENDC"] - - def find(self, pkg, flag): - """Starts to find packages and print - """ - print(f"Packages with name matching [ {self.cyan}" - f"{', '.join(pkg)}{self.endc} ]\n") - self.msg.template(78) - print(f"| Repository Package {' ' * 54}Size") - self.msg.template(78) - - for repo in _meta_.repositories: - PACKAGES_TXT = PackageManager(pkg).list_lib(repo) - packages, sizes = PackageManager(pkg).list_greps(repo, - PACKAGES_TXT) - for find, size in zip(packages, sizes): - - for p in pkg: - - if "--case-ins" in flag: - self.p_cache = p.lower() - self.find_cache = find.lower() - - else: - self.p_cache = p - self.find_cache = find - - if self.p_cache in self.find_cache: - - if self.cache != repo: - self.count_repo += 1 - self.cache = repo - self.count_pkg += 1 - ver = self.sbo_version(repo, find) - - print(f" {self.cyan}{repo}{self.endc}" - f"{' ' * (11 - len(repo))}{find + ver} " - f"{' ' * (54 -len(find + ver))}{size:>11}") - - print("\nFound summary") - print("=" * 79) - print(f"{self.grey}Total found {self.count_pkg} packages in " - f"{self.count_repo} repositories.{self.endc}\n") - - def sbo_version(self, repo, find): - """Adds version to SBo packages - """ - ver = "" - - if repo == "sbo": - ver = f"-{SBoGrep(find).version()}" - - return ver diff --git a/slpkg/queries.py b/slpkg/queries.py new file mode 100644 index 00000000..81ba707d --- /dev/null +++ b/slpkg/queries.py @@ -0,0 +1,90 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +from metadata import Metadata +from models.models import SBoTable +from models.models import session as Session +from dataclasses import dataclass + + +@dataclass() +class SBoQueries: + ''' Queries class for the sbo repository. ''' + name: str + session: str = Session + os_arch: str = Metadata.os_arch + + def names(self): + return list(self._names_grabbing()) + + def slackbuild(self): + sbo = self.session.query( + SBoTable.name).filter(SBoTable.name == self.name).first() + + return sbo + + def location(self): + location = self.session.query( + SBoTable.location).filter(SBoTable.name == self.name).first() + + return location[0] + + def sources(self): + source, source64 = self.session.query( + SBoTable.download, SBoTable.download64).filter( + SBoTable.name == self.name).first() + + return self._chose_arch(source, source64) + + def requires(self): + requires = self.session.query( + SBoTable.requires).filter( + SBoTable.name == self.name).first() + + return requires[0].split() + + def version(self): + version = self.session.query( + SBoTable.version).filter( + SBoTable.name == self.name).first() + + return version[0] + + def checksum(self): + md5sum, md5sum64, = [], [] + mds5, md5s64 = self.session.query( + SBoTable.md5sum, SBoTable.md5sum64).filter( + SBoTable.name == self.name).first() + + if mds5: + md5sum.append(mds5) + if md5s64: + md5sum64.append(md5s64) + + return self._chose_arch(md5sum, md5sum64) + + def description(self): + desc = self.session.query( + SBoTable.short_description).filter( + SBoTable.name == self.name).first() + + return desc[0] + + def files(self): + files = self.session.query( + SBoTable.files).filter( + SBoTable.name == self.name).first() + + return files[0] + + def _chose_arch(self, arch, arch64): + if self.os_arch and arch64: + return arch64 + + return arch + + def _names_grabbing(self): + names = self.session.query(SBoTable.name).all() + for n in names: + yield n[0] diff --git a/slpkg/remove.py b/slpkg/remove.py deleted file mode 100644 index a20dc10d..00000000 --- a/slpkg/remove.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# remove.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import shutil - - -from slpkg.__metadata__ import MetaData as _meta_ - - -def delete_package(path, packages): - """Deletes downloaded packages - """ - if _meta_.del_all in ["on", "ON"]: - - for pkg in packages: - os.remove(f"{path}{pkg}") - - -def delete_folder(folder): - """Deletes folder with all files. - """ - if _meta_.del_folder in ["on", "ON"] and os.path.exists(folder): - shutil.rmtree(folder) diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py new file mode 100644 index 00000000..54f85080 --- /dev/null +++ b/slpkg/remove_packages.py @@ -0,0 +1,79 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import os +import subprocess +from metadata import Metadata + +from dataclasses import dataclass +from views.views import ViewMessage +from models.models import LogsDependencies +from models.models import session as Session + + +@dataclass +class RemovePackages: + ''' Remove installed packages. ''' + packages: str + flags: list + session: str = Session + log_packages: str = Metadata.log_packages + repo_tag: str = Metadata.repo_tag + removepkg: str = Metadata.removepkg + color: str = Metadata.colour + + def remove(self): + ''' Remove package with dependencies. ''' + self.installed_packages = [] + view = ViewMessage() + view.remove_packages() + + for pkg in self.packages: + self.view_installed_packages(pkg) + + self.dependencies = self.session.query( + LogsDependencies.requires).filter( + LogsDependencies.name == pkg).first() + + if self.dependencies and '--resolve-off' not in self.flags: + print('\nDependencies:') + for dep in self.dependencies[0].split(): + self.view_installed_packages(dep) + + view.question(self.flags) + + self.remove_packages() + self.delete_main_logs() + + if self.dependencies and '--resolve-off' not in self.flags: + self.delete_deps_logs() + + def remove_packages(self): + ''' Run Slackware command to remove the packages. ''' + for package in self.installed_packages: + command = f'{self.removepkg} {package}' + subprocess.call(command, shell=True) + + def delete_main_logs(self): + ''' Delete main packages from logs. ''' + for pkg in self.packages: + self.session.query(LogsDependencies).filter( + LogsDependencies.name == pkg).delete() + self.session.commit() + + def delete_deps_logs(self): + ''' Delete depends packages from logs. ''' + for pkg in self.dependencies[0].split(): + self.session.query(LogsDependencies).filter( + LogsDependencies.name == pkg).delete() + self.session.commit() + + def view_installed_packages(self, name): + ''' View and creates list with packages for remove. ''' + installed = os.listdir(self.log_packages) + color = self.color() + for package in installed: + if package.startswith(name) and self.repo_tag in package: + self.installed_packages.append(package) + print(f'[{color["RED"]} delete {color["ENDC"]}] -> {package}') diff --git a/slpkg/repoenable.py b/slpkg/repoenable.py deleted file mode 100644 index a3b9a6e5..00000000 --- a/slpkg/repoenable.py +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# repoenable.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.dialog_box import DialogUtil -from slpkg.__metadata__ import MetaData as _meta_ - - -class RepoEnable(Utils): - """Reads repositories.conf file and update with new enabled or - disabled repositories - """ - def __init__(self): - self.meta = _meta_ - self.red = _meta_.color["RED"] - self.grey = _meta_.color["GREY"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.tag = "[REPOSITORIES]" - self.tag_line = False - self.repositories_conf = "repositories.conf" - self.conf = self.read_file(f"{self.meta.conf_path}" - f"{self.repositories_conf}") - self.enabled = [] - self.disabled = [] - self.selected = [] - - def choose(self): - """Choose repositories - """ - keys = """ -Choose repositories at the right side for enable or to the -left side for disable. - -Keys: SPACE select or deselect the highlighted repositories, - move it between the left and right lists - ^ move the focus to the left list - $ move the focus to the right list - TAB move focus - ENTER press the focused button - - Disabled <---------------- REPOSITORIES ----------------> Enabled""" - - self.read_enabled() - self.read_disabled() - - text, title, backtitle, status = keys, " Repositories ", "", False - - self.selected = DialogUtil(self.disabled, text, title, backtitle, - status).buildlist(self.enabled) - - if self.selected is not None: - self.update_repos() - - else: - self.selected = self.enabled - - self.clear_screen() - self.reference() - - def read_enabled(self): - """Reads enabled repositories - """ - for line in self.conf.splitlines(): - line = line.lstrip() - - if self.tag in line: - self.tag_line = True - - if (line and self.tag_line and not line.startswith("#") and - self.tag not in line): - self.enabled.append(line) - - self.tag_line = False - - def read_disabled(self): - """Reads disabled repositories - """ - for line in self.conf.splitlines(): - line = line.lstrip() - - if self.tag in line: - self.tag_line = True - - if self.tag_line and line.startswith("#"): - line = "".join(line.split("#")).strip() - self.disabled.append(line) - - self.tag_line = False - - def update_repos(self): - """Updates repositories.conf file with enabled or disabled - repositories - """ - with open(f"{self.meta.conf_path}" - f"{self.repositories_conf}", "w") as new_conf: - - for line in self.conf.splitlines(): - line = line.lstrip() - - if self.tag in line: - self.tag_line = True - - if self.tag_line and line.startswith("#"): - repo = "".join(line.split("#")).strip() - - if repo in self.selected: - new_conf.write(line.replace(line, f"{repo}\n")) - continue - - if (self.tag_line and not line.startswith("#") and - line != self.tag): - repo = line.strip() - - if repo not in self.selected: - new_conf.write(line.replace(line, f"# {line}\n")) - continue - - new_conf.write(f"{line}\n") - - def clear_screen(self): - """Clear screen - """ - os.system("clear") - - def reference(self): - """Reference enable repositories - """ - total_enabled = ", ".join(self.selected) - - if len(total_enabled) < 1: - total_enabled = (f"{self.red}Are you crazy? This is a package " - f"manager for packages :p{self.endc}") - - self.msg.template(78) - print("| Enabled repositories:") - self.msg.template(78) - - print(f"| {total_enabled}") - self.msg.template(78) - print(f"{self.grey}Total {len(self.selected)}/" - f"{len(self.enabled + self.disabled)} " - f"repositories enabled.{self.endc}\n") diff --git a/slpkg/repoinfo.py b/slpkg/repoinfo.py deleted file mode 100644 index c1a17f5b..00000000 --- a/slpkg/repoinfo.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# repoinfo.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.sizes import units -from slpkg.utils import Utils -from slpkg.repositories import Repo -from slpkg.repolist import RepoList -from slpkg.__metadata__ import MetaData as _meta_ - - -class RepoInfo(Utils): - """Repository information - """ - def __init__(self): - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.endc = _meta_.color["ENDC"] - self.repo = Repo() - - self.form = { - "Last updated:": "", - "Number of packages:": "", - "Repo id:": "", - "Default:": "", - "Repo url:": "", - "Status:": "", - "Total compressed packages:": "", - "Total uncompressed packages:": "" - } - - self.meta = _meta_ - self.all_repos = self.repo.default_repository() - self.all_repos["slack"] = self.repo.slack() - self.all_repos.update(self.repo.custom_repository()) - - del RepoList().all_repos - - def view(self, repo): - """Views repository information - """ - status = f"{self.red}disabled{self.endc}" - self.form["Status:"] = status - self.form["Default:"] = "no" - - if repo in self.meta.default_repositories: - self.form["Default:"] = "yes" - - if (repo in self.meta.repositories and - os.path.isfile(f"{self.meta.lib_path}" - f"{repo}_repo/PACKAGES.TXT")): - status = f"{self.green}enabled{self.endc}" - - if repo != "sbo": - data = self.repository_data(repo) - size = units(data[1], data[2]) - self.form["Repo id:"] = repo - self.form["Repo url:"] = self.all_repos[repo] - self.form["Total compressed packages:"] = f"{str(size[1][0])} {str(size[0][0])}" - self.form["Total uncompressed packages:"] = f"{str(size[1][1])} {str(size[0][1])}" - self.form["Number of packages:"] = data[0] - self.form["Status:"] = status - self.form["Last updated:"] = data[3] - - elif (repo == "sbo" and os.path.isfile( - f"{self.meta.lib_path}{repo}_repo/SLACKBUILDS.TXT")): - status = f"{self.green}enabled{self.endc}" - sum_sbo_pkgs = 0 - - for line in (self.read_file( - f"{self.meta.lib_path}sbo_repo/SLACKBUILDS." - "TXT").splitlines()): - - if line.startswith("SLACKBUILD NAME: "): - sum_sbo_pkgs += 1 - - changelog_txt = self.read_file( - f"{self.meta.log_path}sbo/ChangeLog.txt") - - last_upd = changelog_txt.split("\n", 1)[0] - - self.form["Repo id:"] = repo - self.form["Repo url:"] = self.all_repos[repo] - self.form["Total compressed packages:"] = "" - self.form["Total uncompressed packages:"] = "" - self.form["Number of packages:"] = sum_sbo_pkgs - self.form["Status:"] = status - self.form["Last updated:"] = last_upd - - for key, value in sorted(self.form.items()): - print(f"{self.green}{key}{self.endc} {value}") - - def repository_data(self, repo): - """Graps data packages - """ - sum_pkgs, size, unsize, last_upd = 0, [], [], "" - f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT" - - for line in self.read_file(f).splitlines(): - - if line.startswith("PACKAGES.TXT;"): - last_upd = line[14:].strip() - - if line.startswith("PACKAGE NAME:"): - sum_pkgs += 1 - - if line.startswith("PACKAGE SIZE (compressed): "): - size.append(line[28:-2].strip()) - - if line.startswith("PACKAGE SIZE (uncompressed): "): - unsize.append(line[30:-2].strip()) - - if repo in ["salix", "slackl"]: - log = self.read_file( - f"{self.meta.log_path}{repo}/ChangeLog.txt") - - last_upd = log.split("\n", 1)[0] - - return [sum_pkgs, size, unsize, last_upd] diff --git a/slpkg/repolist.py b/slpkg/repolist.py deleted file mode 100644 index fca111db..00000000 --- a/slpkg/repolist.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# repolist.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.messages import Msg -from slpkg.repositories import Repo -from slpkg.__metadata__ import MetaData as _meta_ - - -class RepoList: - """List of repositories - """ - def __init__(self): - self.meta = _meta_ - self.green = self.meta.color["GREEN"] - self.red = self.meta.color["RED"] - self.grey = self.meta.color["GREY"] - self.endc = self.meta.color["ENDC"] - self.msg = Msg() - self.all_repos = Repo().default_repository() - self.all_repos["slack"] = Repo().slack() - self.all_repos.update(Repo().custom_repository()) - - def repos(self): - """View or enabled or disabled repositories - """ - def_cnt, cus_cnt = 0, 0 - self.msg.template(78) - print("{0}{1}{2}{3}{4}{5}{6}".format( - "| Repo_id", " " * 2, - "Repo_URL", " " * 44, - "Default", " " * 3, - "Status")) - self.msg.template(78) - - for repo_id, repo_URL in sorted(self.all_repos.items()): - status, COLOR = "disabled", self.red - default = "yes" - - if len(repo_URL) > 49: - repo_URL = repo_URL[:48] + "~" - - if repo_id in self.meta.repositories: - def_cnt += 1 - status, COLOR = "enabled", self.green - - if repo_id not in self.meta.default_repositories: - cus_cnt += 1 - default = "no" - - print(" {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}".format( - repo_id, " " * (9 - len(repo_id)), - repo_URL, " " * (52 - len(repo_URL)), - default, " " * (8 - len(default)), - COLOR, status, self.endc)) - - print("\nRepositories summary") - print("=" * 79) - print(f"{self.grey}{def_cnt}/{len(self.all_repos)} enabled default " - f"repositories and {cus_cnt} custom.") - - print("Edit the file '/etc/slpkg/repositories.conf' for enable " - "and disable default\nrepositories or run 'slpkg " - f"repo-enable' command.{self.endc}") diff --git a/slpkg/repositories.py b/slpkg/repositories.py deleted file mode 100644 index 738fca34..00000000 --- a/slpkg/repositories.py +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# repositories.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.utils import Utils -from slpkg.__metadata__ import MetaData as _meta_ - - -class Repo(Utils): - """Manages repositories configuration files - """ - def __init__(self): - self.meta = _meta_ - self.DEFAULT_REPOS_NAMES = self.meta.default_repositories - self.custom_repo_file = "/etc/slpkg/custom-repositories" - self.default_repo_file = "/etc/slpkg/default-repositories" - self.custom_repositories_list = self.read_file( - self.custom_repo_file) - self.default_repositories_list = self.read_file( - self.default_repo_file) - self.default_repository() - - def add(self, repo, url): - """Writes custom repository name and url in a file - """ - repo_name = [] - if not url.endswith("/"): - url += "/" - - for line in self.custom_repositories_list.splitlines(): - line = line.lstrip() - - if line and not line.startswith("#"): - repo_name.append(line.split()[0]) - - if (repo in self.meta.repositories or repo in repo_name or - repo in self.meta.default_repositories): - - raise SystemExit(f"\nRepository name '{repo}' exist, " - f"select different name.\n" - f"View all repositories with command 'slpkg " - f"repo-list'.\n") - - elif len(repo) > 6: - - raise SystemExit("\nslpkg: Error: Maximum repository name length " - "must be six (6) characters\n") - - with open(self.custom_repo_file, "a") as repos: - new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n" - repos.write(new_line) - - print(f"\nRepository '{repo}' successfully added\n") - - def remove(self, repo): - """Removes custom repository - """ - rem_repo = False - - with open(self.custom_repo_file, "w") as repos: - - for line in self.custom_repositories_list.splitlines(): - repo_name = line.split()[0] - - if repo_name != repo: - repos.write(f"{line}\n") - - else: - print(f"\nRepository '{repo}' successfully " - "removed\n") - rem_repo = True - - if not rem_repo: - print(f"\nRepository '{repo}' doesn't exist\n") - - def custom_repository(self): - """Returns dictionary with repo name and url (used external) - """ - custom_dict_repo = {} - for line in self.custom_repositories_list.splitlines(): - line = line.lstrip() - - if not line.startswith("#"): - custom_dict_repo[line.split()[0]] = line.split()[1] - - return custom_dict_repo - - def default_repository(self): - """Returns dictionary with default repo name and url - """ - default_dict_repo = {} - - for line in self.default_repositories_list.splitlines(): - line = line.lstrip() - - if not line.startswith("#"): - - if line.split()[0] in self.DEFAULT_REPOS_NAMES: - default_dict_repo[line.split()[0]] = line.split()[1] - - else: - raise SystemExit(f"\nslpkg: Error: Repository name " - f"'{line.split()[0]}'" - f" is not default.\n " - f"Please check file: " - f"/etc/slpkg/default-repositories\n") - return default_dict_repo - - def slack(self): - """Official slackware repository - """ - default = "http://mirrors.slackware.com/slackware/" - - if self.meta.arch.startswith("arm"): - default = "http://ftp.arm.slackware.com/slackwarearm/" - - if os.path.isfile("/etc/slpkg/slackware-mirrors"): - mirrors = self.read_file( - f"{self.meta.conf_path}slackware-mirrors") - - for line in mirrors.splitlines(): - line = line.rstrip() - - if not line.startswith("#") and line: - default = line.split()[-1] - - if not default.endswith("/"): - default += "/" - - return default diff --git a/slpkg/sbo/__init__.py b/slpkg/sbo/__init__.py deleted file mode 100644 index 24cb94b3..00000000 --- a/slpkg/sbo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# [ slackbuilds ] directory diff --git a/slpkg/sbo/autobuild.py b/slpkg/sbo/autobuild.py deleted file mode 100644 index 1eaba5e4..00000000 --- a/slpkg/sbo/autobuild.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# autobuild.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.pkg.build import BuildPackage - -from slpkg.sbo.greps import SBoGrep - - -class AutoBuild: - """Autobuild package if sources and script is already - downloaded - """ - def __init__(self, script, sources, path): - self.script = script - self.sources = sources - self.prgnam = self.script[:-7] - self.path = path - self.sbo_sources = [] - - def run(self): - """Builds package and fix ordelist per checksum - """ - self.files_exist() - self.info_file() - sources = self.sources - - if len(sources) > 1 and self.sbo_sources != sources: - sources = self.sbo_sources - # If the list does not have the same order uses from .info - # order. - BuildPackage(self.script, sources, self.path, auto=True).build() - - raise SystemExit() - - def info_file(self): - """Grabs sources from .info file and stores filename - """ - sources = SBoGrep(self.prgnam).source().split() - for source in sources: - self.sbo_sources.append(source.split("/")[-1]) - - def files_exist(self): - """Check if SlackBuild archive.tar.gz and sources exist - """ - if not os.path.isfile(self.path + self.script): - raise SystemExit("\nslpkg: Error: SlackBuild archive.tar.gz " - "not found\n") - - for src in self.sources: - - if not os.path.isfile(self.path + src): - raise SystemExit(f"\nslpkg: Error: Source file '{src}' " - f"not found\n") diff --git a/slpkg/sbo/build_num.py b/slpkg/sbo/build_num.py deleted file mode 100644 index 5765e4cf..00000000 --- a/slpkg/sbo/build_num.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# build_num.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import re - -from slpkg.utils import Utils -from slpkg.url_read import URL -from slpkg.__metadata__ import MetaData as _meta_ - - -class BuildNumber(Utils): - """Gets build number from SlackBuild script - """ - def __init__(self, sbo_url, pkg): - self.sbo_url = sbo_url - self.pkg = pkg - self.meta = _meta_ - - def get(self): - num = "NO_BUILD" - - if self.sbo_url: - SlackBuild = URL(f"{self.sbo_url}" - f"{self.pkg}.SlackBuild").get_request() - - else: - SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/" - f"{self.pkg}.SlackBuild") - - for line in SlackBuild.splitlines(): - - line = line.lstrip() - - if line.startswith("BUILD="): - num = re.findall(r"\d+", line) - break - - return "".join(num) diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py deleted file mode 100644 index 3dd46c5e..00000000 --- a/slpkg/sbo/check.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# check.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from pkg_resources import parse_version - -from slpkg.messages import Msg -from slpkg.blacklist import BlackList -from slpkg.splitting import split_package -from slpkg.upgrade_checklist import choose_upg -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.sbo.greps import SBoGrep - - -def sbo_upgrade(skip, flag): - """Returns packages for upgrade - """ - msg = Msg() - black = BlackList() - msg.checking() - upgrade_names = [] - data = SBoGrep(name="").names() - blacklist = list(black.get_black()) - - for pkg in sbo_list(): - name = split_package(pkg)[0] - ver = split_package(pkg)[1] - - if (name in data and name not in skip and name not in blacklist): - sbo_package = f"{name}-{SBoGrep(name).version()}" - package = f"{name}-{ver}" - - if parse_version(sbo_package) > parse_version(package): - upgrade_names.append(name) - msg.done() - - if "--checklist" in flag: - upgrade_names = choose_upg(upgrade_names) - - return upgrade_names - - -def sbo_list(): - """Returns all SBo packages - """ - for pkg in os.listdir(_meta_.pkg_path): - - if pkg.endswith("_SBo"): - yield pkg diff --git a/slpkg/sbo/compressed.py b/slpkg/sbo/compressed.py deleted file mode 100644 index a2ba6fd1..00000000 --- a/slpkg/sbo/compressed.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# download.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -class SBoLink: - """Creates slackbuild tar.gz archive from url - """ - def __init__(self, sbo_url): - self.sbo_url = sbo_url - - def tar_gz(self): - return f"{self.sbo_url[:-1]}.tar.gz" diff --git a/slpkg/sbo/dependency.py b/slpkg/sbo/dependency.py deleted file mode 100644 index 5de378b8..00000000 --- a/slpkg/sbo/dependency.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# dependency.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import sys -from functools import lru_cache - -from slpkg.blacklist import BlackList -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.sbo.greps import SBoGrep - - -class Requires(BlackList): - """Resolving SBo dependencies - """ - def __init__(self, flag): - super().__init__() - self.flag = flag - self.meta = _meta_ - self.SLACKBUILDS_TXT = SBoGrep(name="").names() - self.blacklist = list(self.get_black()) - self.dep_results = [] - - @lru_cache - def sbo(self, name): - """Builds all dependencies of a package - """ - if (self.meta.rsl_deps in ["on", "ON"] and - "--resolve-off" not in self.flag): - sys.setrecursionlimit(10000) - dependencies = [] - requires = SBoGrep(name).requires() - - if requires: - for req in requires: - # avoids adding %README% as dependency and if - # requires in the blacklist - if "%README%" not in req and req not in self.blacklist: - dependencies.append(req) - - self.deep_check(tuple(dependencies)) - - return self.dep_results - - else: - return [] - - @lru_cache - def deep_check(self, dependencies): - """Checking if dependencies are finished - """ - if dependencies: - self.dep_results.append(dependencies) - [self.sbo(dep) for dep in dependencies] diff --git a/slpkg/sbo/greps.py b/slpkg/sbo/greps.py deleted file mode 100644 index 69d3a954..00000000 --- a/slpkg/sbo/greps.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# greps.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.__metadata__ import MetaData as _meta_ -from slpkg.models.models import SBoTable, session - - -class SBoGrep: - """Grabs data from sbo database - """ - def __init__(self, name): - self.name = name - self.meta = _meta_ - self.arch64 = "x86_64" - self.session = session - - def names(self): - """Alias method convert generator and return - a list - """ - return list(self._names_grabbing()) - - def source(self): - """Grabs sources downloads links - """ - source, source64 = self.session.query( - SBoTable.download, SBoTable.download64).filter( - SBoTable.name == self.name).first() - - return self._sorting_arch(source, source64) - - def requires(self): - """Grabs package requirements - """ - requires = self.session.query( - SBoTable.requires).filter( - SBoTable.name == self.name).first() - - return requires[0].split() - - def version(self): - """Grabs package version - """ - version = self.session.query( - SBoTable.version).filter( - SBoTable.name == self.name).first() - - return version[0] - - def checksum(self): - """Grabs checksum string - """ - md5sum, md5sum64, = [], [] - mds5, md5s64 = self.session.query( - SBoTable.md5sum, SBoTable.md5sum64).filter( - SBoTable.name == self.name).first() - - if mds5: - md5sum.append(mds5) - if md5s64: - md5sum64.append(md5s64) - - return self._sorting_arch(md5sum, md5sum64) - - def description(self): - """Grabs package description - """ - desc = self.session.query( - SBoTable.short_description).filter( - SBoTable.name == self.name).first() - - return desc[0] - - def files(self): - """Grabs files - """ - files = self.session.query( - SBoTable.files).filter( - SBoTable.name == self.name).first() - - return files[0] - - def _names_grabbing(self): - """Generator that collecting all packages names - """ - names = self.session.query(SBoTable.name).all() - for n in names: - yield n[0] - - def _sorting_arch(self, arch, arch64): - """Returns sources by arch - """ - if self.meta.arch == self.arch64 and arch64: - return arch64 - - return arch diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py deleted file mode 100644 index fced7556..00000000 --- a/slpkg/sbo/network.py +++ /dev/null @@ -1,418 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# network.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import pydoc - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.remove import delete_folder -from slpkg.dialog_box import DialogUtil -from slpkg.security import pkg_security -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package -from slpkg.pkg.build import BuildPackage -from slpkg.pkg.manager import PackageManager - -from slpkg.sbo.read import ReadSBo -from slpkg.sbo.greps import SBoGrep -from slpkg.sbo.sbo_arch import SBoArch -from slpkg.sbo.compressed import SBoLink -from slpkg.sbo.search import sbo_search_pkg -from slpkg.sbo.slack_find import slack_package - -from slpkg.slack.slack_version import slack_ver - - -class SBoNetwork(BlackList, Utils): - """View SBo site in the terminal and also read, build or - install packages - """ - def __init__(self, name, flag): - super().__init__() - self.name = name - self.flag = flag - self.meta = _meta_ - self.msg = Msg() - self.data = SBoGrep(name="").names() - self.check_pkg_exist() - self.arch = SBoArch().get() - self.comp_tar = ".tar.gz" - self.choice = "" - self.FAULT = "" - self.green = self.meta.color["GREEN"] - self.red = self.meta.color["RED"] - self.yellow = self.meta.color["YELLOW"] - self.cyan = self.meta.color["CYAN"] - self.grey = self.meta.color["GREY"] - self.endc = self.meta.color["ENDC"] - self.build_folder = self.meta.build_path - self._SOURCES = self.meta.SBo_SOURCES - self.msg.reading() - self.case_insensitive() - - if "--checklist" in self.flag: - self.with_checklist() - - grep = SBoGrep(self.name) - self.sbo_files = grep.files() - self.sbo_url = sbo_search_pkg(self.name) - - if self.sbo_url: - self.sbo_desc = grep.description()[len(self.name) + 2:-1] - self.source_dwn = grep.source().split() - self.sbo_req = grep.requires() - self.sbo_dwn = SBoLink(self.sbo_url).tar_gz() - self.sbo_version = grep.version() - self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn - - if "--checklist" not in self.flag or not self.sbo_url and self.name: - self.msg.done() - - def check_pkg_exist(self): - if self.name not in self.data: - self.msg.pkg_not_found("\n", self.name, "can't find", "\n") - raise SystemExit(1) - - def view(self): - """View SlackBuild package, read or install them - from slackbuilds.org - """ - if self.sbo_url and self.name not in self.get_black(): - self.prgnam = f"{self.name}-{self.sbo_version}" - self.view_sbo() - - while True: - - self.read_choice() - - choice = { - "r": self.choice_README, - "R": self.choice_README, - "s": self.choice_SlackBuild, - "S": self.choice_SlackBuild, - "f": self.choice_info, - "F": self.choice_info, - "o": self.choice_doinst, - "O": self.choice_doinst, - "d": self.choice_download, - "D": self.choice_download, - "download": self.choice_download, - "b": self.choice_build, - "B": self.choice_build, - "build": self.choice_build, - "i": self.choice_install, - "I": self.choice_install, - "install": self.choice_install, - "c": self.choice_clear_screen, - "C": self.choice_clear_screen, - "clear": self.choice_clear_screen, - "q": self.choice_quit, - "quit": self.choice_quit, - "Q": self.choice_quit - } - - try: - choice[self.choice]() - except KeyError: - pass - - else: - self.msg.pkg_not_found("\n", self.name, "Can't view", "\n") - raise SystemExit(1) - - def case_insensitive(self): - """Matching packages distinguish between uppercase and - lowercase - """ - - if "--case-ins" in self.flag: - data_dict = self.case_sensitive(self.data) - - for key, value in data_dict.items(): - - if key == self.name.lower(): - self.name = value - - def read_choice(self): - """Return choice - """ - commands = { - "r": "README", - "R": "README", - "s": f"{self.name}.SlackBuild", - "S": f"{self.name}.SlackBuild", - "f": f"{self.name}.info", - "F": f"{self.name}.info", - "o": "doinst.sh", - "O": "doinst.sh", - "d": "download", - "D": "download", - "download": "download", - "b": "build", - "B": "build", - "build": "build", - "i": "install", - "I": "install", - "install": "install", - "c": "clear", - "C": "clear", - "clear": "clear", - "q": "quit", - "quit": "quit", - "Q": "quit" - } - - try: - message = " Choose an option > " - self.choice = input(f"{self.grey}{message}{self.endc}") - except EOFError: - raise SystemExit('\n') - - try: - print("{0}\x1b[1A{1}{2}{3}\n".format( - " " * len(message), self.cyan, commands[self.choice], - self.endc), end="") - print(end="", flush=True) - except KeyError: - pass - - def choice_README(self): - """View README file - """ - README = ReadSBo(self.sbo_url).readme("README") - fill = self.fill_pager(README) - self.pager(README + fill) - - def choice_SlackBuild(self): - """View .SlackBuild file - """ - SlackBuild = ReadSBo(self.sbo_url).slackbuild(self.name, ".SlackBuild") - fill = self.fill_pager(SlackBuild) - self.pager(SlackBuild + fill) - - def choice_info(self): - """View .info file - """ - info = ReadSBo(self.sbo_url).info(self.name, ".info") - fill = self.fill_pager(info) - self.pager(info + fill) - - def choice_doinst(self): - """View doinst.sh file - """ - if "doinst.sh" in self.sbo_files.split(): - doinst_sh = ReadSBo(self.sbo_url).doinst("doinst.sh") - fill = self.fill_pager(doinst_sh) - self.pager(doinst_sh + fill) - - def choice_download(self): - """Download script.tar.gz and sources - """ - Download(path="", url=self.dwn_srcs, repo="sbo").start() - raise SystemExit() - - def choice_build(self): - """Build package - """ - self.build() - delete_folder(self.build_folder) - raise SystemExit() - - def choice_install(self): - """Download, build and install the package - """ - pkg_security([self.name]) - - if not find_package(self.prgnam, self.meta.pkg_path): - self.build() - self.install() - delete_folder(self.build_folder) - - raise SystemExit() - - else: - self.msg.template(78) - self.msg.pkg_found(self.prgnam) - self.msg.template(78) - - raise SystemExit() - - def choice_clear_screen(self): - """Clear screen - """ - os.system("clear") - self.view() - - def choice_quit(self): - """Quit from choices - """ - raise SystemExit() - - def view_sbo(self): - """View slackbuild.org - """ - sbo_url = self.sbo_url.replace("/slackbuilds/", "/repository/") - br1, br2, fix_sp = "", "", " " - - if self.meta.use_colors in ["off", "OFF"]: - br1 = "(" - br2 = ")" - fix_sp = "" - - print() # new line at start - self.msg.template(78) - print(f"| {' ' * 28}{self.grey}SlackBuilds Repository{self.endc}") - self.msg.template(78) - print(f"| {slack_ver()} > {sbo_url.split('/')[-3].title()} > {self.cyan}{self.name}{self.endc}") - self.msg.template(78) - print(f"| {self.green}Package url{self.endc}: {sbo_url}") - self.msg.template(78) - print(f"| {self.green}Description: {self.endc}{self.sbo_desc}") - print(f"| {self.green}SlackBuild: {self.endc}{self.sbo_dwn.split('/')[-1]}") - print(f"| {self.green}Sources: {self.endc}{', '.join([src.split('/')[-1] for src in self.source_dwn])}") - print(f"| {self.yellow}Requirements: {self.endc}{', '.join(self.sbo_req)}") - self.msg.template(78) - print(f"| {self.red}R{self.endc}{br2}EADME View the README file") - print(f"| {self.red}S{self.endc}{br2}lackBuild View the .SlackBuild file") - print(f"| In{br1}{self.red}f{self.endc}{br2}o{fix_sp} View the .info file") - - if "doinst.sh" in self.sbo_files.split(): - print(f"| D{br1}{self.red}o{self.endc}{br2}inst.sh{fix_sp} View the doinst.sh file") - - print(f"| {self.red}D{self.endc}{br2}ownload Download this package") - print(f"| {self.red}B{self.endc}{br2}uild Download and build") - print(f"| {self.red}I{self.endc}{br2}nstall Download/Build/Install") - print(f"| {self.red}C{self.endc}{br2}lear Clear screen") - print(f"| {self.red}Q{self.endc}{br2}uit Quit") - self.msg.template(78) - - def with_checklist(self): - """Using dialog and checklist option - """ - data = [] - - if not self.name: - data = self.data - - else: - for name in self.data: - if self.name in name: - data.append(name) - - if data: - text = "Press 'spacebar' to choose SlackBuild for view" - title = " SlackBuilds.org " - backtitle = f"{_meta_.__all__} {_meta_.__version__}" - status = False - pkg = DialogUtil(data, text, title, backtitle, status).checklist() - - if pkg and len(pkg) > 1: - os.system("clear") - raise SystemExit("\nslpkg: Error: Choose only one package\n") - - if pkg is None: - raise SystemExit(1) - - self.name = "".join(pkg) - os.system("clear") - - def pager(self, text): - """Read text - """ - pydoc.pager(text) - - def fill_pager(self, page): - """Fixes pager spaces - """ - tty_size = os.popen("stty size", "r").read().split() - rows = int(tty_size[0]) - 1 - lines = sum(1 for line in page.splitlines()) - diff = rows - lines - fill = "\n" * diff - - if diff > 0: - return fill - - else: - return "" - - def error_uns(self): - """Checks if the package supported by an arch - before proceeding to install - """ - self.FAULT = "" - UNST = ["UNSUPPORTED", "UNTESTED"] - - if "".join(self.source_dwn) in UNST: - self.FAULT = "".join(self.source_dwn) - - def build(self): - """Builds slackware package - """ - pkg_security([self.name]) - self.error_uns() - - if self.FAULT: - print() - self.msg.template(78) - print(f"| Package {self.prgnam} {self.red} {self.FAULT} " - f"{self.endc}") - self.msg.template(78) - - else: - sources = [] - - if not os.path.exists(self.meta.build_path): - os.makedirs(self.meta.build_path) - - if not os.path.exists(self._SOURCES): - os.makedirs(self._SOURCES) - - os.chdir(self.meta.build_path) - - Download(self.meta.build_path, self.sbo_dwn.split(), - repo="sbo").start() - - Download(self._SOURCES, self.source_dwn, repo="sbo").start() - - script = self.sbo_dwn.split("/")[-1] - - for src in self.source_dwn: - sources.append(src.split("/")[-1]) - - BuildPackage(script, sources, self.meta.build_path, - auto=False).build() - - slack_package(self.prgnam) # check if build - - def install(self): - """Installs SBo package found in /tmp directory. - """ - binary = slack_package(self.prgnam) - print(f"[ {self.green}Installing{self.endc} ] --> {self.name}") - PackageManager(binary).upgrade(flag="--install-new") diff --git a/slpkg/sbo/queue.py b/slpkg/sbo/queue.py deleted file mode 100644 index dfb36dda..00000000 --- a/slpkg/sbo/queue.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# queue.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from collections import OrderedDict - -from slpkg.utils import Utils -from slpkg.downloader import Download -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package -from slpkg.pkg.build import BuildPackage -from slpkg.pkg.manager import PackageManager - -from slpkg.sbo.greps import SBoGrep -from slpkg.sbo.compressed import SBoLink -from slpkg.sbo.search import sbo_search_pkg -from slpkg.sbo.slack_find import slack_package - - -class QueuePkgs(Utils): - """Manages SBo packages, add or removes for building or - installation - """ - def __init__(self): - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.endc = _meta_.color["ENDC"] - self.queue = self.meta.lib_path + "queue/" - self.queue_list = self.queue + "queue_list" - self._SOURCES = self.meta.SBo_SOURCES - self.touch() - - def touch(self): - """Creating the directories and the queue file - """ - queue_file = [ - "# In this file, you can create a list of\n", - "# packages you want to build or install.\n", - "#\n"] - - if not os.path.exists(self.meta.lib_path): - os.mkdir(self.meta.lib_path) - - if not os.path.exists(self.queue): - os.mkdir(self.queue) - - if not os.path.isfile(self.queue_list): - with open(self.queue_list, "w") as queue: - for line in queue_file: - queue.write(line) - - self.queued = self.read_file(self.queue_list) - - def packages(self): - """Returns queue list from /var/lib/queue/queue_list - file. - """ - for read in self.queued.splitlines(): - - read = read.lstrip() - - if not read.startswith("#"): - yield read.replace("\n", "") - - def listed(self): - """Prints packages from queue - """ - print("Packages in the queue:") - - for pkg in self.packages(): - print(f"{self.green}{pkg}{self.endc}") - - print() - - def add(self, pkgs): - """Adds packages in queue if not exist - """ - queue_list = list(self.packages()) - pkgs = list(OrderedDict.fromkeys(pkgs)) - - print("Add packages in the queue:") - - with open(self.queue_list, "a") as queue: - - for pkg in pkgs: - - find = sbo_search_pkg(pkg) - - if pkg not in queue_list and find is not None: - print(f"{self.green}{pkg}{self.endc}") - queue.write(pkg + "\n") - - else: - print(f"{self.red}{pkg}{self.endc}") - - print() - - def remove(self, pkgs): - """Removes packages from the queue - """ - print("Remove packages from the queue:") - - with open(self.queue_list, "w") as queue: - - for line in self.queued.splitlines(): - - if line not in pkgs: - queue.write(line + "\n") - - else: - print(f"{self.red}{line}{self.endc}") - - print() - - def build(self): - """Builds packages from the queue - """ - sources = [] - packages = list(self.packages()) - - if packages: - - for pkg in packages: - - if pkg not in SBoGrep(pkg).names(): - raise SystemExit(f"\nPackage '{pkg}' was not found in " - f"the SBo repository\n") - - if not os.path.exists(self.meta.build_path): - os.mkdir(self.meta.build_path) - - if not os.path.exists(self._SOURCES): - os.mkdir(self._SOURCES) - - sbo_url = sbo_search_pkg(pkg) - sbo_dwn = SBoLink(sbo_url).tar_gz() - source_dwn = SBoGrep(pkg).source().split() - os.chdir(self.meta.build_path) - script = sbo_dwn.split("/")[-1] - - Download(self.meta.build_path, sbo_dwn.split(), - repo="sbo").start() - - for src in source_dwn: - Download(self._SOURCES, src.split(), repo="sbo").start() - sources.append(src.split("/")[-1]) - - BuildPackage(script, sources, self.meta.build_path, - auto=False).build() - - else: - raise SystemExit("\nPackages not found in the queue for " - "building\n") - - def install(self): - """Installs packages from the queue - """ - packages = list(self.packages()) - - if packages: - - print() # new line at start - - for pkg in packages: - - ver = SBoGrep(pkg).version() - prgnam = f"{pkg}-{ver}" - - if find_package(prgnam, self.meta.output): - binary = slack_package(prgnam) - PackageManager(binary).upgrade(flag="--install-new") - - else: - print(f"\nPackage {prgnam} not found in the " - f"{self.meta.output} for installation\n") - - else: - raise SystemExit("\nPackages not found in the queue for " - "installation\n") diff --git a/slpkg/sbo/read.py b/slpkg/sbo/read.py deleted file mode 100644 index 9ca0e38e..00000000 --- a/slpkg/sbo/read.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# read.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.url_read import URL - - -class ReadSBo: - """Read SBo files from urls - """ - def __init__(self, sbo_url): - self.sbo_url = sbo_url - - def readme(self, sbo_readme): - """Read SlackBuild README file - """ - return URL(self.sbo_url + sbo_readme).get_request() - - def info(self, name, sbo_file): - """Read info file - """ - return URL(self.sbo_url + name + sbo_file).get_request() - - def slackbuild(self, name, sbo_file): - """Read SlackBuild file - """ - return URL(self.sbo_url + name + sbo_file).get_request() - - def doinst(self, doinst_sh): - """Read SlackBuild doinst.sh - """ - return URL(self.sbo_url + doinst_sh).get_request() diff --git a/slpkg/sbo/sbo_arch.py b/slpkg/sbo/sbo_arch.py deleted file mode 100644 index d7769d1e..00000000 --- a/slpkg/sbo/sbo_arch.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# sbo_arch.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.__metadata__ import MetaData as _meta_ - - -class SBoArch: - """Manage computer architecture for sbo repository - """ - def __init__(self): - self.meta = _meta_ - self.arch = self.meta.arch - # Architectures - self.x86 = "i586" - self.arm = "arm" - - def get(self): - """Return sbo arch - """ - if self.arch.startswith("i") and self.arch.endswith("86"): - self.arch = self.x86 - - elif self.meta.arch.startswith("arm"): - self.arch = self.arm - - return self.arch diff --git a/slpkg/sbo/search.py b/slpkg/sbo/search.py deleted file mode 100644 index 443cb3a5..00000000 --- a/slpkg/sbo/search.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# search.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.repositories import Repo -from slpkg.slack.slack_version import slack_ver -from slpkg.models.models import SBoTable, session - - -def sbo_search_pkg(name): - """Search for package path in SLACKBUILDS.TXT file and - return url - """ - location = session.query(SBoTable.location).filter( - SBoTable.name == name).first() - - repo = Repo() - sbo = repo.default_repository()["sbo"] - sbo_url = f"{sbo}{slack_ver()}/" - - return f"{sbo_url}{location[0][2:]}/" diff --git a/slpkg/sbo/slack_find.py b/slpkg/sbo/slack_find.py deleted file mode 100644 index 8d1fcf6d..00000000 --- a/slpkg/sbo/slack_find.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# slack_find.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from pkg_resources import parse_version - -from slpkg.messages import Msg -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - - -def slack_package(prgnam): - """Return maximum binary Slackware package from output directory - """ - msg = Msg() - TAG, binaries, cache, binary = "_SBo", [], "0", "" - - for exp in os.environ.keys(): - if exp == "TAG": - TAG = os.environ["TAG"] - break - - for pkg in find_package(prgnam, _meta_.output): - if pkg.startswith(prgnam) and pkg[:-4].endswith(TAG): - binaries.append(pkg) - - for bins in binaries: - binary = bins - if parse_version(bins) > parse_version(cache): - binary = bins - cache = binary - - if not binary: - msg.pkg_not_found("\n", prgnam, "Can't build", "\n") - raise SystemExit(1) - - return ["".join(_meta_.output + binary)] diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py deleted file mode 100644 index 3f600320..00000000 --- a/slpkg/sbo/slackbuild.py +++ /dev/null @@ -1,432 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# slackbuild.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from pkg_resources import parse_version - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.log_deps import write_deps -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.remove import delete_folder -from slpkg.security import pkg_security -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package -from slpkg.pkg.build import BuildPackage -from slpkg.pkg.manager import PackageManager -from slpkg.pkg.installed import GetFromInstalled - -from slpkg.sbo.greps import SBoGrep -from slpkg.sbo.sbo_arch import SBoArch -from slpkg.sbo.compressed import SBoLink -from slpkg.sbo.dependency import Requires -from slpkg.sbo.search import sbo_search_pkg -from slpkg.sbo.slack_find import slack_package - - -class SBoInstall(BlackList, Utils): - """Build and install SBo packages with all dependencies - """ - def __init__(self, slackbuilds, flag): - super().__init__() - self.slackbuilds = slackbuilds - pkg_security(self.slackbuilds) - self.flag = flag - self.meta = _meta_ - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.yellow = _meta_.color["YELLOW"] - self.grey = _meta_.color["GREY"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.arch = SBoArch().get() - self.build_folder = self.meta.build_path - self._SOURCES = self.meta.SBo_SOURCES - self.unst = ["UNSUPPORTED", "UNTESTED"] - self.master_packages = [] - self.deps = [] - self.dependencies = [] - self.package_not_found = [] - self.package_found = [] - self.deps_dict = {} - self.answer = "" - self.match = False - self.count_ins = 0 - self.count_upg = 0 - self.count_uni = 0 - self.msg.reading() - self.data = SBoGrep(name="").names() - self.blacklist = list(self.get_black()) - - def start(self, is_upgrade): - """Start view, build and install SBo packages - """ - tagc = "" - self.is_upgrade = is_upgrade - self.case_insensitive() - - for _sbo in self.slackbuilds: - if _sbo in self.data and _sbo not in self.blacklist: - sbo_deps = Requires(self.flag).sbo(_sbo) - self.deps += sbo_deps - self.deps_dict[_sbo] = self.one_for_all(sbo_deps) - self.package_found.append(_sbo) - else: - self.package_not_found.append(_sbo) - - self.update_deps() - - if not self.package_found: - self.match = True - self.matching() - - self.master_packages, mas_src = self.sbo_version_source( - self.package_found) - self.msg.done() - - if (self.meta.rsl_deps in ["on", "ON"] and not self.match): - self.msg.resolving() - - self.dependencies, dep_src = self.sbo_version_source( - self.one_for_all(self.deps)) - - if (self.meta.rsl_deps in ["on", "ON"] and not self.match): - self.msg.done() - - self.clear_masters() - - if self.package_found: - - if self.match and [""] != self.slackbuilds: - self.msg.matching(self.slackbuilds) - - else: - print("\nThe following packages will be automatically " - "installed or upgraded \nwith new version:\n") - - self.top_view() - self.msg.upg_inst(self.is_upgrade) - - # view master packages - for sbo, arch in zip(self.master_packages, mas_src): - tagc = self.tag(sbo) - name = "-".join(sbo.split("-")[:-1]) - self.view_packages(tagc, name, sbo.split("-")[-1], - self.select_arch(arch)) - - self.view_installing_for_deps() - - # view dependencies - for dep, arch in zip(self.dependencies, dep_src): - tagc = self.tag(dep) - name = "-".join(dep.split("-")[:-1]) - self.view_packages(tagc, name, dep.split("-")[-1], - self.select_arch(arch)) - - count_total = sum([self.count_ins, self.count_upg, - self.count_uni]) - - if self.match and [""] != self.slackbuilds: - print("\nMatching summary") - print("=" * 79) - raise SystemExit(f"Total {count_total} matching packages\n") - - print("\nInstalling summary") - print("=" * 79) - print(f"{self.grey}Total {count_total} " - f"{self.msg.pkg(count_total)}.") - print(f"{self.count_uni} {self.msg.pkg(self.count_uni)} " - f"will be installed, " - f"{self.count_ins} already installed and " - f"{self.count_upg} {self.msg.pkg(self.count_upg)}") - print(f"will be upgraded.{self.endc}\n") - self.continue_to_install() - - else: - self.msg.not_found(self.is_upgrade) - raise SystemExit() - - def case_insensitive(self): - """Matching packages distinguish between uppercase and - lowercase - """ - if "--case-ins" in self.flag: - data_dict = self.case_sensitive(self.data) - - for name in self.slackbuilds: - index = self.slackbuilds.index(name) - - for key, value in data_dict.items(): - - if key == name.lower(): - self.slackbuilds[index] = value - - def update_deps(self): - """Update dependencies dictionary with all package - """ - onelist, dependencies = [], [] - onelist = self.dimensional_list(self.deps) - dependencies = self.remove_dbs(onelist) - - for dep in dependencies: - deps = Requires(self.flag).sbo(dep) - self.deps_dict[dep] = self.one_for_all(deps) - - def continue_to_install(self): - """Continue to install ? - """ - if (self.count_uni > 0 or self.count_upg > 0 or - "--rebuild" in self.flag): - - if self.master_packages and self.msg.answer() in ["y", "Y"]: - installs, upgraded = self.build_install() - - self.msg.reference(installs, upgraded) - write_deps(self.deps_dict) - delete_folder(self.build_folder) - - def view_installing_for_deps(self): - """View installing message for dependencies - """ - if not self.match and self.dependencies: - print("Installing for dependencies:") - - def clear_masters(self): - """Clear master slackbuilds if already exist in dependencies - or if added to install two or more times - """ - self.master_packages = self.remove_dbs(self.master_packages) - for mas in self.master_packages: - - if mas in self.dependencies: - self.master_packages.remove(mas) - - def matching(self): - """Return found matching SBo packages - """ - for sbo in self.package_not_found: - for pkg in self.data: - if sbo in pkg and pkg not in self.blacklist: - self.package_found.append(pkg) - - def sbo_version_source(self, slackbuilds): - """Create sbo name with version - """ - sbo_versions, sources = [], [] - - for sbo in slackbuilds: - sbo_ver = f"{sbo}-{SBoGrep(sbo).version()}" - sbo_versions.append(sbo_ver) - sources.append(SBoGrep(sbo).source()) - - return [sbo_versions, sources] - - def one_for_all(self, deps): - """Because there are dependencies that depend on other - dependencies are created lists into other lists. - Thus creating this loop create one-dimensional list and - remove double packages from dependencies. - """ - requires, dependencies = [], [] - deps.reverse() - # Inverting the list brings the - # dependencies in order to be installed. - requires = self.dimensional_list(deps) - dependencies = self.remove_dbs(requires) - - return dependencies - - def top_view(self): - """View top template - """ - self.msg.template(78) - - print(f"| Packages{' ' * 16}" - f"New version{' ' * 8}" - f"Arch{' ' * 4}" - f"Build{' ' * 2}" - f"Repos{' ' * 10}" - f"Size") - - self.msg.template(78) - - def view_packages(self, *args): - """:View slackbuild packages with version and arch - args[0] package color - args[1] package - args[2] version - args[3] arch - """ - ver = GetFromInstalled(args[1]).version() - - if ver: - ver = f"-{ver}" - - print(f" {args[0]}{args[1] + ver} {self.endc}" - f"{' ' * (24-len(args[1] + ver))}{args[2]}" - f"{' ' * (18-len(args[2]))} {args[3]}" - f"{' ' * (15-len(args[3]))}{''}" - f"{''}SBo{''}{'':>11}{''}") - - def tag(self, sbo): - """Tag with color green if package already installed, - color yellow for packages to upgrade and color red - if not installed. - """ - # split sbo name with version and get name - sbo_name = "-".join(sbo.split("-")[:-1]) - find = GetFromInstalled(sbo_name).name() - - if find_package(sbo, self.meta.pkg_path): - paint = self.meta.color["GREEN"] - self.count_ins += 1 - - if "--rebuild" in self.flag: - self.count_upg += 1 - - elif sbo_name == find: - paint = self.meta.color["YELLOW"] - self.count_upg += 1 - - else: - paint = self.meta.color["RED"] - self.count_uni += 1 - - return paint - - def select_arch(self, src): - """Looks if sources unsupported or untested - from arch else select arch. - """ - arch = self.arch - - for item in self.unst: - if item in src: - arch = item - - return arch - - def filenames(self, sources): - """Return filenames from sources links - """ - for src in sources: - yield src.split("/")[-1] - - def build_install(self): - """Build and install packages if not already installed - """ - slackbuilds = self.dependencies + self.master_packages - installs, upgraded, = [], [] - - if not os.path.exists(self.build_folder): - os.makedirs(self.build_folder) - - if not os.path.exists(self._SOURCES): - os.makedirs(self._SOURCES) - - os.chdir(self.build_folder) - - for prgnam in slackbuilds: - if (self.meta.not_downgrade == "on" and - self.not_downgrade(prgnam) is True): - continue - - pkg = "-".join(prgnam.split("-")[:-1]) - installed = "".join(find_package(prgnam, self.meta.pkg_path)) - src_link = SBoGrep(pkg).source().split() - - if (installed and "--rebuild" not in self.flag): - self.msg.template(78) - self.msg.pkg_found(prgnam) - self.msg.template(78) - elif self.unst[0] in src_link or self.unst[1] in src_link: - self.msg.template(78) - print(f"| Package {prgnam} {self.red}" - f"{''.join(src_link)}{self.endc}") - self.msg.template(78) - else: - sbo_url = sbo_search_pkg(pkg) - sbo_link = SBoLink(sbo_url).tar_gz() - script = sbo_link.split("/")[-1] - - if self.meta.sbosrcarch in ["on", "ON"]: - src_link = list(self.sbosrcarsh(prgnam, sbo_link, - src_link)) - Download(self.build_folder, sbo_link.split(), - repo="sbo").start() - Download(self._SOURCES, src_link, repo="sbo").start() - - sources = list(self.filenames(src_link)) - BuildPackage(script, sources, self.build_folder, - auto=False).build() - binary = slack_package(prgnam) - - if os.path.isfile("".join(binary)): - if GetFromInstalled(pkg).name() == pkg: - print(f"[ {self.yellow}Upgrading{self.endc} ] --> " - f"{prgnam}") - upgraded.append(prgnam) - - else: - print(f"[ {self.green}Installing{self.endc} ] --> " - f"{prgnam}") - installs.append(prgnam) - - if ("--rebuild" in self.flag and - GetFromInstalled(pkg).name() == pkg): - PackageManager(binary).upgrade(flag="--reinstall") - - else: - PackageManager(binary).upgrade(flag="--install-new") - - return installs, upgraded - - def not_downgrade(self, prgnam): - """Don't downgrade packages if sbo version is lower than - installed""" - name = "-".join(prgnam.split("-")[:-1]) - sbo_ver = prgnam.split("-")[-1] - ins_ver = GetFromInstalled(name).version() - - if not ins_ver: - ins_ver = "0" - - if parse_version(sbo_ver) < parse_version(ins_ver): - self.msg.template(78) - print(f"| Package {name} does not downgrade, " - f"setting by user") - self.msg.template(78) - - return True - - def sbosrcarsh(self, prgnam, sbo_link, src_link): - """Alternative repository for sbo sources""" - name = "-".join(prgnam.split("-")[:-1]) - category = f"{sbo_link.split('/')[-2]}/{name}/" - - for link in src_link: - source = link.split("/")[-1] - yield f"{self.meta.sbosrcarch_link}{category}{source}" diff --git a/slpkg/security.py b/slpkg/security.py deleted file mode 100644 index 57cfb8b6..00000000 --- a/slpkg/security.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# security.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.utils import Utils -from slpkg.messages import Msg - - -def pkg_security(pkgs): - """Checks packages before installing or upgrading for security - reasons. Configuration file in the /etc/slpkg/pkg_security""" - packages, msg, utils = [], Msg(), Utils() - security_packages = utils.read_file("/etc/slpkg/pkg_security") - - for read in security_packages.splitlines(): - read = read.lstrip() - - if not read.startswith("#"): - packages.append(read.replace("\n", "")) - - for p in pkgs: - - for pkg in packages: - - if p == pkg: - msg.security_pkg(p) - - if not msg.answer() in ["y", "Y"]: - raise SystemExit() diff --git a/slpkg/sizes.py b/slpkg/sizes.py deleted file mode 100644 index e193ef5f..00000000 --- a/slpkg/sizes.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# sizes.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -def units(comp_sum, uncomp_sum): - """Calculates package size - """ - compressed = round((sum(map(float, comp_sum)) / 1024), 2) - uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2) - comp_unit = uncomp_unit = "Mb" - - if compressed > 1024: - compressed = round((compressed / 1024), 2) - comp_unit = "Gb" - - if uncompressed > 1024: - uncompressed = round((uncompressed / 1024), 2) - uncomp_unit = "Gb" - - if compressed < 1: - compressed = sum(map(int, comp_sum)) - comp_unit = "Kb" - - if uncompressed < 1: - uncompressed = sum(map(int, uncomp_sum)) - uncomp_unit = "Kb" - - return [comp_unit, uncomp_unit], [compressed, uncompressed] diff --git a/slpkg/slack/__init__.py b/slpkg/slack/__init__.py deleted file mode 100644 index f5920df3..00000000 --- a/slpkg/slack/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# [ slackware ] directory diff --git a/slpkg/slack/mirrors.py b/slpkg/slack/mirrors.py deleted file mode 100644 index e5608eb2..00000000 --- a/slpkg/slack/mirrors.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# mirrors.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.repositories import Repo -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.slack.slack_version import slack_ver - - -def mirrors(name, location): - """Selects Slackware official mirror packages - based architecture and version. - """ - rel = _meta_.slack_rel - ver = slack_ver() - repo = Repo() - slack = repo.slack() - - if _meta_.arch == "x86_64": - - if rel == "stable": - http = f"{slack}slackware64-{ver}/{location}{name}" - - else: - http = f"{slack}slackware64-{rel}/{location}{name}" - - elif _meta_.arch.startswith("arm"): - - if rel == "stable": - http = f"{slack}slackwarearm-{ver}/{location}{name}" - - else: - http = f"{slack}slackwarearm-{rel}/{location}{name}" - - else: - - if rel == "stable": - http = f"{slack}slackware-{ver}/{location}{name}" - - else: - http = f"{slack}slackware-{rel}/{location}{name}" - - return http diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py deleted file mode 100644 index f5dbaf59..00000000 --- a/slpkg/slack/patches.py +++ /dev/null @@ -1,336 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# patches.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import shutil -import subprocess -from pkg_resources import parse_version - - -from slpkg.init import Update -from slpkg.utils import Utils -from slpkg.sizes import units -from slpkg.messages import Msg -from slpkg.url_read import URL -from slpkg.checksum import check_md5 -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.remove import delete_package -from slpkg.grep_md5 import pkg_checksum -from slpkg.dialog_box import DialogUtil -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package -from slpkg.pkg.manager import PackageManager -from slpkg.pkg.installed import GetFromInstalled - -from slpkg.binary.greps import repo_data - -from slpkg.slack.mirrors import mirrors -from slpkg.slack.slack_version import slack_ver - - -class Patches(BlackList, Utils): - """Upgrades distribution from the official Slackware mirrors - """ - def __init__(self, skip, flag): - super().__init__() - self.skip = skip - self.flag = flag - self.meta = _meta_ - self.grey = _meta_.color["GREY"] - self.yellow = _meta_.color["YELLOW"] - self.green = _meta_.color["GREEN"] - self.red = _meta_.color["RED"] - self.endc = _meta_.color["ENDC"] - self.msg = Msg() - self.version = self.meta.slack_rel - self.patch_path = self.meta.slpkg_tmp_patches - self.count_added = 0 - self.count_upg = 0 - self.pkg_for_upgrade = [] - self.dwn_links = [] - self.upgrade_all = [] - self.upgraded = [] - self.installed = [] - self.comp_sum = [] - self.uncomp_sum = [] - self.msg.checking() - - if self.version == "stable": - self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", - "patches/")).get_request() - - else: - self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).get_request() - - def start(self): - """Installs new patches from official Slackware mirrors - """ - self.store() - self.msg.done() - - if self.upgrade_all: - - if "--checklist" in self.flag: - self.dialog_checklist() - - print("\nThese packages need upgrading:\n") - self.msg.template(78) - print(f"| Package{' ' * 17}New Version{' ' * 8}Arch" - f"{' ' * 4}Build{' ' * 2}Repo{' ' * 11}Size") - - self.msg.template(78) - - print("Upgrading:") - - self.views() - - unit, size = units(self.comp_sum, self.uncomp_sum) - - print("\nInstalling summary") - print("=" * 79) - print(f"{self.grey}Total {self.count_upg} " - f"{self.msg.pkg(len(self.upgrade_all))} will be upgraded and" - f" {self.count_added} will be installed.") - print(f"Need to get {size[0]} {unit[0]} of archives.") - print(f"After this process, {size[1]} {unit[1]} of additional disk" - f" space will be used.{self.endc}") - print() - - if self.msg.answer() in ["y", "Y"]: - Download(self.patch_path, self.dwn_links, - repo="slack").start() - self.upgrade_all = list(self.check_downloaded( - self.patch_path, self.upgrade_all)) - self.upgrade() - self.kernel() - - if self.meta.slackpkg_log in ["on", "ON"]: - # update the slackpkg ChanheLog.txt file - self.slackpkg_update() - - self.msg.reference(self.installed, self.upgraded) - - # delete the downloaded packages - delete_package(self.patch_path, self.upgrade_all) - - # update the packages lists - self.update_lists() - - else: - slack_arch = "" - - if self.meta.arch == "x86_64": - slack_arch = "64" - - print(f"\nSlackware{slack_arch} '{self.version}' v{slack_ver()}" - f" distribution is up to date!\n") - - def store(self): - """Stores and returns packages for upgrading - """ - data = repo_data(self.PACKAGES_TXT, "slack", self.flag) - black = list(self.get_black()) - for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]): - repo_pkg_name = split_package(name)[0] - - if self.meta.only_installed in ["on", "ON"]: - pkg_name = split_package(name)[0] - pkg_ver = split_package(name)[1] - - if (GetFromInstalled(pkg_name).name() and - repo_pkg_name not in black and - repo_pkg_name not in self.skip and - parse_version(pkg_ver) > parse_version( - GetFromInstalled(pkg_name).version())): - self.dwn_links.append(f"{mirrors('', '')}{loc}/{name}") - self.comp_sum.append(comp) - self.uncomp_sum.append(uncomp) - self.upgrade_all.append(name) - self.count_upg += 1 - - if not find_package(f"{repo_pkg_name}-", - self.meta.pkg_path): - self.count_added += 1 - self.count_upg -= 1 - - elif (not os.path.isfile(self.meta.pkg_path + name[:-4]) and - repo_pkg_name not in black and - repo_pkg_name not in self.skip): - self.dwn_links.append(f"{mirrors('', '')}{loc}/{name}") - self.comp_sum.append(comp) - self.uncomp_sum.append(uncomp) - self.upgrade_all.append(name) - self.count_upg += 1 - - if not find_package(f"{repo_pkg_name}-", self.meta.pkg_path): - self.count_added += 1 - self.count_upg -= 1 - - return self.count_upg - - def dialog_checklist(self): - """Creates checklist to choose packages for upgrade - """ - data = [] - for upg in self.upgrade_all: - data.append(upg[:-4]) - - text = "Press 'spacebar' to unchoose packages from upgrade" - title = " Upgrade " - status = True - - backtitle = f"{self.meta.__all__} {self.meta.__version__}" - - pkgs = DialogUtil(data, text, title, backtitle, - status).checklist() - - index = 0 - for pkg, comp, uncomp in zip(self.upgrade_all, self.comp_sum, - self.uncomp_sum): - - if pkg[:-4] not in pkgs: - self.dwn_links.pop(index) - self.upgrade_all.pop(index) - self.comp_sum.pop(index) - self.uncomp_sum.pop(index) - self.count_upg -= 1 - del comp, uncomp - index -= 1 - - index += 1 - - if not self.upgrade_all: - raise SystemExit() - - def views(self): - """Views packages - """ - for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)): - pkg_repo = split_package(upg[:-4]) - color = self.red - pkg_inst = GetFromInstalled(pkg_repo[0]).name() - - if pkg_repo[0] == pkg_inst: - color = self.yellow - - ver = GetFromInstalled(pkg_repo[0]).version() - - if ver: - ver = f"-{ver}" - - print(f" {color}{pkg_repo[0] + ver}{self.endc}" - f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}" - f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}" - f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}" - f"{' ' * (7-len(pkg_repo[3]))}Slack{size:>12} K") - - def upgrade(self): - """Upgrades packages - """ - for pkg in self.upgrade_all: - check_md5(pkg_checksum(pkg, "slack_patches"), - self.patch_path + pkg) - - pkg_ver = f"{split_package(pkg)[0]}-{split_package(pkg)[1]}" - - if find_package(f"{split_package(pkg)[0]}-", - self.meta.pkg_path): - print(f"[ {self.yellow}upgrading{self.endc} ] --> {pkg[:-4]}") - PackageManager((self.patch_path + pkg).split()).upgrade( - "--install-new") - self.upgraded.append(pkg_ver) - - else: - print(f"[ {self.green}installing{self.endc} ] --> {pkg[:-4]}") - PackageManager((self.patch_path + pkg).split()).upgrade( - "--install-new") - self.installed.append(pkg_ver) - - def kernel(self): - """Checks if kernel upgraded if true - then reinstall boot loader - """ - for core in self.upgrade_all: - - if "kernel" in core: - - if self.meta.default_answer in ["y", "Y"]: - answer = self.meta.default_answer - - else: - print() - self.msg.template(78) - print(f"| {self.red}*** HIGHLY recommended reinstall " - f"boot loader ***{self.endc}") - print("| L=lilo / E=elilo / G=grub") - self.msg.template(78) - - try: - answer = input("\nThe kernel has been upgraded, " - "reinstall boot loader [L/E/G]? ") - except EOFError: - raise SystemExit("\n") - - if answer in ["L"]: - subprocess.call("lilo", shell=True) - break - - elif answer in ["E"]: - subprocess.call("eliloconfig", shell=True) - break - - elif answer in ["G"]: - subprocess.call("grub-mkconfig -o /boot/grub/grub.cfg", - shell=True) - break - - def slackpkg_update(self): - """This replace slackpkg ChangeLog.txt file with new one - from Slackware official mirrors after update distribution. - """ - NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).get_request() - - if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"): - os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old") - - if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt"): - shutil.copy2(f"{self.meta.slackpkg_lib_path}ChangeLog.txt", - f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old") - os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt") - - with open(f"{self.meta.slackpkg_lib_path}ChangeLog.txt", "w") as log: - log.write(NEW_ChangeLog_txt) - - def update_lists(self): - """Updates packages list and ChangeLog.txt file after - upgrade distribution - """ - print(f"{self.green}Update the package lists ?{self.endc}") - print("=" * 79) - - if self.msg.answer() in ["y", "Y"]: - Update().run(["slack"]) diff --git a/slpkg/slack/slack_version.py b/slpkg/slack/slack_version.py deleted file mode 100644 index 5b7d66ad..00000000 --- a/slpkg/slack/slack_version.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# slack_version.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import re - -from slpkg.utils import Utils -from slpkg.__metadata__ import MetaData as _meta_ - - -def slack_ver(): - """Opens the file and read Slackware version - """ - utils = Utils() - - if _meta_.slackware_version in ["off", "OFF"]: - sv = utils.read_file("/etc/slackware-version") - version = re.findall(r"\d+", sv) - - if len(sv) > 2: - return (".".join(version[:2])) - - else: - return (".".join(version)) - - return _meta_.slackware_version diff --git a/slpkg/slack/slackware_repo.py b/slpkg/slack/slackware_repo.py deleted file mode 100644 index f8968db3..00000000 --- a/slpkg/slack/slackware_repo.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# slackware_repo.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.utils import Utils -from slpkg.binary.greps import repo_data -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - - -def slackware_repository(): - """Returns all official Slackware packages - """ - utils = Utils() - slack_repo, packages, names = [], [], [] - - slack_repo = repo_data( - utils.read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"), - "slack", "") - - for pkg in slack_repo[0]: - names.append(split_package(pkg)[0]) - packages.append(pkg[:-4]) - - return packages, names diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py new file mode 100644 index 00000000..0fc60573 --- /dev/null +++ b/slpkg/slackbuild.py @@ -0,0 +1,204 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import os +import shutil +import hashlib +import subprocess +from dataclasses import dataclass + +from downloader import Wget +from metadata import Metadata +from queries import SBoQueries +from utilities import Utilities +from dependencies import Requires +from views.views import ViewMessage +from models.models import LogsDependencies +from models.models import session as Session + + +@dataclass +class Slackbuilds: + ''' Download build and install the SlackBuilds. ''' + slackbuilds: str + flags: list + install: bool + session: str = Session + build_path: str = Metadata.build_path + sbo_url: str = Metadata.sbo_url + build_path: str = Metadata.build_path + tmp_slpkg: str = Metadata.tmp_slpkg + tmp_path: str = Metadata.tmp_path + tar_suffix: str = Metadata.tar_suffix + os_arch: str = Metadata.os_arch + repo_tag: str = Metadata.repo_tag + pkg_suffix: str = Metadata.pkg_suffix + installpkg: str = Metadata.installpkg + + def execute(self): + ''' Starting build or install the slackbuilds. ''' + self.sbos_order = [] + self.creating_dictionary() + + if '--resolve-off' not in self.flags: + self.creating_dependencies_for_build() + self.creating_main_for_build() + + self.view_before_build() + + self.download_slackbuilds_and_build() + + def view_before_build(self): + ''' View slackbuilds before proceed. ''' + view = ViewMessage() + + if self.install: + view.install_packages(self.sbos_order) + else: + view.build_packages(self.sbos_order) + + view.question(self.flags) + + def creating_dictionary(self): + ''' Dictionary with the main slackbuilds and dependencies. ''' + self.sbos = {} + for sbo in self.slackbuilds: + self.sbos[sbo] = Requires(sbo).resolve() + + def creating_dependencies_for_build(self): + ''' List with the dependencies. ''' + for deps in self.sbos.values(): + for dep in deps: + self.sbos_order.append(dep) + + def creating_main_for_build(self): + ''' List with the main slackbuilds. ''' + for main in self.sbos.keys(): + self.sbos_order.append(main) + + def download_slackbuilds_and_build(self): + ''' Downloads files and sources and starting the build. ''' + wget = Wget() + utils = Utilities() + + for sbo in self.sbos_order: + file = f'{sbo}{self.tar_suffix}' + + self.remove_file_if_exists(self.tmp_slpkg, file) + self.remove_folder_if_exists(self.build_path, sbo) + + location = SBoQueries(sbo).location() + url = f'{self.sbo_url}/{location}/{file}' + + wget.download(self.tmp_slpkg, url) + + utils.untar_archive(self.tmp_slpkg, file, self.build_path) + + sources = SBoQueries(sbo).sources() + self.download_sources(sbo, sources) + + self.execute_the_script(self.build_path, sbo) + + if self.install: + + package = self.creating_package_for_install(sbo) + self.install_package(package) + + if '--resolve-off' not in self.flags: + self.logging_installed_dependencies(sbo) + + def logging_installed_dependencies(self, name): + ''' Logging installed dependencies and used for remove. ''' + exist = self.session.query(LogsDependencies.name).filter( + LogsDependencies.name == name).first() + + requires = Requires(name).resolve() + + # Update the dependencies if exist else create it. + if exist: + self.session.query( + LogsDependencies).filter( + LogsDependencies.name == name).update( + {LogsDependencies.requires: ' '.join(requires)}) + + elif requires: + deps = LogsDependencies(name=name, + requires=' '.join(requires)) + self.session.add(deps) + self.session.commit() + + def install_package(self, package): + ''' Install the packages that before created in the tmp directory. ''' + command = f'{self.installpkg} {self.tmp_path}/{package}' + subprocess.call(command, shell=True) + + def creating_package_for_install(self, name: str): + ''' Creating a list with all the finished packages for + installation. + ''' + utils = Utilities() + build_tag = utils.build_tag(self.build_path, name) + version = SBoQueries(name).version() + return (f'{name}-{version}-{self.os_arch}-{build_tag[0]}' + f'{self.repo_tag}{self.pkg_suffix}') + + def execute_the_script(self, path: str, name: str): + ''' Run the .SlackBuild script. ''' + folder = f'{path}/{name}/' + slackbuild = f'./{name}.SlackBuild' + execute = folder + slackbuild + stdout = subprocess.call(execute) + if stdout > 0: + raise SystemExit(stdout) + + def download_sources(self, name, sources: str): + ''' Download the sources. ''' + wget = Wget() + path = f'{self.build_path}/{name}' + checksums = SBoQueries(name).checksum() + + for source, checksum in zip(sources.split(), checksums[0].split()): + wget.download(path, source) + md5sum = Md5sum(source, checksum, name) + md5sum.check() + + def remove_file_if_exists(self, path: str, file: str): + ''' Clean the the old files. ''' + archive = f'{path}/{file}' + if os.path.isfile(archive): + os.remove(archive) + + def remove_folder_if_exists(self, path: str, folder: str): + ''' Clean the the old folders. ''' + directory = f'{path}/{folder}' + if os.path.isdir(directory): + shutil.rmtree(directory) + + +@dataclass +class Md5sum: + ''' Checksum the sources. ''' + source: str + checksum: str + name: str + build_path: str = Metadata.build_path + + def check(self): + path = f'{self.build_path}/{self.name}' + filename = f'{path}/{self.source.split("/")[-1]}' + + md5 = self.read_file(filename) + + file_check = hashlib.md5(md5).hexdigest() + + if file_check not in self.checksum: + print('\nExpected:', ''.join(self.checksum)) + print('Found:', file_check) + print(f'\nMD5SUM check for {self.sbo} FAILED.') + + view = ViewMessage() + view.question(['--no']) + + def read_file(self, filename): + with open(filename, 'rb') as f: + return f.read() diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py deleted file mode 100644 index a71d80c6..00000000 --- a/slpkg/slpkg_update.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# slpkg_update.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import re -import tarfile -import subprocess - -from slpkg.url_read import URL -from slpkg.checksum import check_md5 -from slpkg.downloader import Download -from slpkg.grep_md5 import pkg_checksum -from slpkg.__metadata__ import MetaData as _meta_ - - -def it_self_update(): - """Checks from GitLab slpkg repository if a new version is available - """ - __new_version__ = "" - repository = "gitlab" - branch = "master" - ver_link = ("https://{0}.com/{1}/{2}/raw/" - "{3}/{4}/__metadata__.py".format(repository, - _meta_.__author__, - _meta_.__all__, - branch, - _meta_.__all__)) - - version_data = URL(ver_link).get_request() - - for line in version_data.splitlines(): - line = line.strip() - - if line.startswith("__version_info__"): - __new_version__ = ".".join(re.findall(r"\d+", line)) - - if __new_version__ > _meta_.__version__: - - if _meta_.default_answer in ["y", "Y"]: - answer = _meta_.default_answer - - else: - print("\nNew version '{0}-{1}' is available !\n".format( - _meta_.__all__, __new_version__)) - - try: - answer = input("Would you like to upgrade [y/N]? ") - except EOFError: - raise SystemExit("\n") - - if answer in ["y", "Y"]: - print() # new line after answer - - else: - raise SystemExit() - - dwn_link = ["https://{0}.com/{1}/{2}/-/archive/" - "{3}/{4}-{5}.tar.gz".format(repository, - _meta_.__author__, - _meta_.__all__, - __new_version__, - _meta_.__all__, - __new_version__)] - - if not os.path.exists(_meta_.build_path): - os.makedirs(_meta_.build_path) - - Download(_meta_.build_path, dwn_link, repo="").start() - - os.chdir(_meta_.build_path) - - slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz" - tar = tarfile.open(slpkg_tar_file) - tar.extractall() - tar.close() - - file_name = f"{_meta_.__all__}-{__new_version__}" - - os.chdir(file_name) - - check_md5(pkg_checksum(slpkg_tar_file, _meta_.__all__), - _meta_.build_path + slpkg_tar_file) - - subprocess.call("chmod +x {0}".format("install.sh"), shell=True) - subprocess.call("sh install.sh", shell=True) - - else: - print(f"\n{_meta_.__all__}: There is no new version, " - "already you use the last!\n") - - raise SystemExit() diff --git a/slpkg/splitting.py b/slpkg/splitting.py deleted file mode 100644 index 5c393b04..00000000 --- a/slpkg/splitting.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# splitting.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -def split_package(package): - """Splits package in name, version - arch and build tag. - """ - name = ver = arch = build = [] - split = package.split("-") - - if len(split) > 2: - build = split[-1] - build_a, build_b = "", "" - build_a = build[:1] - - if build[1:2].isdigit(): - build_b = build[1:2] - - build = build_a + build_b - arch = split[-2] - ver = split[-3] - name = "-".join(split[:-3]) - - return [name, ver, arch, build] diff --git a/slpkg/status_deps.py b/slpkg/status_deps.py deleted file mode 100644 index 2e17fe96..00000000 --- a/slpkg/status_deps.py +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# status_deps.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os - -from slpkg.utils import Utils -from slpkg.messages import Msg -from slpkg.graph import Graph -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - - -class DependenciesStatus(Utils): - """Prints dependencies status used by packages - """ - def __init__(self, image): - self.image = image - self.meta = _meta_ - self.msg = Msg() - self.grey = self.meta.color["GREY"] - self.green = self.meta.color["GREEN"] - self.endc = self.meta.color["ENDC"] - self.dmap = {} - self.count_pkg = 0 - self.count_dep = 0 - self.dep_path = self.meta.log_path + "dep/" - self.logs = find_package("", self.dep_path) - - if not self.logs: - self.no_logs() - - self.installed = find_package("", self.meta.pkg_path) - - def data(self): - """Checks all installed packages and create - dictionary database - """ - for pkg in self.installed: - - if os.path.isfile(f"{self.meta.pkg_path}{pkg}"): - name = split_package(pkg)[0] - - for log in self.logs: - deps = self.read_file(f"{self.dep_path}{log}") - - for dep in deps.splitlines(): - - if name == dep: - - if name not in self.dmap.keys(): - self.dmap[name] = [log] - - if not self.count_pkg: - self.count_pkg = 1 - - else: - self.dmap[name] += [log] - self.count_packages() - - def count_packages(self): - """Counts dependencies and packages - """ - packages = [] - - for pkg in self.dmap.values(): - packages += pkg - self.count_dep += 1 - - self.count_pkg = len(set(packages)) - - def show(self): - """Show dependencies status - """ - self.data() - - print() - self.msg.template(78) - print(f"| Dependencies{' ' * 20}Packages") - self.msg.template(78) - - for key, value in self.dmap.items(): - print(" {0}{1}{2}{3}{4}".format( - self.green, key, self.endc, " " * (32-len(key)), - ", ".join(value))) - self.summary() - - if self.image: - Graph(self.image).dependencies(self.dmap) - - def tree(self): - """Like tree view mode - """ - self.msg.template(78) - print("| Dependencies\n" - "| -- Packages") - self.msg.template(78) - - self.data() - - for pkg, dep in self.dmap.items(): - print(f"+ {self.green}{pkg}{self.endc}") - print("|") - - for d in dep: - print(f"+-- {d}") - print("|") - - print("\x1b[1A \n", end="", flush=True) - - self.summary() - - if self.image: - Graph(self.image).dependencies(self.dmap) - - def no_logs(self): - """Print message if no logs found - """ - raise SystemExit("\n There were no logs files. " - "Obviously not used the\n" - " installation method with the command:\n" - " '$ slpkg -s ' yet.\n") - - def summary(self): - """Summary by packages and dependencies - """ - print("\nStatus summary") - print("=" * 79) - print("{0}found {1} dependencies in {2} packages.{3}\n".format( - self.grey, self.count_dep, self.count_pkg, self.endc)) diff --git a/slpkg/superuser.py b/slpkg/superuser.py deleted file mode 100644 index 1e2da766..00000000 --- a/slpkg/superuser.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# superuser.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -import getpass - - -def s_user(): - """Checks for root user - """ - if getpass.getuser() != "root": - raise SystemExit("\nslpkg: Error: Must have root privileges\n") - - -def virtual_env(): - """Checks if a virtual enviroment exists - """ - if "VIRTUAL_ENV" in os.environ.keys(): - raise SystemExit("\nslpkg: Error: Please exit from virtual " - "environment first\n") diff --git a/slpkg/tracking.py b/slpkg/tracking.py deleted file mode 100644 index 38f2d2f1..00000000 --- a/slpkg/tracking.py +++ /dev/null @@ -1,244 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# tracking.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.utils import Utils -from slpkg.graph import Graph -from slpkg.messages import Msg -from slpkg.blacklist import BlackList -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package - -from slpkg.sbo.greps import SBoGrep -from slpkg.sbo.dependency import Requires -from slpkg.sbo.search import sbo_search_pkg - -from slpkg.binary.search import search_pkg -from slpkg.binary.dependency import Dependencies - - -class TrackingDeps(BlackList, Utils): - """Views tree of dependencies and also - highlights packages with the colour green - if already installed and the colour red - if not installed. - """ - def __init__(self, name, repo, flag): - super().__init__() - self.name = name - self.repo = repo - self.flag = flag - self.meta = _meta_ - self.msg = Msg() - self.green = self.meta.color["GREEN"] - self.yellow = self.meta.color["YELLOW"] - self.cyan = self.meta.color["CYAN"] - self.red = self.meta.color["RED"] - self.endc = self.meta.color["ENDC"] - self.requires = [] - self.dependencies = [] - self.dependencies_list = [] - self.deps_dict = {} - self.init_flags() - - def init_flags(self): - """Flags initialization - """ - for i in range(0, len(self.flag)): - - if self.flag[i].startswith("--graph="): - self.image = self.flag[i].split("=")[1] - self.flag[i] = "--graph=" - - def run(self): - """Runs tracking dependencies - """ - self.msg.resolving() - self.repositories() - - if self.find_pkg: - self.dependencies_list.reverse() - self.requires = self.dimensional_list(self.dependencies_list) - self.dependencies = self.remove_dbs(self.requires) - - if self.dependencies == []: - self.dependencies = ["No dependencies"] - - if "--graph=" in self.flag: - self.deps_tree() - - self.msg.done() - - pkg_len = len(self.name) + 24 - - print() # new line at start - self.msg.template(pkg_len) - print(f"| Package {self.cyan}{self.name}{self.endc} " - f"dependencies :") - self.msg.template(pkg_len) - - print("\\") - print(f" +---{self.yellow}[ Tree of dependencies ]{self.endc}") - - index = 0 - - for pkg in self.dependencies: - - if "--check-deps" in self.flag: - used = self.check_used(pkg) - self.deps_used(pkg, used) - used = (f"is dependence on --> " - f"{self.cyan}{', '.join(used)}{self.endc}") - - else: - used = "" - - index += 1 - installed = "" - - if find_package(f"{pkg}-", self.meta.pkg_path): - - if self.meta.use_colors in ["off", "OFF"]: - installed = "* " - - print(" |") - print(f" +--{index}: {self.green}{pkg}{self.endc} " - f"{installed}{used}") - - else: - print(" |") - print(f" +--{index}: {self.red}{pkg}{self.endc} " - f"{installed}") - - if self.meta.use_colors in ["off", "OFF"]: - print("\n * = Installed\n") - - else: - print() # new line at end - - if "--graph=" in self.flag: - self.graph() - - else: - self.msg.done() - raise SystemExit("\nNo package was found to match\n") - - def repositories(self): - """Gets dependencies by repositories - """ - if self.repo == "sbo": - self.sbo_case_insensitive() - self.find_pkg = sbo_search_pkg(self.name) - - if self.find_pkg: - self.dependencies_list = Requires(self.flag).sbo(self.name) - - else: - PACKAGES_TXT = self.read_file( - f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT") - self.names = list(self.package_name(PACKAGES_TXT)) - self.bin_case_insensitive() - self.find_pkg = search_pkg(self.name, self.repo) - - if self.find_pkg: - self.black = list(self.get_black()) - self.dependencies_list = Dependencies( - self.repo, self.black).binary(self.name, self.flag) - - def sbo_case_insensitive(self): - """Matching packages distinguish between uppercase and - lowercase for sbo repository - """ - if "--case-ins" in self.flag: - data = SBoGrep(name="").names() - data_dict = self.case_sensitive(data) - - for key, value in data_dict.items(): - - if key == self.name.lower(): - self.name = value - - def bin_case_insensitive(self): - """Matching packages distinguish between uppercase and - lowercase - """ - if "--case-ins" in self.flag: - data_dict = self.case_sensitive(self.names) - - for key, value in data_dict.items(): - - if key == self.name.lower(): - self.name = value - - def graph(self): - """Drawing image dependencies map - """ - Graph(self.image).dependencies(self.deps_dict) - - def check_used(self, pkg): - """Checks if dependencies used - """ - used = [] - dep_path = f"{self.meta.log_path}dep/" - logs = find_package("", dep_path) - - for log in logs: - deps = self.read_file(f"{dep_path}{log}") - - for dep in deps.splitlines(): - - if pkg == dep: - used.append(log) - return used - - def deps_tree(self): - """Package dependencies image map file - """ - dependencies = self.dependencies + [self.name] - if self.repo == "sbo": - - for dep in dependencies: - deps = Requires(flag="").sbo(dep) - - if dep not in self.deps_dict.values(): - self.deps_dict[dep] = self.dimensional_list(deps) - - else: - - for dep in dependencies: - deps = Dependencies(self.repo, self.black).binary(dep, flag="") - - if dep not in self.deps_dict.values(): - self.deps_dict[dep] = self.dimensional_list(deps) - - def deps_used(self, pkg, used): - """Creates dependencies dictionary - """ - if find_package(f"{pkg}-", self.meta.pkg_path): - - if pkg not in self.deps_dict.values(): - self.deps_dict[pkg] = used - - else: - self.deps_dict[pkg] += used diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py new file mode 100644 index 00000000..b8bf6ffd --- /dev/null +++ b/slpkg/update_repository.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import os +from os import path +from create_data import CreateData +from downloader import Wget +from metadata import Metadata +from models.models import SBoTable +from models.models import session as Session +from dataclasses import dataclass + + +@dataclass +class UpdateRepository: + ''' Deletes and install the data. ''' + sbo_repo_path: str = Metadata.sbo_repo_path + url: str = Metadata.sbo_url + sbo_txt: str = Metadata.sbo_txt + db_path: str = Metadata.db_path + database: str = Metadata.database + session: str = Session + + def sbo(self): + self.delete_file(self.sbo_repo_path, self.sbo_txt) + self.delete_sbo_data() + + sbo_url = f'{self.url}/{self.sbo_txt}' + + wget = Wget() + wget.download(self.sbo_repo_path, sbo_url) + + data = CreateData() + data.insert_sbo_table() + + def delete_file(self, dir, txt_file): + file = f'{dir}/{txt_file}' + if path.exists(file): + os.remove(file) + + def delete_sbo_data(self): + self.session.query(SBoTable).delete() + self.session.commit() diff --git a/slpkg/upgrade_checklist.py b/slpkg/upgrade_checklist.py deleted file mode 100644 index c421a99c..00000000 --- a/slpkg/upgrade_checklist.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# upgrade_checklist.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.dialog_box import DialogUtil -from slpkg.splitting import split_package -from slpkg.__metadata__ import MetaData as _meta_ - -from slpkg.pkg.find import find_package -from slpkg.pkg.installed import GetFromInstalled - - -def choose_upg(packages): - """Creating checklist to choose packages for upgrade - """ - selected_packages, data = [], [] - - if packages: - - for pkg in packages: - name = GetFromInstalled(pkg).name() - ver = GetFromInstalled(pkg).version() - binary = f"{name}-{ver}" - installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0] - data.append(installed) - - text = "Press 'spacebar' to unchoose packages from upgrade" - title = " Upgrade " - - backtitle = f"{_meta_.__all__} {_meta_.__version__}" - - status = True - - pkgs = DialogUtil(data, text, title, backtitle, - status).checklist() - - pkgs = [] if pkgs is None else pkgs - - for pkg in pkgs: - name = split_package(pkg)[0] - - if name in packages: - selected_packages.append(name) - - if not selected_packages: - raise SystemExit(1) - - print() - - return selected_packages diff --git a/slpkg/url_read.py b/slpkg/url_read.py deleted file mode 100644 index 4ca4f420..00000000 --- a/slpkg/url_read.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# url_read.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import urllib3 - -from slpkg.__metadata__ import MetaData as _meta_ - - -class URL: - """Urls reading class - """ - def __init__(self, link): - self.link = link - self.meta = _meta_ - self.red = _meta_.color["RED"] - self.endc = _meta_.color["ENDC"] - - if self.meta.http_proxy: - self.http = urllib3.ProxyManager(self.meta.http_proxy) - - else: - self.http = urllib3.PoolManager() - - def get_request(self): - """Opens url and read - """ - try: - f = self.http.request('GET', self.link) - return f.data.decode("utf-8", "ignore") - except urllib3.exceptions.NewConnectionError: - print(f"\n{self.red}Can't read the file " - f"'{self.link.split('/')[-1]}'{self.endc}") - - return " " diff --git a/slpkg/utilities.py b/slpkg/utilities.py new file mode 100644 index 00000000..8a4adce1 --- /dev/null +++ b/slpkg/utilities.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import os +import re +import tarfile +from dataclasses import dataclass + + +@dataclass +class Utilities: + + def build_tag(self, path: str, name: str): + ''' Opens the .SlackBuild file and reads the BUILD TAG. ''' + folder = f'{path}/{name}' + slackbuild = f'{name}.SlackBuild' + + if os.path.isfile(f'{folder}/{slackbuild}'): + with open(f'{folder}/{slackbuild}', 'r', encoding='utf-8') as sbo: + lines = sbo.readlines() + + for line in lines: + if line.startswith('BUILD'): + return re.findall(r'\d+', line) + + def untar_archive(self, path: str, archive: str, ext_path: str): + ''' Untar the file to the build folder. ''' + tar_file = f'{path}/{archive}' + untar = tarfile.open(tar_file) + untar.extractall(ext_path) + untar.close() diff --git a/slpkg/utils.py b/slpkg/utils.py deleted file mode 100644 index db348080..00000000 --- a/slpkg/utils.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# utils.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import os -from collections import OrderedDict - -from slpkg.splitting import split_package - - -class Utils: - """Class with useful utilities - """ - def case_sensitive(self, lst): - """Create dictionary from list with key in lower case - and value with default - """ - dictionary = {} - for pkg in lst: - dictionary[pkg.lower()] = pkg - return dictionary - - def dimensional_list(self, lists): - """Creates one dimensional list - """ - one_list = [] - - for lst in lists: - one_list += lst - - return one_list - - def remove_dbs(self, double): - """Removes double item from list - """ - return list(OrderedDict.fromkeys(double)) - - def read_file(self, registry): - """Returns reading file - """ - code = self.check_encoding('', registry) - - if not code: - code = "utf-8" - - with open(registry, "r", encoding=code) as file_txt: - read_file = file_txt.read() - return read_file - - def package_name(self, PACKAGES_TXT): - """Returns list with all the names of packages repository - """ - for line in PACKAGES_TXT.splitlines(): - - if line.startswith("PACKAGE NAME:"): - yield split_package(line[14:].strip())[0] - - def check_downloaded(self, path, downloaded): - """Checks if files downloaded and return downloaded - packages - """ - for pkg in downloaded: - - if os.path.isfile(f"{path}{pkg}"): - yield pkg - - def read_config(self, config): - """Reads config file and returns first uncomment line - and stops. Used for Slackware mirrors - """ - for line in config.splitlines(): - line = line.lstrip() - - if line and not line.startswith("#"): - return line - - def fix_file_name(self, file_name): - """Get file name from url and fix passing char '+' - """ - if "%2b" in file_name: - return file_name.replace("%2b", "+", 5) - - elif "%2B" in file_name: - return file_name.replace("%2B", "+", 5) - - else: - return file_name - - def check_encoding(self, path, f): - """Checking the file encoding default is utf-8 - """ - try: - with open(f"{path}{f}", "r") as ftest: - ftest.read() - except UnicodeDecodeError: - return "ISO-8859-1" - - def debug(self, test): - """A function used to print some stuff for debugging - """ - print(test) diff --git a/slpkg/version.py b/slpkg/version.py deleted file mode 100644 index eed320f7..00000000 --- a/slpkg/version.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -# version.py file is part of slpkg. - -# Copyright 2014-2022 Dimitris Zlatanidis -# All rights reserved. - -# Slpkg is a user-friendly package manager for Slackware installations - -# https://gitlab.com/dslackw/slpkg - -# Slpkg is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -from slpkg.__metadata__ import MetaData as m - - -def prog_version(): - """Prints version, license and email - """ - print(f"Version : {m.__version__}\n" - f"Licence : {m.__license__}\n" - f"Email : {m.__email__}\n" - f"Homepage : {m.__homepage__}\n" - f"Maintainer: {m.__maintainer__}") diff --git a/slpkg/views/__init__.py b/slpkg/views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/slpkg/views/views.py b/slpkg/views/views.py new file mode 100644 index 00000000..27f26ffe --- /dev/null +++ b/slpkg/views/views.py @@ -0,0 +1,60 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import os +from dataclasses import dataclass +from queries import SBoQueries +from metadata import Metadata + + +@dataclass +class ViewMessage: + colors: str = Metadata.colour + + def build_packages(self, slackbuilds): + color = self.colors() + + print('The following packages will be build:\n') + + for sbo in slackbuilds: + version = SBoQueries(sbo).version() + print(f'[{color["GREEN"]} build {color["ENDC"]}] -> ' + f'{sbo}-{version}') + + def install_packages(self, slackbuilds): + is_installed = IsInstalled() + color = self.colors() + + print('The following packages will be installed:\n') + + for sbo in slackbuilds: + version = SBoQueries(sbo).version() + installed = is_installed.check(f'{sbo}-{version}-') + if installed: + print(f'[{color["YELLOW"]} install {color["ENDC"]}] -> ' + f'{sbo}-{version}') + else: + print(f'[{color["GREEN"]} install {color["ENDC"]}] -> ' + f'{sbo}-{version}') + + def remove_packages(self): + print('The following packages will be removed:\n') + + def question(self, flags): + + if '--yes' not in flags: + answer = input('\nDo you want to continue [y/N]: ') + print() + if answer not in ['Y', 'y']: + raise SystemExit() + print() + + +@dataclass +class IsInstalled: + log_packages: str = Metadata.log_packages + + def check(self, package): + for pkg in os.listdir(self.log_packages): + if package in pkg: + return True diff --git a/tests/test_file_size.py b/tests/test_file_size.py deleted file mode 100644 index b3ebe1d0..00000000 --- a/tests/test_file_size.py +++ /dev/null @@ -1,19 +0,0 @@ -import unittest -from slpkg.file_size import FileSize - - -class TestFileSize(unittest.TestCase): - - def test_FileSize(self): - """Testing the remote and local servers - """ - url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt" - lc = "test_units.py" - fs1 = FileSize(url) - fs2 = FileSize(lc) - self.assertIsNotNone(fs1.server()) - self.assertIsNotNone(fs2.local()) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_installed.py b/tests/test_installed.py deleted file mode 100644 index 150f0cef..00000000 --- a/tests/test_installed.py +++ /dev/null @@ -1,23 +0,0 @@ -import unittest -from slpkg.pkg.installed import GetFromInstalled - - -class TestPkgInstalled(unittest.TestCase): - - def setUp(self): - self.pkg_name = 'aaa_base' - self.pkg_ver = '15.0' - self.installed = GetFromInstalled('aaa_base') - - def test_pkg_name(self): - """Testing the installed package name - """ - self.assertEqual(self.pkg_name, self.installed.name()) - - def test_pkg_version(self): - """Testing the version of installed package""" - self.assertEqual(self.pkg_ver, self.installed.version()) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_md5sum.py b/tests/test_md5sum.py deleted file mode 100644 index a8d1080d..00000000 --- a/tests/test_md5sum.py +++ /dev/null @@ -1,21 +0,0 @@ -import unittest -from slpkg.md5sum import md5 - - -class TestMd5(unittest.TestCase): - - def test_md5_superuser(self): - """Testing checksum for superuser.py file - """ - result = md5('test_file_size.py') - self.assertEqual(result, "e3e7b72be80efc922b0e1f1cd409a417") - - def test_md5_security(self): - """Testing checksum for security.py file - """ - result = md5('test_units.py') - self.assertEqual(result, "58a694171449e923414e3e3339a0097e") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_sbo_grep.py b/tests/test_sbo_grep.py deleted file mode 100644 index d976ba88..00000000 --- a/tests/test_sbo_grep.py +++ /dev/null @@ -1,49 +0,0 @@ -import unittest -from slpkg.sbo.greps import SBoGrep - - -class TestSBoGreps(unittest.TestCase): - - def setUp(self): - self.grep = SBoGrep('Flask') - - def test_source(self): - """Test package source - """ - source = self.grep.source() - flask_source = ('https://files.pythonhosted.org/packages/source/f' - '/flask/Flask-2.1.2.tar.gz') - self.assertEqual(source, flask_source) - - def test_requires(self): - """Test package requires - """ - requires = self.grep.requires() - flask_dep = ['werkzeug', 'python3-itsdangerous', - 'click', 'python-importlib_metadata'] - self.assertListEqual(requires, flask_dep) - - def test_version(self): - """Test package version - """ - version = self.grep.version() - flask_ver = '2.1.2' - self.assertEqual(version, flask_ver) - - def test_checksum(self): - """Test package checksum - """ - checksum = self.grep.checksum() - flask_md5 = ['93f1832e5be704ef6ff2a4124579cd85'] - self.assertListEqual(checksum, flask_md5) - - def test_description(self): - """Test package description - """ - desc = self.grep.description() - flask_desc = 'Flask (Microframework for Python)' - self.assertEqual(desc, flask_desc) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_search_package.py b/tests/test_search_package.py deleted file mode 100644 index 52ca9798..00000000 --- a/tests/test_search_package.py +++ /dev/null @@ -1,25 +0,0 @@ -import unittest -from slpkg.binary.search import search_pkg -from slpkg.sbo.search import sbo_search_pkg - - -class TestFindPkg(unittest.TestCase): - - def test_search(self): - """Testing found the name from binaries repos - """ - name = "vlc" - repo = "alien" - test = search_pkg(name, repo) - self.assertEqual(name, test) - - def test_sbo_search(self): - """Testing found the name from binaries repos - """ - name = "slpkg" - test = sbo_search_pkg(name).split("/")[-2] - self.assertEqual(name, test) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_slack_version.py b/tests/test_slack_version.py deleted file mode 100644 index 6d693fb6..00000000 --- a/tests/test_slack_version.py +++ /dev/null @@ -1,15 +0,0 @@ -import unittest -from slpkg.slack.slack_version import slack_ver - - -class TestSlackVersion(unittest.TestCase): - - def test_slack_version(self): - """Testing the current Slackware version - """ - ver = '15.0' - self.assertEqual(ver, slack_ver()) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_split_package.py b/tests/test_split_package.py deleted file mode 100644 index 04c6b402..00000000 --- a/tests/test_split_package.py +++ /dev/null @@ -1,26 +0,0 @@ -import unittest -from slpkg.splitting import split_package -from slpkg.pkg.find import searching - - -class TestSplitting(unittest.TestCase): - - def test_split_pkg(self): - path = '/var/log/packages/' - pkg_1 = ''.join(list(searching('slpkg', path))) - pkg_2 = ''.join(list(searching('akonadi-mime', path))) - pkg_3 = ''.join(list(searching('autoconf-archive', path))) - pkg_4 = ''.join(list(searching('bind', path))) - - self.assertListEqual(['slpkg', '3.9.9', 'x86_64', '1'], - split_package(pkg_1)) - self.assertListEqual(['akonadi-mime', '21.12.1', 'x86_64', '1'], - split_package(pkg_2)) - self.assertListEqual(['autoconf-archive', '2021.02.19', 'noarch', '1'], - split_package(pkg_3)) - self.assertListEqual(['bind', '9.16.29', 'x86_64', '1'], - split_package(pkg_4)) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_units.py b/tests/test_units.py deleted file mode 100644 index 096aa786..00000000 --- a/tests/test_units.py +++ /dev/null @@ -1,19 +0,0 @@ -import unittest -from slpkg.sizes import units - - -class TetsUnits(unittest.TestCase): - - def test_units(self): - """Testing the units metrics - """ - self.assertCountEqual((["Kb", "Kb"], [100, 100]), - units(["100"], ["100"])) - self.assertCountEqual((["Mb", "Mb"], [1000, 1000]), - units(["1024000"], ["1024000"])) - self.assertCountEqual((["Gb", "Gb"], [976.56, 976.56]), - units(["1024000000"], ["1024000000"])) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_utils.py b/tests/test_utils.py deleted file mode 100644 index f176f213..00000000 --- a/tests/test_utils.py +++ /dev/null @@ -1,34 +0,0 @@ -import unittest -from slpkg.utils import Utils - - -class TestUtils(unittest.TestCase): - - def setUp(self): - self.utils = Utils() - - def test_dimensional_list(self): - """Testing dimesional list util - """ - lists = [[1, 2, 3, 4, 5]] - self.assertListEqual([1, 2, 3, 4, 5], - self.utils.dimensional_list(lists)) - - def test_remove_dbs(self): - """Testing removing doubles item from list - """ - lists = [1, 2, 3, 3, 4, 5, 2, 1] - self.assertListEqual([1, 2, 3, 4, 5], self.utils.remove_dbs(lists)) - - def test_case_sensitive(self): - """Testing case sensitive - """ - lists = ['Vlc', 'OpenOffice', 'APScheduler'] - dictionary = {'vlc': 'Vlc', - 'openoffice': 'OpenOffice', - 'apscheduler': 'APScheduler'} - self.assertDictEqual(dictionary, self.utils.case_sensitive(lists)) - - -if __name__ == "__main__": - unittest.main() diff --git a/tools/gen_repos_files.sh b/tools/gen_repos_files.sh deleted file mode 100644 index a4962988..00000000 --- a/tools/gen_repos_files.sh +++ /dev/null @@ -1,945 +0,0 @@ -#!/bin/bash -# Copyright (c) 2006-2014 Eric Hameleers, Eindhoven, The Netherlands -# All rights reserved. -# -# 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. -# -# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# --------------------------------------------------------------------------- -# -# Generate the PACKAGES.TXT FILELIST.TXT and CHECKSUMS.md5 files, -# needed by 3rd-party Slackware package management tools. -# -# Eric Hameleers -# --------------------------------------------------------------------------- -cat <<"EOT" -# -------------------------------------------------------------------# -# $Id: gen_repos_files.sh,v 1.94 2018/05/03 15:02:39 root Exp root $ # -# -------------------------------------------------------------------# -EOT - -# The script's basename will be displayed in the RSS feed: -BASENAME=$( basename $0 ) - -# The script'""s revision number will be displayed in the RSS feed: -REV=$( echo "$Revision: 1.94 $" | cut -d' ' -f2 ) - -# The repository owner's defaults file; -# you can override any of the default values in this file: -USERDEFS=${USERDEFS:-~/.genreprc} - -# --------------------------------------------------------------------------- -# Sane defaults: - -# The directory of the Slackware package repository: -REPOSROOT=${REPOSROOT:-"/home/www/sox/slackware/slackbuilds/"} - -# Repository maintainer -REPOSOWNER=${REPOSOWNER:-"Eric Hameleers "} - -# The GPG key for the repository owner can contain a different string than -# the value of $REPOSOWNER . If you leave $REPOSOWNERGPG empty, the script will -# use the value you've set for $REPOSOWNER instead to search the GPG keyfile. -REPOSOWNERGPG=${REPOSOWNERGPG:-""} - -# Under what URL is the repository accessible: -DL_URL=${DL_URL:-""} - -# The title of the generated RSS feed: -RSS_TITLE=${RSS_TITLE:-"Alien's Slackware packages"} - -# The logo picture used for the RSS feed: -RSS_ICON=${RSS_ICON:-"http://www.slackware.com/~alien/graphics/blueorb.png"} - -# The URL linked to when clicking on the logo: -RSS_LINK=${RSS_LINK:-"http://www.slackware.com/~alien/"} - -# URL to the full changelog.txt: -RSS_CLURL=${RSS_CLURL:-"http://www.slackware.com/~alien/slackbuilds/ChangeLog.txt"} - -# The descriptive text for the RSS feed: -RSS_DESCRIPTION=${RSS_DESCRIPTION:-"Eric Hameleers (alien's) Slackware package repository. The package directories include the SlackBuild script and sources."} - -# Maximum number of RSS feed entries to display: -RSS_FEEDMAX=${RSS_FEEDMAX:-15} - -# The RSS generator must use a unique feed identifier. -# Generate one for your feed by using the string returned by "uuidgen -t": -RSS_UUID=${RSS_UUID:-""} - -# Either use gpg or gpg2: -GPGBIN=${GPGBIN:-"/usr/bin/gpg"} - -# Optionally use gpg-agent to cache the gpg passphrase instead of letting the -# script keep it in the environment (note that if you define USE_GPGAGENT=1 -# but gpg-agent is not running, you will get prompted for a passphrase every -# single time gpg runs): -USE_GPGAGENT=${USE_GPGAGENT:-0} - -# Generate slack-requires, slack-suggests, and slack-conflicts lines in the -# metadata files by setting FOR_SLAPTGET to "1" -- these are used by slapt-get -FOR_SLAPTGET=${FOR_SLAPTGET:-0} - -# Follow symlinks in case the repository has symlinks like 14.0 -> 13.37 -# indicating that one package works for those two Slackware releases. -# If the script does _not_ follow symlinks, then the symlinks will appear in -# the repository listing instead of the packages they point to. -FOLLOW_SYMLINKS=${FOLLOW_SYMLINKS:-1} - -# If the repository has separate package subdirectories (for separate -# Slackware releases or architectures) then define them here. -# Separate FILELIST.TXT, MANIFEST etc.. files will be created for all of them: -REPO_SUBDIRS=${REPO_SUBDIRS:-""} - -# If you want to exclude certain directories or files from being included -# in the repository metadata, define them here (space-separated). -# Example: REPO_EXCLUDES="RCS logs .genreprc" -REPO_EXCLUDES=${REPO_EXCLUDES:-""} - -# --------------------------------------------------------------------------- - -# By default, no debug messages -DEBUG=0 - -# Timestamp to be used all around the script: -UPDATEDATE="$(LC_ALL=C date -u)" - -# A value of "yes" means that .meta .md5 and/or .asc files are -# always (re)generated. -# while "no" means: only generate these files if they are missing. -FORCEMD5="no" # .md5 files -FORCEPKG="no" # .meta files -FORCEASC="no" # .asc files -TOUCHUP="no" # rsync has issues with files whose content has changed, but - # both size and timestamp remain unchanged (needs expensive - # '--checksum' to detect these file changes) -# We may have a need to only update the ChangeLog files: -RSSONLY="no" # ChangeLog .rss and .txt -# For a sub-repository we do not have a ChangeLog: -CHANGELOG="yes" - -# Variable used to limit the search for packages which lack .md5/.asc file, -# to those packages changed less than NOTOLDER days ago. -NOTOLDER="" - -# Variable used to import the content of a text file as the new ChangeLog.txt -# entry. If empty, you will be asked to type a new entry yourself. -LOGINPUT="" - -# -# --- no need to change anything below this line ---------------------------- -# - -# Import the repository owner's defaults -if [ -f $USERDEFS ]; then - echo "Importing user defaults." - . $USERDEFS -fi - -# We prevent the mirror from running more than one instance: -PIDFILE=/var/tmp/$(basename $0 .sh).pid - -# Make sure the PID file is removed when we kill the process -trap 'rm -f $PIDFILE; exit 1' TERM INT - -# Determine the prune parameters for the 'find' commands: -PRUNES="" -if [ -n "$REPO_EXCLUDES" ]; then - echo "--- Excluding: $REPO_EXCLUDES" - for substr in $REPO_EXCLUDES ; do - PRUNES="${PRUNES} -o -name ${substr} -prune " - done -fi - -# Command line parameter processing: -while getopts ":ahl:mn:prstv" Option -do - case $Option in - h ) echo "Parameters are:" - echo " -h : This help text" - echo " -a : Force generation of .asc gpg signature files" - echo " -l : Use file as input for ChangeLog.txt" - echo " -m : Force generation of .md5 files" - echo " -n : Only look for packages not older than days" - echo " -p : Force generation of package .meta files" - echo " -r : Update ChangeLog TXT and RSS files only" - echo " -s : Sub-repository: does not have ChangeLog TXT or RSS" - echo " -t : Timestamp of metafiles equal to package timestamp" - echo " -v : Verbose messages about packages found" - exit - ;; - a ) FORCEASC="yes" - ;; - l ) LOGINPUT="${OPTARG}" - ;; - m ) FORCEMD5="yes" - ;; - n ) NOTOLDER=${OPTARG} - ;; - p ) FORCEPKG="yes" - ;; - r ) RSSONLY="yes" - ;; - s ) CHANGELOG="no" - ;; - t ) TOUCHUP="yes" - ;; - v ) DEBUG=1 - ;; - * ) echo "You passed an illegal switch to the program!" - echo "Run '$0 -h' for more help." - exit - ;; # DEFAULT - esac -done - -# End of option parsing. -shift $(($OPTIND - 1)) -# $1 now references the first non option item supplied on the command line -# if one exists. -# --------------------------------------------------------------------------- - -# -# --- HELPER FUNCTIONS ------------------------------------------------------ -# - -# -# pkgcomp -# -function pkgcomp { - # Return the compression utility used for this package, - # based on the package's extension. - # Determine extension: - PEXT="$( echo $1 | rev | cut -f 1 -d . | rev)" - # Determine compression used: - case $PEXT in - 'tgz' ) - COMP=gzip - ;; - 'tbz' ) - COMP=bzip2 - ;; - 'tlz' ) - COMP=lzma - ;; - 'txz' ) - COMP=xz - ;; - esac - echo ${COMP:-"gzip"} -} - -# -# addpkg -# -function addpkg { - # ----------------------------------------------- - # Functionality used from the slapt-get FAQ#17 at - # http://software.jaos.org/BUILD/slapt-get/FAQ : - # ----------------------------------------------- - # Generate a package's metafile if missing, and add the content of - # this metafile to the PACKAGES.TXT - # Argument #1 : full path to a package - # Argument #2 : full path to PACKAGES.TXT file/ - - if [ ! -f "$1" -o ! -f "$2" ]; then - echo "Required arguments '$1' and/or '$2' are invalid files!" - exit 1 - fi - PKG=$1 - PACKAGESFILE=$2 - - if [ "$(echo $PKG|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).t[blxg]z[ ]{0,}$')" == "" ]; - then - return; - fi - - NAME=$(echo $PKG|sed -re "s/(.*\/)(.*.t[blxg]z)$/\2/") - LOCATION=$(echo $PKG|sed -re "s/(.*)\/(.*.t[blxg]z)$/\1/") - METAFILE=${NAME%t[blxg]z}meta - TXTFILE=${NAME%t[blxg]z}txt - - if [ "$FORCEPKG" == "yes" -o ! -f $LOCATION/$TXTFILE ]; then - # This is a courtesy service: - echo "--> Generating .txt file for $NAME" - rm -f $LOCATION/$TXTFILE - $COMPEXE -cd $PKG | tar xOf - install/slack-desc | sed -n '/^#/d;/:/p' > $LOCATION/$TXTFILE - [ "$TOUCHUP" == "yes" ] && touch -r $PKG $LOCATION/$TXTFILE || touch -d "$UPDATEDATE" $LOCATION/$TXTFILE - fi - - if [ "$FORCEPKG" == "yes" -o ! -f $LOCATION/$METAFILE ]; then - echo "--> Generating .meta file for $NAME" - - # Determine the compression tool used for this package: - COMPEXE=$( pkgcomp $PKG ) - - SIZE=$(du -s $PKG | cut -f 1) - - if [ "$COMPEXE" = "xz" ]; then - # xz does not support the "-l" switch yet: - cat $PKG | $COMPEXE -dc | dd 1> /dev/null 2> $HOME/.temp.uncomp.$$ - USIZE="$(expr $(cat $HOME/.temp.uncomp.$$ | head -n 1 | cut -f1 -d+) / 2)" - rm -f $HOME/.temp.uncomp.$$ - else - USIZE=$( expr $(gunzip -l $PKG |tail -1|awk '{print $2}') / 1024 ) - fi - - if [ $FOR_SLAPTGET -eq 1 ]; then - REQUIRED=$($COMPEXE -cd $PKG | tar xOf - install/slack-required 2>/dev/null|tr -d ' '|xargs -r -iZ echo -n "Z,"|sed -e "s/,$//") - CONFLICTS=$($COMPEXE -cd $PKG | tar xOf - install/slack-conflicts 2>/dev/null|tr -d ' '|xargs -r -iZ echo -n "Z,"|sed -e "s/,$//") - SUGGESTS=$($COMPEXE -cd $PKG | tar xOf - install/slack-suggests 2>/dev/null|xargs -r ) - fi - - rm -f $LOCATION/$METAFILE - echo "PACKAGE NAME: $NAME" > $LOCATION/$METAFILE - if [ -n "$DL_URL" ]; then - echo "PACKAGE MIRROR: $DL_URL" >> $LOCATION/$METAFILE - fi - echo "PACKAGE LOCATION: $LOCATION" >> $LOCATION/$METAFILE - echo "PACKAGE SIZE (compressed): $SIZE K" >> $LOCATION/$METAFILE - echo "PACKAGE SIZE (uncompressed): $USIZE K" >> $LOCATION/$METAFILE - if [ $FOR_SLAPTGET -eq 1 ]; then - echo "PACKAGE REQUIRED: $REQUIRED" >> $LOCATION/$METAFILE - echo "PACKAGE CONFLICTS: $CONFLICTS" >> $LOCATION/$METAFILE - echo "PACKAGE SUGGESTS: $SUGGESTS" >> $LOCATION/$METAFILE - fi - echo "PACKAGE DESCRIPTION:" >> $LOCATION/$METAFILE - if [ -f $LOCATION/$TXTFILE ]; then - cat $LOCATION/$TXTFILE >> $LOCATION/$METAFILE - else - $COMPEXE -cd $PKG | tar xOf - install/slack-desc | sed -n '/^#/d;/:/p' >> $LOCATION/$METAFILE - fi - echo "" >> $LOCATION/$METAFILE - [ "$TOUCHUP" == "yes" ] && touch -r $PKG $LOCATION/$METAFILE || touch -d "$UPDATEDATE" $LOCATION/$METAFILE - fi - - # Package location may have changed: - sed -e "/^PACKAGE LOCATION: /s,^.*$,PACKAGE LOCATION: $LOCATION," $LOCATION/$METAFILE >> $PACKAGESFILE - -} # end of function 'addpkg' - -# -# addman -# -function addman { - # Add a package's content to the MANIFEST file - # Argument #1 : full path to a package - # Argument #2 : full path to MANIFEST file - - if [ ! -f "$1" -o ! -f "$2" ]; then - echo "Required arguments '$1' and/or '$2' are invalid files!" - exit 1 - fi - PKG=$1 - MANIFESTFILE=$2 - - if [ "$(echo $PKG|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).t[blxg]z[ ]{0,}$')" == "" ]; - then - return; - fi - - NAME=$(echo $PKG|sed -re "s/(.*\/)(.*.t[blxg]z)$/\2/") - LOCATION=$(echo $PKG|sed -re "s/(.*)\/(.*.t[blxg]z)$/\1/") - LSTFILE=${NAME%t[blxg]z}lst - - if [ "$FORCEPKG" == "yes" -o ! -f $LOCATION/$LSTFILE ]; then - echo "--> Generating .lst file for $NAME" - - # Determine the compression tool used for this package: - COMPEXE=$( pkgcomp $PKG ) - - rm -f $LOCATION/$LSTFILE - cat << EOF > $LOCATION/$LSTFILE -++======================================== -|| -|| Package: $PKG -|| -++======================================== -EOF - - $COMPEXE -cd $PKG | tar -tvvf - >> $LOCATION/$LSTFILE - echo "" >> $LOCATION/$LSTFILE - echo "" >> $LOCATION/$LSTFILE - [ "$TOUCHUP" == "yes" ] && touch -r $PKG $LOCATION/$LSTFILE || touch -d "$UPDATEDATE" $LOCATION/$LSTFILE - fi - - # Compensate for partial pathnames in .lst files found in sub-repos: - cat $LOCATION/$LSTFILE \ - | sed -e "s%^|| Package: .*$%|| Package: $PKG%" \ - >> $MANIFESTFILE -} # end of function 'addman' - - -# -# genmd5 -# -function genmd5 { - # Generate a package's MD5SUM (*.md5 file) if missing, - # Argument #1 : full path to a package - - if [ ! -f "$1" ]; then - echo "Required argument '$1' is an invalid file!" - exit 1 - fi - PKG=$1 - - NAME=$(echo $PKG|sed -re "s/(.*\/)(.*.t[blxg]z)$/\2/") - LOCATION=$(echo $PKG|sed -re "s/(.*)\/(.*.t[blxg]z)$/\1/") - BASE=${NAME%.t[blxg]z} - MD5FILE=${NAME}.md5 - - if [ "$FORCEMD5" == "yes" -o ! -f $LOCATION/$MD5FILE ]; then - echo "--> Generating .md5 file for $NAME" - (cd $LOCATION - rm -f $MD5FILE - md5sum $NAME > $MD5FILE - ) - [ "$TOUCHUP" == "yes" ] && touch -r $PKG $LOCATION/$MD5FILE || touch -d "$UPDATEDATE" $LOCATION/$MD5FILE - fi - -} # end of function 'genmd5' - - -# -# genasc -# -function genasc { - # Generate a package's GPG signature (*.asc file) if missing, - # Argument #1 : full path to a package - - if [ ! -f "$1" ]; then - echo "Required argument '$1' is invalid filename!" - exit 1 - fi - PKG=$1 - - NAME=$(echo $PKG|sed -re "s/(.*\/)(.*.t[blxg]z)$/\2/") - LOCATION=$(echo $PKG|sed -re "s/(.*)\/(.*.t[blxg]z)$/\1/") - ASCFILE=${NAME}.asc - - if [ "$FORCEASC" == "yes" -o ! -f $LOCATION/$ASCFILE ]; then - echo "--> Generating .asc file for $NAME" - (cd $LOCATION - rm -f $ASCFILE - gpg_sign $NAME - ) - [ "$TOUCHUP" == "yes" ] && touch -r $PKG $LOCATION/$ASCFILE || touch -d "$UPDATEDATE" $LOCATION/$ASCFILE - fi - -} # end of function 'genasc' - - -# -# gen_filelist -# -function gen_filelist { - # Argument #1 : full path to a directory - # Argument #2 : output filename (defaults to FILELIST.TXT) will be - # created in directory $1 (overwriting existing file). - - if [ ! -d "$1" ]; then - echo "Required argument '$1' must be a directory!" - exit 1 - fi - DIR=$1 - LISTFILE=${2:-FILELIST.TXT} - - ( cd ${DIR} - rm -f ${LISTFILE} - cat < ${LISTFILE} -$UPDATEDATE - -Here is the file list for ${DL_URL:-this directory} , -maintained by ${REPOSOWNER} . -If you are using a mirror site and find missing or extra files -in the subdirectories, please have the archive administrator -refresh the mirror. - -EOT - if [ $FOLLOW_SYMLINKS -eq 1 ]; then - find -L . -print $PRUNES | sort | xargs ls -nld --time-style=long-iso >> ${LISTFILE} - else - find . -print $PRUNES | sort | xargs ls -nld --time-style=long-iso >> ${LISTFILE} - fi - ) -} # end of function 'gen_filelist' - -# -# upd_changelog -# -function upd_changelog { - # Update the ChangeLog.txt with a new entry - # - written at the beginning of the file. - # Argument #1 : full path to a directory - # Argument #2 : a filename (defaults to 'ChangeLog.txt') - - if [ ! -d "$1" ]; then - echo "Required argument '$1' must be an existing directory!" - exit 1 - fi - local DIR=$1 - local CHANGELOG=${2:-ChangeLog.txt} - if [ -e $DIR/$CHANGELOG -a ! -w $DIR/$CHANGELOG ]; then - echo "Can not write to file ${DIR}/${CHANGELOG}!" - exit 1 - fi - - local MAXLINE=78 # Lines will be wrapped at MAXLINE characters. - local LOGTEXT="" - local i=0 - - if [ "$LOGINPUT" == "" ]; then - # Ask for a new ChangeLog entry - read -er -p "Enter ChangeLog.txt description: " - else - REPLY=$(cat "$LOGINPUT" 2>/dev/null) - fi - - if [ "$REPLY" == "" ]; then - echo "No input, so I won't update your $CHANGELOG" - return - fi - - LOGTXT="" - for WORD in $REPLY ; do - # The word 'NEWLINE' forces a... newline in the output. - # The word 'LINEFEED' also signals the start of a new line, but indented. - if [ "${WORD}" == "NEWLINE" ]; then - LOGLINE[$i]="$LOGTXT" - LOGTXT="" - i=$(( $i+1 )) - elif [ "${WORD}" == "LINEFEED" ]; then - LOGLINE[$i]="$LOGTXT" - LOGTXT=" " - i=$(( $i+1 )) - elif [ $(( ${#LOGTXT}+1+${#WORD} )) -gt $MAXLINE ]; then - LOGLINE[$i]="$LOGTXT" - LOGTXT=" ${WORD}" # indent the text two spaces. - i=$(( $i+1 )) - else - [ "$LOGTXT" != "" ] && LOGTXT="${LOGTXT} ${WORD}" || LOGTXT="${WORD}" - fi - done - LOGLINE[$i]="$LOGTXT" - - cat <<-EOT > ${DIR}/.${CHANGELOG} - +--------------------------+ - $UPDATEDATE - EOT - - for IND in $(seq 0 $i); do - echo "${LOGLINE[$IND]}" >> ${DIR}/.${CHANGELOG} - done - echo "" >> ${DIR}/.${CHANGELOG} - if [ -f "${DIR}/${CHANGELOG}" ]; then - cat ${DIR}/${CHANGELOG} >> ${DIR}/.${CHANGELOG} - fi - mv -f ${DIR}/.${CHANGELOG} ${DIR}/${CHANGELOG} -} - -# -# gpg_sign -# -function gpg_sign { - # Create a gpg signature for a file. Use either gpg or gpg2 and optionally - # let gpg-agent provide the passphrase. - if [ $USE_GPGAGENT -eq 1 ]; then - $GPGBIN --use-agent -bas -u "$REPOSOWNERGPG" --batch --quiet $1 - else - echo $TRASK | $GPGBIN -bas -u "$REPOSOWNERGPG" --passphrase-fd 0 --batch --quiet $1 - fi - return $? -} - -# -# rss_changelog -# -function rss_changelog { - # Create a RSS feed out of the ChangeLog.txt - # Argument #1 : full path to a directory - # Argument #2 : a filename (defaults to 'ChangeLog.txt') - # Argument #2 : a filename (defaults to 'ChangeLog.rss') - - if [ ! -d "$1" ]; then - echo "Required argument '$1' must be an existing directory!" - exit 1 - fi - DIR=$1 - INFILE=${DIR}/${2:-ChangeLog.txt} - RSSFILE=${DIR}/${3:-ChangeLog.rss} - if [ -e $RSSFILE -a ! -w $RSSFILE ]; then - echo "Can not write to RSS file ${RSSFILE}!" - exit 1 - fi - - # These values are all set in the beginning (can be user-overridden): - TITLE="$RSS_TITLE" - LINK="$RSS_LINK" - ICON="$RSS_ICON" - CLURL="$RSS_CLURL" - DESCRIPTION="$RSS_DESCRIPTION" - FEEDMAX=$RSS_FEEDMAX - UUID="$RSS_UUID" - - PUBDATE="" - LASTBUILDDATE=$(LC_ALL=C TZ=GMT date +"%a, %e %b %Y %H:%M:%S GMT") - # The 'date -R' RFC-2822 compliant string - # does not work for Thunderbird! - counter=0 - - # Parse the input file - cat ${INFILE} | while IFS= read cline ; do - if [ "$PUBDATE" == "" ]; then - # PUBDATE is empty, means we're reading the first line of input. - # The first line contains the most recent pubdate. - # For backward compatibility, if the file starts with - # "+--------------------------+" then we just skip that. - [ "$cline" == "+--------------------------+" ] && read cline - PUBDATE=$(LC_ALL=C TZ=GMT date +"%a, %e %b %Y %H:%M:%S GMT" -d "$cline") - rm -f ${RSSFILE} - cat <<-_EOT_ > ${RSSFILE} - - - - ${TITLE} - ${LINK} - - ${TITLE} - ${ICON} - ${LINK} - - ${DESCRIPTION} - en-us - urn:uuid:${UUID} - ${PUBDATE} - ${LASTBUILDDATE} - ${BASENAME} v ${REV} - - ${PUBDATE} - ${CLURL} - ${PUBDATE} - $(LC_ALL=C date -d "${PUBDATE}" +%Y%m%d%H%M%S) - - - _EOT_ - elif [ "$cline" == "+--------------------------+" ]; then - # This line masrks the start of a new entry. - # Only dump a certain amount of recent entries. - [ $counter -gt $FEEDMAX ] && break - - # Close the previous entry: - cat <<-_EOT_ >> ${RSSFILE} - ]]> - - - _EOT_ - - # Next line is the pubdate for the next entry: - read PUBDATE - PUBDATE=$(LC_ALL=C TZ=GMT date +"%a, %e %b %Y %H:%M:%S GMT" -d "$PUBDATE") - - # Write the header for the next entry: - cat <<-_EOT_ >> ${RSSFILE} - - ${PUBDATE} - ${CLURL} - ${PUBDATE} - $(LC_ALL=C date -d "${PUBDATE}" +%Y%m%d%H%M%S) - - - _EOT_ - - counter=$(( ${counter}+1 )) - else - # Add a line of description - [ "${cline}" != "" ] && echo "${cline}" >> ${RSSFILE} - fi - done - - # Close the last entry: - cat <<-_EOT_ >> ${RSSFILE} - ]]> - - - _EOT_ - - # Close the XML output: - cat <<-_EOT_ >> ${RSSFILE} - - - _EOT_ -} - -# -# run_repo -# -run_repo() { - # Run through a repository tree, generating the repo meta files. - - # Change directory to the root of the repository, so all generated - # information is relative to here: - local RDIR=$1 - - cd $RDIR - - # Create temporary MANIFEST and PACKAGES.TXT files: - cat /dev/null > .MANIFEST - cat /dev/null > .PACKAGES.TXT - - # This tries to look for filenames with the Slackware package name format: - if [ $FOLLOW_SYMLINKS -eq 1 ]; then - PKGS=$( find -L . -type f -name '*-*-*-*.t[blxg]z' -print $PRUNES | sort ) - else - PKGS=$( find . -type f -name '*-*-*-*.t[blxg]z' -print $PRUNES | sort ) - fi - for pkg in $PKGS; do - # Found a filename with matching format, is it really a slackpack? - COMPEXE=$( pkgcomp $pkg ) - if $COMPEXE -cd $pkg | tar tOf - install/slack-desc 1>/dev/null 2>&1 ; then - [ $DEBUG -eq 1 ] && echo "+++ Found package $pkg" - # We need to run addpkg for every package, to populate PACKAGES.TXT: - addpkg $pkg ${RDIR}/.PACKAGES.TXT - - # We need to run addman for every package, to populate MANIFEST - addman $pkg ${RDIR}/.MANIFEST - - if [ "x$NOTOLDER" != "x" ]; then - # When to generate md5sum/gpg signature if we have a $NOTOLDER value: - # 'date +%s' gives the current time in seconds since the Epoch; - # 'stat -c %Z $pkg' gives the ctime of $pkg file in seconds since Epoch; - # The difference of these two divided by 3600 is the file age in hours. - # '24 * $NOTOLDER' gives the maximum allowed age of the file in hours. - # If the package is too old, we do not try to create md5sum/gpg sig. - if [ $(( ( $(LC_ALL=C date +%s) - $(stat -c %Z $pkg) ) / 3600 )) -lt $(( 24 * $NOTOLDER )) ]; then - [ "$USEGPG" == "yes" ] && genasc $pkg - genmd5 $pkg - else - [ $DEBUG -eq 1 ] && echo " - Skipping md5/gpg calculation for $(basename $pkg)" - fi - else - [ "$USEGPG" == "yes" ] && genasc $pkg - genmd5 $pkg - fi - else - echo "*** Warning: $pkg does not contain a slack-desc file. ***" - fi - done - - # Make the changes visible: - rm -f PACKAGES.TXT - echo "PACKAGES.TXT; $UPDATEDATE" > PACKAGES.TXT - echo "" >> PACKAGES.TXT - if [ -n "$DL_URL" ]; then - cat .PACKAGES.TXT >> PACKAGES.TXT - else - cat .PACKAGES.TXT | grep -v "PACKAGE MIRROR: " >> PACKAGES.TXT - fi - rm -f .PACKAGES.TXT - rm -f MANIFEST - cat .MANIFEST > MANIFEST - rm -f .MANIFEST - - rm -f PACKAGES.TXT.gz MANIFEST.bz2 - bzip2 -9f MANIFEST - gzip -9cf PACKAGES.TXT > PACKAGES.TXT.gz - if [ "${CHANGELOG}" == "yes" -a -f ChangeLog.txt ]; then - rm -f ChangeLog.txt.gz - gzip -9cf ChangeLog.txt > ChangeLog.txt.gz - fi - -} # End run_repo() - - -# -# gen_checksums -# -gen_checksums() { - # Run through a repository tree, generating the checksum files. - - # Change directory to the root of the repository, so all generated - # information is relative to here: - local RDIR=$1 - - cd $RDIR - - # Create temporary CHECKSUMS.md5 file: - cat /dev/null > .CHECKSUMS.md5 - - # Generate the overall CHECKSUMS.md5 for this (sub-)repo: - cat << EOF > .CHECKSUMS.md5 -These are the MD5 message digests for the files in this directory. -If you want to test your files, use 'md5sum' and compare the values to -the ones listed here. - -To test all these files, use this command: - -tail +13 CHECKSUMS.md5 | md5sum --check | less - -'md5sum' can be found in the GNU coreutils package on ftp.gnu.org in -/pub/gnu, or at any GNU mirror site. - -MD5 message digest Filename -EOF - if [ $FOLLOW_SYMLINKS -eq 1 ]; then - find -L . -type f -print $PRUNES | grep -v CHECKSUMS | sort | xargs md5sum $1 2>/dev/null >> .CHECKSUMS.md5 - else - find . -type f -print $PRUNES | grep -v CHECKSUMS | sort | xargs md5sum $1 2>/dev/null >> .CHECKSUMS.md5 - fi - rm -f CHECKSUMS.md5 CHECKSUMS.md5.gz - cat .CHECKSUMS.md5 > CHECKSUMS.md5 - gzip -9cf CHECKSUMS.md5 > CHECKSUMS.md5.gz - - rm -f .CHECKSUMS.md5 CHECKSUMS.md5.asc CHECKSUMS.md5.gz.asc - - if [ "$USEGPG" == "yes" ]; then - # The CHECKSUMS.md5* files need a gpg signature: - gpg_sign CHECKSUMS.md5 - gpg_sign CHECKSUMS.md5.gz - fi - -} # End gen_checksums() - - -# -# --- MAIN ------------------------------------------------------------------ -# - -# Abort if we need to create the RSS file and RSS_UUID is empty: -if [ -z "${RSS_UUID}" -a "${CHANGELOG}" = "yes" ]; then - echo "**" - echo "** Please supply a value for the Universally Unique IDentifier (UUID) !" - echo "** Look for the RSS_UUID variable inside the script or in '$USERDEFS'," - echo "** and (for instance) use the return value from command 'uuidgen -t'." - echo "**" - exit 1 -fi - -echo "--- Generating repository metadata for $REPOSROOT ---" -echo "--- Repository owner is $REPOSOWNER ---" -echo "" - -# If the GPG key contains a different identification string than the name -# you want to use for the repository owner, set the REPOSOWNERGPG variable. -# If $REPOSOWNERGPG has an empty value we will use the value of $REPOSOWNER -# to search the GPG keyring. -if [ "x${REPOSOWNERGPG}" == "x" ]; then - REPOSOWNERGPG="${REPOSOWNER}" -fi - -# We will test correctness of the GPG passphrase against a temp file: -TESTTMP=$(mktemp) - -if [ "${CHANGELOG}" == "yes" ]; then - # Update ChangeLog.txt with a new entry - upd_changelog $REPOSROOT - # Write a RSS file for the ChangeLog.txt - rss_changelog $REPOSROOT -fi - -# If we only want to update the ChangeLog files, then we skip a lot: -if [ "$RSSONLY" = "yes" ]; then - echo "--- Exiting after re-generation of ChangeLog files (requested). ---" - echo "" -else - # Only generate GPG signatures if we have a GPG key - if ! $GPGBIN --list-secret-keys "$REPOSOWNERGPG" >/dev/null 2>&1 ; then - USEGPG="no" - echo "The GPG private key for \"$REPOSOWNERGPG\" wasn't found!" - echo "*** packages will not be signed! ***" - read -er -p "Continue? [y|N] " - [ "${REPLY:0:1}" = "y" -o "${REPLY:0:1}" = "Y" ] || exit 1 - else - USEGPG="yes" - if [ $USE_GPGAGENT -eq 0 ]; then - read -ers -p "Enter your GPG passphrase: " - TRASK=$REPLY - echo "." - if [ "$REPLY" == "" ]; then - echo "Empty GPG passphrase - disabling generation of signatures." - USEGPG="no" - fi - fi - fi - - if [ "$USEGPG" == "yes" ]; then - gpg_sign $TESTTMP 2>/dev/null - if [ $? -ne 0 ]; then - echo "GPG test failed, incorrect GPG passphrase? Aborting the script." - rm -f $TESTTMP - exit 1 - else - # Use the key fingerprint to determine whether GPG-KEY is outdated: - GPG_FPR=$($GPGBIN --with-colon --with-fingerprint --list-keys "$REPOSOWNERGPG" |grep ^fpr |cut -d: -f10) - if [ -r ${REPOSROOT}/GPG-KEY ]; then - # If the GPG-KEY file is outdated (user may have a new key), - # then we delete this file and re-generate it in the next step: - if ! grep -q $GPG_FPR ${REPOSROOT}/GPG-KEY ; then - rm -f ${REPOSROOT}/GPG-KEY - fi - fi - if [ ! -r ${REPOSROOT}/GPG-KEY ]; then - echo "Generating a "GPG-KEY" file in '$REPOSROOT'," - echo " containing the public key information for '$REPOSOWNERGPG'..." - $GPGBIN --list-keys "$REPOSOWNERGPG" > ${REPOSROOT}/GPG-KEY - echo "Key fingerprint: $GPG_FPR" >> ${REPOSROOT}/GPG-KEY - $GPGBIN -a --export "$REPOSOWNERGPG" >> ${REPOSROOT}/GPG-KEY - chmod 444 ${REPOSROOT}/GPG-KEY - fi - if [ -n "$REPO_SUBDIRS" ]; then - for SUBDIR in $REPO_SUBDIRS ; do - if [ -r ${REPOSROOT}}/${SUBDIR}/GPG-KEY ]; then - # If the GPG-KEY file is outdated (user may have a new key), - # then we delete this file and re-generate it in the next step: - if ! grep -q $GPG_FPR ${REPOSROOT}}/${SUBDIR}/GPG-KEY ; then - rm -f ${REPOSROOT}}/${SUBDIR}/GPG-KEY - fi - fi - if [ ! -r ${REPOSROOT}/${SUBDIR}/GPG-KEY ]; then - echo "Generating a "GPG-KEY" file in '$REPOSROOT/$SUBDIR'," - echo " containing the public key information for '$REPOSOWNERGPG'." - $GPGBIN --list-keys "$REPOSOWNERGPG" > $REPOSROOT/$SUBDIR/GPG-KEY - echo "Key fingerprint: $GPG_FPR" >> $REPOSROOT/$SUBDIR/GPG-KEY - $GPGBIN -a --export "$REPOSOWNERGPG" >> $REPOSROOT/$SUBDIR/GPG-KEY - chmod 444 ${REPOSROOT}/${SUBDIR}/GPG-KEY - fi - done - fi - fi - fi - - # Run through the repository, generating the MANIFEST etc: - if [ -n "$REPO_SUBDIRS" ]; then - echo "--- Populating repo subdirectories '${REPO_SUBDIRS}' ---" - for SUBDIR in $REPO_SUBDIRS ; do - run_repo $REPOSROOT/$SUBDIR - gen_filelist ${REPOSROOT}/$SUBDIR - gen_checksums ${REPOSROOT}/$SUBDIR - done - fi - run_repo $REPOSROOT - -fi # end !RSSONLY - -# Finally, generate the FILELIST.TXT and CHECKSUMS.md5* for the whole repo: -gen_filelist ${REPOSROOT} -gen_checksums ${REPOSROOT} - -# Clean up: -TRASK="" -rm -f ${TESTTMP}* - -# Done.