diff --git a/.github/workflows/empaquetamiento.yml b/.github/workflows/empaquetamiento.yml new file mode 100644 index 0000000..18596ba --- /dev/null +++ b/.github/workflows/empaquetamiento.yml @@ -0,0 +1,204 @@ +on: + pull_request: + branches: [main] + types: ["labeled"] +name: construir +jobs: + crear_release: + name: Creando lanzamiento + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.release.outputs.upload_url }} + steps: + - name: Creando lanzamiento + uses: actions/create-release@v1 + id: release + with: + draft: false + prerelease: false + release_name: "ApmPKG v1.5.0 Nix y archivos dentro de home" + tag_name: 1.5.0 + env: + GITHUB_TOKEN: ${{ github.token }} + artefactos_debian: + name: Creando artefactos para debian + runs-on: ubuntu-latest + needs: crear_release + outputs: + link: ${{ steps.construir_deb.outputs.link }} + steps: + - name: Construir y subir (debian) + uses: kedap/poa@debian + id: construir_deb + with: + repositorio: "${{ github.repository }}" + nombre: "apmpkg" + rama: "develop" #Cambiame posteriormente por develop o algo asi + ruta-control: "poa/control" + ruta-script: "poa/debian.sh" + descarga_subida_debian: + name: Descargando y subiendo artefactos para debian + runs-on: ubuntu-latest + needs: [artefactos_debian, crear_release] + steps: + - name: Descargando artefactos de debian + run: curl -O ${{ needs.artefactos_debian.outputs.link }} + - name: Subir artefacto + uses: actions/upload-artifact@v2 + with: + name: paquete_debian_64.deb + path: ./apmpkg-amd64.deb + - name: Subir artefactos debian + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.crear_release.outputs.upload_url }} + asset_path: ./apmpkg-amd64.deb + asset_name: apmpkg-amd64.deb + asset_content_type: application/vnd.debian.binary-package + artefacto_apmpkg: + name: Creando artefactos para apmpkg y subirlos a upload.sh + runs-on: ubuntu-latest + needs: crear_release + outputs: + link: ${{ steps.construir_abi.outputs.link }} + steps: + - name: Construir y subir (apmpkg) + uses: kedap/poa@apmpkg + id: construir_abi + with: + repositorio: "${{ github.repository }}" + nombre: "apmpkg" + rama: "develop" + ruta-abc: "poa/apmpkg.abc" + descarga_subida_apmpkg: + name: Descargando y subiendo artefactos para apmpkg + runs-on: ubuntu-latest + needs: [artefacto_apmpkg, crear_release] + steps: + - name: Descargando artefactos de apmpkg + run: curl -O ${{ needs.artefacto_apmpkg.outputs.link }} + - name: Subir artefacto + uses: actions/upload-artifact@v2 + with: + name: paquete_abi.abi.tar.gz + path: ./apmpkg-1.5.0.abi.tar.gz + - name: Subir + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.crear_release.outputs.upload_url }} + asset_path: ./apmpkg-1.5.0.abi.tar.gz + asset_name: apmpkg-1.5.0.abi.tar.gz + asset_content_type: application/gzip + artefacto_rpm_fedora: + name: Creando artefactos rpm (fedora) y subirlos a upload.sh + runs-on: ubuntu-latest + needs: crear_release + outputs: + link: ${{ steps.construir_rpm_fedora.outputs.link }} + steps: + - name: Construir y subir (rpm fedora) + uses: kedap/poa@rpm_fedora + id: construir_rpm_fedora + with: + repositorio: "${{ github.repository }}" + nombre: "apmpkg" + ruta-spec: "poa/apmpkg.spec" + version: 1.5.0 + rama: "develop" + descarga_subida_rpm_fedora: + name: Descargando y subiendo artefactos rpm (fedora) + runs-on: ubuntu-latest + needs: [artefacto_rpm_fedora, crear_release] + steps: + - name: Descargando artefactos de fedora + run: curl -O ${{ needs.artefacto_rpm_fedora.outputs.link }} + - name: Subir artefacto + uses: actions/upload-artifact@v2 + with: + name: paquete_rpm_fedora.rpm + path: ./apmpkg*.rpm + - name: Subir + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.crear_release.outputs.upload_url }} + asset_path: ./apmpkg-1.5.0-1.fc34.x86_64.rpm + asset_name: apmpkg-1.5.0-1.fc34.x86_64.rpm + asset_content_type: application/x-rpm + artefacto_zst_pacman: + name: Creando artefactos para archlinux (pacman) y subirlos a upload.sh + runs-on: ubuntu-latest + needs: crear_release + outputs: + link: ${{ steps.construir_zst.outputs.link }} + steps: + - name: Construir y subir (zst pacman) + uses: kedap/poa@archlinux + id: construir_zst + with: + repositorio: "${{ github.repository }}" + nombre: "apmpkg" + rama: "develop" + ruta-pkgbuild: "poa/PKGBUILD" + descarga_subida_zst_pacman: + name: Descargando y subiendo artefactos para archlinux (pacman) + runs-on: ubuntu-latest + needs: [artefacto_zst_pacman, crear_release] + steps: + - name: Descargando artefactos de pacman + run: curl -O ${{ needs.artefacto_zst_pacman.outputs.link }} + - name: Subir artefacto + uses: actions/upload-artifact@v2 + with: + name: paquete_pacman.pkg.tar.zst + path: ./apmpkg*.pkg.* + - name: Subir + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.crear_release.outputs.upload_url }} + asset_path: ./apmpkg-1.5.0-1-x86_64.pkg.tar.zst + asset_name: apmpkg-1.5.0-1.pkg.tar.zst + asset_content_type: application/zstd + artefacto_apk: + name: Creando artefactos para alpine subirlos a upload.sh + runs-on: ubuntu-latest + needs: crear_release + outputs: + link: ${{ steps.construir_apk.outputs.link }} + steps: + - name: Construir y subir (apk alpine) + uses: kedap/poa@alpine + id: construir_apk + with: + repositorio: "${{ github.repository }}" + nombre: "apmpkg" + rama: "develop" + ruta-apkbuild: "poa/APKBUILD" + descarga_subida_apk: + name: Descargando y subiendo artefactos para alpine (apk) + runs-on: ubuntu-latest + needs: [artefacto_apk, crear_release] + steps: + - name: Descargando artefactos de alpine + run: curl -O ${{ needs.artefacto_apk.outputs.link }} + - name: Subir artefacto + uses: actions/upload-artifact@v2 + with: + name: paquete_alpine.apk + path: ./apmpkg*.apk + - name: Subir + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.crear_release.outputs.upload_url }} + asset_path: ./apmpkg-1.5.0-r0.apk + asset_name: apmpkg-1.5.0-r0.apk + asset_content_type: application/gzip diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2a9c33f..ce92ef2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,7 +2,7 @@ name: Rust on: push: - branches: [ main, develop ] + branches: [ develop ] pull_request: branches: [ main, develop ] diff --git a/Cargo.lock b/Cargo.lock index 2a4e55e..2ca5b6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -14,9 +23,15 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" +[[package]] +name = "anyhow" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" + [[package]] name = "apmpkg" -version = "1.4.1" +version = "1.5.0" dependencies = [ "clap", "colored", @@ -29,10 +44,132 @@ dependencies = [ "reqwest", "sha2", "tar", + "testdir", "tokio", "toml", ] +[[package]] +name = "async-channel" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +dependencies = [ + "async-task 4.0.3", + "concurrent-queue", + "fastrand", + "futures-lite 1.12.0", + "once_cell", + "slab", +] + +[[package]] +name = "async-fs" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2" +dependencies = [ + "async-lock", + "blocking 1.0.2", + "futures-lite 1.12.0", +] + +[[package]] +name = "async-io" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +dependencies = [ + "concurrent-queue", + "futures-lite 1.12.0", + "libc", + "log", + "once_cell", + "parking 2.0.0", + "polling", + "slab", + "socket2 0.4.0", + "waker-fn", + "winapi", +] + +[[package]] +name = "async-lock" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-net" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5373304df79b9b4395068fb080369ec7178608827306ce4d081cba51cac551df" +dependencies = [ + "async-io", + "blocking 1.0.2", + "futures-lite 1.12.0", +] + +[[package]] +name = "async-process" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b21b63ab5a0db0369deb913540af2892750e42d949faacc7a61495ac418a1692" +dependencies = [ + "async-io", + "blocking 1.0.2", + "cfg-if 1.0.0", + "event-listener", + "futures-lite 1.12.0", + "libc", + "once_cell", + "signal-hook", + "winapi", +] + +[[package]] +name = "async-task" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" + +[[package]] +name = "async-task" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" + +[[package]] +name = "async-trait" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + [[package]] name = "atty" version = "0.2.14" @@ -50,6 +187,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.13.0" @@ -77,6 +229,34 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" +dependencies = [ + "async-channel", + "atomic-waker", + "futures-lite 0.1.11", + "once_cell", + "parking 1.0.6", + "waker-fn", +] + +[[package]] +name = "blocking" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" +dependencies = [ + "async-channel", + "async-task 4.0.3", + "atomic-waker", + "fastrand", + "futures-lite 1.12.0", + "once_cell", +] + [[package]] name = "bumpalo" version = "3.7.0" @@ -89,6 +269,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +[[package]] +name = "cache-padded" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" + [[package]] name = "cc" version = "1.0.69" @@ -134,6 +320,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", +] + [[package]] name = "core-foundation" version = "0.9.1" @@ -237,12 +432,27 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "event-listener" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" + [[package]] name = "exitcode" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" +[[package]] +name = "fastrand" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b394ed3d285a429378d3b384b9eb1285267e7df4b166df24b7a6939a04dc392e" +dependencies = [ + "instant", +] + [[package]] name = "filetime" version = "0.2.14" @@ -298,6 +508,20 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.16" @@ -305,6 +529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -313,6 +538,42 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99" +[[package]] +name = "futures-io" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" + +[[package]] +name = "futures-lite" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking 2.0.0", + "pin-project-lite 0.1.12", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking 2.0.0", + "pin-project-lite 0.2.7", + "waker-fn", +] + [[package]] name = "futures-sink" version = "0.3.16" @@ -325,6 +586,12 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2" +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + [[package]] name = "futures-util" version = "0.3.16" @@ -332,10 +599,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78" dependencies = [ "autocfg", + "futures-channel", "futures-core", + "futures-io", + "futures-sink", "futures-task", - "pin-project-lite", + "memchr", + "pin-project-lite 0.2.7", "pin-utils", + "slab", ] [[package]] @@ -359,6 +631,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" + [[package]] name = "glob" version = "0.3.0" @@ -390,6 +668,125 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +[[package]] +name = "heim" +version = "0.1.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1014732324a9baf5a691525faabb33909bf6f40dcc2b03c8f2fb07bb01e7e3f" +dependencies = [ + "heim-common", + "heim-process", + "heim-runtime", +] + +[[package]] +name = "heim-common" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767e6e47cf88abe7c9a5ebb4df82f180d30d9c0ba0269b6d166482461765834" +dependencies = [ + "cfg-if 1.0.0", + "core-foundation", + "futures-core", + "futures-util", + "lazy_static", + "libc", + "mach", + "nix 0.19.1", + "pin-utils", + "uom", + "winapi", +] + +[[package]] +name = "heim-cpu" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba5fb13a3b90581d22b4edf99e87c54316444622ae123d36816a227a7caa6df" +dependencies = [ + "cfg-if 1.0.0", + "futures", + "glob", + "heim-common", + "heim-runtime", + "lazy_static", + "libc", + "mach", + "ntapi", + "smol 1.2.5", + "winapi", +] + +[[package]] +name = "heim-host" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9abf6cd02bc4f6e6aa31a7f80702a2d0e574f4f2c6156a93c3550eb036304722" +dependencies = [ + "cfg-if 1.0.0", + "heim-common", + "heim-runtime", + "lazy_static", + "libc", + "log", + "mach", + "ntapi", + "platforms 1.0.3", + "winapi", +] + +[[package]] +name = "heim-net" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d13afa5e9b71c813c1e087bb27f51ae87d3a6d68a2bdd045bae4322dfae4948b" +dependencies = [ + "bitflags 1.2.1", + "cfg-if 1.0.0", + "heim-common", + "heim-runtime", + "libc", + "macaddr", + "nix 0.19.1", +] + +[[package]] +name = "heim-process" +version = "0.1.1-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd969deb2a89a488b6a9bf18a65923ae4cdef6b128fa2dedb74ef5c694deb5ae" +dependencies = [ + "async-trait", + "cfg-if 0.1.10", + "darwin-libproc", + "futures", + "heim-common", + "heim-cpu", + "heim-host", + "heim-net", + "heim-runtime", + "lazy_static", + "libc", + "mach", + "memchr", + "ntapi", + "ordered-float", + "smol 0.1.18", + "winapi", +] + +[[package]] +name = "heim-runtime" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ec7e5238c8f0dd0cc60914d31a5a7aadd4cde74c966a76c1caed1f5224e9b8" +dependencies = [ + "futures", + "futures-timer", + "once_cell", + "smol 1.2.5", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -418,7 +815,7 @@ checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" dependencies = [ "bytes", "http", - "pin-project-lite", + "pin-project-lite 0.2.7", ] [[package]] @@ -449,8 +846,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite", - "socket2", + "pin-project-lite 0.2.7", + "socket2 0.4.0", "tokio", "tower-service", "tracing", @@ -551,6 +948,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "macaddr" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baee0bbc17ce759db233beb01648088061bf678383130602a298e6998eedb2d8" + [[package]] name = "mach" version = "0.3.2" @@ -641,6 +1044,18 @@ dependencies = [ "void", ] +[[package]] +name = "nix" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" +dependencies = [ + "bitflags 1.2.1", + "cc", + "cfg-if 1.0.0", + "libc", +] + [[package]] name = "nix" version = "0.20.0" @@ -662,6 +1077,36 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.13.0" @@ -672,11 +1117,20 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55827317fb4c08822499848a14237d2874d6f139828893017237e7ab93eb386" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.8.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "opaque-debug" @@ -717,6 +1171,27 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" +dependencies = [ + "num-traits", +] + +[[package]] +name = "parking" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + [[package]] name = "parking_lot" version = "0.11.1" @@ -760,6 +1235,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + [[package]] name = "pin-project-lite" version = "0.2.7" @@ -784,6 +1265,25 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" +[[package]] +name = "platforms" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc77a3fc329982cbf3ea772aa265b742a550998bad65747c630406ee52dac425" + +[[package]] +name = "polling" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "log", + "wepoll-ffi", + "winapi", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -813,7 +1313,7 @@ dependencies = [ "nix 0.17.0", "num_cpus", "once_cell", - "platforms", + "platforms 0.2.1", "thiserror", "unescape", ] @@ -913,7 +1413,7 @@ dependencies = [ "mime", "native-tls", "percent-encoding", - "pin-project-lite", + "pin-project-lite 0.2.7", "serde", "serde_json", "serde_urlencoded", @@ -926,6 +1426,12 @@ dependencies = [ "winreg", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "ryu" version = "1.0.5" @@ -942,6 +1448,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "1.1.0" @@ -1013,6 +1525,16 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "signal-hook" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c98891d737e271a2954825ef19e46bd16bdb98e2746f2eec4f7a4ef7946efd1" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1034,6 +1556,56 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "smol" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" +dependencies = [ + "async-task 3.0.0", + "blocking 0.4.7", + "concurrent-queue", + "fastrand", + "futures-io", + "futures-util", + "libc", + "once_cell", + "scoped-tls", + "slab", + "socket2 0.3.19", + "wepoll-sys-stjepang", + "winapi", +] + +[[package]] +name = "smol" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4" +dependencies = [ + "async-channel", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-net", + "async-process", + "blocking 1.0.2", + "futures-lite 1.12.0", + "once_cell", +] + +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi", +] + [[package]] name = "socket2" version = "0.4.0" @@ -1086,6 +1658,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "testdir" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c13a556e110c7d373db3c12464a80e4d24ed25942381242b17aad43aee98085" +dependencies = [ + "anyhow", + "backtrace", + "heim", + "once_cell", + "smol 1.2.5", + "whoami", +] + [[package]] name = "textwrap" version = "0.9.0" @@ -1154,7 +1740,7 @@ dependencies = [ "num_cpus", "once_cell", "parking_lot", - "pin-project-lite", + "pin-project-lite 0.2.7", "signal-hook-registry", "tokio-macros", "winapi", @@ -1191,7 +1777,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "pin-project-lite", + "pin-project-lite 0.2.7", "tokio", ] @@ -1217,7 +1803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" dependencies = [ "cfg-if 1.0.0", - "pin-project-lite", + "pin-project-lite 0.2.7", "tracing-core", ] @@ -1278,6 +1864,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +[[package]] +name = "uom" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed" +dependencies = [ + "num-rational", + "num-traits", + "typenum", +] + [[package]] name = "url" version = "2.2.2" @@ -1314,6 +1911,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + [[package]] name = "want" version = "0.3.0" @@ -1408,6 +2011,34 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + +[[package]] +name = "wepoll-sys-stjepang" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fdfbb03f290ca0b27922e8d48a0997b4ceea12df33269b9f75e713311eb178d" +dependencies = [ + "cc", +] + +[[package]] +name = "whoami" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7741161a40200a867c96dfa5574544efa4178cf4c8f770b62dd1cc0362d7ae1" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 02502ec..de821a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apmpkg" -version = "1.4.1" +version = "1.5.0" authors = ["kedap "] edition = "2018" description = "Un administrador de paquetes universal para linux como modelo: PKGBUILD" @@ -26,3 +26,6 @@ sha2 = "0.9.3" nix = "0.20.0" psutil = "3.2.0" exitcode = "1.1.2" + +[dev-dependencies] +testdir = "0.4.0" diff --git a/README.md b/README.md index 1f02854..6c44d37 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,16 @@ A Package Manager as a model: PKGBUILD

+[English](./README_en.md) + # NOTICIAS -- Se ha liberado la versión: v1.4.1 Para todos!!! +- Se ha liberado la versión: v1.5 Para todos!!! - Creacion de los binarios para todas las distribuciones disponibles - Se a subido ApmPKG esta en [AUR](https://aur.archlinux.org/packages/apmpkg/) -- Se cambio slackpkg por slapt-get para administrar mejor los paquetes en Slackware -- Arreglo sobre npm para instalar modulos y no dependencias que no sean modulos de js -- Correcciones menores +- Agregando soporte para Nix +- Arreglando el bug ocacionado con `apmpkg crear abc hello-world` +- Se puede agregar archivos en `/home` de distintos usuarios +- En instalacion binaria no se ejecuta los scripts pre-instalacion * * * Un gestor de paquetes que desea ser una poderosa herramienta universal para linux con el fin de la cracion e instalacion de paquetes. @@ -33,9 +36,9 @@ Los gestores que son soportado por ApmPKG: - [x] Apk - [x] Pkg (termux) - [x] Slapt-get +- [x] Nix - [ ] Emerge - [ ] Yay -- [ ] Nix De igual manera se pueden crear binarios para una instalacion offline [binarios](doc/modos_de_instalacion.md/#instalacion-desde-un-archivo-binario-de-instalacion) para saber [mas infomarcion aqui](doc/modos_de_instalacion.md) @@ -64,6 +67,7 @@ Para ello puedes dirijirte a la seccion de [lanzamientos](https://github.com/Ked - Construir tus binarios, Con la llegada de la version 1.2 se puede construir binarios sin la necesidad de instalarlos, solo debes de ejecutar: `apmpkg construir foo.adi` o si es un paquete .abc: `apmpkg construir foo.abc` - Con la llegada de la version 1.3 se puede ejecutar scripts post instalacion [mas info aqui](doc/creando_paquetes.md/#instalacion) - En la version 1.4 se pueden ejecutar scripts pre instalacion +- Apartir de la version 1.5 se pueden colocar archivos dentro de `/home` ## Contribuir Si tienes una buena idea o quieres contribuir con este proyecto puedes empezar por [aqui](https://github.com/Kedap/apmpkg/issues) y [leer esto](CONTRIBUTING.md) diff --git a/README_en.md b/README_en.md new file mode 100644 index 0000000..20e39f1 --- /dev/null +++ b/README_en.md @@ -0,0 +1,93 @@ +# ApmPKG +[![version](https://img.shields.io/github/v/release/kedap/apmpkg)](https://github.com/Kedap/apmpkg/releases/) [![Build Status](https://travis-ci.com/Kedap/apmpkg.svg?branch=main)](https://travis-ci.com/Kedap/apmpkg) [![Paquete arch](https://img.shields.io/aur/version/apmpkg)](https://aur.archlinux.org/packages/apmpkg) [![AUR develop](https://img.shields.io/aur/version/apmpkg-git-dev)](https://aur.archlinux.org/packages/apmpkg-git-dev) [![Github Action Rust](https://img.shields.io/github/workflow/status/kedap/apmpkg/Rust)](https://github.com/Kedap/apmpkg/actions) + +A Package Manager as a model: PKGBUILD +

+ +

+ +[Spanish](./README.md) + +# NEWS +- Version has been released: v1.5 For everybody!!! +- Creation of the binaries for all available distributions +- ApmPKG is uploaded is in [AUR](https://aur.archlinux.org/packages/apmpkg/) +- Adding support for Nix +- Fixing the bug caused with `apmpkg create abc hello-world` +- You can add files in `/home` of different users +- In binary installation the pre-installation scripts are not executed + +* * * +A package manager that wants to be a powerful universal tool for Linux in order to create and install packages. +![Captura](img/captura_prin.png) + +## Creating packages + +This is a tool written in rust and bash, that uses native package managers for the resolution of dependencies, you can create packages from a simple file with TOML syntax and you can even create it from a PKGBUILD! +The managers that are supported by ApmPKG: + +- [x] Apt +- [x] Pacman +- [x] Dnf +- [x] Snap +- [x] Flatpak +- [x] Zypper +- [x] Yum +- [x] Apk +- [x] Pkg (termux) +- [x] Slapt-get +- [x] Nix +- [ ] Emerge +- [ ] Yay + +In the same way, binaries can be created for an offline installation. [binary](doc/modos_de_instalacion.md/#instalacion-desde-un-archivo-binario-de-instalacion) to know [more information here](doc/modos_de_instalacion.md) + +## Intallation +* * * +Although it is something difficult or strange, in the same way we can install apmpkg with the same apmpkg, even because we believe that the distribution of packages is important we try to make available and create native binaries for each distribution where package managers are supported, but first you must have the dependencies, among them: +- pip3/pip2 +- npm +- bundle +- wget +- fakeroot +- git +- rsync + +For this you can go to the section of [release](https://github.com/Kedap/apmpkg/releases/) where the packages are uploaded, if you want to have more information, [click here](doc/instalacion.md) + +# Feature +![Esquema](img/esquema.png) + +- Creation of packages for scripting languages, a clear example is python, javascript / typescript and ruby. With support with pip, bundle and npm [more information here](doc/creando_paquetes.md/#adi) +- Ease of creation of packages on the model [PKGBUILD of archlinux](https://wiki.archlinux.org/index.php/PKGBUILD) that is, we have support for AUR, although we have certain [limitations to say that we have support for all existing PKGBUILD](doc/creando_paquetes.md/#complicaciones-abc) but in the same way we are working on that +- Dependency resolution with the package managers mentioned above, we will work to make the list more extensive +- Download and / or compile from a url, example: `apmpkg instalar -u https://foo.com/bar` +- Extensions of our tool, *.adi, .abc y .abi.tar.gz* each one has a special function, [more information here](doc/modos_de_instalacion.md) +- Create a prototype for a generate a .adi or .abc file, with the command: `apmpkg crear adi foo` In the case of creating an .abc file, the following must be executed: `apmpkg crear abc foo` +- Build your binaries, With the arrival of version 1.2 you can build binaries without the need to install them, you just have to run: `apmpkg construir foo.adi` or if it is an .abc package: `apmpkg construir foo.abc` +- With the arrival of version 1.3 you can run post installation scripts [more information here](doc/creando_paquetes.md/#instalacion) +- In the version 1.4 pre-install scripts can be run +- Apartir de la version 1.5 se pueden colocar archivos dentro de `/home` + +## Contribute +If you have a good idea or want to contribute to this project you can start with [here](https://github.com/Kedap/apmpkg/issues) and [read this](CONTRIBUTING.md) + +## FAQ / Frequently Asked Questions + +**Is it really universal for ALL available gnu / linux distributions?** + +No, only for those that we have support for dependencies, package managers and their architecture. +in the same way, not all dependencies are called the same in all distributions that are similarly +solves by asking for some alternative dependency name found in your preferred package manager + +**Why is there no binary for X distribution if the X manager is available?** + +Although we try to do that we cannot, we generate the binaries of the most used distributions and apart each distribution has its architectures and packaging ways, in the event that we do not provide said binary it is highly recommended to [compile it](doc/installation_modes.md) + +**¿Existe una documentacion en ingles / Is there an English documentation?** + +Esta en nuestro planes agregar una documentacion en ingles. It will soon be available + +**Why don't they implement X feature?** + +For the same reason, because you do not share your idea, we will be happy to know your idea, you can support [here](https://github.com/Kedap/apmpkg/issues) and/or if you want more information [here](CONTRIBUTING.md) diff --git a/doc/creando_paquetes.md b/doc/creando_paquetes.md index e131e03..5578d76 100644 --- a/doc/creando_paquetes.md +++ b/doc/creando_paquetes.md @@ -1,6 +1,8 @@ # Guia para crear paquetes utilizando ApmPKG En esta guia aprenderas todo lo que se debe de saber al crear paquetes para ApmPKG, de esta manera podemos extender su uso mucho mas y tener paquetes para linux +[English](./creando_paquetes_en.md) + Tabla de contenidos 1. [Contruyendo con un Archivo de Descarga e Instalacion: ADI](#adi) 1. [Datos del paquete](#paquete) @@ -71,8 +73,8 @@ sha256sum = "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" # SALT #opt_src = true pre_install = "pre_apmpkg.sh" -files = ["main.rb" , "config.conf"] -ruta = ["/usr/bin/foo", "/etc/foo/config.conf"] +files = ["main.rb" , "config.conf", "porfile_user_default.py"] +ruta = ["/usr/bin/foo", "/etc/foo/config.conf", ".local/share/porfile_app.py"] post_install = "post_apmpkg.sh" mensaje = "Para poder ejecutar, prueba con 'foo'!" ``` @@ -180,14 +182,15 @@ Aqui se enfoca la informacion refrente a la ruta de instalacion, este se inicia ``` #opt_src = true pre_install = "pre_install.sh" -files = ["main.rb" , "config.conf"] -ruta = ["/usr/bin/foo", "/etc/foo/config.conf"] +files = ["main.rb" , "config.conf", "porfile_user_default.py"] +ruta = ["/usr/bin/foo", "/etc/foo/config.conf", ".local/share/porfile_app.py"] post_install = "post_apmpkg.sh" mensaje = "Para poder ejecutar, prueba con 'foo'!" ``` La variable **opt_src** es un boleano que admite true o false si es que se desea que todo el directorio obtenido por git o por la descarga se copia a la carpeta /opt, un ejemplo de esto es el paquete metasploit que se instala en la carpeta opt. -**files** y **ruta** ambos son arrays que contienen ruta de archivos, files selecciona los archivos que se van a instalar y ruta la ruta donde estos van a ser instalados, el primer archivo seleccionado se va a instalar con `install -Dm 755` ya que se da por hecho que el index 0 de ambos array es un binario. +**files** y **ruta** ambos son arrays que contienen ruta de archivos, files selecciona los archivos que se van a instalar y ruta la ruta donde estos van a ser instalados, el primer archivo seleccionado se va a instalar con `install -Dm 755` ya que se da por hecho que el index 0 de ambos array es un binario. en el caso de que quiera colocar un archivo dentro de `/home` debe de colocar una ruta relativa (no root) +como en este ejemplo ".local/share/foo.bar" se instalara dentro de `/home` en cualquiera de los usuarios existentes Encontraremos con la variable **post_install** que no es mas un variable string que almacena la ruta del script escrito en bash que se ejecutara una vez instalado el paquete en el caso de dar otra salida que no sea exit code 0, se dara por fallido diff --git a/doc/creando_paquetes_en.md b/doc/creando_paquetes_en.md new file mode 100644 index 0000000..24f23fe --- /dev/null +++ b/doc/creando_paquetes_en.md @@ -0,0 +1,240 @@ +# Guide to creating packages using ApmPKG +In this guide you will learn everything you need to know when creating packages for ApmPKG, in this way we can extend its use much more and have packages for linux + +[Spanish](./creando_paquetes.md) + +Table of Contents +1. [Build a Archivo de Descarga e Instalacion (Download and Installation File): ADI](#adi) + 1. [Package data](#package) + 2. [External dependencies](#dependencies-adi) + 3. [Ruby gems](#gem) + 4. [Pip2 / pip3](#pip) + 5. [Npm](#npm) + 6. [download](#download) + 7. [installation](#installation) +2. [Compile and install from a Archivo de Bash y Compilando (Bash File and Compiling)](#abc) + 1. [Errors with abc](#complications-abc) +3. [Generate a file easily](#create-command) +4. [FAQs / Frequently Asked Questions](#frequent-questions) + +# Adi +Your name from the acronym for (spanish): +**A**rchivo de +**D**escarga e +**I**nstalacion + +**D**ownload and +**I**nstallation +**F**ile +(English) + +This method was created with the purpose of being able to create applications written in python and / or ruby since ApmPKG has support for Pip and Bundle, in this way it seeks to be easier and more practical to create applications with these languages. First; what an ADI file looks like, then here is a prototype of this: +``` +[paquete] + +nombre = "foo" +version = "1.1" +rama = "estable" # git / beta +descrip = "Ejemplo para el prototipo de apmpkg" +pagina = "https://foo.com/" +licensia = "GPL-V3" +dependencias = ["ruby", "metasploit"] +#cmd_depen = ["ruby" , "msfconsole"] +#abi_dependencias = ["metasploit"] +#arch = "x86_64" +conflicto = "/opt/foo/" + +#[dependencias_adi] +#metasploit = "https://foo/bar/alterntiva/metasploit.abi.tar.gz" + +[gem] + +gemfile = true +file = "Gemfile" +#gemfile = false +#gemas = ["colorized", "rails"] + +#[pip] + +#version = 3 / 2 +#requirements = false / true +#packages = ["requests", "pytest-shutil", "objdict"] +#file = "requeriments.txt" + +#[npm] +#package_json = true / false +#ruta_package_json = "package.json" +#modulos = ["angular", "electron"] + +[descarga] + +url = "https://foo.com/bar.tar.gz" +carpeta = "foo-bar" +#git = "https://serviciogit.com/foo/bar" +#local = "/path/de/las/fuentes/foo.tar.gz" +sha256sum = "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" # SALTAR + +[instalacion] + +#opt_src = true +pre_install = "pre_apmpkg.sh" +files = ["main.rb" , "config.conf", "porfile_user_default.py"] +ruta = ["/usr/bin/foo", "/etc/foo/config.conf", ".local/share/porfile_app.py"] +post_install = "post_apmpkg.sh" +mensaje = "Para poder ejecutar, prueba con 'foo'!" +``` +A lot of information, we go by steps, ADI has the TOML syntax to make it easier to create packages, in this way we are going to see each of the lines: + +## Package +The package start is nothing more and nothing less than the data of the package to which to install, it is written with the start of `[paquete]`, something like that: +``` +nombre = "foo" +version = "1.1" +rama = "estable" # git / beta +descrip = "Ejemplo para el prototipo de apmpkg" +pagina = "https://foo.com/" +licensia = "GPL-V3" +dependencias = ["ruby", "metasploit"] +#cmd_depen = ["ruby" , "msfconsole"] +conflicto = "/opt/foo/" +#abi_dependencias = ["metasploit"] +``` +A little easier, right? From here we see basic things like the name and the version that are strings, nothing very important to discard, but we see something in the branch. +The **branch** variable is a string that is used to differentiate between what the package is, if it is a beta version, if it is from the git or development branch or if it is a stable version. + +Let's go to the following which is **descrip**, and **license**. These are strings where you place a short description of the package and the license to specify what type of package license it is. + +**dependencies** and **cmd-depen**: dependencies is an array where the name of the packages to which they should be installed are placed, and cmd_depen is something very curious, since to verify that the dependencies are installed, run a command; In other words, if the dependency is python after executing the installation command, `python` is executed and if an output of 127 is obtained, it is assumed that the dependency is installed, but nevertheless there are packages that are executed in different ways such as It is the example of `openssh` that is executed with` ssh` or in this case `metasploit` that is executed with` msfconsole` that is why this array was created. However, it is not necessary IF ALL the dependencies are executed with the same name with which it is installed, as is the case of `ruby` + +**conflict**: This string must contain a path, if said path or file exists it cannot be installed, that is, it prevents a package from being installed when it is already installed with another package manager + +**abi_dependencies** It is an array where dependencies are placed that **in the case** of not being found and/or resolved with native package managers, these dependencies will be installed externally by ApmPKG, see more information in [dependencies_adi](#dependencies-adi) + +**arch** It is a string variable that must be placed in the event that said package is compatible only for said architecture, in the event that it is available for all architectures, this variable should not be placed, since if said variable it is not placed it is assumed that the package is built for any architecture + +## Adi dependencies + +This section was integrated with version 1.2.0, the function of this section is to grant the sources of dependencies that have not been resolved with the native package managers, either because they are not in the repository or because they are found broken and/or for some other reason ... + +```toml +metasploit = "https://foo/bar/alterntiva/metasploit.abi.tar.gz" +``` + +We have a simple line, the variables in this section will have the name of the dependency that in the case of not being fulfilled will be installed through this option, in this case the **metasploit** dependency, the value of said variable will make a string containing the path from where to download said package in .abi.tar.gz format so that it can be installed by apmpkg + +## Gem +This section was created to contain information regarding gems that the package depends on, of course ruby gems and that will be installed with `bundle` or` gem` This section begins with `[gem]`, this section is not mandatory, it is only placed If the project depends on gems, if the case is yes, here is an example: +``` +gemfile = true +file = "Gemfile" +#gemfile = false +#gemas = ["colorized", "rails"] +``` +The **gemfile** variable is a boolean (true/false) that it must be placed in a mandatory way, this is to know if the project has a Gemfile to download the gems with this file, in the case that the project It contains a Gemfile, this must be set as true and if not then as false. + +**file** this variable is ONLY placed if the gemfile contains true, since here in this string the path of the Gemfile will be specified, in this case only "Gemfile" is set since it is found in the project folder + +**gems** this is an array where the gems on which it depends are specified, it is recommended that it must be few, few gems how to create a Gemfile but not so many, it is designed for projects that depend on 2 or 3 gems + +## Pip +Like ruby, python also has dependencies, these will be installed with pip by ApmPKG, in the same way this field is not mandatory unless the project requires it, we have support for pip2 and pip3, this is placed with `[pip] `below what it must contain: +``` +version = 3 # 2 +requirements = true # false +#packages = ["requests", "pytest-shutil", "objdict"] +file = "requeriments.txt" +``` +In **version** it must contain an integer and the version number of python / pip with which the dependencies will be installed, in the example we can see that it will be installed with pip3. + +En **requirements** es un boleano donde se debe de colocar true si es que el proyecto instala sus dependencias con el archivo requeriments.txt y false si no + +In **packages** it is an array where the dependencies are specified, this should not be put if the requirements are set to false. + +On the contrary **file** is a string where the path of the file requirements.txt is specified so that from here the dependencies are installed with pip + +## Npm +In this section we can find a space to correctly manage the npm modules, in an adi file it can be seen like this: +``` +#[npm] +#package_json = true / false +#ruta_package_json = "package.json" +#modulos = ["angular", "electron"] +``` + +In the variable **package.json** it is a boolean that indicates if the modules will be installed from a `package_json` + +In the **package_json_path** it is a string of the path where the `package_json` is located within the project + +On the array **modules** in case package_json is false it should contain the modules that should be installed + +## Download +The download section is for this, where you specify the details of the download, it starts `[download] `in one of the examples: +``` +url = "https://foo.com/bar.tar.gz" +#git = "https://serviciogit.com/foo/bar" +#local = "/path/local/de/las/fuentes" +carpeta = "foo-bar" +sha256sum = "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" # SALTAR +``` +The **url** variable is a string where the package download link is said, it must be compressed in `tar.gz` since it will be extracted with this compression format, but nevertheless in the git versions it has been created the **git** variable that is placed instead of url, when placing git the repository described here will be cloned, or failing that, if you have one of the sources on your computer, you can place its path in the variable **local** + +In **folder** the directory that must be accessed once the tar.gz has been extracted or the git cloned is placed + +In **sha256sums** you must enter the sha256 sums of the file to download, in the case that a git version is used, this must change its value as: `sha256sums =" SKIP "` in this way get verification by sha256 + +## Installation +Here the information regarding the installation path is focused, this starts with `[installation]` example: +``` +#opt_src = true +pre_install = "pre_install.sh" +files = ["main.rb" , "config.conf", "porfile_user_default.py"] +ruta = ["/usr/bin/foo", "/etc/foo/config.conf", ".local/share/porfile_app.py"] +post_install = "post_apmpkg.sh" +mensaje = "Para poder ejecutar, prueba con 'foo'!" +``` +The **opt_src** variable is a boolean that admits true or false if you want the entire directory obtained by git or by the download to be copied to the /opt folder, an example of this is the metasploit package that is installed in the opt folder. + +**files** and **path** are both arrays that contain file paths, files select the files to be installed and path the path where they are to be installed, the first selected file will be installed with ` install -Dm 755` since the index 0 of both arrays is assumed to be binary. in case you want to place a file inside `/home` you must put a relative path (not root) +as in this example ".local/share/foo.bar" will be installed inside `/home` in any of the existing users + +We will find with the **post_install** variable that is no longer a string variable that stores the path of the script written in bash that will be executed once the package is installed in the case of giving another output that is not exit code 0, it will be given by failed + +In the pre_install variable you will find the path where the bash script is, like the post_install script, it will be considered as failed if it returns an output other than 0 + +## Abc +Su nombre es el acronimo de (spanish): +**A**rchivo de +**B**ash y +**C**ompilacion + +(english) +**B**ash +**F**ile and +**C**ompilation + +This type of file is based on and/or cloned from the [PKGBUILD](https://wiki.archlinux.org/index.php/PKGBUILD) of archlinux, it is not necessary to explain what this great archlinux model can do, but without However, we will focus on what ApmPKG cannot do with a PKGBUILD because we still cannot have absolute compatibility, but we are working so that it is not so in the future, so we present the limitations in relation to abc +## Complications abc +We currently do not have support with the following variables +- groups: We currently do not have groups for packages +- depends: As we saw that to create ADI and how dependencies are checked is [executing](# package), with abc files they are checked looking for the name of the dependency in `/bin` and in` /usr/bin` and if not then It is given as a dependency not installed. +- optdepeds: We just don't use this variable like provides, conflicts, backups, options, install, changelog and all non-sha256 sums +In the same way, with the arrival of version 1.0.1, the `cmd_depen` variable was implemented so that the dependency can also be checked if this command is executed, giving 127 as output, it is considered not installed + + +# Create command + +In the update of version 1.1 we have integrated a subcommand for the creation of a prototype of which it is necessary to create, which is the following: +``` +apmpkg crear +``` +So to facilitate the creation of a package + +# Frequent questions +**Do PKGBUILD or .abc files work on any right-handed than archlinux?** +Yes, since a process similar to `makepkg` is carried out, but nevertheless` iiabc` (interpreter for the installation with .abc) does a similar but very different process, like the binaries that are generated are similar to a `pkg. tar.xz` but very different from `adi.tar.gz` + +**I have dependency issues! In X distribution the dependencies are installed but in Y not** +This is a warning, that is to say that a solution will be found as quickly as possible when launching ApmPKG since there are packages with different names in different repositories, an example is the package `openssh` that in archlinux is called` openssh` but in debian it is call `ssh`. A temporary solution would be to modify the name of the dependencies for each distribution, but we are working to eliminate this problem. But with version 1.0.1 the solution was given of being able to ask the user for a package that is not found + +**Is root permissions required?** +To install packages you need to be root, but nevertheless to create binaries it is not necessary diff --git a/doc/instalacion.md b/doc/instalacion.md index 6880d8d..80ba3a2 100644 --- a/doc/instalacion.md +++ b/doc/instalacion.md @@ -2,6 +2,8 @@ La opcion mas recomendable es que se dirja a la [seccion de lanzamientos](https://github.com/Kedap/apmpkg/releases/) y descargar los binarios, de igual manera se intentara distribuir para la mayoria de destribuciones y plataformas ¡SE PUEDE INSTALAR DESDE APMPKG! De igual manera en este markdown dara las manera de llevar la instalacion de ApmPKG a tu maquina. +[English](./instalacion_en.md) + Tabla de contenido: 1. [Instalar desde los binarios](#instalacion-de-los-binarios) 1. [apt](#apt) diff --git a/doc/instalacion_en.md b/doc/instalacion_en.md new file mode 100644 index 0000000..7f096f0 --- /dev/null +++ b/doc/instalacion_en.md @@ -0,0 +1,126 @@ +# INSTALLATION + +The most recommended option is to go to the [releases section](https://github.com/Kedap/apmpkg/releases/) and download the binaries, in the same way it will try to distribute for most distributions and platforms! IT CAN BE INSTALLED FROM APMPKG! In the same way, in this markdown it will give the way to take the ApmPKG installation to your machine. + +[Spanish](./instalacion_en.md) + +Table of Contents: +1. [Install from binaries](#installation-of-binaries) + 1. [apt](#apt) + 2. [dnf](#dnf) + 3. [pacman](#pacman) + 4. [zypper](#zypper) + 5. [apmpkg](#apmpkg) + 6. [yay](#yay) + 7. [apk](#apk) + 8. [binary](#binary) +2. [Manual installation (build)](#build) + 1. [Post-Installation](#post-installation) + +# Installation of binaries +This is just a guide on how it is recommended to install the binaries with the package managers below: + +## Apt +Apt is the package manager for debian and its derivatives, to do an installation using apt just by typing the following commands in your terminal: +`wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-1.3.0-amd64.deb; apt install ./apmpkg-1.3.0-amd64.deb` + +In this way apt searches for the necessary dependencies for ApmPKG + +## Dnf +Dnf, the next generation of yum, we highly recommend using dnf for the installation of ApmPKG so that it is a desired installation as it should, in the event that the installation does not work with this binary you can use the other one destined for zypper, to install with this tool it is necessary to execute the following: + +`wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-1.3.0-1.fc34.x86_64.rpm; dnf localinstall apmpkg-1.3.0-1.fc34.x86_64.rpm` + +In this way you will already have Apm PKG installed on your computer + +## Pacman +Pacman ...<. the archlinux package manager, in the same way it can be installed with this manager, you just need to run: + +`wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-1.3.0-3-x86_64.pkg.tar.zst; pacman -U apmpkg-1.3.0-3-x86_64.pkg.tar.zst` + +Or in a better way you can have the latest versions with the repository [krep0](https://krep0.bitbucket.io/archlinux/), if you don't have it in your pacman.conf, you should do the following: +Place the following lines in `/etc/pacman.conf`: +```toml +[krep0] +SigLevel = Optional TrustAll +Server = https://$repo.bitbucket.io/archlinux/$arch +``` +And update with `pacman -Syu` + +Once you have krep0 in your pacman.conf you must execute the following to install apmpkg: + +```sh +pacman -S apmpkg +``` + +In case you want to install the development version (not recommended) you should run: +```sh +pacman -S apmpkg-dev +``` + +## Zypper +Zypper is the OpenSUSE package manager and for ApmPKG to be installed, you just need to execute the following: + +`wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-1.3.0-1.fc34.x86_64.rpm; zypper in apmpkg-1.3.0-1.fc34.x86_64.rpm` + +## Apmpkg +A universal package manager for linux written in rust and bash. As we said before that to install ApmPKG it can also be used to download ApmPKG, obviously you will not be able to download ApmPKG in ApmPKG without first having it installed, this method is used more to update ApmPKG, because you just need to write the following command. +`apmpkg instalar -u https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-1.3.0.abi.tar.gz` + +## Yay +*Yet another yogurt* or with any other helper to install AUR packages, ApmPKG is also in [AUR](https://aur.archlinux.org/packages/apmpkg) and what better way than to install it with yay, with the following command + +`yay -S apmpkg` + +Similarly there are more ApmPKG versions in AUR. + +## Apk +Alpine linux package manager, and in this update we have support for it, +why don't you install it with: +``` +wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-1.3.0-r0.apk; apk add --allow-untrusted apmpkg-1.3.0-r0.apk +``` +And if you want to have the documentation installed, try with: +``` +wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-doc-1.3.0-r0.apk;apk apk add --allow-untrusted apmpkg-doc-1.3.0-r0.apk +``` +Or in your case it can be installed from the testing branch of [alpine](https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Repository_pinning) + +```sh +apk add apmpkg@testing +``` + +## Binary +In the [releases section](https://github.com/Kedap/apmpkg/releases/) you can download and install it with the following command: +`wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-bin-x86_64; mv apmpkg-bin-x86_64 /usr/bin/apmpkg` +But if you want to run it in a portable way you can do it: +`wget https://github.com/Kedap/apmpkg/releases/download/1.3.0/apmpkg-bin-x86_64; ./apmpkg-bin-x86_64 --help` + + +# Build + +For manual installation and compilation, you must meet the following requirements: + +- Dependencies to compile: git, cargo, pkg-config, openssl and openssl can vary in different distributions, this is necessary for openssl rust, [more information here](https://docs.rs/openssl/0.10.33/openssl/ index.html # automatic) +- ApmPKG dependencies: pip3 / pip2, bundle, wget, fakeroot, rsync, npm and git + +To start the compilation process, you must execute the following: + +``` +$ git clone https://github.com/kedap/apmpkg +$ cd apmpkg +$ cargo build --release +# cp target/release/apmpkg /usr/bin +# mkdir -p /etc/apmpkg/iiabc +# cp -r src/iiabc /etc/apmpkg/iiabc +# mkdir -p /etc/apmpkg/paquetes +``` +## Post-installation +### Manually +To install the manuals just run, as you need to have man installed to be able to read the manual pages since many distributions do not have it installed by default +``` +# mkdir -p /usr/local/share/man/man1 +# cp man/* /usr/local/share/man/man1 +``` +## Execute +`apmpkg --help` diff --git a/doc/modos_de_instalacion.md b/doc/modos_de_instalacion.md index 6a5b0ea..3646a0e 100644 --- a/doc/modos_de_instalacion.md +++ b/doc/modos_de_instalacion.md @@ -1,6 +1,8 @@ # MODOS DE INSTALACION En ApmPKG tenemos 2 formas de instalar paquetes, obviamente antes ya hechos como se dice en [creando paquetes](creando_paquetes.md) para compartir estos paquetes se pueden hacer desde un [archivo .adi](creando_paquetes.md#adi), [archivo.abc](creando_paquetes.md#abc) y/o desde un archivo binario (.abi.tar.gz) realizados por usted mismo o por otra persona. Aunque es lo mismo para todos lo archivos posibles. Veamos los modos de instalacion: +[English](./modos_de_instalacion_en.md) + Tabla de contenido: 1. [Instalacion desde un archivo ADI](#instalacion-desde-un-archivo-de-descarga-e-instalacion) 1. [Instalacion desde un archivo ADI alojado en la web](#desde-la-web) diff --git a/doc/modos_de_instalacion_en.md b/doc/modos_de_instalacion_en.md new file mode 100644 index 0000000..36d39d9 --- /dev/null +++ b/doc/modos_de_instalacion_en.md @@ -0,0 +1,55 @@ +# INSTALLATION MODES +In ApmPKG we have 2 ways to install packages, obviously already made before as stated in [creating packages](./creando_paquetes_en.md) to share these packages can be done from a [.adi file](creating_packages.md # adi), [file .abc](creating_packages.md#abc) and/or from a binary file (.abi.tar.gz) made by yourself or someone else. Although it is the same for all possible files. Let's see the installation modes: + +[Spanish](./modos_de_instalacion.md) + +Table of Contents: +1. [Install from an ADI file](#installing-from-a-download-and-installation-file) + 1. [Installing from a web-hosted ADI file](#from-web) +2. [installation from an ABC file](#install-from-a-file-abc) + 1. [Installation from an ABC file hosted on the web](#abc-from-web) +3. [Install from a file ADI.TAR.GZ](#installing-from-an-installation-binary-file) + 1. [Install from a file ADI.TAR.GZ](#binary-from-the-internet) + + + + +## Installing from a download and installation file +As we will remember, a .adi file is nothing more than a document with TOML syntax for the creation of packages written in some scripting language, also for other languages, but this is its recommended use. To install from a .adi file you can type the following command: + +`# apmpkg instalar foo.adi` + +The installation of said packages will begin immediately, what this process does is download and install dependencies as well as dependencies of pip or bundle, as the case may be, once this step is carried out, the next thing to do is install the files specified in this file and thus conclude with the installation. + +### From web + +If you want to install from a web-hosted .adi file, you can perform the following command: + +`# apmpkg instalar -u https://foo.com/bar.adi` + +This only downloads the specified file and will proceed to the install function as in the process above. + + +## Install from a file abc + +The .ABC files are the ones that will be seen the most from the panorama from this tool, this type of files are read by [iiabc](./creando_paquetes_en.md # abc) that we had agreed in [creating packages](./creando_paquetes_en.md#complications-abc) this is a file similar or the same as a [PKGBUILD](https://wiki.archlinux.org/index.php/PKGBUILD) from archlinux, but of course we have [certain problems](./creando_paquetes_en.md) with the compatibility of ALL existing PKGBUILD's, but we will continue working so that it is not so. To install from an .ABC file, we can execute the following command: +`# apmpkg instalar foo.abc` + +### Abc from web + +In the same way, the same command is used: +`# apmpkg instalar -u https://foo.com/bar.abc` + +## Installing from an installation binary file + +The .ABI.TAR.GZ files are for an offline installation to be possible, this is where you have all the files necessary for an installation and metadata of the package to be interpreted by apmpkg, as everything here with this article is used the same command for everything, even so in case there is any doubt we must make it clear. For installation from an ABI.TAR.GZ file: + +`# apmpkg instalar foo.abi.tar.gz` + +### Binary from the internet + +Similarly, the command is the same. ApmPKG downloads the specified file and starts the installation process with this type of file, in a normal way, as it does not affect whether it has been created from an ADI or an ABC, ApmPKG will know what type of file is with which this package was made And in the same way it will install the files, to install with the ADI file that is hosted on some website can be done with the following command: +`# apmpkg instalar -u https://foo.com/bar.abi.tar.gz` + +En conclusion: +`# apmpkg instalar foo.bar` if it is a local installation, that is, you already have the file on your computer and if not: `# apmpkg instalar -u https://foo.com/bar.bar` diff --git a/img/captura_prin.png b/img/captura_prin.png index e50fa48..924be13 100644 Binary files a/img/captura_prin.png and b/img/captura_prin.png differ diff --git a/man/apmpkg-en.1 b/man/apmpkg-en.1 index f9f4886..4b3af4a 100644 --- a/man/apmpkg-en.1 +++ b/man/apmpkg-en.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.3. -.TH APMPKG "1" "June 2021" "apmpkg 1.4.1" "User Commands" +.TH APMPKG "1" "June 2021" "apmpkg 1.5.0" "User Commands" .SH NAME -apmpkg \- manual page for apmpkg 1.4.1 +apmpkg \- manual page for apmpkg 1.5.0 .SH DESCRIPTION -ApmPKG v1.4.1 +ApmPKG v1.5.0 Kedap. A Package Manager as model: PKGBUILD .SS "USAGE:" diff --git a/man/apmpkg.1 b/man/apmpkg.1 index a5ef39a..cba2b3a 100644 --- a/man/apmpkg.1 +++ b/man/apmpkg.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.3. -.TH APMPKG "1" "June 2021" "apmpkg 1.4.1" "User Commands" +.TH APMPKG "1" "June 2021" "apmpkg 1.5.0" "User Commands" .SH NAME -apmpkg \- Pagina manual para ApmPKG 1.4.1 +apmpkg \- Pagina manual para ApmPKG 1.5.0 .SH DESCRIPTION -ApmPKG v1.4.1 +ApmPKG v1.5.0 Kedap. Un administrador de paquetes universal para linux como modelo PKGBUILD .SS "USAGE:" diff --git a/poa/APKBUILD b/poa/APKBUILD new file mode 100644 index 0000000..af2d588 --- /dev/null +++ b/poa/APKBUILD @@ -0,0 +1,26 @@ +# Contributor: kedap +# Maintainer: kedap +pkgname=apmpkg +pkgver=1.5.0 +pkgrel=0 +pkgdesc="A Package Manager as a model: PKGBUILD" +url="https://github.com/kedap/apmpkg" +arch="x86_64 armv7 armhf aarch64 x86 ppc64le" # limited by rust/cargo +license="Apache-2.0" +depends="git fakeroot wget ruby-bundler py3-pip rsync bash ruby-dev npm" +makedepends="openssl-dev" +source="$pkgname-$pkgver.tar.gz::https://github.com/kedap/apmpkg/archive/refs/tags/$pkgver.tar.gz" + +build() { + cargo build --release --locked --verbose +} + +package() { + install -Dm 755 target/release/apmpkg -t "$pkgdir"/usr/bin + mkdir -p "$pkgdir"/etc/apmpkg + cp -r src/iiabc "$pkgdir"/etc/apmpkg + mkdir -p $pkgdir/etc/apmpkg/paquetes +} + +sha512sums=" +0e7ba0c127c5e61f855917d0fa732bf776830492cd63410cce9b4c4d5cf1ef139e31e840496724b273e9bb99a6ce1b575fb5215b5709cd7e0237ebd8c0b696a0 apmpkg-1.5.0.tar.gz" diff --git a/poa/PKGBUILD b/poa/PKGBUILD new file mode 100644 index 0000000..4b95308 --- /dev/null +++ b/poa/PKGBUILD @@ -0,0 +1,36 @@ +# Maintainer: kedap + +pkgname=apmpkg +pkgver=1.5.0 +pkgrel=1 +pkgdesc="Un administrador de paquetes universal para linux como modelo: PKGBUILD" +arch=('x86_64') +url="https://github.com/Kedap/apmpkg" +license=('Apache') +optdepends=('flatpak: for install dependencies' + 'snapd: for install dependencies') +depends=('git' 'python-pip' 'python2-pip' 'wget' 'fakeroot' 'ruby-bundler' 'rsync' 'npm') +makedepends=('cargo') +conflicts=('apmpkg-git-dev' 'apmpkg-dev') +source=("https://github.com/kedap/${pkgname}/archive/refs/tags/${pkgver}.tar.gz") +sha256sums=('SKIP') + +build() { + cd "$pkgname-$pkgver" + cargo build --release --locked +} + +check() { + cd "$pkgname-$pkgver" + cargo test --release --locked +} + +package() { + cd "$pkgname-$pkgver" + install -Dm 755 "target/release/${pkgname}" -t "${pkgdir}/usr/bin" + mkdir -p ${pkgdir}/etc/apmpkg/iiabc + cp -r src/iiabc/ ${pkgdir}/etc/apmpkg/ + mkdir -p ${pkgdir}/etc/apmpkg/paquetes + install -Dm 644 "man/${pkgname}.1" -t ${pkgdir}/usr/share/man/man1 + install -Dm 644 "man/${pkgname}-en.1" -t ${pkgdir}/usr/share/man/man1 +} diff --git a/poa/apmpkg.abc b/poa/apmpkg.abc new file mode 100644 index 0000000..ee358f9 --- /dev/null +++ b/poa/apmpkg.abc @@ -0,0 +1,36 @@ +# Maintainer: kedap + +pkgname=apmpkg +pkgver=1.5.0 +pkgrel=1 +pkgdesc="Un administrador de paquetes universal para linux como modelo: PKGBUILD" +arch=('x86_64') +url="https://github.com/Kedap/apmpkg" +license=('Apache') +optdepends=('flatpak: for install dependencies' + 'snapd: for install dependencies') +depends=('git' 'python-pip' 'python2-pip' 'wget' 'fakeroot' 'ruby-bundler' 'rsync' 'npm') +makedepends=('cargo') +conflicts=('apmpkg-git-dev' 'apmpkg-dev') +source=("https://github.com/kedap/apmpkg/archive/refs/tags/${pkgver}.tar.gz") +sha256sums=('SKIP') + +build() { + cd "apmpkg-${pkgver}" + cargo build --release --locked +} + +check() { + cd "apmpkg-${pkgver}" + cargo test --release --locked +} + +package() { + cd "apmpkg-${pkgver}" + install -Dm 755 "target/release/${pkgname}" -t "${pkgdir}/usr/bin" + mkdir -p ${pkgdir}/etc/apmpkg/iiabc + cp -r src/iiabc/ ${pkgdir}/etc/apmpkg/ + mkdir -p ${pkgdir}/etc/apmpkg/paquetes + install -Dm 644 "man/${pkgname}.1" -t ${pkgdir}/usr/share/man/man1 + install -Dm 644 "man/${pkgname}-en.1" -t ${pkgdir}/usr/share/man/man1 +} diff --git a/poa/apmpkg.spec b/poa/apmpkg.spec new file mode 100644 index 0000000..960139c --- /dev/null +++ b/poa/apmpkg.spec @@ -0,0 +1,43 @@ +Name: apmpkg +Version: 1.5.0 +Release: 1%{?dist} +Summary: Package Manager + +License: Apache-2 +URL: https://github.com/kedap/apmpkg +Source0: %{version}.tar.gz + +BuildRequires: cargo, pkg-config, openssl-devel +Requires: git, python-pip, wget, fakeroot, rubygem-bundler, rsync, npm + +%description +A Package Manager as model: PKGBUILD + +%prep +%autosetup + + +%build +cargo build --release --locked + + +%install +rm -rf $RPM_BUILD_ROOT +install -Dm 755 "target/release/apmpkg" -t "%{buildroot}/usr/bin" +mkdir -p %{buildroot}/etc/apmpkg/iiabc +cp -r src/iiabc/ %{buildroot}/etc/apmpkg/ +mkdir -p %{buildroot}/etc/apmpkg/paquetes +install -Dm 644 "man/apmpkg.1" -t %{buildroot}/usr/share/man/man1 +install -Dm 644 "man/apmpkg-en.1" -t %{buildroot}/usr/share/man/man1 + + +%files +%license LICENSE +/usr/share/man/man1/* +/usr/bin/apmpkg +/etc/apmpkg/* + + +%changelog +* Wed Sep 29 2021 kedap +- Nix support and home files diff --git a/poa/control b/poa/control new file mode 100644 index 0000000..66cf46c --- /dev/null +++ b/poa/control @@ -0,0 +1,7 @@ +Package: apmpkg +Version: 1.5.0 +Priority: optional +Architecture: amd64 +Depends: git, python3-pip, wget, fakeroot, bundle, bundler, rsync, npm +Maintainer: kedap +Description: A Package Manager as model PKGBUILD diff --git a/poa/debian.sh b/poa/debian.sh new file mode 100644 index 0000000..506ee1b --- /dev/null +++ b/poa/debian.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +echo "Put the binary" +install -Dm 755 "target/release/apmpkg" -t "apmpkg/usr/bin" +if [[ $? -ne 0 ]]; then + echo "Oops... A error" + exit 1 +fi + +echo "Creating iiabc tree..." +mkdir -p apmpkg/etc/apmpkg/iiabc +if [[ $? -ne 0 ]]; then + echo "Oops... A error" + exit 1 +fi + +echo "Coping iiabc..." +cp -r src/iiabc/ apmpkg/etc/apmpkg/ +if [[ $? -ne 0 ]]; then + echo "Oops... A error" + exit 1 +fi + +echo "Make paquetes folder.." +mkdir -p apmpkg/etc/apmpkg/paquetes +if [[ $? -ne 0 ]]; then + echo "Oops... A error" + exit 1 +fi + +echo "Put manpage (español)" +install -Dm 644 "man/apmpkg.1" -t apmpkg/usr/share/man/man1 +if [[ $? -ne 0 ]]; then + echo "Oops... A error" + exit 1 +fi + +echo "Put manpage (english)" +install -Dm 644 "man/apmpkg-en.1" -t apmpkg/usr/share/man/man1 +if [[ $? -ne 0 ]]; then + echo "Oops... A error" + exit 1 +fi diff --git a/src/archivos.rs b/src/archivos.rs index db50f8b..35ffe3d 100644 --- a/src/archivos.rs +++ b/src/archivos.rs @@ -3,6 +3,7 @@ use { crate::estructuras::{Adi, AdiInstalacion, Fuente, GestoresLenguajes, MsgError}, flate2::{read::GzDecoder, write::GzEncoder, Compression}, + read_input::prelude::*, sha2::{Digest, Sha256}, std::{fs, fs::File, io, path::Path, process::Command}, tar::Archive, @@ -128,6 +129,7 @@ pub fn instalar_archivos(adi_instalacion: AdiInstalacion, carpeta_src: &str) { let fuente = adi_instalacion.fuente; let destino = adi_instalacion.destino; let carpeta_fuente = Path::new(carpeta_src); + let mut usuario = String::new(); for i in 0..fuente.len() { let archivo = carpeta_fuente.join(fuente[i].as_str().unwrap()); @@ -141,13 +143,68 @@ pub fn instalar_archivos(adi_instalacion: AdiInstalacion, carpeta_src: &str) { .expect("Algo fallo con install"); let _result = child.wait().unwrap(); } else { - let mut child = Command::new("rsync") - .arg("-a") - .arg(archivo) - .arg(destino[i].as_str().unwrap()) - .spawn() - .expect("Ocurrio un error con rsync"); - let _result = child.wait().unwrap(); + if Path::new(destino[i].as_str().unwrap()).is_relative() { + if usuario.is_empty() { + let directorys = match fs::read_dir("/home") { + Ok(v) => v, + Err(e) => { + let error = MsgError::new(&e.to_string()); + error.print_salir(); + panic!(); + } + }; + println!("¿Para que usuario quieres instalar este paquete?"); + for usuario in directorys { + println!( + "{}", + usuario + .unwrap() + .path() + .file_name() + .unwrap() + .to_str() + .unwrap() + ); + } + + print!("> "); + usuario = input().get(); + if usuario.is_empty() { + let error = MsgError::new("Eso no parece el nombre de un usuario"); + error.print_salir(); + } + + let destino_usuario = Path::new("/home") + .join(usuario.clone()) + .join(destino[i].as_str().unwrap()); + let mut child = Command::new("rsync") + .arg("-a") + .arg(archivo) + .arg(destino_usuario.to_str().unwrap()) + .spawn() + .expect("Ocurrio un error con rsync"); + let _result = child.wait().unwrap(); + } else { + let destino_usuario = Path::new("/home") + .join(usuario.clone()) + .join(destino[i].as_str().unwrap()); + let mut child = Command::new("rsync") + .arg("-a") + .arg(archivo) + .arg(destino_usuario.to_str().unwrap()) + .spawn() + .expect("Ocurrio un error con rsync"); + let _result = child.wait().unwrap(); + } + } else { + let mut child = Command::new("rsync") + .arg("-a") + .arg(archivo) + .arg(destino[i].as_str().unwrap()) + .spawn() + .expect("Ocurrio un error con rsync"); + let _result = child.wait().unwrap(); + } } } @@ -184,6 +241,8 @@ pub fn binario_completo(adi: Adi) -> bool { conservar = true; } else if let Fuente::Git(_repositorio) = adi.descarga.fuente { conservar = true; + } else if !adi.instalacion.pre_instalacion.is_empty() { + conservar = true; } else { conservar = true; } @@ -253,9 +312,53 @@ pub fn construir_binario(adi: Adi, ruta: &Path, ruta_adi: &str) { pub fn remover_archivos(adi: Adi) { let adi_descarga = adi.descarga.clone(); let adi_instalacion = adi.instalacion; + let mut usuario = String::new(); for archivos in adi_instalacion.destino { - remover_rm(&archivos.as_str().unwrap()); + if Path::new(archivos.as_str().unwrap()).is_relative() { + if usuario.is_empty() { + let directorys = match fs::read_dir("/home") { + Ok(v) => v, + Err(e) => { + let error = MsgError::new(&e.to_string()); + error.print_salir(); + panic!(); + } + }; + println!("¿Para que usuario quieres desinstalar este paquete?"); + for usuario in directorys { + println!( + "{}", + usuario + .unwrap() + .path() + .file_name() + .unwrap() + .to_str() + .unwrap() + ); + } + + print!("> "); + usuario = input().get(); + if usuario.is_empty() { + let error = MsgError::new("Eso no parece el nombre de un usuario"); + error.print_salir(); + } + + let destino_usuario = Path::new("/home") + .join(usuario.clone()) + .join(archivos.as_str().unwrap()); + remover_rm(destino_usuario.to_str().unwrap()); + } else { + let destino_usuario = Path::new("/home") + .join(usuario.clone()) + .join(archivos.as_str().unwrap()); + remover_rm(destino_usuario.to_str().unwrap()); + } + } else { + remover_rm(&archivos.as_str().unwrap()); + } } if adi_instalacion.fuente_opt { diff --git a/src/cli.yml b/src/cli.yml index 0dc9966..28ce900 100644 --- a/src/cli.yml +++ b/src/cli.yml @@ -1,5 +1,5 @@ name: ApmPKG -version: "v1.4.1" +version: "v1.5.0" author: Kedap. about: Un administrador de paquetes universal para linux como modelo PKGBUILD args: diff --git a/src/core_funcions.rs b/src/core_funcions.rs index b2b3537..4233de1 100644 --- a/src/core_funcions.rs +++ b/src/core_funcions.rs @@ -223,6 +223,12 @@ fn gestor(gestor: String) -> GestorNativo { instalacion: "add".to_string(), confirmacion: String::new(), }, + "nix" => GestorNativo { + nombre: "nix-env".to_string(), + buscar: "search".to_string(), + instalacion: "-i".to_string(), + confirmacion: String::new(), + }, "slapt-get" => GestorNativo { nombre: "slapt-get".to_string(), buscar: "--search".to_string(), @@ -266,6 +272,7 @@ pub fn instalar_dependencias(adi_paquete: AdiPaquete) -> bool { "zypper", "yum", "apk", + "nix", "slapt-get", "snap", "flatpak", @@ -303,12 +310,21 @@ pub fn instalar_dependencias(adi_paquete: AdiPaquete) -> bool { //); listo = true } else { - let mut child = Command::new(gestor.nombre.clone()) - .arg(gestor.buscar.clone()) - .arg(dependencia) - .spawn() - .expect("Ocurrio un error al buscar posibles dependencias"); - let _result = child.wait().unwrap(); + if gestor.nombre == "nix-env" { + let mut child = Command::new("nix") + .arg("search") + .arg(dependencia) + .spawn() + .expect("Ocurrio un error al buscar posibles dependencias"); + let _result = child.wait().unwrap(); + } else { + let mut child = Command::new(gestor.nombre.clone()) + .arg(gestor.buscar.clone()) + .arg(dependencia) + .spawn() + .expect("Ocurrio un error al buscar posibles dependencias"); + let _result = child.wait().unwrap(); + } println!( "\nQue paquete sastiface la dependencia {}?", dependencia.green() @@ -344,6 +360,7 @@ pub fn instalar_dependencia_vector(depen_arr: Vec) -> bool { "zypper", "yum", "apk", + "nix", "slapt-get", "snap", "flatpak", diff --git a/src/iiabc/core_fn.sh b/src/iiabc/core_fn.sh index 1ca7e40..bd110ff 100644 --- a/src/iiabc/core_fn.sh +++ b/src/iiabc/core_fn.sh @@ -2,7 +2,7 @@ #Variables de cajon NOMBRE='iiabc' -VERSION='1.4.1' +VERSION='1.5.0' TRUE=1 FALSE=0 ROJO='\033[91m' diff --git a/src/iiabc/iiabc.sh b/src/iiabc/iiabc.sh index 8dfb3a0..6f626cb 100644 --- a/src/iiabc/iiabc.sh +++ b/src/iiabc/iiabc.sh @@ -5,7 +5,7 @@ ################################################################ # # # Interpretador para la Instalacion con archivos .ABC (IIABC) # -# v1.4.1 # +# v1.5.0 # # # # Autor / Contribudores # # # @@ -94,6 +94,10 @@ create_bin(){ # Sumas if [ "$sha256sums" == "SKIP" ]; then warn "Omitiendo la suma sha256" + msg1 "Extrayendo fuentes..." + cd $src_dir + tar -xf source.tar.gz + cd .. else msg1 "Verificando la integridad de los archivos..." echo $sha256sums $pkgname.d/source.tar.gz | sha256sum -c > /dev/null 2>&1 diff --git a/src/main.rs b/src/main.rs index 11db3ab..f57736b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -127,6 +127,7 @@ fn crear(tipo: &str, nombre: &str) { std::process::Command::new("bash") .arg("/etc/apmpkg/iiabc/iiabc.sh") .arg("-bb") + .arg(nombre) .spawn() .expect("Algo fallo al crear el archivo .abc"); println!("La creacion del archivo {}.abc a sido correcta", nombre); diff --git a/src/metodos_de_instalacion.rs b/src/metodos_de_instalacion.rs index 3481272..f585d85 100644 --- a/src/metodos_de_instalacion.rs +++ b/src/metodos_de_instalacion.rs @@ -332,7 +332,7 @@ pub fn instalar_abi(ruta: &str, confirmacion: bool) { } } //Barra de progreso - let contador = 9; + let contador = 8; let mut pb = ProgressBar::new(contador); pb.format("(->.)"); @@ -378,17 +378,6 @@ pub fn instalar_abi(ruta: &str, confirmacion: bool) { adi.clone(), ); - pb.message("Ejecutando scripts pre-instalacion"); - pb.inc(); - if !adi.instalacion.pre_instalacion.is_empty() { - let pre_instalacion_hecha = - core_funcions::pre_instalacion(adi.instalacion.clone(), &ruta_archivos); - if !pre_instalacion_hecha { - let error = MsgError::new("Algo fallo al ejecutar los scripts pre-instalacion"); - error.print_salir(); - } - } - pb.message("Instalando archivos "); pb.inc(); let temporal = ruta_archivos.as_path(); @@ -415,19 +404,6 @@ pub fn instalar_abi(ruta: &str, confirmacion: bool) { adi.clone(), ); - pb.message("Ejecutando scripts pre-instalacion"); - pb.inc(); - if !adi.instalacion.pre_instalacion.is_empty() { - let pre_instalacion_hecha = core_funcions::pre_instalacion( - adi.instalacion.clone(), - ruta_proyecto.as_path(), - ); - if !pre_instalacion_hecha { - let error = MsgError::new("Algo fallo al ejecutar el script pre-instalacion"); - error.print_salir(); - } - } - pb.message("Instalando archivos"); pb.inc(); let temporal = ruta_proyecto.as_path(); @@ -526,7 +502,7 @@ pub fn remover_adi(nombre: &str, confirmacion: bool) { } pub fn construir_binario_adi(ruta: &str) { - let mut pb = ProgressBar::new(5); + let mut pb = ProgressBar::new(7); pb.format("(->.)"); pb.message("Leyendo archivo "); pb.inc(); @@ -634,6 +610,19 @@ pub fn construir_binario_adi(ruta: &str) { } } + pb.message("Ejecutando scripts pre-instalacion"); + pb.inc(); + if !adi.instalacion.pre_instalacion.is_empty() { + let pre_instalacion_hecha = core_funcions::pre_instalacion( + adi.instalacion.clone(), + directorio.join(adi.descarga.carpeta.clone()).as_path(), + ); + if !pre_instalacion_hecha { + let error = MsgError::new("Ocurrio un error al ejecutar el script post instalacion"); + error.print_salir() + } + } + pb.message("Construyendo binario "); pb.inc(); archivos::construir_binario(adi, &directorio, ruta); diff --git a/src/tests.rs b/src/tests.rs index db44fd6..9e2254c 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,15 +1,18 @@ -use crate::{archivos, estructuras::Adi}; +use { + crate::{archivos, estructuras::Adi}, + std::path::PathBuf, + testdir::testdir, +}; #[test] fn descarga_test() { - let testeo = archivos::descarga( + let dir: PathBuf = testdir!(); + let path = dir.join("nspawn.adi"); + let _testeo = archivos::descarga( "https://raw.githubusercontent.com/Kedap/apmpkg/main/ejemplos/nspawn.adi", - "testdir/test_descarga.adi", - ); - match testeo { - Err(e) => panic!("fallo el test de descarga: {}", e), - _ => {} - } + path.to_str().unwrap(), + ) + .unwrap(); } #[test] @@ -19,9 +22,7 @@ fn leer_adi_test() { #[test] fn extraer_tar_test() { - let testeo = archivos::extraer_tar("testdir/test-tar.tar.gz", "testdir/extraer_tar.d"); - match testeo { - Err(e) => panic!("fallo al test de extraer tar: {}", e), - _ => {} - } + let dir: PathBuf = testdir!(); + let path = dir.join("tar_extraido/"); + let _testeo = archivos::extraer_tar("testdir/test-tar.tar.gz", path.to_str().unwrap()).unwrap(); }