From cda21df13882b69d012373d56b09855be2e36802 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 13:57:56 +1000 Subject: [PATCH 01/11] DCD-386: Initial test of pipenv. --- Pipfile | 12 +++ Pipfile.lock | 213 +++++++++++++++++++++++++++++++++++++++ bin/ansible-with-atl-env | 6 +- bin/install-ansible | 8 +- bin/run-all-tests | 7 +- requirements.txt | 3 - 6 files changed, 231 insertions(+), 18 deletions(-) create mode 100644 Pipfile create mode 100644 Pipfile.lock delete mode 100644 requirements.txt diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..93032e7 --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.python.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +ansible = "==2.7.11" + +[dev-packages] + +[requires] +python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..66cb399 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,213 @@ +{ + "_meta": { + "hash": { + "sha256": "0eaff090d43a4d334b1ab4c48ce6e76f16be0e33cda3ea6abd38c2232f4f940c" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.7" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "ansible": { + "hashes": [ + "sha256:e7e6de461b7d07cb4d8b2dd2a32b231af7c56e6bf39b851024671aaa52fd377e" + ], + "index": "pypi", + "version": "==2.7.11" + }, + "asn1crypto": { + "hashes": [ + "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87", + "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49" + ], + "version": "==0.24.0" + }, + "bcrypt": { + "hashes": [ + "sha256:0ba875eb67b011add6d8c5b76afbd92166e98b1f1efab9433d5dc0fafc76e203", + "sha256:21ed446054c93e209434148ef0b362432bb82bbdaf7beef70a32c221f3e33d1c", + "sha256:28a0459381a8021f57230954b9e9a65bb5e3d569d2c253c5cac6cb181d71cf23", + "sha256:2aed3091eb6f51c26b7c2fad08d6620d1c35839e7a362f706015b41bd991125e", + "sha256:2fa5d1e438958ea90eaedbf8082c2ceb1a684b4f6c75a3800c6ec1e18ebef96f", + "sha256:3a73f45484e9874252002793518da060fb11eaa76c30713faa12115db17d1430", + "sha256:3e489787638a36bb466cd66780e15715494b6d6905ffdbaede94440d6d8e7dba", + "sha256:44636759d222baa62806bbceb20e96f75a015a6381690d1bc2eda91c01ec02ea", + "sha256:678c21b2fecaa72a1eded0cf12351b153615520637efcadc09ecf81b871f1596", + "sha256:75460c2c3786977ea9768d6c9d8957ba31b5fbeb0aae67a5c0e96aab4155f18c", + "sha256:8ac06fb3e6aacb0a95b56eba735c0b64df49651c6ceb1ad1cf01ba75070d567f", + "sha256:8fdced50a8b646fff8fa0e4b1c5fd940ecc844b43d1da5a980cb07f2d1b1132f", + "sha256:9b2c5b640a2da533b0ab5f148d87fb9989bf9bcb2e61eea6a729102a6d36aef9", + "sha256:a9083e7fa9adb1a4de5ac15f9097eb15b04e2c8f97618f1b881af40abce382e1", + "sha256:b7e3948b8b1a81c5a99d41da5fb2dc03ddb93b5f96fcd3fd27e643f91efa33e1", + "sha256:b998b8ca979d906085f6a5d84f7b5459e5e94a13fc27c28a3514437013b6c2f6", + "sha256:dd08c50bc6f7be69cd7ba0769acca28c846ec46b7a8ddc2acf4b9ac6f8a7457e", + "sha256:de5badee458544ab8125e63e39afeedfcf3aef6a6e2282ac159c95ae7472d773", + "sha256:ede2a87333d24f55a4a7338a6ccdccf3eaa9bed081d1737e0db4dbd1a4f7e6b6" + ], + "version": "==3.1.6" + }, + "cffi": { + "hashes": [ + "sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774", + "sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d", + "sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90", + "sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b", + "sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63", + "sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45", + "sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25", + "sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3", + "sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b", + "sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647", + "sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016", + "sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4", + "sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb", + "sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753", + "sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7", + "sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9", + "sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f", + "sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8", + "sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f", + "sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc", + "sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42", + "sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3", + "sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909", + "sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45", + "sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d", + "sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512", + "sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff", + "sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201" + ], + "version": "==1.12.3" + }, + "cryptography": { + "hashes": [ + "sha256:24b61e5fcb506424d3ec4e18bca995833839bf13c59fc43e530e488f28d46b8c", + "sha256:25dd1581a183e9e7a806fe0543f485103232f940fcfc301db65e630512cce643", + "sha256:3452bba7c21c69f2df772762be0066c7ed5dc65df494a1d53a58b683a83e1216", + "sha256:41a0be220dd1ed9e998f5891948306eb8c812b512dc398e5a01846d855050799", + "sha256:5751d8a11b956fbfa314f6553d186b94aa70fdb03d8a4d4f1c82dcacf0cbe28a", + "sha256:5f61c7d749048fa6e3322258b4263463bfccefecb0dd731b6561cb617a1d9bb9", + "sha256:72e24c521fa2106f19623a3851e9f89ddfdeb9ac63871c7643790f872a305dfc", + "sha256:7b97ae6ef5cba2e3bb14256625423413d5ce8d1abb91d4f29b6d1a081da765f8", + "sha256:961e886d8a3590fd2c723cf07be14e2a91cf53c25f02435c04d39e90780e3b53", + "sha256:96d8473848e984184b6728e2c9d391482008646276c3ff084a1bd89e15ff53a1", + "sha256:ae536da50c7ad1e002c3eee101871d93abdc90d9c5f651818450a0d3af718609", + "sha256:b0db0cecf396033abb4a93c95d1602f268b3a68bb0a9cc06a7cff587bb9a7292", + "sha256:cfee9164954c186b191b91d4193989ca994703b2fff406f71cf454a2d3c7327e", + "sha256:e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6", + "sha256:f27d93f0139a3c056172ebb5d4f9056e770fdf0206c2f422ff2ebbad142e09ed", + "sha256:f57b76e46a58b63d1c6375017f4564a28f19a5ca912691fd2e4261b3414b618d" + ], + "version": "==2.7" + }, + "jinja2": { + "hashes": [ + "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", + "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" + ], + "version": "==2.10.1" + }, + "markupsafe": { + "hashes": [ + "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", + "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", + "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", + "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", + "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", + "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", + "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", + "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", + "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", + "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", + "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", + "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", + "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", + "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", + "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", + "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", + "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", + "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", + "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", + "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", + "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", + "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", + "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", + "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", + "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", + "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", + "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", + "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" + ], + "version": "==1.1.1" + }, + "paramiko": { + "hashes": [ + "sha256:69c219df239775800a2589ee60159aa7cfd87175809b6557da7fb9dcb44ca430", + "sha256:9f081281064b5180dc0ef60e256224a280ff16f603a99f3dd4ba6334ebb65f7e" + ], + "version": "==2.5.0" + }, + "pycparser": { + "hashes": [ + "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" + ], + "version": "==2.19" + }, + "pynacl": { + "hashes": [ + "sha256:05c26f93964373fc0abe332676cb6735f0ecad27711035b9472751faa8521255", + "sha256:0c6100edd16fefd1557da078c7a31e7b7d7a52ce39fdca2bec29d4f7b6e7600c", + "sha256:0d0a8171a68edf51add1e73d2159c4bc19fc0718e79dec51166e940856c2f28e", + "sha256:1c780712b206317a746ace34c209b8c29dbfd841dfbc02aa27f2084dd3db77ae", + "sha256:2424c8b9f41aa65bbdbd7a64e73a7450ebb4aa9ddedc6a081e7afcc4c97f7621", + "sha256:2d23c04e8d709444220557ae48ed01f3f1086439f12dbf11976e849a4926db56", + "sha256:30f36a9c70450c7878053fa1344aca0145fd47d845270b43a7ee9192a051bf39", + "sha256:37aa336a317209f1bb099ad177fef0da45be36a2aa664507c5d72015f956c310", + "sha256:4943decfc5b905748f0756fdd99d4f9498d7064815c4cf3643820c9028b711d1", + "sha256:57ef38a65056e7800859e5ba9e6091053cd06e1038983016effaffe0efcd594a", + "sha256:5bd61e9b44c543016ce1f6aef48606280e45f892a928ca7068fba30021e9b786", + "sha256:6482d3017a0c0327a49dddc8bd1074cc730d45db2ccb09c3bac1f8f32d1eb61b", + "sha256:7d3ce02c0784b7cbcc771a2da6ea51f87e8716004512493a2b69016326301c3b", + "sha256:a14e499c0f5955dcc3991f785f3f8e2130ed504fa3a7f44009ff458ad6bdd17f", + "sha256:a39f54ccbcd2757d1d63b0ec00a00980c0b382c62865b61a505163943624ab20", + "sha256:aabb0c5232910a20eec8563503c153a8e78bbf5459490c49ab31f6adf3f3a415", + "sha256:bd4ecb473a96ad0f90c20acba4f0bf0df91a4e03a1f4dd6a4bdc9ca75aa3a715", + "sha256:e2da3c13307eac601f3de04887624939aca8ee3c9488a0bb0eca4fb9401fc6b1", + "sha256:f67814c38162f4deb31f68d590771a29d5ae3b1bd64b75cf232308e5c74777e0" + ], + "version": "==1.3.0" + }, + "pyyaml": { + "hashes": [ + "sha256:57acc1d8533cbe51f6662a55434f0dbecfa2b9eaf115bede8f6fd00115a0c0d3", + "sha256:588c94b3d16b76cfed8e0be54932e5729cc185caffaa5a451e7ad2f7ed8b4043", + "sha256:68c8dd247f29f9a0d09375c9c6b8fdc64b60810ebf07ba4cdd64ceee3a58c7b7", + "sha256:70d9818f1c9cd5c48bb87804f2efc8692f1023dac7f1a1a5c61d454043c1d265", + "sha256:86a93cccd50f8c125286e637328ff4eef108400dd7089b46a7be3445eecfa391", + "sha256:a0f329125a926876f647c9fa0ef32801587a12328b4a3c741270464e3e4fa778", + "sha256:a3c252ab0fa1bb0d5a3f6449a4826732f3eb6c0270925548cac342bc9b22c225", + "sha256:b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955", + "sha256:cd0618c5ba5bda5f4039b9398bb7fb6a317bb8298218c3de25c47c4740e4b95e", + "sha256:ceacb9e5f8474dcf45b940578591c7f3d960e82f926c707788a570b51ba59190", + "sha256:fe6a88094b64132c4bb3b631412e90032e8cfe9745a58370462240b8cb7553cd" + ], + "version": "==5.1.1" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + } + }, + "develop": {} +} diff --git a/bin/ansible-with-atl-env b/bin/ansible-with-atl-env index c58cd46..43712f5 100755 --- a/bin/ansible-with-atl-env +++ b/bin/ansible-with-atl-env @@ -14,8 +14,4 @@ source $ENV_FILE set +a # Use Ansible from virtualenv if provided -if [[ -f .venv/bin/ansible ]]; then - source .venv/bin/activate -fi - -ansible-playbook -v -i $INV $PLAYBOOK 2>&1 | tee --append $LOG_FILE +pipenv run ansible-playbook -v -i $INV $PLAYBOOK 2>&1 | tee --append $LOG_FILE diff --git a/bin/install-ansible b/bin/install-ansible index b1d60a2..51d504d 100755 --- a/bin/install-ansible +++ b/bin/install-ansible @@ -5,8 +5,6 @@ set -e # The Amazon Linux 2 Ansible package is 2.4, which has issue # interacting with RDS, so use the PIP version. -virtualenv --system-site-packages .venv -source .venv/bin/activate -pip install -U setuptools -pip install ansible==2.7.10 -pip list --format columns +pip install pipenv +pipenv install + diff --git a/bin/run-all-tests b/bin/run-all-tests index 7489276..0967276 100755 --- a/bin/run-all-tests +++ b/bin/run-all-tests @@ -3,13 +3,10 @@ set -e # Use Ansible from virtualenv if provided -if [[ -f .venv/bin/ansible ]]; then - source .venv/bin/activate - pip install molecule docker six -fi +pipenv install molecule docker six for role in `find roles/ -name molecule | sort`; do pushd `dirname $role` - molecule test --all + pipenv run molecule test --all popd done diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9572a3d..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -ansible==2.7.10 -molecule==2.20.1 -docker==4.0.1 \ No newline at end of file From 65dea20e787d79937d5fabf2faabf8b87f92baa0 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 13:59:24 +1000 Subject: [PATCH 02/11] DCD-386: Lock to 2.7 --- Pipfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 93032e7..8139b62 100644 --- a/Pipfile +++ b/Pipfile @@ -9,4 +9,4 @@ ansible = "==2.7.11" [dev-packages] [requires] -python_version = "3.7" +python_version = "2.7" From 5716f863d17a6e514e121f6a1435f4876339ed52 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 15:06:29 +1000 Subject: [PATCH 03/11] DCD-386: Use pacapt to install pip from the system. --- bin/install-ansible | 9 +- bin/pacapt | 2561 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2568 insertions(+), 2 deletions(-) create mode 100755 bin/pacapt diff --git a/bin/install-ansible b/bin/install-ansible index 51d504d..c76fc9f 100755 --- a/bin/install-ansible +++ b/bin/install-ansible @@ -3,8 +3,13 @@ set -e # The Amazon Linux 2 Ansible package is 2.4, which has issue -# interacting with RDS, so use the PIP version. +# interacting with RDS, so use pipenv to install a known-good version. + +# Luckily AmzLnx2 and Ubuntu use the same package name. This may need +# some logic if other distros are added. Note: Parsing /etc/os-release +# is probably a good starting point for that. +./bin/pacapt install python-pip pip install pipenv -pipenv install +pipenv install diff --git a/bin/pacapt b/bin/pacapt new file mode 100755 index 0000000..bf1b711 --- /dev/null +++ b/bin/pacapt @@ -0,0 +1,2561 @@ +#!/usr/bin/env bash +# +# Purpose: A wrapper for all Unix package managers +# License: Fair license (http://www.opensource.org/licenses/fair) +# Source : http://github.com/icy/pacapt/ +# Version: 2.4.2 +# Authors: Anh K. Huynh et al. + +# Copyright (C) 2010 - 2019 \ +# | 10sr (10sr) +# | Alexander Dupuy (dupuy) +# | Anh K. Huynh (icy) +# | Antony Lee (anntzer) +# | Alex Lyon (Arcterus) +# | Carl X. Su (bcbcarl) +# | Cuong Manh Le (Gnouc) +# | Daniel YC Lin (dlintw) +# | Danny George (dangets) +# | Darshit Shah (darnir) +# | Dmitry Kudriavtsev (dkudriavtsev) +# | Eric Crosson (EricCrosson) +# | Evan Relf (evanrelf) +# | GijsTimmers (GijsTimmers) +# | Hà-Dương Nguyễn (cmpitg) +# | Huy Ngô (NgoHuy) +# | James Pearson (xiongchiamiov) +# | Janne Heß (dasJ) +# | Jiawei Zhou (4679) +# | Karol Blazewicz +# | Kevin Brubeck (unhammer) +# | Konrad Borowski (xfix) +# | Kylie McClain (somasis) +# | Valerio Pizzi (Pival81) +# | Siôn Le Roux (sinisterstuf) +# | Thiago Perrotta (thiagowfx) +# | Vojtech Letal (letalvoj) +# +# Usage of the works is permitted provided that this instrument is +# retained with the works, so that any entity that uses the works is +# notified of this instrument. +# +# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. +# + +_print_pacapt_version() { + cat <<_EOF_ +pacapt version '2.4.2' + +Copyright (C) 2010 - 2019 \\ + | 10sr (10sr) + | Alexander Dupuy (dupuy) + | Anh K. Huynh (icy) + | Antony Lee (anntzer) + | Alex Lyon (Arcterus) + | Carl X. Su (bcbcarl) + | Cuong Manh Le (Gnouc) + | Daniel YC Lin (dlintw) + | Danny George (dangets) + | Darshit Shah (darnir) + | Dmitry Kudriavtsev (dkudriavtsev) + | Eric Crosson (EricCrosson) + | Evan Relf (evanrelf) + | GijsTimmers (GijsTimmers) + | Hà-Dương Nguyễn (cmpitg) + | Huy Ngô (NgoHuy) + | James Pearson (xiongchiamiov) + | Janne Heß (dasJ) + | Jiawei Zhou (4679) + | Karol Blazewicz + | Kevin Brubeck (unhammer) + | Konrad Borowski (xfix) + | Kylie McClain (somasis) + | Valerio Pizzi (Pival81) + | Siôn Le Roux (sinisterstuf) + | Thiago Perrotta (thiagowfx) + | Vojtech Letal (letalvoj) + +Usage of the works is permitted provided that this +instrument is retained with the works, so that any +entity that uses the works is notified of this instrument. + +DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. +_EOF_ +} + +export PACAPT_VERSION='2.4.2' + +_help() { + cat <<'EOF' +NAME + pacapt - An `ArchLinux`'s pacman-like wrapper for many package managers. + +SYNTAX + + $ pacapt + +BASIC OPTIONS + + -h or --help print this help message + -P print supported operations + -V print version information + +SYSGET STYLE OPERATIONS + + update Update package database + upgrade Upgrade system + install Install some packages + search Search some package + remove Remove some packages + autoremove Remove orphans (WIP; may not work correctly) + clean Clean package manager caches + +PACMAN STYLE OPERATIONS + + Query + -Q list all installed packages + -Qc show package's changelog + -Qe [] only list explicitly installed packages + -Qi print package status + -Ql list package's files + -Qm list installed packages that aren't available + in any installation source + -Qo query package that provides + -Qp query a package file (don't use package database) + -Qs search for installed package + + Synchronize + -S install package(s) + -Sg list groups + -Sg list packages in group + -Ss search for packages + -Su upgrade the system + -Sy update package database + -Suy update package database, then upgrade the system + + Remove / Clean up + -R remove some packages + -Sc delete old downloaded packages + -Scc delete all downloaded packages + -Sccc clean variant files. + (debian) See also http://dragula.viettug.org/blogs/646 + + Upgrade + -U upgrade or add package from local file path (or remote uri) + +OPTIONS + + -w download packages but don't install them + --noconfirm don't wait for user's confirmation + +EXAMPLES + + 1. To install a package from Debian's backports repository + $ pacapt -S foobar -t lenny-backports + $ pacapt -S -- -t lenny-backports foobar + + 2. To update package database and then update your system + $ pacapt -Syu + + 3. To download a package without installing it + $ pacapt -Sw foobar + + +ENVIRONMENT + + PACAPT_DEBUG + + This is useful for debugging purpose. The variable can be set to `auto` + or any valid packager. For example, on `Debian` system the two following + commands are the same and they will print out what the script would do: + + PACAPT_DEBUG=auto pacman -Su + PACAPT_DEBUG=dpkg pacman -Su + +NOTES + + When being executed on Arch-based system, the tool simply invokes + the system package manager (`/usr/bin/pacman`). + + Though you can specify option by its own word, for example, + $ pacapt -S -y -u + + it's always the best to combine them + $ pacapt -Syu + +READMORE + + Please visit https://github.com/icy/pacapt. +EOF + +} + + + + +_error() { + echo >&2 "Error: $*" + return 1 +} + +_warn() { + echo >&2 "Warning: $*" + return 0 +} + +_die() { + echo >&2 "$@" + exit 1 +} + +_not_implemented() { + # shellcheck disable=2153 + echo >&2 "${_PACMAN}: '${_POPT}:${_SOPT}:${_TOPT}' operation is invalid or not implemented." + return 1 +} + +_removing_is_dangerous() { + echo >&2 "${_PACMAN}: removing with '$*' is too dangerous" + return 1 +} + +_issue2pacman() { + local _pacman + + _pacman="$1"; shift + + # The following line is added by Daniel YC Lin to support SunOS. + # + # [ `uname` = "$1" ] && _PACMAN="$_pacman" && return + # + # This is quite tricky and fast, however I don't think it works + # on Linux/BSD systems. To avoid extra check, I slightly modify + # the code to make sure it's only applicable on SunOS. + # + [[ "$(uname)" == "SunOS" ]] && _PACMAN="$_pacman" && return + + $GREP -qis "$@" /etc/issue \ + && _PACMAN="$_pacman" && return + + $GREP -qis "$@" /etc/os-release \ + && _PACMAN="$_pacman" && return +} + +_PACMAN_detect() { + _PACMAN_found_from_script_name && return + + _issue2pacman sun_tools "SunOS" && return + _issue2pacman pacman "Arch Linux" && return + _issue2pacman dpkg "Debian GNU/Linux" && return + _issue2pacman dpkg "Ubuntu" && return + _issue2pacman cave "Exherbo Linux" && return + _issue2pacman yum "CentOS" && return + _issue2pacman yum "Red Hat" && return + # + # FIXME: The multiple package issue. + # + # On #63, Huy commented out this line. This is because new generation + # of Fedora uses `dnf`, and `yum` becomes a legacy tool. On old Fedora + # system, `yum` is still detectable by looking up `yum` binary. + # + # I'm not sure how to support this case easily. Let's wait, e.g, 5 years + # from now to make `dnf` becomes a default? Oh no! + # + # And here why `pacman` is still smart. Debian has a set of tools. + # Fedora has `yum` (and a set of add-ons). Now Fedora moves to `dnf`. + # This means that a package manager is not a heart of a system ;) + # + # _issue2pacman yum "Fedora" && return + _issue2pacman zypper "SUSE" && return + _issue2pacman pkg_tools "OpenBSD" && return + _issue2pacman pkg_tools "Bitrig" && return + _issue2pacman apk "Alpine Linux" && return + + [[ -z "$_PACMAN" ]] || return + + # Prevent a loop when this script is installed on non-standard system + if [[ -x "/usr/bin/pacman" ]]; then + $GREP -q "${FUNCNAME[0]}" '/usr/bin/pacman' >/dev/null 2>&1 + [[ $? -ge 1 ]] && _PACMAN="pacman" \ + && return + fi + + [[ -x "/usr/bin/apt-get" ]] && _PACMAN="dpkg" && return + [[ -x "/data/data/com.termux/files/usr/bin/apt-get" ]] && _PACMAN="dpkg" && return + [[ -x "/usr/bin/cave" ]] && _PACMAN="cave" && return + [[ -x "/usr/bin/dnf" ]] && _PACMAN="dnf" && return + [[ -x "/usr/bin/yum" ]] && _PACMAN="yum" && return + [[ -x "/opt/local/bin/port" ]] && _PACMAN="macports" && return + [[ -x "/usr/bin/emerge" ]] && _PACMAN="portage" && return + [[ -x "/usr/bin/zypper" ]] && _PACMAN="zypper" && return + [[ -x "/usr/sbin/pkg" ]] && _PACMAN="pkgng" && return + # make sure pkg_add is after pkgng, FreeBSD base comes with it until converted + [[ -x "/usr/sbin/pkg_add" ]] && _PACMAN="pkg_tools" && return + [[ -x "/usr/sbin/pkgadd" ]] && _PACMAN="sun_tools" && return + [[ -x "/sbin/apk" ]] && _PACMAN="apk" && return + [[ -x "/usr/bin/tazpkg" ]] && _PACMAN="tazpkg" && return + [[ -x "/usr/bin/swupd" ]] && _PACMAN="swupd" && return + + command -v brew >/dev/null && _PACMAN="homebrew" && return + + return 1 +} + +_translate_w() { + + echo "$_EOPT" | $GREP -q ":w:" || return 0 + + local _opt= + local _ret=0 + + case "$_PACMAN" in + "dpkg") _opt="-d";; + "cave") _opt="-f";; + "macports") _opt="fetch";; + "portage") _opt="--fetchonly";; + "zypper") _opt="--download-only";; + "pkgng") _opt="fetch";; + "yum") _opt="--downloadonly"; + if ! rpm -q 'yum-downloadonly' >/dev/null 2>&1; then + _error "'yum-downloadonly' package is required when '-w' is used." + _ret=1 + fi + ;; + "tazpkg") + _error "$_PACMAN: Use '$_PACMAN get' to download and save packages to current directory." + _ret=1 + ;; + "apk") _opt="fetch";; + *) + _opt="" + _ret=1 + + _error "$_PACMAN: Option '-w' is not supported/implemented." + ;; + esac + + echo $_opt + return "$_ret" +} + +_translate_debug() { + echo "$_EOPT" | $GREP -q ":v:" || return 0 + + case "$_PACMAN" in + "tazpkg") + _error "$_PACMAN: Option '-v' (debug) is not supported/implemented by tazpkg" + return 1 + ;; + esac + + echo "-v" +} + +_translate_noconfirm() { + + echo "$_EOPT" | $GREP -q ":noconfirm:" || return 0 + + local _opt= + local _ret=0 + + case "$_PACMAN" in + # FIXME: Update environment DEBIAN_FRONTEND=noninteractive + # FIXME: There is also --force-yes for a stronger case + "dpkg") _opt="--yes";; + "dnf") _opt="--assumeyes";; + "yum") _opt="--assumeyes";; + # FIXME: pacman has 'assume-yes' and 'assume-no' + # FIXME: zypper has better mode. Similar to dpkg (Debian). + "zypper") _opt="--no-confirm";; + "pkgng") _opt="-y";; + "tazpkg") _opt="--auto";; + *) + _opt="" + _ret=1 + _error "$_PACMAN: Option '--noconfirm' is not supported/implemented." + ;; + esac + + echo $_opt + return $_ret +} + +_translate_all() { + local _args="" + local _debug= + local _noconfirm= + + _debug="$(_translate_debug)" + _noconfirm="$(_translate_noconfirm)" + _args="$(_translate_w)" || return 1 + _args="${_args}${_noconfirm:+ }${_noconfirm}" || return 1 + _args="${_args}${_debug:+ }${_debug}" || return 1 + + export _EOPT="${_args# }" +} + +_print_supported_operations() { + local _pacman="$1" + echo -n "pacapt($_pacman): available operations:" + # shellcheck disable=2016 + $GREP -E "^${_pacman}_[^ \\t]+\\(\\)" "$0" \ + | $AWK -F '(' '{print $1}' \ + | sed -e "s/${_pacman}_//g" \ + | while read -r O; do + echo -n " $O" + done + echo +} + + +export _SUPPORTED_EXTERNALS=" + :conda + :tlmgr + :texlive + :gem + :npm + :pip +" +readonly _SUPPORTED_EXTERNALS + +_PACMAN_found_from_script_name() { + local _tmp_name= + local _pacman= + + _tmp_name="${BASH_SOURCE[0]:-?}" + if [[ "$_tmp_name" == "?" ]]; then + _error "Unable to get script name." + return 1 + fi + + _tmp_name="${_tmp_name##*/}" # base name (remove everything before the last `/`) + _tmp_name="${_tmp_name%.*}" # remove extension if any (remove everything from the last `.`) + _pacman="${_tmp_name##*-}" # remove every thing before the last `-` + + if grep -Eq -e ":$_pacman[[:space:]]*" <<< "$_SUPPORTED_EXTERNALS"; then + export _PACMAN="$_pacman" + return 0 + else + export _PACMAN="" + return 1 + fi +} + + + +_apk_init() { + : +} + +apk_Q() { + if [[ -z "$_TOPT" ]]; then + apk info + else + _not_implemented + fi +} + +apk_Qi() { + apk info -a -- "$@" +} + +apk_Ql() { + apk info -L -- "$@" +} + +apk_Qo() { + apk info --who-owns -- "$@" +} + +apk_Qs() { + apk info -- "*${*}*" +} + +apk_Qu() { + apk version -l '<' +} + +apk_R() { + apk del -- "$@" +} + +apk_Rn() { + apk del --purge -- "$@" +} + +apk_Rns() { + apk del --purge -r -- "$@" +} + +apk_Rs() { + apk del -r -- "$@" +} + +apk_S() { + case ${_EOPT} in + # Download only + ("fetch") shift + apk fetch -- "$@" ;; + (*) apk add $_TOPT -- "$@" ;; + esac +} + +apk_Sc() { + apk cache -v clean +} + +apk_Scc() { + rm -rf /var/cache/apk/* +} + +apk_Sccc() { + apk_Scc +} + +apk_Si() { + apk_Qi "$@" +} + +apk_Sii() { + apk info -r -- "$@" +} + +apk_Sl() { + apk search -v -- "$@" +} + +apk_Ss() { + apk_Sl "$@" +} + +apk_Su() { + apk upgrade +} + +apk_Suy() { + if [ "$#" -gt 0 ]; then + apk add -U -u -- "$@" + else + apk upgrade -U -a + fi +} + +apk_Sy() { + apk update +} + +apk_Sw() { + apk fetch -- "$@" +} + +apk_U() { + apk add --allow-untrusted -- "$@" +} + + + +_cave_init() { + shopt -u globstar +} + +cave_Q() { + if [[ "$_TOPT" == "q" ]]; then + cave show -f "${@:-world}" \ + | grep -v '^$' + else + cave show -f "${@:-world}" + fi +} + +cave_Qi() { + cave show "$@" +} + +cave_Ql() { + if [[ -n "$*" ]]; then + cave contents "$@" + return + fi + + cave show -f "${@:-world}" \ + | grep -v '^$' \ + | while read -r _pkg; do + if [[ "$_TOPT" == "q" ]]; then + cave --color no contents "$_pkg" + else + cave contents "$_pkg" + fi + done +} + +cave_Qo() { + cave owner "$@" +} + +cave_Qp() { + _not_implemented +} + +cave_Qu() { + if [[ -z "$*" ]];then + cave resolve -c world \ + | grep '^u.*' \ + | while read -r _pkg; do + echo "$_pkg" | cut -d'u' -f2- + done + else + cave resolve -c world \ + | grep '^u.*' \ + | grep -- "$@" + fi +} + +cave_Qs() { + cave show -f world | grep -- "$@" +} + +cave_Rs() { + if [[ "$_TOPT" == "" ]]; then + cave uninstall -r "$@" \ + && echo "Control-C to stop uninstalling..." \ + && sleep 2s \ + && cave uninstall -xr "$@" + else + cave purge "$@" \ + && echo "Control-C to stop uninstalling (+ dependencies)..." \ + && sleep 2s \ + && cave purge -x "$@" + fi +} + +cave_Rn() { + _not_implemented +} + +cave_Rns() { + _not_implemented +} + +cave_R() { + cave uninstall "$@" \ + && echo "Control-C to stop uninstalling..." \ + && sleep 2s \ + && cave uninstall -x "$@" +} + +cave_Si() { + cave show "$@" +} + +cave_Suy() { + cave sync && cave resolve -c "${@:-world}" \ + && echo "Control-C to stop upgrading..." \ + && sleep 2s \ + && cave resolve -cx "${@:-world}" +} + +cave_Su() { + cave resolve -c "$@" \ + && echo "Control-C to stop upgrading..." \ + && sleep 2s \ + && cave resolve -cx "$@" +} + +cave_Sy() { + cave sync "$@" +} + +cave_Ss() { + cave search "$@" +} + +cave_Sc() { + cave fix-cache "$@" +} + +cave_Scc() { + cave fix-cache "$@" +} + +cave_Sccc() { + #rm -fv /var/cache/paludis/* + _not_implemented +} + +cave_S() { + cave resolve $_TOPT "$@" \ + && echo "Control-C to stop installing..." \ + && sleep 2s \ + && cave resolve -x $_TOPT "$@" +} + +cave_U() { + _not_implemented +} + + + +_conda_init() { + : +} + +conda_Q() { + if [[ $# -gt 0 ]]; then + conda list "$(python -c 'import sys; print("^" + "|".join(sys.argv[1:]) + "$")' "$@")" + else + conda list + fi +} + +conda_R() { + conda remove "$@" +} + +conda_S() { + conda install "$@" +} + +conda_Sc() { + conda clean --all "$@" +} + +conda_Si() { + conda search "$@" --info +} + +conda_Ss() { + conda search "*$@*" +} + +conda_Suy() { + conda update --all "$@" +} + + + + +_dnf_init() { + : +} + +dnf_S() { + dnf install $_TOPT "$@" +} + +dnf_Sc() { + dnf clean expire-cache "$@" +} + +dnf_Scc() { + dnf clean packages "$@" +} + +dnf_Sccc() { + dnf clean all "$@" +} + +dnf_Si() { + dnf info "$@" +} + +dnf_Sg() { + if [[ $# -gt 0 ]]; then + dnf group info "$@" + else + dnf group list + fi +} + +dnf_Sl() { + dnf list available "$@" +} + +dnf_Ss() { + dnf search "$@" +} + +dnf_Su() { + dnf upgrade "$@" +} + +dnf_Suy() { + dnf upgrade "$@" +} + +dnf_Sw() { + dnf download "$@" +} + +dnf_Sy() { + dnf clean expire-cache && dnf check-update +} + +dnf_Q() { + if [[ "$_TOPT" == "q" ]]; then + rpm -qa --qf "%{NAME}\\n" + elif [[ "$_TOPT" == "" ]]; then + rpm -qa --qf "%{NAME} %{VERSION}\\n" + else + _not_implemented + fi +} + +dnf_Qc() { + rpm -q --changelog "$@" +} + +dnf_Qe() { + dnf repoquery --userinstalled "$@" +} + +dnf_Qi() { + dnf info "$@" +} + +dnf_Ql() { + rpm -ql "$@" +} + +dnf_Qm() { + dnf list extras +} + +dnf_Qo() { + rpm -qf "$@" +} + +dnf_Qp() { + rpm -qp "$@" +} + +dnf_Qs() { + rpm -qa "*${*}*" +} + +dnf_Qu() { + dnf list updates "$@" +} + +dnf_R() { + dnf remove "$@" +} + +dnf_U() { + dnf install "$@" +} + + + +_dpkg_init() { + : +} + +dpkg_Q() { + if [[ "$_TOPT" == "q" ]]; then + dpkg -l \ + | grep -E '^[hi]i' \ + | awk '{print $2}' + elif [[ "$_TOPT" == "" ]]; then + dpkg -l "$@" \ + | grep -E '^[hi]i' + else + _not_implemented + fi +} + +dpkg_Qi() { + dpkg-query -s "$@" +} + +dpkg_Ql() { + if [[ -n "$*" ]]; then + dpkg-query -L "$@" + return + fi + + dpkg -l \ + | grep -E '^[hi]i' \ + | awk '{print $2}' \ + | while read -r _pkg; do + if [[ "$_TOPT" == "q" ]]; then + dpkg-query -L "$_pkg" + else + dpkg-query -L "$_pkg" \ + | while read -r _line; do + echo "$_pkg $_line" + done + fi + done +} + +dpkg_Qo() { + dpkg-query -S "$@" +} + +dpkg_Qp() { + dpkg-deb -I "$@" +} + +dpkg_Qu() { + apt-get upgrade --trivial-only "$@" +} + +dpkg_Qs() { + # dpkg >= 1.16.2 dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\t${Version}\t${binary:Summary}\n' + dpkg-query -W -f='${Status} ${Package}\t${Version}\t${Description}\n' \ + | grep -E '^((hold)|(install)|(deinstall))' \ + | sed -r -e 's#^(\w+ ){3}##g' \ + | grep -Ei "${@:-.}" +} + +dpkg_Rs() { + if [[ "$_TOPT" == "" ]]; then + apt-get autoremove "$@" + else + _not_implemented + fi +} + +dpkg_Rn() { + apt-get purge "$@" +} + +dpkg_Rns() { + apt-get --purge autoremove "$@" +} + +dpkg_R() { + apt-get remove "$@" +} + +dpkg_Si() { + apt-cache show "$@" +} + +dpkg_Suy() { + apt-get update \ + && apt-get upgrade "$@" \ + && apt-get dist-upgrade "$@" +} + +dpkg_Su() { + apt-get upgrade "$@" \ + && apt-get dist-upgrade "$@" +} + + +dpkg_Sy() { + apt-get update "$@" +} + +dpkg_Ss() { + apt-cache search "$@" +} + +dpkg_Sc() { + apt-get clean "$@" +} + +dpkg_Scc() { + apt-get autoclean "$@" +} + +dpkg_S() { + apt-get install $_TOPT "$@" +} + +dpkg_U() { + dpkg -i "$@" +} + +dpkg_Sii() { + apt-cache rdepends "$@" +} + +dpkg_Sccc() { + rm -fv /var/cache/apt/*.bin + rm -fv /var/cache/apt/archives/*.* + rm -fv /var/lib/apt/lists/*.* + apt-get autoclean +} + + + +_homebrew_init() { + : +} + +homebrew_Qi() { + brew info "$@" +} + +homebrew_Ql() { + brew list "$@" +} + +homebrew_Qo() { + local pkg prefix cellar + + # FIXME: What happens if the file is not exectutable? + cd "$(dirname -- "$(which "$@")")" || return + pkg="$(pwd -P)/$(basename -- "$@")" + prefix="$(brew --prefix)" + cellar="$(brew --cellar)" + + for package in $cellar/*; do + files=(${package}/*/${pkg/#$prefix\//}) + if [[ -e "${files[${#files[@]} - 1]}" ]]; then + echo "${package/#$cellar\//}" + break + fi + done +} + +homebrew_Qc() { + brew log "$@" +} + +homebrew_Qu() { + brew outdated | grep "$@" +} + +homebrew_Qs() { + brew list | grep "$@" +} + +homebrew_Q() { + if [[ "$_TOPT" == "" ]]; then + if [[ "$*" == "" ]]; then + brew list + else + brew list | grep "$@" + fi + else + _not_implemented + fi +} + +homebrew_Rs() { + which join > /dev/null + if [ $? -ne 0 ]; then + _die "pacapt: join binary does not exist in system." + fi + + which sort > /dev/null + if [ $? -ne 0 ]; then + _die "pacapt: sort binary does not exist in system." + fi + + if [[ "$@" == "" ]]; then + _die "pacapt: ${FUNCNAME[0]} requires arguments" + fi + + for _target in $@; + do + brew rm $_target + + while [ "$(join <(sort <(brew leaves)) <(sort <(brew deps $_target)))" != "" ] + do + brew rm $(join <(sort <(brew leaves)) <(sort <(brew deps $_target))) + done + done + +} + +homebrew_R() { + brew remove "$@" +} + +homebrew_Si() { + brew info "$@" +} + +homebrew_Suy() { + brew update \ + && brew upgrade "$@" +} + +homebrew_Su() { + brew upgrade "$@" +} + +homebrew_Sy() { + brew update "$@" +} + +homebrew_Ss() { + brew search "$@" +} + +homebrew_Sc() { + brew cleanup "$@" +} + +homebrew_Scc() { + brew cleanup -s "$@" +} + +homebrew_Sccc() { + # See more discussion in + # https://github.com/icy/pacapt/issues/47 + + local _dcache + + _dcache="$(brew --cache)" + case "$_dcache" in + ""|"/"|" ") + _error "${FUNCNAME[0]}: Unable to delete '$_dcache'." + ;; + + *) + # FIXME: This is quite stupid!!! But it's an easy way + # FIXME: to avoid some warning from #shellcheck. + # FIXME: Please note that, $_dcache is not empty now. + rm -rf "${_dcache:-/x/x/x/x/x/x/x/x/x/x/x//x/x/x/x/x/}/" + ;; + esac +} + +homebrew_S() { + brew install $_TOPT "$@" +} + + + +_macports_init() { + : +} + +macports_Ql() { + port contents "$@" +} + +macports_Qo() { + port provides "$@" +} + +macports_Qc() { + port log "$@" +} + +macports_Qu() { + port outdated "$@" +} + +macports_Rs() { + if [[ "$_TOPT" == "" ]]; then + port uninstall --follow-dependencies "$@" + else + _not_implemented + fi +} + +macports_R() { + port uninstall "$@" +} + +macports_Si() { + port info "$@" +} + +macports_Suy() { + port selfupdate \ + && port upgrade outdated "$@" +} + +macports_Su() { + port upgrade outdate "$@" +} + +macports_Sy() { + port selfupdate "$@" +} + +macports_Ss() { + port search "$@" +} + +macports_Sc() { + port clean --all inactive "$@" +} + +macports_Scc() { + port clean --all installed "$@" +} + +macports_S() { + if [[ "$_TOPT" == "fetch" ]]; then + port patch "$@" + else + port install "$@" + fi +} + + + +_pkgng_init() { + : +} + +pkgng_Qi() { + pkg info "$@" +} + +pkgng_Ql() { + pkg info -l "$@" +} + +pkgng_Qo() { + pkg which "$@" +} + +pkgng_Qp() { + pkg query -F "$@" '%n %v' +} + +pkgng_Qu() { + pkg upgrade -n "$@" +} + +pkgng_Q() { + if [[ "$_TOPT" == "q" ]]; then + pkg query '%n' "$@" + elif [[ "$_TOPT" == "" ]]; then + pkg query '%n %v' "$@" + else + _not_implemented + fi +} + +pkgng_Rs() { + if [[ "$_TOPT" == "" ]]; then + pkg remove "$@" + pkg autoremove + else + _not_implemented + fi +} + +pkgng_R() { + pkg remove "$@" +} + +pkgng_Si() { + pkg search -S name -ef "$@" +} + +pkgng_Suy() { + pkg upgrade "$@" +} + +pkgng_Su() { + pkg upgrade -U "$@" +} + +pkgng_Sy() { + pkg update "$@" +} + +pkgng_Ss() { + pkg search "$@" +} + +pkgng_Sc() { + pkg clean "$@" +} + +pkgng_Scc() { + pkg clean -a "$@" +} + +pkgng_S() { + if [[ "$_TOPT" == "fetch" ]]; then + pkg fetch "$@" + else + pkg install "$@" + fi +} + + + +_pkg_tools_init() { + : +} + +pkg_tools_Qi() { + # disable searching mirrors for packages + export PKG_PATH= + pkg_info "$@" +} + +pkg_tools_Ql() { + export PKG_PATH= + pkg_info -L "$@" +} + +pkg_tools_Qo() { + export PKG_PATH= + pkg_info -E "$@" +} + +pkg_tools_Qp() { + _not_implemented +} + +pkg_tools_Qu() { + export PKG_PATH= + pkg_add -u "$@" +} + +pkg_tools_Q() { + export PKG_PATH= + # the dash after the pkg name is so we don't catch partial matches + # because all packages in openbsd have the format 'pkgname-pkgver' + if [[ "$_TOPT" == "q" && ! -z "$*" ]]; then + pkg_info -q | grep "^${*}-" + elif [[ "$_TOPT" == "q" && -z "$*" ]];then + pkg_info -q + elif [[ "$_TOPT" == "" && ! -z "$*" ]]; then + pkg_info | grep "^${*}-" + elif [[ "$_TOPT" == "" && -z "$*" ]];then + pkg_info + else + _not_implemented + fi +} + +pkg_tools_Rs() { + if [[ "$_TOPT" == "" ]]; then + pkg_delete -D dependencies "$@" + else + _not_implemented + fi +} + +pkg_tools_Rn() { + if [[ "$_TOPT" == "" ]];then + pkg_delete -c "$@" + else + _not_implemented + fi +} + +pkg_tools_Rns() { + _not_implemented +} + +pkg_tools_R() { + pkg_delete "$@" +} + +pkg_tools_Si() { + pkg_info "$@" +} + +pkg_tools_Sl() { + pkg_info -L "$@" +} + +pkg_tools_Suy() { + # pkg_tools doesn't really have any concept of a database + # there's actually not really any database to update, so + # this function is mostly just for convienience since on arch + # doing -Su is normally a bad thing to do since it's a partial upgrade + + pkg_tools_Su "$@" +} + +pkg_tools_Su() { + pkg_add -u "$@" +} + +pkg_tools_Sy() { + _not_implemented +} + +pkg_tools_Ss() { + if [[ -z "$*" ]];then + _not_implemented + else + pkg_info -Q "$@" + fi +} + +pkg_tools_Sc() { + # by default no cache directory is used + if [[ -z "$PKG_CACHE" ]];then + echo "You have no cache directory set, set \$PKG_CACHE for a cache directory." + elif [[ ! -d "$PKG_CACHE" ]];then + echo "You have a cache directory set, but it does not exist. Create \"$PKG_CACHE\"." + else + _removing_is_dangerous "rm -rf $PKG_CACHE/*" + fi +} + +pkg_tools_Scc() { + _not_implemented +} + +pkg_tools_S() { + pkg_add "$@" +} + + + +_portage_init() { + : +} + +portage_Qi() { + emerge --info "$@" +} + +portage_Ql() { + if [[ -x '/usr/bin/qlist' ]]; then + qlist "$@" + elif [[ -x '/usr/bin/equery' ]]; then + equery files "$@" + else + _error "'portage-utils' or 'gentoolkit' package is required to perform this opreation." + fi +} + +portage_Qo() { + if [[ -x '/usr/bin/equery' ]]; then + equery belongs "$@" + else + _error "'gentoolkit' package is required to perform this operation." + fi +} + +portage_Qc() { + emerge -p --changelog "$@" +} + +portage_Qu() { + emerge -uvN "$@" +} + +portage_Q() { + if [[ "$_TOPT" == "" ]]; then + if [[ -x '/usr/bin/eix' ]]; then + eix -I "$@" + elif [[ -x '/usr/bin/equery' ]]; then + equery list -i "$@" + else + LS_COLORS=never \ + ls -1 -d /var/db/pkg/*/* + fi + else + _not_implemented + fi +} + +portage_Rs() { + if [[ "$_TOPT" == "" ]]; then + emerge --depclean world "$@" + else + _not_implemented + fi +} + +portage_R() { + emerge --depclean "@" +} + +portage_Si() { + emerge --info "$@" +} + +portage_Suy() { + if [[ -x '/usr/bin/layman' ]]; then + layman --sync-all \ + && emerge --sync \ + && emerge -auND world "$@" + else + emerge --sync \ + && emerge -uND world "$@" + fi +} + +portage_Su() { + emerge -uND world "$@" +} + +portage_Sy() { + if [[ -x "/usr/bin/layman" ]]; then + layman --sync-all \ + && emerge --sync "$@" + else + emerge --sync "$@" + fi +} + +portage_Ss() { + if [[ -x "/usr/bin/eix" ]]; then + eix "$@" + else + emerge --search "$@" + fi +} + +portage_Sc() { + if [[ -x "/usr/bin/eclean-dist" ]]; then + eclean-dist -d -t1m -s50 -f "$@" + else + _error "'gentoolkit' package is required to perform this operation." + fi +} + +portage_Scc() { + if [[ -x "/usr/bin/eclean" ]]; then + eclean -i distfiles "$@" + else + _error "'gentoolkit' package is required to perform this operation." + fi +} + +portage_Sccc() { + rm -fv /usr/portage/distfiles/*.* +} + +portage_S() { + emerge "$@" +} + + + +_sun_tools_init() { + # The purpose of `if` is to make sure this function + # can be invoked on other system (Linux, BSD). + if [[ "$(uname)" == "SunOS" ]]; then + export GREP=/usr/xpg4/bin/grep + export AWK=nawk + fi +} + +sun_tools_Qi() { + pkginfo -l "$@" +} + +sun_tools_Ql() { + pkginfo -l "$@" +} + +sun_tools_Qo() { + $GREP "$@" /var/sadm/install/contents +} + +sun_tools_Qs() { + pkginfo | $GREP -i "$@" +} + +sun_tools_Q() { + # the dash after the pkg name is so we don't catch partial matches + # because all packages in openbsd have the format 'pkgname-pkgver' + if [[ "$_TOPT" == "q" && ! -z "$*" ]]; then + pkginfo | $GREP "$@" + elif [[ "$_TOPT" == "q" && -z "$*" ]]; then + pkginfo + else + pkginfo "$@" + fi +} + +sun_tools_R() { + pkgrm "$@" +} + +sun_tools_U() { + pkgadd "$@" +} + + + +_swupd_init() { + : +} + +swupd_Qk() { + swupd verify "$@" +} + +swupd_Qo() { + swupd search "$@" +} + +swupd_Qs() { + swupd search "$@" +} + +swupd_R() { + swupd bundle-remove "$@" +} + +swupd_Suy() { + swupd update +} + +swupd_Su() { + swupd update +} + +swupd_Sy() { + swupd search -i + swupd update +} + +swupd_Ss() { + swupd search "$@" +} + +swupd_S() { + swupd bundle-add "$@" +} + + +_tazpkg_init() { + : +} + +tazpkg_Q() { + if [[ "$_TOPT" == "q" ]]; then + tazpkg list "$@" \ + | awk '{ if (NF == 2 || NF == 3) { print $1; }}' + elif [[ "$_TOPT" == "" ]]; then + tazpkg list "$@" + else + _not_implemented + fi +} + +tazpkg_Qi() { + tazpkg info "$@" +} + +tazpkg_Ql() { + if [[ -z "$*" ]]; then + _not_implemented + return + fi + + if [[ "$_TOPT" == "q" ]]; then + { + tazpkg list-files "$@" + tazpkg list-config "$@" + } \ + | grep ^/ + else + tazpkg list-files "$@" + tazpkg list-config "$@" + fi +} + +tazpkg_Sy() { + tazpkg recharge +} + +tazpkg_Su() { + tazpkg up +} + +tazpkg_Suy() { + tazpkg_Sy \ + && tazpkg_Su +} + +tazpkg_S() { + local _forced="" + + if grep -q -- "--forced" <<<"$*"; then + _forced="--forced" + fi + + while (( $# )); do + if [[ "$1" == "--forced" ]]; then + _forced="--forced" + shift + continue + fi + + tazpkg get-install "$1" $_forced + shift + done +} + +tazpkg_R() { + local _auto="" + + if grep -q -- "--auto" <<<"$*"; then + _auto="--auto" + fi + + while (( $# )); do + if [[ "$1" == "--auto" ]]; then + _auto="--auto" + shift + continue + fi + + tazpkg remove "$1" $_auto + shift + done +} + +tazpkg_Sc() { + tazpkg clean-cache +} + +tazpkg_Scc() { + tazpkg clean-cache + cd /var/lib/tazpkg/ \ + && { + rm -fv \ + ./*.bak \ + ID \ + packages.* \ + files.list.* + } +} + +tazpkg_Ss() { + tazpkg search "$@" +} + +tazpkg_Qo() { + tazpkg search-pkgname "$@" +} + +tazpkg_U() { + local _forced="" + + if grep -q -- "--forced" <<<"$*"; then + _forced="--forced" + fi + + while (( $# )); do + if [[ "$1" == "--forced" ]]; then + _forced="--forced" + shift + continue + fi + + tazpkg install "$1" $_forced + shift + done +} + + + +_tlmgr_init() { + : +} + +tlmgr_Qi() { + tlmgr info --only-installed "$@" +} + +tlmgr_Qk() { + tlmgr check files +} + +tlmgr_Ql() { + tlmgr info --only-installed --list "$@" +} + +tlmgr_R() { + tlmgr remove "$@" +} + +tlmgr_S() { + tlmgr install "$@" +} + +tlmgr_Si() { + tlmgr info "$@" +} + +tlmgr_Sl() { + tlmgr info +} + +tlmgr_Ss() { + tlmgr search --global "$@" +} + +tlmgr_Suy() { + tlmgr update --all +} + +tlmgr_U() { + tlmgr install --file "$@" +} + + + +_yum_init() { + : +} + +yum_Q() { + if [[ "$_TOPT" == "q" ]]; then + rpm -qa --qf "%{NAME}\\n" + elif [[ "$_TOPT" == "" ]]; then + rpm -qa --qf "%{NAME} %{VERSION}\\n" + else + _not_implemented + fi +} + +yum_Qi() { + yum info "$@" +} + +yum_Qs() { + rpm -qa "*${*}*" +} + +yum_Ql() { + rpm -ql "$@" +} + +yum_Qo() { + rpm -qf "$@" +} + +yum_Qp() { + rpm -qp "$@" +} + +yum_Qc() { + rpm -q --changelog "$@" +} + +yum_Qu() { + yum list updates "$@" +} + +yum_Qm() { + yum list extras "$@" +} + +yum_Rs() { + if [[ "$_TOPT" == "" ]]; then + yum erase "$@" + else + _not_implemented + fi +} + +yum_R() { + yum erase "$@" +} + +yum_Si() { + yum info "$@" +} + +yum_Suy() { + yum update "$@" +} + +yum_Su() { + yum update "$@" +} + +yum_Sy() { + yum check-update "$@" +} + +yum_Ss() { + yum -C search "$@" +} + +yum_Sc() { + yum clean expire-cache "$@" +} + +yum_Scc() { + yum clean packages "$@" +} + +yum_Sccc() { + yum clean all "$@" +} + +yum_S() { + yum install $_TOPT "$@" +} + +yum_U() { + yum localinstall "$@" +} + +yum_Sii() { + yum resolvedep "$@" +} + + + +_zypper_init() { + : +} + +zypper_Qc() { + rpm -q --changelog "$@" +} + +zypper_Qi() { + zypper info "$@" +} + +zypper_Ql() { + rpm -ql "$@" +} + +zypper_Qu() { + zypper list-updates "$@" +} + +zypper_Qm() { + zypper search -si "$@" \ + | grep 'System Packages' +} + +zypper_Qo() { + rpm -qf "$@" +} + +zypper_Qp() { + rpm -qip "$@" +} + +zypper_Qs() { + zypper search --installed-only "$@" +} + +zypper_Q() { + if [[ "$_TOPT" == "q" ]]; then + zypper search -i "$@" \ + | grep ^i \ + | awk '{print $3}' + elif [[ "$_TOPT" == "" ]]; then + zypper search -i "$@" + else + _not_implemented + fi +} + +zypper_Rs() { + if [[ "$_TOPT" == "s" ]]; then + zypper remove "$@" --clean-deps + else + _not_implemented + fi +} + +zypper_R() { + zypper remove "$@" +} + +zypper_Rn() { + # Remove configuration files + while read -r file; do + if [[ -f "$file" ]]; then + rm -fv "$file" + fi + done < <(rpm -ql "$@") + + # Now remove the package per-se + zypper remove "$@" +} + +zypper_Rs() { + if [[ "$_TOPT" == "s" ]]; then + zypper remove "$@" --clean-deps + else + _not_implemented + fi +} + +zypper_Rns() { + # Remove configuration files + while read -r file; do + if [[ -f "$file" ]]; then + rm -fv "$file" + fi + done < <(rpm -ql "$@") + + zypper remove "$@" --clean-deps +} + +zypper_Suy() { + zypper dup "$@" +} + +zypper_Sy() { + zypper refresh "$@" +} + +zypper_Sl() { + if [[ $# -eq 0 ]]; then + zypper pa -R + else + zypper pa -r "$@" + fi +} + +zypper_Ss() { + zypper search "$@" +} + +zypper_Su() { + zypper --no-refresh dup "$@" +} + +zypper_Sc() { + zypper clean "$@" +} + +zypper_Scc() { + zypper clean "$@" +} + +zypper_Sccc() { + # Not way to do this in zypper + _not_implemented +} + +zypper_Si() { + zypper info --requires "$@" +} + +zypper_Sii() { + # Ugly and slow, but does the trick + local packages= + + packages="$(zypper pa -R | cut -d \| -f 3 | tr -s '\n' ' ')" + for package in $packages; do + zypper info --requires "$package" \ + | grep -q "$@" && echo $package + done +} + +zypper_S() { + zypper install $_TOPT "$@" +} + +zypper_Sw() { + zypper install --download-only "$@" +} + +zypper_U() { + zypper install "$@" +} +_validate_operation() { + case "$1" in + "apk_Q") ;; + "apk_Qi") ;; + "apk_Ql") ;; + "apk_Qo") ;; + "apk_Qs") ;; + "apk_Qu") ;; + "apk_R") ;; + "apk_Rn") ;; + "apk_Rns") ;; + "apk_Rs") ;; + "apk_S") ;; + "apk_Sc") ;; + "apk_Scc") ;; + "apk_Sccc") ;; + "apk_Si") ;; + "apk_Sii") ;; + "apk_Sl") ;; + "apk_Ss") ;; + "apk_Su") ;; + "apk_Suy") ;; + "apk_Sy") ;; + "apk_Sw") ;; + "apk_U") ;; + "cave_Q") ;; + "cave_Qi") ;; + "cave_Ql") ;; + "cave_Qo") ;; + "cave_Qp") ;; + "cave_Qu") ;; + "cave_Qs") ;; + "cave_Rs") ;; + "cave_Rn") ;; + "cave_Rns") ;; + "cave_R") ;; + "cave_Si") ;; + "cave_Suy") ;; + "cave_Su") ;; + "cave_Sy") ;; + "cave_Ss") ;; + "cave_Sc") ;; + "cave_Scc") ;; + "cave_Sccc") ;; + "cave_S") ;; + "cave_U") ;; + "conda_Q") ;; + "conda_R") ;; + "conda_S") ;; + "conda_Sc") ;; + "conda_Si") ;; + "conda_Ss") ;; + "conda_Suy") ;; + "dnf_S") ;; + "dnf_Sc") ;; + "dnf_Scc") ;; + "dnf_Sccc") ;; + "dnf_Si") ;; + "dnf_Sg") ;; + "dnf_Sl") ;; + "dnf_Ss") ;; + "dnf_Su") ;; + "dnf_Suy") ;; + "dnf_Sw") ;; + "dnf_Sy") ;; + "dnf_Q") ;; + "dnf_Qc") ;; + "dnf_Qe") ;; + "dnf_Qi") ;; + "dnf_Ql") ;; + "dnf_Qm") ;; + "dnf_Qo") ;; + "dnf_Qp") ;; + "dnf_Qs") ;; + "dnf_Qu") ;; + "dnf_R") ;; + "dnf_U") ;; + "dpkg_Q") ;; + "dpkg_Qi") ;; + "dpkg_Ql") ;; + "dpkg_Qo") ;; + "dpkg_Qp") ;; + "dpkg_Qu") ;; + "dpkg_Qs") ;; + "dpkg_Rs") ;; + "dpkg_Rn") ;; + "dpkg_Rns") ;; + "dpkg_R") ;; + "dpkg_Si") ;; + "dpkg_Suy") ;; + "dpkg_Su") ;; + "dpkg_Sy") ;; + "dpkg_Ss") ;; + "dpkg_Sc") ;; + "dpkg_Scc") ;; + "dpkg_S") ;; + "dpkg_U") ;; + "dpkg_Sii") ;; + "dpkg_Sccc") ;; + "homebrew_Qi") ;; + "homebrew_Ql") ;; + "homebrew_Qo") ;; + "homebrew_Qc") ;; + "homebrew_Qu") ;; + "homebrew_Qs") ;; + "homebrew_Q") ;; + "homebrew_Rs") ;; + "homebrew_R") ;; + "homebrew_Si") ;; + "homebrew_Suy") ;; + "homebrew_Su") ;; + "homebrew_Sy") ;; + "homebrew_Ss") ;; + "homebrew_Sc") ;; + "homebrew_Scc") ;; + "homebrew_Sccc") ;; + "homebrew_S") ;; + "macports_Ql") ;; + "macports_Qo") ;; + "macports_Qc") ;; + "macports_Qu") ;; + "macports_Rs") ;; + "macports_R") ;; + "macports_Si") ;; + "macports_Suy") ;; + "macports_Su") ;; + "macports_Sy") ;; + "macports_Ss") ;; + "macports_Sc") ;; + "macports_Scc") ;; + "macports_S") ;; + "pkgng_Qi") ;; + "pkgng_Ql") ;; + "pkgng_Qo") ;; + "pkgng_Qp") ;; + "pkgng_Qu") ;; + "pkgng_Q") ;; + "pkgng_Rs") ;; + "pkgng_R") ;; + "pkgng_Si") ;; + "pkgng_Suy") ;; + "pkgng_Su") ;; + "pkgng_Sy") ;; + "pkgng_Ss") ;; + "pkgng_Sc") ;; + "pkgng_Scc") ;; + "pkgng_S") ;; + "pkg_tools_Qi") ;; + "pkg_tools_Ql") ;; + "pkg_tools_Qo") ;; + "pkg_tools_Qp") ;; + "pkg_tools_Qu") ;; + "pkg_tools_Q") ;; + "pkg_tools_Rs") ;; + "pkg_tools_Rn") ;; + "pkg_tools_Rns") ;; + "pkg_tools_R") ;; + "pkg_tools_Si") ;; + "pkg_tools_Sl") ;; + "pkg_tools_Suy") ;; + "pkg_tools_Su") ;; + "pkg_tools_Sy") ;; + "pkg_tools_Ss") ;; + "pkg_tools_Sc") ;; + "pkg_tools_Scc") ;; + "pkg_tools_S") ;; + "portage_Qi") ;; + "portage_Ql") ;; + "portage_Qo") ;; + "portage_Qc") ;; + "portage_Qu") ;; + "portage_Q") ;; + "portage_Rs") ;; + "portage_R") ;; + "portage_Si") ;; + "portage_Suy") ;; + "portage_Su") ;; + "portage_Sy") ;; + "portage_Ss") ;; + "portage_Sc") ;; + "portage_Scc") ;; + "portage_Sccc") ;; + "portage_S") ;; + "sun_tools_Qi") ;; + "sun_tools_Ql") ;; + "sun_tools_Qo") ;; + "sun_tools_Qs") ;; + "sun_tools_Q") ;; + "sun_tools_R") ;; + "sun_tools_U") ;; + "swupd_Qk") ;; + "swupd_Qo") ;; + "swupd_Qs") ;; + "swupd_R") ;; + "swupd_Suy") ;; + "swupd_Su") ;; + "swupd_Sy") ;; + "swupd_Ss") ;; + "swupd_S") ;; + "tazpkg_Q") ;; + "tazpkg_Qi") ;; + "tazpkg_Ql") ;; + "tazpkg_Sy") ;; + "tazpkg_Su") ;; + "tazpkg_Suy") ;; + "tazpkg_S") ;; + "tazpkg_R") ;; + "tazpkg_Sc") ;; + "tazpkg_Scc") ;; + "tazpkg_Ss") ;; + "tazpkg_Qo") ;; + "tazpkg_U") ;; + "tlmgr_Qi") ;; + "tlmgr_Qk") ;; + "tlmgr_Ql") ;; + "tlmgr_R") ;; + "tlmgr_S") ;; + "tlmgr_Si") ;; + "tlmgr_Sl") ;; + "tlmgr_Ss") ;; + "tlmgr_Suy") ;; + "tlmgr_U") ;; + "yum_Q") ;; + "yum_Qi") ;; + "yum_Qs") ;; + "yum_Ql") ;; + "yum_Qo") ;; + "yum_Qp") ;; + "yum_Qc") ;; + "yum_Qu") ;; + "yum_Qm") ;; + "yum_Rs") ;; + "yum_R") ;; + "yum_Si") ;; + "yum_Suy") ;; + "yum_Su") ;; + "yum_Sy") ;; + "yum_Ss") ;; + "yum_Sc") ;; + "yum_Scc") ;; + "yum_Sccc") ;; + "yum_S") ;; + "yum_U") ;; + "yum_Sii") ;; + "zypper_Qc") ;; + "zypper_Qi") ;; + "zypper_Ql") ;; + "zypper_Qu") ;; + "zypper_Qm") ;; + "zypper_Qo") ;; + "zypper_Qp") ;; + "zypper_Qs") ;; + "zypper_Q") ;; + "zypper_Rs") ;; + "zypper_R") ;; + "zypper_Rn") ;; + "zypper_Rs") ;; + "zypper_Rns") ;; + "zypper_Suy") ;; + "zypper_Sy") ;; + "zypper_Sl") ;; + "zypper_Ss") ;; + "zypper_Su") ;; + "zypper_Sc") ;; + "zypper_Scc") ;; + "zypper_Sccc") ;; + "zypper_Si") ;; + "zypper_Sii") ;; + "zypper_S") ;; + "zypper_Sw") ;; + "zypper_U") ;; + *) return 1 ;; + esac +} + + + +set -u +unset GREP_OPTIONS + +: "${PACAPT_DEBUG=}" # Show what will be going +: "${GREP:=grep}" # Need to update in, e.g, _sun_tools_init +: "${AWK:=awk}" # Need to update in, e.g, _sun_tools_init + +_sun_tools_init # Dirty tricky patch for SunOS + +export PACAPT_DEBUG GREP AWK + +_POPT="" # primary operation +_SOPT="" # secondary operation +_TOPT="" # options for operations +_EOPT="" # extra options (directly given to package manager) + # these options will be translated by (_translate_all) method. +_PACMAN="" # name of the package manager + +_PACMAN_detect \ +|| _die "'pacapt' doesn't support your package manager." + +if [[ -z "$PACAPT_DEBUG" ]]; then + [[ "$_PACMAN" != "pacman" ]] \ + || exec "/usr/bin/pacman" "$@" +elif [[ "$PACAPT_DEBUG" != "auto" ]]; then + _PACMAN="$PACAPT_DEBUG" +fi + +case "${1:-}" in +"update") shift; set -- -Sy "$@" ;; +"upgrade") shift; set -- -Su "$@" ;; +"install") shift; set -- -S "$@" ;; +"search") shift; set -- -Ss "$@" ;; +"remove") shift; set -- -R "$@" ;; +"autoremove") shift; set -- -Rs "$@" ;; +"clean") shift; set -- -Scc "$@" ;; +esac + +while :; do + _args="${1-}" + + [[ "${_args:0:1}" == "-" ]] || break + + case "${_args}" in + "--help") + _help + exit 0 + ;; + + "--noconfirm") + shift + _EOPT="$_EOPT:noconfirm:" + continue + ;; + + "-"|"--") + shift + break + ;; + esac + + i=1 + while [[ "$i" -lt "${#_args}" ]]; do + _opt="${_args:$i:1}" + (( i ++ )) + + case "$_opt" in + h) + _help + exit 0 + ;; + V) + _print_pacapt_version; + exit 0 + ;; + P) + _print_supported_operations "$_PACMAN" + exit 0 + ;; + + Q|S|R|U) + if [[ -n "$_POPT" && "$_POPT" != "$_opt" ]]; then + _error "Only one operation may be used at a time" + exit 1 + fi + _POPT="$_opt" + ;; + + # Comment 2015 May 26th: This part deals with the 2nd option. + # Most of the time, there is only one 2nd option. But some + # operation may need extra and/or duplicate (e.g, Sy <> Syy). + # + # See also + # + # * https://github.com/icy/pacapt/issues/13 + # + # This implementation works, but with a bug. #Rsn works + # but #Rns is translated to #Rn (incorrectly.) + # Thanks Huy-Ngo for this nice catch. + # + # FIXME: Please check pacman(8) to see if they are really 2nd operation + # + e|g|i|l|m|n|o|p|s) + if [[ "$_SOPT" == '' ]]; then + _SOPT="$_opt" + continue + fi + + # Understand it: + # If there is already an option recorded, the incoming option + # will come and compare itself with known one. + # We have a table + # + # known one vs. incoming ? | result + # < | one-new + # = | one-one + # > | new-one + # + # Let's say, after this step, the 3rd option comes (named X), + # and the current result is "a-b". We have a table + # + # a(b) vs. X | result + # < | aX (b dropped) + # = | aa (b dropped) + # > | Xa (b dropped) + # + # In any case, the first one matters. + # + if [[ "${_SOPT:0:1}" < "$_opt" ]]; then + _SOPT="${_SOPT:0:1}$_opt" + elif [[ "${_SOPT:0:1}" == "$_opt" ]]; then + _SOPT="$_opt$_opt" + else + _SOPT="$_opt${_SOPT:0:1}" + fi + + ;; + + q) + _TOPT="$_opt" ;; # Thanks to James Pearson + + u) + if [[ "${_SOPT:0:1}" == "y" ]]; then + _SOPT="uy" + else + _SOPT="u" + fi + ;; + + y) + if [[ "${_SOPT:0:1}" == "u" ]]; then + _SOPT="uy" + else + _SOPT="y" + fi + ;; + + c) + if [[ "${_SOPT:0:2}" == "cc" ]]; then + _SOPT="ccc" + elif [[ "${_SOPT:0:1}" == "c" ]]; then + _SOPT="cc" + else + _SOPT="$_opt" + fi + ;; + + w|v) + _EOPT="$_EOPT:$_opt:" + ;; + + *) + # FIXME: If option is unknown, we will break the loop + # FIXME: and this option will be used by the native program. + # FIXME: break 2 + _die "pacapt: Unknown option '$_opt'." + ;; + esac + done + + shift + + # If the primary option and the secondary are known + # we would break the argument detection, but for sure we will look + # forward to see there is anything interesting... + if [[ -n "$_POPT" && -n "$_SOPT" ]]; then + case "${1:-}" in + "-w"|"--noconfirm") ;; + *) break;; + esac + + # Don't have anything from the **first** argument. Something wrong. + # FIXME: This means that user must enter at least primary action + # FIXME: or secondary action in the very first part... + elif [[ -z "${_POPT}${_SOPT}${_TOPT}" ]]; then + break + fi +done + +[[ -n "$_POPT" ]] \ +|| _die "Usage: pacapt # -h for help, -P list supported functions" + +_validate_operation "${_PACMAN}_${_POPT}${_SOPT}" \ +|| { + _not_implemented + exit 1 +} + +_translate_all || exit + +if [[ -n "$*" ]]; then + case "${_POPT}${_SOPT}" in + "Su"|"Sy"|"Suy") + echo 1>&2 "WARNING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + echo 1>&2 " The -Sy/u options refresh and/or upgrade all packages." + echo 1>&2 " To install packages as well, use separate commands:" + echo 1>&2 + echo 1>&2 " $0 -S$_SOPT; $0 -S ${*}" + echo 1>&2 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + esac +fi + +if [[ -n "$PACAPT_DEBUG" ]]; then + echo "pacapt: $_PACMAN, p=$_POPT, s=$_SOPT, t=$_TOPT, e=$_EOPT" + echo "pacapt: execute '${_PACMAN}_${_POPT}${_SOPT} $_EOPT ${*}'" + declare -f "${_PACMAN}_${_POPT}${_SOPT}" +else + "_${_PACMAN}_init" || exit + "${_PACMAN}_${_POPT}${_SOPT}" $_EOPT "$@" +fi From 267da04e40aefa2424510be663c9cff47d09a9ef Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 15:18:48 +1000 Subject: [PATCH 04/11] DCD-386: Use dev dependencies for molecule dependencies. --- Pipfile | 3 + Pipfile.lock | 669 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 669 insertions(+), 3 deletions(-) diff --git a/Pipfile b/Pipfile index 8139b62..d45d474 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,9 @@ name = "pypi" ansible = "==2.7.11" [dev-packages] +molecule = "==2.20.1" +docker = "==4.0.1" +six = "*" [requires] python_version = "2.7" diff --git a/Pipfile.lock b/Pipfile.lock index 66cb399..3eaf8a5 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "0eaff090d43a4d334b1ab4c48ce6e76f16be0e33cda3ea6abd38c2232f4f940c" + "sha256": "b90f4d19268d9193176d820d1ca2fdf11b6878f79d5039d085149e57e33609f3" }, "pipfile-spec": 6, "requires": { - "python_version": "3.7" + "python_version": "2.7" }, "sources": [ { @@ -108,6 +108,24 @@ ], "version": "==2.7" }, + "enum34": { + "hashes": [ + "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", + "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", + "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", + "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" + ], + "markers": "python_version < '3'", + "version": "==1.1.6" + }, + "ipaddress": { + "hashes": [ + "sha256:64b28eec5e78e7510698f6d4da08800a5c575caa4a286c93d651c5d3ff7b6794", + "sha256:b146c751ea45cad6188dd6cf2d9b757f6f4f8d6ffb96a023e6f2e26eea02a72c" + ], + "markers": "python_version < '3'", + "version": "==1.0.22" + }, "jinja2": { "hashes": [ "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", @@ -209,5 +227,650 @@ "version": "==1.12.0" } }, - "develop": {} + "develop": { + "ansible": { + "hashes": [ + "sha256:e7e6de461b7d07cb4d8b2dd2a32b231af7c56e6bf39b851024671aaa52fd377e" + ], + "index": "pypi", + "version": "==2.7.11" + }, + "ansible-lint": { + "hashes": [ + "sha256:9430ea6e654ba4bf5b9c6921efc040f46cda9c4fd2896a99ff71d21037bcb123", + "sha256:c1b442b01091eca13ef11d98c3376e9489ba5b69a8467828ca86044f384bc0a1" + ], + "version": "==4.1.0" + }, + "anyconfig": { + "hashes": [ + "sha256:4d6016ae6eecc5e502bc7e99ae0639c5710c5c67bde5f21b06b9eaafd9ce0e7e" + ], + "version": "==0.9.7" + }, + "arrow": { + "hashes": [ + "sha256:03404b624e89ac5e4fc19c52045fa0f3203419fd4dd64f6e8958c522580a574a", + "sha256:41be7ea4c53c2cf57bf30f2d614f60c411160133f7a0a8c49111c30fb7e725b5" + ], + "version": "==0.14.2" + }, + "asn1crypto": { + "hashes": [ + "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87", + "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49" + ], + "version": "==0.24.0" + }, + "atomicwrites": { + "hashes": [ + "sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", + "sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6" + ], + "version": "==1.3.0" + }, + "attrs": { + "hashes": [ + "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", + "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" + ], + "version": "==19.1.0" + }, + "backports.functools-lru-cache": { + "hashes": [ + "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", + "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" + ], + "markers": "python_version == '2.7'", + "version": "==1.5" + }, + "backports.ssl-match-hostname": { + "hashes": [ + "sha256:bb82e60f9fbf4c080eabd957c39f0641f0fc247d9a16e31e26d594d8f42b9fd2" + ], + "markers": "python_version < '3.5'", + "version": "==3.7.0.1" + }, + "binaryornot": { + "hashes": [ + "sha256:359501dfc9d40632edc9fac890e19542db1a287bbcfa58175b66658392018061", + "sha256:b8b71173c917bddcd2c16070412e369c3ed7f0528926f70cac18a6c97fd563e4" + ], + "version": "==0.4.4" + }, + "cerberus": { + "hashes": [ + "sha256:f5c2e048fb15ecb3c088d192164316093fcfa602a74b3386eefb2983aa7e800a" + ], + "version": "==1.2" + }, + "certifi": { + "hashes": [ + "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", + "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" + ], + "version": "==2019.3.9" + }, + "cffi": { + "hashes": [ + "sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774", + "sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d", + "sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90", + "sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b", + "sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63", + "sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45", + "sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25", + "sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3", + "sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b", + "sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647", + "sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016", + "sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4", + "sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb", + "sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753", + "sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7", + "sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9", + "sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f", + "sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8", + "sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f", + "sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc", + "sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42", + "sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3", + "sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909", + "sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45", + "sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d", + "sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512", + "sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff", + "sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201" + ], + "version": "==1.12.3" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "click": { + "hashes": [ + "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d", + "sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b" + ], + "version": "==6.7" + }, + "click-completion": { + "hashes": [ + "sha256:7ca12978493a7450486cef155845af4fae48744c3f97b7250a254de65c9e5e5a" + ], + "version": "==0.3.1" + }, + "colorama": { + "hashes": [ + "sha256:463f8483208e921368c9f306094eb6f725c6ca42b0f97e313cb5d5512459feda", + "sha256:48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1" + ], + "version": "==0.3.9" + }, + "configparser": { + "hashes": [ + "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", + "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" + ], + "markers": "python_version < '3.2'", + "version": "==3.7.4" + }, + "contextlib2": { + "hashes": [ + "sha256:509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48", + "sha256:f5260a6e679d2ff42ec91ec5252f4eeffdcf21053db9113bd0a8e4d953769c00" + ], + "markers": "python_version < '3'", + "version": "==0.5.5" + }, + "cookiecutter": { + "hashes": [ + "sha256:1316a52e1c1f08db0c9efbf7d876dbc01463a74b155a0d83e722be88beda9a3e", + "sha256:ed8f54a8fc79b6864020d773ce11539b5f08e4617f353de1f22d23226f6a0d36" + ], + "version": "==1.6.0" + }, + "cryptography": { + "hashes": [ + "sha256:24b61e5fcb506424d3ec4e18bca995833839bf13c59fc43e530e488f28d46b8c", + "sha256:25dd1581a183e9e7a806fe0543f485103232f940fcfc301db65e630512cce643", + "sha256:3452bba7c21c69f2df772762be0066c7ed5dc65df494a1d53a58b683a83e1216", + "sha256:41a0be220dd1ed9e998f5891948306eb8c812b512dc398e5a01846d855050799", + "sha256:5751d8a11b956fbfa314f6553d186b94aa70fdb03d8a4d4f1c82dcacf0cbe28a", + "sha256:5f61c7d749048fa6e3322258b4263463bfccefecb0dd731b6561cb617a1d9bb9", + "sha256:72e24c521fa2106f19623a3851e9f89ddfdeb9ac63871c7643790f872a305dfc", + "sha256:7b97ae6ef5cba2e3bb14256625423413d5ce8d1abb91d4f29b6d1a081da765f8", + "sha256:961e886d8a3590fd2c723cf07be14e2a91cf53c25f02435c04d39e90780e3b53", + "sha256:96d8473848e984184b6728e2c9d391482008646276c3ff084a1bd89e15ff53a1", + "sha256:ae536da50c7ad1e002c3eee101871d93abdc90d9c5f651818450a0d3af718609", + "sha256:b0db0cecf396033abb4a93c95d1602f268b3a68bb0a9cc06a7cff587bb9a7292", + "sha256:cfee9164954c186b191b91d4193989ca994703b2fff406f71cf454a2d3c7327e", + "sha256:e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6", + "sha256:f27d93f0139a3c056172ebb5d4f9056e770fdf0206c2f422ff2ebbad142e09ed", + "sha256:f57b76e46a58b63d1c6375017f4564a28f19a5ca912691fd2e4261b3414b618d" + ], + "version": "==2.7" + }, + "docker": { + "hashes": [ + "sha256:3db499d4d25847fed86acf8e100c989f7bc0f75a6fff6c52855726ada1d124f6", + "sha256:f61c37d721b489b7d55ef631b241be2d6a5884c3ffe63dc8f7dd9a3c3cd60489" + ], + "index": "pypi", + "version": "==4.0.1" + }, + "entrypoints": { + "hashes": [ + "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", + "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" + ], + "version": "==0.3" + }, + "enum34": { + "hashes": [ + "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", + "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", + "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", + "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" + ], + "markers": "python_version < '3'", + "version": "==1.1.6" + }, + "fasteners": { + "hashes": [ + "sha256:007e4d2b2d4a10093f67e932e5166722d2eab83b77724156e92ad013c6226574", + "sha256:3a176da6b70df9bb88498e1a18a9e4a8579ed5b9141207762368a1017bf8f5ef" + ], + "version": "==0.15" + }, + "flake8": { + "hashes": [ + "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", + "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" + ], + "version": "==3.7.7" + }, + "funcsigs": { + "hashes": [ + "sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca", + "sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50" + ], + "markers": "python_version < '3.0'", + "version": "==1.0.2" + }, + "functools32": { + "hashes": [ + "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", + "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" + ], + "markers": "python_version < '3.2'", + "version": "==3.2.3.post2" + }, + "future": { + "hashes": [ + "sha256:67045236dcfd6816dc439556d009594abf643e5eb48992e36beac09c2ca659b8" + ], + "version": "==0.17.1" + }, + "git-url-parse": { + "hashes": [ + "sha256:4655ee22f1d8bf7a1eb1066c1da16529b186966c6d8331f7f55686a76a9f7aef", + "sha256:7b5f4e3aeb1d693afeee67a3bd4ac063f7206c2e8e46e559f0da0da98445f117", + "sha256:9353ff40d69488ff2299b27f40e0350ad87bd5348ea6ea09a1895eda9e5733de" + ], + "version": "==1.2.2" + }, + "idna": { + "hashes": [ + "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e", + "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16" + ], + "version": "==2.7" + }, + "importlib-metadata": { + "hashes": [ + "sha256:6dfd58dfe281e8d240937776065dd3624ad5469c835248219bd16cf2e12dbeb7", + "sha256:cb6ee23b46173539939964df59d3d72c3e0c1b5d54b84f1d8a7e912fe43612db" + ], + "version": "==0.18" + }, + "ipaddress": { + "hashes": [ + "sha256:64b28eec5e78e7510698f6d4da08800a5c575caa4a286c93d651c5d3ff7b6794", + "sha256:b146c751ea45cad6188dd6cf2d9b757f6f4f8d6ffb96a023e6f2e26eea02a72c" + ], + "markers": "python_version < '3'", + "version": "==1.0.22" + }, + "jinja2": { + "hashes": [ + "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", + "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" + ], + "version": "==2.10.1" + }, + "jinja2-time": { + "hashes": [ + "sha256:d14eaa4d315e7688daa4969f616f226614350c48730bfa1692d2caebd8c90d40", + "sha256:d3eab6605e3ec8b7a0863df09cc1d23714908fa61aa6986a845c20ba488b4efa" + ], + "version": "==0.2.0" + }, + "markupsafe": { + "hashes": [ + "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", + "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", + "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", + "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", + "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", + "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", + "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", + "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", + "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", + "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", + "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", + "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", + "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", + "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", + "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", + "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", + "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", + "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", + "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", + "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", + "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", + "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", + "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", + "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", + "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", + "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", + "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", + "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" + ], + "version": "==1.1.1" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "molecule": { + "hashes": [ + "sha256:0e9ef6845cdf2a01f6c386445e4e54add3f515a033ee16b7b658e6122c8f0d76", + "sha256:621797c54299775f284bbb010d5bb9be485500eecaaa14a476cbc0df285d0da7" + ], + "index": "pypi", + "version": "==2.20.1" + }, + "monotonic": { + "hashes": [ + "sha256:23953d55076df038541e648a53676fb24980f7a1be290cdda21300b3bc21dfb0", + "sha256:552a91f381532e33cbd07c6a2655a21908088962bb8fa7239ecbcc6ad1140cc7" + ], + "version": "==1.5" + }, + "more-itertools": { + "hashes": [ + "sha256:38a936c0a6d98a38bcc2d03fdaaedaba9f412879461dd2ceff8d37564d6522e4", + "sha256:c0a5785b1109a6bd7fac76d6837fd1feca158e54e521ccd2ae8bfe393cc9d4fc", + "sha256:fe7a7cae1ccb57d33952113ff4fa1bc5f879963600ed74918f1236e212ee50b9" + ], + "markers": "python_version <= '2.7'", + "version": "==5.0.0" + }, + "packaging": { + "hashes": [ + "sha256:0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af", + "sha256:9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3" + ], + "version": "==19.0" + }, + "pathlib2": { + "hashes": [ + "sha256:25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", + "sha256:5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7" + ], + "markers": "python_version < '3.6'", + "version": "==2.3.3" + }, + "pathspec": { + "hashes": [ + "sha256:54a5eab895d89f342b52ba2bffe70930ef9f8d96e398cccf530d21fa0516a873" + ], + "version": "==0.5.9" + }, + "pbr": { + "hashes": [ + "sha256:f59d71442f9ece3dffc17bc36575768e1ee9967756e6b6535f0ee1f0054c3d68", + "sha256:f6d5b23f226a2ba58e14e49aa3b1bfaf814d0199144b95d78458212444de1387" + ], + "version": "==5.1.1" + }, + "pexpect": { + "hashes": [ + "sha256:2a8e88259839571d1251d278476f3eec5db26deb73a70be5ed5dc5435e418aba", + "sha256:3fbd41d4caf27fa4a377bfd16fef87271099463e6fa73e92a52f92dfee5d425b" + ], + "version": "==4.6.0" + }, + "pluggy": { + "hashes": [ + "sha256:0825a152ac059776623854c1543d65a4ad408eb3d33ee114dff91e57ec6ae6fc", + "sha256:b9817417e95936bf75d85d3f8767f7df6cdde751fc40aed3bb3074cbcb77757c" + ], + "version": "==0.12.0" + }, + "poyo": { + "hashes": [ + "sha256:c34a5413191210ed564640510e9c4a4ba3b698746d6b454d46eb5bfb30edcd1d", + "sha256:d1c317054145a6b1ca0608b5e676b943ddc3bfd671f886a2fe09288b98221edb" + ], + "version": "==0.4.2" + }, + "psutil": { + "hashes": [ + "sha256:0ff2b16e9045d01edb1dd10d7fbcc184012e37f6cd38029e959f2be9c6223f50", + "sha256:254adb6a27c888f141d2a6032ae231d8ed4fc5f7583b4c825e5f7d7c78d26d2e", + "sha256:319e12f6bae4d4d988fbff3bed792953fa3b44c791f085b0a1a230f755671ef7", + "sha256:529ae235896efb99a6f77653a7138273ab701ec9f0343a1f5030945108dee3c4", + "sha256:686e5a35fe4c0acc25f3466c32e716f2d498aaae7b7edc03e2305b682226bcf6", + "sha256:6d981b4d863b20c8ceed98b8ac3d1ca7f96d28707a80845d360fa69c8fc2c44b", + "sha256:7789885a72aa3075d28d028236eb3f2b84d908f81d38ad41769a6ddc2fd81b7c", + "sha256:7f4616bcb44a6afda930cfc40215e5e9fa7c6896e683b287c771c937712fbe2f", + "sha256:7fdb3d02bfd68f508e6745021311a4a4dbfec53fca03721474e985f310e249ba", + "sha256:a9b85b335b40a528a8e2a6b549592138de8429c6296e7361892958956e6a73cf", + "sha256:dc85fad15ef98103ecc047a0d81b55bbf5fe1b03313b96e883acc2e2fa87ed5c" + ], + "version": "==5.4.6" + }, + "ptyprocess": { + "hashes": [ + "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", + "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" + ], + "version": "==0.6.0" + }, + "py": { + "hashes": [ + "sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", + "sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53" + ], + "version": "==1.8.0" + }, + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "version": "==2.5.0" + }, + "pycparser": { + "hashes": [ + "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" + ], + "version": "==2.19" + }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "version": "==2.1.1" + }, + "pyparsing": { + "hashes": [ + "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", + "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" + ], + "version": "==2.4.0" + }, + "pytest": { + "hashes": [ + "sha256:4a784f1d4f2ef198fe9b7aef793e9fa1a3b2f84e822d9b3a64a181293a572d45", + "sha256:926855726d8ae8371803f7b2e6ec0a69953d9c6311fa7c3b6c1b929ff92d27da" + ], + "version": "==4.6.3" + }, + "python-dateutil": { + "hashes": [ + "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", + "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" + ], + "version": "==2.8.0" + }, + "python-gilt": { + "hashes": [ + "sha256:4fd58c128635d1f4a8c93305e648f23379ce56e23624e4c5479427fcd2d5656e", + "sha256:c7321ef1a8efddbdef657b4fd21c3eaf1b4cb24a9656d97b73a444b1feb2067a", + "sha256:e23a45a6905e6bb7aec3ff7652b48309933a6991fad4546d9e793ac7e0513f8a" + ], + "version": "==1.2.1" + }, + "pyyaml": { + "hashes": [ + "sha256:57acc1d8533cbe51f6662a55434f0dbecfa2b9eaf115bede8f6fd00115a0c0d3", + "sha256:588c94b3d16b76cfed8e0be54932e5729cc185caffaa5a451e7ad2f7ed8b4043", + "sha256:68c8dd247f29f9a0d09375c9c6b8fdc64b60810ebf07ba4cdd64ceee3a58c7b7", + "sha256:70d9818f1c9cd5c48bb87804f2efc8692f1023dac7f1a1a5c61d454043c1d265", + "sha256:86a93cccd50f8c125286e637328ff4eef108400dd7089b46a7be3445eecfa391", + "sha256:a0f329125a926876f647c9fa0ef32801587a12328b4a3c741270464e3e4fa778", + "sha256:a3c252ab0fa1bb0d5a3f6449a4826732f3eb6c0270925548cac342bc9b22c225", + "sha256:b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955", + "sha256:cd0618c5ba5bda5f4039b9398bb7fb6a317bb8298218c3de25c47c4740e4b95e", + "sha256:ceacb9e5f8474dcf45b940578591c7f3d960e82f926c707788a570b51ba59190", + "sha256:fe6a88094b64132c4bb3b631412e90032e8cfe9745a58370462240b8cb7553cd" + ], + "version": "==5.1.1" + }, + "requests": { + "hashes": [ + "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", + "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" + ], + "version": "==2.22.0" + }, + "ruamel.ordereddict": { + "hashes": [ + "sha256:08b4b19fe518d32251a5338e039c4dc9eb0876f2919f94c9b8d2f9446ea80806", + "sha256:150ce8e6c514a2a2b62753622a75874962561f8e5eeec81a3172ab952807bf0b", + "sha256:45541836cbfdde630033cae7bbbe35acbac87a0ceec79f944b7a3bedd940fe78", + "sha256:854dd4a524811b16111b1107d8a751e4ca064d2bb103d3d91deab75de36b6620", + "sha256:aee2fa23e884249b4284b728888c553d551e5bfd4de2731f10153fd7813ec55f", + "sha256:bf0a198c8ce5d973c24e5dba12d3abc254996788ca6ad8448eabc6aa710db149" + ], + "markers": "platform_python_implementation == 'CPython' and python_version <= '2.7'", + "version": "==0.4.13" + }, + "ruamel.yaml": { + "hashes": [ + "sha256:17dbf6b7362e7aee8494f7a0f5cffd44902a6331fe89ef0853b855a7930ab845", + "sha256:23731c9efb79f3f5609dedffeb6c5c47a68125fd3d4b157d9fc71b1cd49076a9", + "sha256:2bbdd598ae57bac20968cf9028cc67d37d83bdb7942a94b9478110bc72193148", + "sha256:34586084cdd60845a3e1bece2b58f0a889be25450db8cc0ea143ddf0f40557a2", + "sha256:35957fedbb287b01313bb5c556ffdc70c0277c3500213b5e73dfd8716f748d77", + "sha256:414cb87a40974a575830b406ffab4ab8c6cbd82eeb73abd2a9d1397c1f0223e1", + "sha256:428775be75db68d908b17e4e8dda424c410222f170dc173246aa63e972d094b3", + "sha256:514f670f7d36519bda504d507edfe63e3c20489f86c86d42bc4d9a6dbdf82c7b", + "sha256:5cb962c1ac6887c5da29138fbbe3b4b7705372eb54e599907fa63d4cd743246d", + "sha256:5f6e30282cf70fb7754e1a5f101e27b5240009766376e131b31ab49f14fe81be", + "sha256:86f8e010af6af0b4f42de2d0d9b19cb441e61d3416082186f9dd03c8552d13ad", + "sha256:8d47ed1e557d546bd2dfe54f504d7274274602ff7a0652cde84c258ad6c2d96d", + "sha256:98668876720bce1ac08562d8b93a564a80e3397e442c7ea19cebdcdf73da7f74", + "sha256:9e1f0ddc18d8355dcf5586a5d90417df56074f237812b8682a93b62cca9d2043", + "sha256:a7bc812a72a79d6b7dbb96fa5bee3950464b65ec055d3abc4db6572f2373a95c", + "sha256:b72e13f9f206ee103247b07afd5a39c8b1aa98e8eba80ddba184d030337220ba", + "sha256:bcff8ea9d916789e85e24beed8830c157fb8bc7c313e554733a8151540e66c01", + "sha256:c76e78b3bab652069b8d6f7889b0e72f3455c2b854b2e0a8818393d149ad0a0d" + ], + "version": "==0.15.97" + }, + "scandir": { + "hashes": [ + "sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e", + "sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022", + "sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f", + "sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f", + "sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae", + "sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173", + "sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4", + "sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32", + "sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188", + "sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d", + "sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac" + ], + "markers": "python_version < '3.5'", + "version": "==1.10.0" + }, + "sh": { + "hashes": [ + "sha256:ae3258c5249493cebe73cb4e18253a41ed69262484bad36fdb3efcb8ad8870bb", + "sha256:b52bf5833ed01c7b5c5fb73a7f71b3d98d48e9b9b8764236237bdc7ecae850fc" + ], + "version": "==1.12.14" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "tabulate": { + "hashes": [ + "sha256:e4ca13f26d0a6be2a2915428dc21e732f1e44dad7f76d7030b2ef1ec251cf7f2" + ], + "version": "==0.8.2" + }, + "testinfra": { + "hashes": [ + "sha256:8dbbf25039674d419598f576c5652947cebdf7cbbea8f23acacc80271009c6cb", + "sha256:d13dda899d5a051465f041a821363e2ebdd079391fbeae04089a2df7d35e3d54" + ], + "version": "==1.19.0" + }, + "tree-format": { + "hashes": [ + "sha256:a538523aa78ae7a4b10003b04f3e1b37708e0e089d99c9d3b9e1c71384c9a7f9", + "sha256:b5056228dbedde1fb81b79f71fb0c23c98e9d365230df9b29af76e8d8003de11" + ], + "version": "==0.1.2" + }, + "typing": { + "hashes": [ + "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", + "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", + "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" + ], + "markers": "python_version < '3.5'", + "version": "==3.6.6" + }, + "urllib3": { + "hashes": [ + "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", + "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" + ], + "version": "==1.25.3" + }, + "wcwidth": { + "hashes": [ + "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", + "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c" + ], + "version": "==0.1.7" + }, + "websocket-client": { + "hashes": [ + "sha256:1151d5fb3a62dc129164292e1227655e4bbc5dd5340a5165dfae61128ec50aa9", + "sha256:1fd5520878b68b84b5748bb30e592b10d0a91529d5383f74f4964e72b297fd3a" + ], + "version": "==0.56.0" + }, + "whichcraft": { + "hashes": [ + "sha256:7533870f751901a0ce43c93cc9850186e9eba7fe58c924dfb435968ba9c9fa4e", + "sha256:fecddd531f237ffc5db8b215409afb18fa30300699064cca4817521b4fc81815" + ], + "version": "==0.5.2" + }, + "yamllint": { + "hashes": [ + "sha256:9a4fec2d40804979de5f54453fd1551bc1f8b59a7ad4a26fd7f26aeca34a83af", + "sha256:f97cd763fe7b588444a94cc44fd3764b832a613b5250baa2bfe8b84c91e4c330" + ], + "version": "==1.16.0" + }, + "zipp": { + "hashes": [ + "sha256:8c1019c6aad13642199fbe458275ad6a84907634cc9f0989877ccc4a2840139d", + "sha256:ca943a7e809cc12257001ccfb99e3563da9af99d52f261725e96dfe0f9275bc3" + ], + "version": "==0.5.1" + } + } } From 8925cd5af93c994d6a8f1cc8b2ccca8ea51381b3 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 15:24:31 +1000 Subject: [PATCH 05/11] DCD-386: Use sync rather than install to use locked package versions. --- bin/install-ansible | 2 +- bin/run-all-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install-ansible b/bin/install-ansible index c76fc9f..f29e024 100755 --- a/bin/install-ansible +++ b/bin/install-ansible @@ -12,4 +12,4 @@ set -e pip install pipenv -pipenv install +pipenv sync diff --git a/bin/run-all-tests b/bin/run-all-tests index 0967276..82b1c02 100755 --- a/bin/run-all-tests +++ b/bin/run-all-tests @@ -3,7 +3,7 @@ set -e # Use Ansible from virtualenv if provided -pipenv install molecule docker six +pipenv sync --dev for role in `find roles/ -name molecule | sort`; do pushd `dirname $role` From e1dab14a7f3690e350cd6d443d71ddfcb3ceb743 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 15:30:56 +1000 Subject: [PATCH 06/11] DCD-386: Cleanups and clarifications. --- bin/ansible-with-atl-env | 3 ++- bin/install-ansible | 10 ++++++---- bin/run-all-tests | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/ansible-with-atl-env b/bin/ansible-with-atl-env index 43712f5..14a9938 100755 --- a/bin/ansible-with-atl-env +++ b/bin/ansible-with-atl-env @@ -14,4 +14,5 @@ source $ENV_FILE set +a # Use Ansible from virtualenv if provided -pipenv run ansible-playbook -v -i $INV $PLAYBOOK 2>&1 | tee --append $LOG_FILE +pipenv run \ + ansible-playbook -v -i $INV $PLAYBOOK 2>&1 | tee --append $LOG_FILE diff --git a/bin/install-ansible b/bin/install-ansible index f29e024..15b53d4 100755 --- a/bin/install-ansible +++ b/bin/install-ansible @@ -4,12 +4,14 @@ set -e # The Amazon Linux 2 Ansible package is 2.4, which has issue # interacting with RDS, so use pipenv to install a known-good version. +# Another alternative here would be nix, however that has issues +# installing as root, and can be slow in practice. -# Luckily AmzLnx2 and Ubuntu use the same package name. This may need -# some logic if other distros are added. Note: Parsing /etc/os-release -# is probably a good starting point for that. +# Luckily AmazonLinux2 and Ubuntu use the same package name for +# pip. This may need some logic if other distros are added. Note: +# Parsing /etc/os-release is probably a good starting point for that. ./bin/pacapt install python-pip +# See Pipfile and Pipfile.lock. pip install pipenv - pipenv sync diff --git a/bin/run-all-tests b/bin/run-all-tests index 82b1c02..2cc903f 100755 --- a/bin/run-all-tests +++ b/bin/run-all-tests @@ -2,11 +2,12 @@ set -e -# Use Ansible from virtualenv if provided +# Install dev packages from Pipfile.loc if necessary. pipenv sync --dev for role in `find roles/ -name molecule | sort`; do pushd `dirname $role` - pipenv run molecule test --all + pipenv run \ + molecule test --all popd done From b12d204267f996c9d9de51dd93eb77d9eee09822 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 15:58:25 +1000 Subject: [PATCH 07/11] DCD-386: Use noconfirm for package installation. --- bin/install-ansible | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-ansible b/bin/install-ansible index 15b53d4..b7d1736 100755 --- a/bin/install-ansible +++ b/bin/install-ansible @@ -10,7 +10,7 @@ set -e # Luckily AmazonLinux2 and Ubuntu use the same package name for # pip. This may need some logic if other distros are added. Note: # Parsing /etc/os-release is probably a good starting point for that. -./bin/pacapt install python-pip +./bin/pacapt install --noconfirm python-pip # See Pipfile and Pipfile.lock. pip install pipenv From 1c706c8cc5eac6c11feca157632c8a28e297f367 Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Thu, 13 Jun 2019 16:14:20 +1000 Subject: [PATCH 08/11] DCD-386: Remove use of amazon-linux-extras command as it breaks in a clean virtualenv; psql isn't actually used, and can be installed manually if needed. --- roles/product_common/tasks/amazon.yml | 6 ------ roles/product_common/tasks/ubuntu.yml | 1 - 2 files changed, 7 deletions(-) diff --git a/roles/product_common/tasks/amazon.yml b/roles/product_common/tasks/amazon.yml index 7e9abb1..c34c322 100644 --- a/roles/product_common/tasks/amazon.yml +++ b/roles/product_common/tasks/amazon.yml @@ -10,9 +10,3 @@ yum: name: - dejavu-fonts-common # Required by the installer - -# Amazon Linux 2 supplies extra packages via a special command. -- name: Enable Postgresql from 'extras' - command: amazon-linux-extras install -y "postgresql{{ postgres_version }}" - args: - creates: /usr/bin/psql diff --git a/roles/product_common/tasks/ubuntu.yml b/roles/product_common/tasks/ubuntu.yml index 7b28b70..68a20ff 100644 --- a/roles/product_common/tasks/ubuntu.yml +++ b/roles/product_common/tasks/ubuntu.yml @@ -11,5 +11,4 @@ - name: Install other base packages on Ubuntu package: name: - - postgresql-client - fonts-dejavu-core # Required by installer From 8c28593151e014fb2e7430a26852ae7dde94ebde Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Fri, 14 Jun 2019 09:49:40 +1000 Subject: [PATCH 09/11] DCD-386: Add taskcat as a dev dependency and update development readme. --- DEVELOPMENT.md | 45 ++++++++++++-------- Pipfile | 1 + Pipfile.lock | 112 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 137 insertions(+), 21 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index f711762..3740464 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -15,26 +15,38 @@ All other requirements will be installed under Virtualenv. git clone git@bitbucket.org:atlassian/dc-deployments-automation.git -### Step 1.2: Install Ansible +### Step 1.2: Install development environment dependencies -To ensure compatibility we specify a specific Ansible version; currently 2.7.10 -(some older versions had issues with RDS). We do this by creating a virtualenv -and installing a pinned version: +To ensure compatibility we specify a specific Ansible version; currently 2.7.11 +(some older versions had issues with RDS). We do this with +[Pipenv](https://docs.pipenv.org/) to lock the dependency tree. There are 2 main +ways to do this; either directly if packaged, or via pip... - virtualenv -p python3 .venv - source .venv/bin/activate - pip install ansible==2.7.10 + # Ubuntu 19.04+, Debian 10+ + sudo apt-get install pipenv python-dev + + # Older versions & RHEL/Amazon Linux, etc. + sudo apt-get install python-pip python-dev + pip install pipenv -### Step 1.3: Install Molecule for testing + # Mac via Homebrew + brew install pipenv + +### Step 1.3: Enter the development environment + +pipenv has 2 methods of entering the environment; `pipenv shell` and `pipenv +run`. As we need additional testing dependencies we all need to specify the +development environment: + + pipenv sync --dev + pipenv shell --dev + +### Step 1.4: Run some tests against a role Molecule is a testing framework for Ansible. We use this to test the functionality of individual and groups of roles, and to ensure cross-platform compatibility (currently Amazon Linux 2 and Ubuntu LTS). - pip install molecule docker - -### Step 1.4: Run some tests against a role - We’re going to check that the role that downloads the products works for both Jira Core and Confluence, on boths supported Linux distributions. So run the following: @@ -58,14 +70,11 @@ that uses the baseline Amazon Linux 2 AMI and Ansible. The branch containing the changes is in the Atlassian Github fork of the upstream repository, in the branch DCD-221-jira-dc-linux2-ansible-rework. -### Step 2.2: Install taskcat +### Step 2.2: Setup taskcat Taskcat is a tool for testing Cloudformation templates. It is generally the -simplest method of getting a template up and running from local changes. - -Assuming you’re still in the virtualenv, install it with: - - pip install taskcat +simplest method of getting a template up and running from local changes. It is +automatically installed as part of the pipenv environment. You may also need to create the file ~/.aws/taskcat_global_override.json and set the KeyPair parameter to access the deployed EC2 instances. See the taskcat docs diff --git a/Pipfile b/Pipfile index d45d474..a3b67e3 100644 --- a/Pipfile +++ b/Pipfile @@ -10,6 +10,7 @@ ansible = "==2.7.11" molecule = "==2.20.1" docker = "==4.0.1" six = "*" +taskcat = "*" [requires] python_version = "2.7" diff --git a/Pipfile.lock b/Pipfile.lock index 3eaf8a5..12753dd 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "b90f4d19268d9193176d820d1ca2fdf11b6878f79d5039d085149e57e33609f3" + "sha256": "d19b07115cf0a0e5ea9ce4283e43ee9c0efa52683080b730b8bf943ed87861e8" }, "pipfile-spec": 6, "requires": { @@ -276,6 +276,12 @@ ], "version": "==19.1.0" }, + "aws-sam-translator": { + "hashes": [ + "sha256:db872c43bdfbbae9fc8c9201e6a7aeb9a661cda116a94708ab0577b46a38b962" + ], + "version": "==1.11.0" + }, "backports.functools-lru-cache": { "hashes": [ "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", @@ -298,6 +304,20 @@ ], "version": "==0.4.4" }, + "boto3": { + "hashes": [ + "sha256:794a9a4b6a9e40c1ac57a377de609872d28d62afe4295c48cdc1b1c92f96ab8e", + "sha256:962b078568cc520869ea2842f307864c9abc30ad5ed160e12b2a89debf220161" + ], + "version": "==1.9.168" + }, + "botocore": { + "hashes": [ + "sha256:675f2b66af486dd02f5825601bb0c8378773999f8705c6f75450849ca41fed80", + "sha256:c3fc314c0e0aa13aa024d272d991e23d37550050abf96b3c7dea889ed1743723" + ], + "version": "==1.12.168" + }, "cerberus": { "hashes": [ "sha256:f5c2e048fb15ecb3c088d192164316093fcfa602a74b3386eefb2983aa7e800a" @@ -344,6 +364,13 @@ ], "version": "==1.12.3" }, + "cfn-lint": { + "hashes": [ + "sha256:16500272b5e2a3e9eb94e6b42c0a652b1a084fa96f8c5efb07ff4adde3b448ec", + "sha256:ce4bf8c0e6d5b8ad3f1b4cd8261e1eca795d61fb3723e3dce85c78eff95ab120" + ], + "version": "==0.21.5" + }, "chardet": { "hashes": [ "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", @@ -423,6 +450,14 @@ "index": "pypi", "version": "==4.0.1" }, + "docutils": { + "hashes": [ + "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", + "sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", + "sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6" + ], + "version": "==0.14" + }, "entrypoints": { "hashes": [ "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", @@ -467,7 +502,7 @@ "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" ], - "markers": "python_version < '3.2'", + "markers": "python_version == '2.7'", "version": "==3.2.3.post2" }, "future": { @@ -476,6 +511,14 @@ ], "version": "==0.17.1" }, + "futures": { + "hashes": [ + "sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265", + "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1" + ], + "markers": "python_version == '2.6' or python_version == '2.7'", + "version": "==3.2.0" + }, "git-url-parse": { "hashes": [ "sha256:4655ee22f1d8bf7a1eb1066c1da16529b186966c6d8331f7f55686a76a9f7aef", @@ -520,6 +563,34 @@ ], "version": "==0.2.0" }, + "jmespath": { + "hashes": [ + "sha256:3720a4b1bd659dd2eecad0666459b9788813e032b83e7ba58578e48254e0a0e6", + "sha256:bde2aef6f44302dfb30320115b17d030798de8c4110e28d5cf6cf91a7a31074c" + ], + "version": "==0.9.4" + }, + "jsonpatch": { + "hashes": [ + "sha256:49f29cab70e9068db3b1dc6b656cbe2ee4edf7dfe9bf5a0055f17a4b6804a4b9", + "sha256:8bf92fa26bc42c346c03bd4517722a8e4f429225dbe775ac774b2c70d95dbd33" + ], + "version": "==1.23" + }, + "jsonpointer": { + "hashes": [ + "sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362", + "sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e" + ], + "version": "==2.0" + }, + "jsonschema": { + "hashes": [ + "sha256:000e68abd33c972a5248544925a0cae7d1125f9bf6c58280d37546b946769a08", + "sha256:6ff5f3180870836cae40f06fa10419f557208175f13ad7bc26caa77beb1f6e02" + ], + "version": "==2.6.0" + }, "markupsafe": { "hashes": [ "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", @@ -560,6 +631,13 @@ ], "version": "==0.6.1" }, + "mock": { + "hashes": [ + "sha256:5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1", + "sha256:b158b6df76edd239b8208d481dc46b6afd45a846b7812ff0ce58971cf5bc8bba" + ], + "version": "==2.0.0" + }, "molecule": { "hashes": [ "sha256:0e9ef6845cdf2a01f6c386445e4e54add3f515a033ee16b7b658e6122c8f0d76", @@ -596,7 +674,6 @@ "sha256:25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", "sha256:5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7" ], - "markers": "python_version < '3.6'", "version": "==2.3.3" }, "pathspec": { @@ -676,6 +753,13 @@ ], "version": "==2.19" }, + "pyfiglet": { + "hashes": [ + "sha256:c6c2321755d09267b438ec7b936825a4910fec696292139e664ca8670e103639", + "sha256:d555bcea17fbeaf70eaefa48bb119352487e629c9b56f30f383e2c62dd67a01c" + ], + "version": "==0.8.post1" + }, "pyflakes": { "hashes": [ "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", @@ -702,6 +786,7 @@ "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" ], + "markers": "python_version >= '2.7'", "version": "==2.8.0" }, "python-gilt": { @@ -770,6 +855,13 @@ ], "version": "==0.15.97" }, + "s3transfer": { + "hashes": [ + "sha256:6efc926738a3cd576c2a79725fed9afde92378aa5c6a957e3af010cb019fac9d", + "sha256:b780f2411b824cb541dbcd2c713d0cb61c7d1bcadae204cdddda2b35cef493ba" + ], + "version": "==0.2.1" + }, "scandir": { "hashes": [ "sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e", @@ -807,6 +899,13 @@ ], "version": "==0.8.2" }, + "taskcat": { + "hashes": [ + "sha256:af4149d6b951cbc4974e5a03f8eb8c137e1f81ac98a348715eb6dc287f728b2a" + ], + "index": "pypi", + "version": "==0.8.35" + }, "testinfra": { "hashes": [ "sha256:8dbbf25039674d419598f576c5652947cebdf7cbbea8f23acacc80271009c6cb", @@ -835,6 +934,7 @@ "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" ], + "markers": "python_version == '2.7'", "version": "==1.25.3" }, "wcwidth": { @@ -865,6 +965,12 @@ ], "version": "==1.16.0" }, + "yattag": { + "hashes": [ + "sha256:d7214d100315093e3ddc34da9840acbfa65c79ec84b48a8191ddf535353c2e3f" + ], + "version": "==1.11.2" + }, "zipp": { "hashes": [ "sha256:8c1019c6aad13642199fbe458275ad6a84907634cc9f0989877ccc4a2840139d", From bc0edf40ee50dcc7cfbb6dd4038c8476cf158c2b Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Fri, 14 Jun 2019 10:22:30 +1000 Subject: [PATCH 10/11] DCD-386: apt-get vs yum. --- DEVELOPMENT.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3740464..141531d 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -26,7 +26,10 @@ ways to do this; either directly if packaged, or via pip... sudo apt-get install pipenv python-dev # Older versions & RHEL/Amazon Linux, etc. - sudo apt-get install python-pip python-dev + sudo apt-get install -y python-pip python-dev + # Or... + sudo yum install -y python-pip python-dev + pip install pipenv # Mac via Homebrew From 3eb5af4cd2932e85a11beeb31fce0c84e9eaafec Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Fri, 14 Jun 2019 10:23:40 +1000 Subject: [PATCH 11/11] DCD-386: Typo --- bin/run-all-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run-all-tests b/bin/run-all-tests index 2cc903f..2e95c22 100755 --- a/bin/run-all-tests +++ b/bin/run-all-tests @@ -2,7 +2,7 @@ set -e -# Install dev packages from Pipfile.loc if necessary. +# Install dev packages from Pipfile.lock if necessary. pipenv sync --dev for role in `find roles/ -name molecule | sort`; do