├── .github ├── codeql │ └── codeql-config.yaml └── workflows │ ├── ci.yaml │ ├── codeql.yaml │ ├── coverity-scan.yml │ └── doxygen.yaml ├── .gitignore ├── .travis.yml ├── 3RDPARTY ├── AUTHORS ├── LICENSE ├── LICENSE.3RDPARTY ├── Makefile ├── NEWS ├── README.md ├── TODO ├── bin ├── Makefile ├── xbps-alternatives │ ├── Makefile │ ├── main.c │ └── xbps-alternatives.1 ├── xbps-checkvers │ ├── Makefile │ ├── main.c │ └── xbps-checkvers.1 ├── xbps-create │ ├── Makefile │ ├── main.c │ └── xbps-create.1 ├── xbps-dgraph │ ├── Makefile │ ├── main.c │ └── xbps-dgraph.1 ├── xbps-digest │ ├── Makefile │ ├── main.c │ └── xbps-digest.1 ├── xbps-fbulk │ ├── Makefile │ ├── main.c │ └── xbps-fbulk.1 ├── xbps-fetch │ ├── Makefile │ ├── main.c │ └── xbps-fetch.1 ├── xbps-install │ ├── Makefile │ ├── defs.h │ ├── fetch_cb.c │ ├── main.c │ ├── question.c │ ├── state_cb.c │ ├── transaction.c │ ├── util.c │ └── xbps-install.1 ├── xbps-pkgdb │ ├── Makefile │ ├── check.c │ ├── check_pkg_alternatives.c │ ├── check_pkg_files.c │ ├── check_pkg_rundeps.c │ ├── check_pkg_symlinks.c │ ├── check_pkg_unneeded.c │ ├── defs.h │ ├── main.c │ └── xbps-pkgdb.1 ├── xbps-query │ ├── Makefile │ ├── defs.h │ ├── list.c │ ├── main.c │ ├── ownedby.c │ ├── search.c │ ├── show-deps.c │ ├── show-info-files.c │ └── xbps-query.1 ├── xbps-reconfigure │ ├── Makefile │ ├── defs.h │ ├── find-deps.c │ ├── main.c │ └── xbps-reconfigure.1 ├── xbps-remove │ ├── Makefile │ ├── clean-cache.c │ ├── defs.h │ ├── main.c │ └── xbps-remove.1 ├── xbps-rindex │ ├── Makefile │ ├── defs.h │ ├── index-add.c │ ├── index-clean.c │ ├── main.c │ ├── remove-obsoletes.c │ ├── repoflush.c │ ├── sign.c │ └── xbps-rindex.1 ├── xbps-uchroot │ ├── Makefile │ ├── main.c │ └── xbps-uchroot.1 ├── xbps-uhelper │ ├── Makefile │ ├── main.c │ └── xbps-uhelper.1 └── xbps-uunshare │ ├── Makefile │ ├── main.c │ └── xbps-uunshare.1 ├── configure ├── data ├── 60:ae:0c:d6:f0:95:17:80:bc:93:46:7a:89:af:a3:2d.plist ├── Makefile ├── _xbps ├── _xbps_src ├── libxbps.pc.in ├── repod-main.conf ├── xbps.bash ├── xbps.conf └── xbps.d.5 ├── doc ├── Makefile ├── images │ └── .gitignore ├── xbps-logo.png ├── xbps_api_doxyfile.in ├── xbps_binary_pkg_content.dot ├── xbps_pkg_files_dictionary.dot ├── xbps_pkg_props_dictionary.dot ├── xbps_pkgdb_dictionary.dot └── xbps_transaction_dictionary.dot ├── include ├── Makefile ├── compat.h ├── mainpage.h ├── queue.h ├── uthash.h ├── xbps.h.in ├── xbps │ ├── xbps_array.h │ ├── xbps_bool.h │ ├── xbps_data.h │ ├── xbps_dictionary.h │ ├── xbps_number.h │ ├── xbps_object.h │ └── xbps_string.h └── xbps_api_impl.h ├── lib ├── Makefile ├── archive.c ├── cb_util.c ├── compat │ ├── humanize_number.c │ ├── strcasestr.c │ ├── strlcat.c │ ├── strlcpy.c │ └── vasprintf.c ├── conf.c ├── download.c ├── external │ ├── dewey.c │ ├── fexec.c │ └── mkpath.c ├── fetch │ ├── common.c │ ├── common.h │ ├── errlist.sh │ ├── fetch.c │ ├── fetch.h │ ├── file.c │ ├── ftp.c │ ├── ftp.errors │ ├── http.c │ └── http.errors ├── initend.c ├── log.c ├── package_alternatives.c ├── package_config_files.c ├── package_configure.c ├── package_fulldeptree.c ├── package_orphans.c ├── package_register.c ├── package_remove.c ├── package_script.c ├── package_state.c ├── package_unpack.c ├── pkgdb.c ├── pkgdb_conversion.c ├── plist.c ├── plist_fetch.c ├── plist_find.c ├── plist_match.c ├── plist_remove.c ├── portableproplib │ ├── prop │ │ ├── prop_array.h │ │ ├── prop_bool.h │ │ ├── prop_data.h │ │ ├── prop_dictionary.h │ │ ├── prop_ingest.h │ │ ├── prop_number.h │ │ ├── prop_object.h │ │ ├── prop_string.h │ │ ├── proplib.h │ │ └── rbtree.h │ ├── prop_array.c │ ├── prop_array_util.c │ ├── prop_bool.c │ ├── prop_data.c │ ├── prop_dictionary.c │ ├── prop_dictionary_util.c │ ├── prop_ingest.c │ ├── prop_number.c │ ├── prop_object.c │ ├── prop_object_impl.h │ ├── prop_rb_impl.h │ ├── prop_stack.c │ ├── prop_stack.h │ ├── prop_string.c │ ├── prop_zlib.c │ └── rb.c ├── proplib_wrapper.c ├── pubkey2fp.c ├── repo.c ├── repo_sync.c ├── rpool.c ├── transaction_check_conflicts.c ├── transaction_check_replaces.c ├── transaction_check_revdeps.c ├── transaction_check_shlibs.c ├── transaction_commit.c ├── transaction_fetch.c ├── transaction_files.c ├── transaction_internalize.c ├── transaction_ops.c ├── transaction_pkg_deps.c ├── transaction_prepare.c ├── transaction_store.c ├── util.c ├── util_hash.c ├── util_path.c └── verifysig.c ├── mk ├── prog.mk ├── subdir.mk └── test.mk ├── run-tests └── tests ├── Makefile └── xbps ├── Kyuafile ├── Makefile ├── common └── Makefile ├── libxbps ├── Kyuafile ├── Makefile ├── Makefile.inc ├── cmpver │ ├── Kyuafile │ ├── Makefile │ └── main.c ├── common │ └── Makefile ├── config │ ├── 1.include.cf │ ├── 2.include.cf │ ├── Kyuafile │ ├── Makefile │ ├── main.c │ ├── no-trailing-nl.cf │ ├── trim.cf │ ├── xbps.cf │ ├── xbps_absolute.cf │ ├── xbps_absolute_glob.cf │ └── xbps_nomatch.cf ├── find_pkg_orphans │ ├── Kyuafile │ ├── Makefile │ ├── main.c │ └── pkgdb-0.38.plist ├── pkgdb │ ├── Kyuafile │ ├── Makefile │ ├── main.c │ └── pkgdb-0.38.plist ├── pkgpattern_match │ ├── Kyuafile │ ├── Makefile │ └── main.c ├── plist_match │ ├── Kyuafile │ ├── Makefile │ └── main.c ├── plist_match_virtual │ ├── Kyuafile │ ├── Makefile │ └── main.c ├── shell │ ├── Kyuafile │ ├── Makefile │ ├── conf_files_test.sh │ ├── configure_test.sh │ ├── conflicts_test.sh │ ├── cyclic_deps_test.sh │ ├── hold_test.sh │ ├── ignore_test.sh │ ├── incorrect_deps_test.sh │ ├── install_test.sh │ ├── installmode_test.sh │ ├── issue18_test.sh │ ├── issue20_test.sh │ ├── issue31_test.sh │ ├── issue6_test.sh │ ├── noextract_files_test.sh │ ├── obsoletefiles_test.sh │ ├── orphans_test.sh │ ├── preserve_files_test.sh │ ├── preserve_test.sh │ ├── remove_test.sh │ ├── replace_test.sh │ ├── repo_test.sh │ ├── scripts_test.sh │ ├── transaction_check_revdeps_test.sh │ ├── update_hold_test.sh │ ├── update_itself_test.sh │ ├── update_repolock_test.sh │ ├── update_shlibs_test.sh │ └── vpkg_test.sh ├── util │ ├── Kyuafile │ ├── Makefile │ └── main.c └── util_path │ ├── Kyuafile │ ├── Makefile │ └── main.c ├── xbps-alternatives ├── Kyuafile ├── Makefile └── main_test.sh ├── xbps-checkvers ├── Kyuafile ├── Makefile └── checkvers_test.sh ├── xbps-create ├── Kyuafile ├── Makefile └── basic_test.sh ├── xbps-digest ├── Kyuafile ├── Makefile └── basic_test.sh ├── xbps-fetch ├── Kyuafile ├── Makefile └── fetch_test.sh ├── xbps-install ├── Kyuafile ├── Makefile ├── behaviour_tests.sh └── revert_tests.sh ├── xbps-query ├── Kyuafile ├── Makefile ├── ignore_repos_test.sh ├── list_test.sh ├── query_test.sh └── remote_test.sh ├── xbps-remove ├── Kyuafile ├── Makefile └── basic_test.sh ├── xbps-rindex ├── Kyuafile ├── Makefile ├── add_test.sh ├── clean_test.sh └── remove_test.sh └── xbps-uhelper ├── Kyuafile ├── Makefile └── arch_test.sh /.github/codeql/codeql-config.yaml: -------------------------------------------------------------------------------- 1 | queries: 2 | - uses: security-extended 3 | - uses: security-and-quality 4 | paths-ignore: 5 | - tests/** 6 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - 'master' 7 | - 'ci-**' 8 | 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref }} 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | testsuite: 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | c_library: [glibc, musl] 19 | c_compiler: [gcc, clang] 20 | include: 21 | - c_library: glibc 22 | void_image: ghcr.io/void-linux/void-glibc-full:20230830r1 23 | 24 | - c_library: musl 25 | void_image: ghcr.io/void-linux/void-musl-full:20230830r1 26 | 27 | runs-on: ubuntu-latest 28 | container: ${{ matrix.void_image }} 29 | steps: 30 | - uses: actions/checkout@v1 31 | - name: Prepare container 32 | run: | 33 | xbps-install -Syu xbps; xbps-install -Syu 34 | xbps-install -Sy ${{ matrix.c_compiler }} ${{ matrix.extra_deps }} make pkg-config zlib-devel openssl-devel libarchive-devel kyua atf-devel 35 | - name: Build 36 | env: 37 | CC: ${{ matrix.c_compiler }} 38 | run: | 39 | ./configure --enable-tests 40 | make -j 41 | - name: Check 42 | run: make check 43 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yaml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | schedule: 9 | - cron: '0 0 * * 0' 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | analyze: 17 | name: Analyze 18 | runs-on: ubuntu-latest 19 | permissions: 20 | actions: read 21 | contents: read 22 | security-events: write 23 | container: 24 | image: ghcr.io/void-linux/void-glibc-full:20240526R1 25 | steps: 26 | - name: Prepare container 27 | run: | 28 | xbps-install -Syu xbps 29 | xbps-install -yu 30 | # node-based actions require libstdc++.so.6 31 | # codeql runs some bash scripts 32 | xbps-install -Sy \ 33 | libstdc++ bash git \ 34 | gcc make pkg-config zlib-devel openssl-devel libarchive-devel 35 | - name: Checkout repository 36 | uses: actions/checkout@v3 37 | - run: git config --global --add safe.directory $(pwd) 38 | - name: Initialize CodeQL 39 | uses: github/codeql-action/init@v3 40 | with: 41 | languages: cpp 42 | config-file: ./.github/codeql/codeql-config.yaml 43 | - name: Build xbps 44 | run: | 45 | ./configure 46 | make -j 47 | - name: Perform CodeQL Analysis 48 | uses: github/codeql-action/analyze@v3 49 | with: 50 | category: "/language:cpp" 51 | -------------------------------------------------------------------------------- /.github/workflows/coverity-scan.yml: -------------------------------------------------------------------------------- 1 | # based on https://github.com/ruby/actions-coverity-scan/blob/282dd059/.github/workflows/coverity-scan.yml 2 | name: coverity-scan 3 | on: 4 | schedule: 5 | - cron: '0 18 * * *' # Daily at 18:00 UTC 6 | workflow_dispatch: 7 | 8 | jobs: 9 | latest: 10 | if: github.repository == 'void-linux/xbps' 11 | runs-on: ubuntu-latest 12 | container: ghcr.io/void-linux/void-glibc-full:20230830r1 13 | env: 14 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 15 | steps: 16 | - uses: actions/checkout@v1 17 | 18 | - name: Updating and installing packages 19 | run: | 20 | xbps-install -Suy xbps; xbps-install -Suy 21 | xbps-install -Sy gcc make pkgconf kyua zlib-devel libarchive-devel atf-devel curl 22 | 23 | - name: Download Coverity Build Tool 24 | run: | 25 | curl -L -o cov-analysis-linux64.tar.gz --data "token=$TOKEN&project=void-linux%2Fxbps" https://scan.coverity.com/download/linux64 26 | mkdir cov-analysis-linux64 27 | tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64 28 | 29 | 30 | - name: Configure and build 31 | run: | 32 | CC=gcc ./configure --enable-tests 33 | PATH=$PWD/cov-analysis-linux64/bin:$PATH cov-build --dir cov-int make -j$(nproc) 34 | 35 | - name: Submit the result to Coverity Scan 36 | run: | 37 | tar czvf xbps.tgz --ignore-failed-read cov-int 38 | curl \ 39 | --form project=xbps \ 40 | --form token=$TOKEN \ 41 | --form email=github@voidlinux.org \ 42 | --form file=@xbps.tgz \ 43 | --form version=trunk \ 44 | --form description="github action coverity scan" \ 45 | https://scan.coverity.com/builds?project=void-linux%2Fxbps 46 | -------------------------------------------------------------------------------- /.github/workflows/doxygen.yaml: -------------------------------------------------------------------------------- 1 | name: Deploy Doxygen 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | workflow_dispatch: 7 | 8 | permissions: 9 | contents: read 10 | pages: write 11 | id-token: write 12 | 13 | concurrency: 14 | group: ${{ github.workflow }} 15 | cancel-in-progress: true 16 | 17 | jobs: 18 | build: 19 | runs-on: ubuntu-latest 20 | container: ghcr.io/void-linux/void-glibc-full:20230830r1 21 | steps: 22 | - name: Prepare container 23 | run: | 24 | xbps-install -Syu xbps; xbps-install -Syu 25 | xbps-install -Sy bash git gcc make pkg-config zlib-devel openssl-devel libarchive-devel doxygen graphviz 26 | - uses: classabbyamp/treeless-checkout-action@v1 27 | - name: Build 28 | run: | 29 | ./configure --enable-api-docs 30 | make -j -C include && make -j -C doc 31 | rm -rf ./api/html/Nodes.xml Info.plist Makefile Tokens.xml 32 | - name: Upload artifact 33 | uses: actions/upload-pages-artifact@v3 34 | with: 35 | path: ./api/html 36 | deploy: 37 | environment: 38 | name: github-pages 39 | url: ${{ steps.deployment.outputs.page_url }} 40 | runs-on: ubuntu-latest 41 | needs: build 42 | steps: 43 | - name: Deploy to GitHub Pages 44 | id: deployment 45 | uses: actions/deploy-pages@v4 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | 3 | config.h 4 | config.mk 5 | bin/xbps-alternatives/xbps-alternatives 6 | bin/xbps-create/xbps-create 7 | bin/xbps-dgraph/xbps-dgraph 8 | bin/xbps-fbulk/xbps-fbulk 9 | bin/xbps-install/xbps-install 10 | bin/xbps-pkgdb/xbps-pkgdb 11 | bin/xbps-query/xbps-query 12 | bin/xbps-reconfigure/xbps-reconfigure 13 | bin/xbps-remove/xbps-remove 14 | bin/xbps-rindex/xbps-rindex 15 | bin/xbps-uhelper/xbps-uhelper 16 | bin/xbps-uchroot/xbps-uchroot 17 | bin/xbps-checkvers/xbps-checkvers 18 | bin/xbps-uunshare/xbps-uunshare 19 | bin/xbps-digest/xbps-digest 20 | bin/xbps-fetch/xbps-fetch 21 | *.static 22 | *.so* 23 | *.o 24 | *.a 25 | *.xml 26 | *.png 27 | *.pc 28 | api/ 29 | doc/xbps_api_doxyfile 30 | ftperr.h 31 | httperr.h 32 | tests/*/*/*/*_test 33 | tests/*/*/*/*_tests 34 | tests/*/*/*_test 35 | tests/*/*/*_tests 36 | include/xbps.h 37 | 38 | # vim backup files 39 | .*.swp 40 | *~ 41 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | 3 | dist: bionic 4 | 5 | notifications: 6 | email: false 7 | 8 | services: 9 | - docker 10 | 11 | env: 12 | matrix: 13 | - CC=gcc IMG=voidlinux/voidlinux DEPS="gcc glibc-devel" 14 | - CC=clang IMG=voidlinux/voidlinux DEPS="clang glibc-devel" 15 | - CC=gcc IMG=voidlinux/voidlinux-musl DEPS="gcc musl-devel" 16 | - CC=clang IMG=voidlinux/voidlinux-musl DEPS="clang musl-devel" 17 | - CC=pcc IMG=voidlinux/voidlinux-musl DEPS="pcc binutils musl-devel" 18 | 19 | install: 20 | - docker pull "$IMG" 21 | - docker run -v "$PWD":/tmp/build-dir -w "/tmp/build-dir" "$IMG" /bin/sh -c "xbps-install -Syu xbps && xbps-install -yu && xbps-install -y $DEPS make pkgconf kyua zlib-devel libarchive-devel atf-devel && CC=$CC ./configure --enable-tests && make -j$(nproc) && make check" 22 | 23 | script: 24 | - echo BUILDS PASSED 25 | -------------------------------------------------------------------------------- /3RDPARTY: -------------------------------------------------------------------------------- 1 | XBPS includes the following software from third parties for 2 | internal use in the code: 3 | 4 | - queue.h from NetBSD: include/queue.h. 5 | 6 | - relational dewey version matching code from NetBSD: 7 | lib/external/dewey.c 8 | 9 | - strlcat and strlcpy functions from OpenBSD: 10 | lib/compat/strlc{at,cpy}.c 11 | 12 | - humanize_number(3) from NetBSD: lib/external/humanize_number.c 13 | 14 | - mkpath from NetBSD's mkdir(1): lib/external/mkpath.c 15 | 16 | - fexec from NetBSD's pkg_install: lib/external/fexec.c 17 | 18 | - libfetch-2.34 from NetBSD (pkgsrc/net/libfetch): lib/fetch 19 | 20 | - portableproplib-0.6.8 (lib/portableproplib) from 21 | https://github.com/xtraeme/portableproplib 22 | 23 | - uthash-2.1.0 (include/uthash.h) from 24 | http://troydhanson.github.com/uthash/ 25 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Juan Romero Pardines 2 | Enno Boland 3 | Duncan Overbruck 4 | 5 | Thanks to many others that also have contributed: 6 | 7 | Michael Gehring 8 | Piotr Wójcik 9 | Johannes Brechtmann 10 | Eivind Uggedal 11 | human 12 | davehome 13 | q66 14 | Roman Neuhauser 15 | Leah Neukirchen 16 | Wolfgang Draxinger 17 | Steve Prybylski 18 | Agustin Chiappe Berrini 19 | Cameron Nemo 20 | Giedrius Statkevičius 21 | Foxlet 22 | Joey Gouly 23 | Piraty 24 | Robert Lowry 25 | Eli Schwartz 26 | Andreas Kempe 27 | Toyam Cox 28 | Jan Tatje 29 | Jakukyo Friel 30 | Frank Steinborn 31 | Ingo Blechschmidt 32 | Christopher Brannon 33 | Bheesham Persaud 34 | Anthony Iliopoulos 35 | Andrea Brancaleoni 36 | Mohamad Barbar 37 | Natanael Copa 38 | Wqer555 39 | Yuxuan Shui 40 | Alain Kalker 41 | Aleksej Lebedev 42 | Josh de Kock 43 | m3tav3rse 44 | kayvenm 45 | ojab 46 | parke 47 | sineemore 48 | wuhanck 49 | yupi2 50 | Đoàn Trần Công Danh 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2020 Juan Romero Pardines 2 | Copyright (c) 2014-2019 Enno Boland 3 | Copyright (c) 2016-2019 Duncan Overbruck 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | -include config.mk 2 | 3 | SUBDIRS = include lib bin data 4 | 5 | ifdef BUILD_API_DOCS 6 | SUBDIRS += doc 7 | endif 8 | 9 | ifdef BUILD_TESTS 10 | SUBDIRS += tests 11 | endif 12 | 13 | all: 14 | @if test ! -e config.mk; then \ 15 | echo "You didn't run ./configure ... exiting."; \ 16 | exit 1; \ 17 | fi 18 | @for dir in $(SUBDIRS); do \ 19 | $(MAKE) -C $$dir || exit 1; \ 20 | done 21 | 22 | install: all 23 | @for dir in $(SUBDIRS); do \ 24 | $(MAKE) -C $$dir install || exit 1; \ 25 | done 26 | install -d $(DESTDIR)$(SHAREDIR)/licenses/xbps 27 | install -m644 ./LICENSE $(DESTDIR)$(SHAREDIR)/licenses/xbps 28 | install -m644 ./LICENSE.3RDPARTY $(DESTDIR)$(SHAREDIR)/licenses/xbps 29 | 30 | uninstall: 31 | @for dir in $(SUBDIRS); do \ 32 | $(MAKE) -C $$dir uninstall || exit 1; \ 33 | done 34 | 35 | check: all 36 | -rm -f result.db* 37 | @./run-tests 38 | 39 | clean: 40 | @for dir in $(SUBDIRS); do \ 41 | $(MAKE) -C $$dir clean || exit 1; \ 42 | done 43 | -rm -f result* config.mk _ccflag.{,c,err} 44 | 45 | .PHONY: all install uninstall check clean 46 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | libxbps: 2 | - transaction: avoid fetching the whole pkg when updating and only fetch 3 | modified files from target pkg. 4 | - transaction: check for free space in all affected top-level dirs. 5 | - transaction: check all pkg top-level dirs to see if they are writable. 6 | - cache: download cached packages and signatures into a per repository 7 | directory like repodata files in /var/db/xbps 8 | 9 | xbps-*: 10 | - Document exit codes. 11 | 12 | xbps-create: 13 | - Move all configuration files to /share//conf/. 14 | - Add -i --installed option to create binpkg from an installed version. 15 | 16 | xbps-fetch: 17 | - stdout support 18 | - configurable libfetch timeout 19 | - configurable number of connection retries 20 | 21 | xbps-digest: 22 | - blake2b support 23 | 24 | Issues listed at https://github.com/void-linux/xbps/issues 25 | -------------------------------------------------------------------------------- /bin/Makefile: -------------------------------------------------------------------------------- 1 | -include ../config.mk 2 | 3 | SUBDIRS += xbps-alternatives 4 | SUBDIRS += xbps-create 5 | SUBDIRS += xbps-dgraph 6 | SUBDIRS += xbps-install 7 | SUBDIRS += xbps-pkgdb 8 | SUBDIRS += xbps-query 9 | SUBDIRS += xbps-reconfigure 10 | SUBDIRS += xbps-remove 11 | SUBDIRS += xbps-rindex 12 | SUBDIRS += xbps-uhelper 13 | SUBDIRS += xbps-checkvers 14 | SUBDIRS += xbps-fbulk 15 | SUBDIRS += xbps-digest 16 | SUBDIRS += xbps-fetch 17 | 18 | ifeq (${XBPS_OS},linux) 19 | SUBDIRS += xbps-uchroot 20 | SUBDIRS += xbps-uunshare 21 | endif 22 | 23 | include ../mk/subdir.mk 24 | -------------------------------------------------------------------------------- /bin/xbps-alternatives/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-alternatives 5 | 6 | include $(TOPDIR)/mk/prog.mk 7 | -------------------------------------------------------------------------------- /bin/xbps-checkvers/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | EXTRA_CFLAGS += -Wno-deprecated-declarations 5 | 6 | BIN = xbps-checkvers 7 | 8 | include $(TOPDIR)/mk/prog.mk 9 | -------------------------------------------------------------------------------- /bin/xbps-create/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-create 5 | 6 | include $(TOPDIR)/mk/prog.mk 7 | -------------------------------------------------------------------------------- /bin/xbps-dgraph/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-dgraph 5 | 6 | include $(TOPDIR)/mk/prog.mk 7 | -------------------------------------------------------------------------------- /bin/xbps-digest/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-digest 5 | OBJS = main.o 6 | 7 | include $(TOPDIR)/mk/prog.mk 8 | -------------------------------------------------------------------------------- /bin/xbps-digest/main.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2019 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | static void __attribute__((noreturn)) 37 | usage(bool fail) 38 | { 39 | fprintf(stdout, 40 | "Usage: xbps-digest [options] [file] [file+N]\n" 41 | "\n" 42 | "OPTIONS\n" 43 | " -h, --help Show usage\n" 44 | " -m, --mode Selects the digest mode, sha256 (default)\n" 45 | " -V, --version Show XBPS version\n" 46 | "\nNOTES\n" 47 | " If [file] not set, reads from stdin\n"); 48 | exit(fail ? EXIT_FAILURE : EXIT_SUCCESS); 49 | } 50 | 51 | int 52 | main(int argc, char **argv) 53 | { 54 | int c; 55 | char sha256[XBPS_SHA256_SIZE]; 56 | const char *mode = NULL, *progname = argv[0]; 57 | const struct option longopts[] = { 58 | { "mode", required_argument, NULL, 'm' }, 59 | { "help", no_argument, NULL, 'h' }, 60 | { "version", no_argument, NULL, 'V' }, 61 | { NULL, 0, NULL, 0 } 62 | }; 63 | 64 | while ((c = getopt_long(argc, argv, "m:hV", longopts, NULL)) != -1) { 65 | switch (c) { 66 | case 'h': 67 | usage(false); 68 | /* NOTREACHED */ 69 | case 'm': 70 | mode = optarg; 71 | break; 72 | case 'V': 73 | printf("%s\n", XBPS_RELVER); 74 | exit(EXIT_SUCCESS); 75 | case '?': 76 | default: 77 | usage(true); 78 | /* NOTREACHED */ 79 | } 80 | } 81 | 82 | argc -= optind; 83 | argv += optind; 84 | 85 | if (mode && strcmp(mode, "sha256")) { 86 | /* sha256 is the only supported mode currently */ 87 | xbps_error_printf("%s: unsupported digest mode\n", progname); 88 | exit(EXIT_FAILURE); 89 | } 90 | 91 | if (argc < 1) { 92 | if (!xbps_file_sha256(sha256, sizeof sha256, "/dev/stdin")) 93 | exit(EXIT_FAILURE); 94 | 95 | printf("%s\n", sha256); 96 | } else { 97 | for (int i = 0; i < argc; i++) { 98 | if (!xbps_file_sha256(sha256, sizeof sha256, argv[i])) { 99 | xbps_error_printf( 100 | "%s: couldn't get hash for %s (%s)\n", 101 | progname, argv[i], strerror(errno)); 102 | exit(EXIT_FAILURE); 103 | } 104 | printf("%s\n", sha256); 105 | } 106 | } 107 | exit(EXIT_SUCCESS); 108 | } 109 | -------------------------------------------------------------------------------- /bin/xbps-digest/xbps-digest.1: -------------------------------------------------------------------------------- 1 | .Dd Feb 9, 2023 2 | .Dt XBPS-DIGEST 1 3 | .Os 4 | .Sh NAME 5 | .Nm xbps-digest 6 | .Nd XBPS utility to generate message digests 7 | .Sh SYNOPSIS 8 | .Nm 9 | .Op OPTIONS 10 | .Op FILE 11 | .Op FILE+N 12 | .Sh DESCRIPTION 13 | The 14 | .Nm 15 | utility generates message digests for specified 16 | .Ar FILE 17 | or 18 | .Ar stdin 19 | if unset. 20 | .Sh OPTIONS 21 | .Bl -tag -width -x 22 | .It Fl m, Fl -mode Ar mode 23 | Sets the message digest mode. Supported: 24 | .Ar sha256 . 25 | If unset, defaults to 26 | .Ar sha256 . 27 | .It Fl h, Fl -help 28 | Show the help message. 29 | .It Fl V, Fl -version 30 | Show the version information. 31 | .El 32 | .Sh SEE ALSO 33 | .Xr xbps-alternatives 1 , 34 | .Xr xbps-checkvers 1 , 35 | .Xr xbps-create 1 , 36 | .Xr xbps-dgraph 1 , 37 | .Xr xbps-fbulk 1 , 38 | .Xr xbps-fetch 1 , 39 | .Xr xbps-install 1 , 40 | .Xr xbps-pkgdb 1 , 41 | .Xr xbps-query 1 , 42 | .Xr xbps-reconfigure 1 , 43 | .Xr xbps-remove 1 , 44 | .Xr xbps-rindex 1 , 45 | .Xr xbps-uchroot 1 , 46 | .Xr xbps-uunshare 1 , 47 | .Xr xbps.d 5 48 | .Sh AUTHORS 49 | .An Juan Romero Pardines Aq Mt xtraeme@gmail.com 50 | .Sh BUGS 51 | Probably, but I try to make this not happen. Use it under your own 52 | responsibility and enjoy your life. 53 | .Pp 54 | Report bugs at 55 | .Lk https://github.com/void-linux/xbps/issues 56 | -------------------------------------------------------------------------------- /bin/xbps-fbulk/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-fbulk 5 | 6 | include $(TOPDIR)/mk/prog.mk 7 | -------------------------------------------------------------------------------- /bin/xbps-fetch/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-fetch 5 | OBJS = main.o ../xbps-install/fetch_cb.o 6 | 7 | include $(TOPDIR)/mk/prog.mk 8 | -------------------------------------------------------------------------------- /bin/xbps-fetch/xbps-fetch.1: -------------------------------------------------------------------------------- 1 | .Dd Feb 9, 2023 2 | .Dt XBPS-FETCH 1 3 | .Os 4 | .Sh NAME 5 | .Nm xbps-fetch 6 | .Nd XBPS utility to fetch files from URLs 7 | .Sh SYNOPSIS 8 | .Nm 9 | .Op OPTIONS 10 | .Ar 11 | .Ar 12 | .Sh DESCRIPTION 13 | The 14 | .Nm 15 | utility downloads files from specified URLs. 16 | Multiple protocols are supported: 17 | .Ar ftp , 18 | .Ar http , 19 | .Ar https , 20 | .Ar socks5 . 21 | .Sh OPTIONS 22 | .Bl -tag -width -x 23 | .It Fl d 24 | Enables debug messages on stderr. 25 | .It Fl h 26 | Show the help message. 27 | .It Fl o Ar output 28 | Rename file from specified URL to 29 | .Ar output . 30 | .It Fl v 31 | Enables verbose messages. 32 | .It Fl s 33 | Print sha256sums of downloaded files. 34 | .It Fl V 35 | Show the version information. 36 | .El 37 | .Sh ENVIRONMENT 38 | .Bl -tag -width -x 39 | .It Sy FORCE_IPV4 40 | Only use IPv4. 41 | .It Sy FORCE_IPV6 42 | Only use IPv6. 43 | .It Sy FTP_PASSIVE_MODE 44 | If set to anything else than 45 | .Ar "no" 46 | passive mode will be set for the ftp connection. 47 | .It Sy FTP_LOGIN 48 | User name to be set for ftp authentication. 49 | .It Sy FTP_PASSWORD 50 | Password to be set for ftp authentication. 51 | .It Sy FTP_PROXY 52 | Proxy URL that will be used to establish a ftp connection. 53 | .It Sy HTTP_PROXY 54 | Proxy URL that will be used to establish a http connection. 55 | .It Sy HTTP_PROXY_AUTH 56 | Sets the credentials to authenticate a user agent to a proxy server, in the form 57 | .Ar user:pass . 58 | .It Sy HTTP_AUTH 59 | Sets the credentials to authenticate to a http server, in the form 60 | .Ar user:pass . 61 | .It Sy HTTP_REFERER 62 | Overrides the default Referer http header. 63 | .It Sy HTTP_USER_AGENT 64 | Override the default User-Agent http header. 65 | .It Sy NO_PROXY 66 | Specifies a set of domains for which the proxy should not be consulted. 67 | The contents is a comma-, or space-separated list of domain names. 68 | A single asterisk will override all proxy variables and no transactions 69 | will be proxied. 70 | .It Sy SOCKS_PROXY 71 | Proxy URL that will be used to establish a socks connection. 72 | .It Sy SSL_NO_VERIFY_HOSTNAME 73 | Disables SSL/TLS hostname verification. 74 | .It Sy SSL_NO_VERIFY_PEER 75 | Disables SSL/TLS peer verification. 76 | .It Sy SSL_CA_CERT_FILE 77 | Overrides the default CA certificates file, by default set to 78 | .Ar /etc/ssl/certs/ca-certificates.crt . 79 | .It Sy SSL_CA_CERT_PATH 80 | Overrides the default CA certificates path, by default set to 81 | .Ar /etc/ssl/certs . 82 | .It Sy SSL_CLIENT_CERT_FILE 83 | Sets the SSL/TLS client verification certificate file. 84 | .It Sy SSL_CLIENT_KEY_FILE 85 | Sets the SSL/TLS client verification key file. 86 | .It Sy CONNECTION_TIMEOUT 87 | Sets connection timeout in milliseconds 88 | instead of default value of 5 minutes. 89 | When -1, waits indefinitely. 90 | .El 91 | .Sh SEE ALSO 92 | .Xr xbps-alternatives 1 , 93 | .Xr xbps-checkvers 1 , 94 | .Xr xbps-create 1 , 95 | .Xr xbps-dgraph 1 , 96 | .Xr xbps-digest 1 , 97 | .Xr xbps-fbulk 1 , 98 | .Xr xbps-install 1 , 99 | .Xr xbps-pkgdb 1 , 100 | .Xr xbps-query 1 , 101 | .Xr xbps-reconfigure 1 , 102 | .Xr xbps-remove 1 , 103 | .Xr xbps-rindex 1 , 104 | .Xr xbps-uchroot 1 , 105 | .Xr xbps-uunshare 1 , 106 | .Xr xbps.d 5 107 | .Sh AUTHORS 108 | .An Juan Romero Pardines Aq Mt xtraeme@gmail.com 109 | .Sh BUGS 110 | Probably, but I try to make this not happen. 111 | Use it under your own responsibility and enjoy your life. 112 | .Pp 113 | Report bugs at 114 | .Lk https://github.com/void-linux/xbps/issues 115 | -------------------------------------------------------------------------------- /bin/xbps-install/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-install 5 | OBJS = main.o transaction.o question.o fetch_cb.o state_cb.o util.o 6 | 7 | include $(TOPDIR)/mk/prog.mk 8 | -------------------------------------------------------------------------------- /bin/xbps-install/defs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009-2014 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _XBPS_INSTALL_DEFS_H_ 27 | #define _XBPS_INSTALL_DEFS_H_ 28 | 29 | #include 30 | #include 31 | 32 | struct xferstat { 33 | struct timeval start; 34 | struct timeval last; 35 | }; 36 | 37 | struct transaction { 38 | struct xbps_handle *xhp; 39 | xbps_dictionary_t d; 40 | xbps_object_iterator_t iter; 41 | uint32_t inst_pkgcnt; 42 | uint32_t up_pkgcnt; 43 | uint32_t cf_pkgcnt; 44 | uint32_t rm_pkgcnt; 45 | uint32_t dl_pkgcnt; 46 | uint32_t hold_pkgcnt; 47 | }; 48 | 49 | /* from transaction.c */ 50 | int install_new_pkg(struct xbps_handle *, const char *, bool); 51 | int update_pkg(struct xbps_handle *, const char *, bool); 52 | int dist_upgrade(struct xbps_handle *, unsigned int, bool, bool); 53 | int exec_transaction(struct xbps_handle *, unsigned int, bool, bool); 54 | 55 | /* from question.c */ 56 | bool yesno(const char *, ...); 57 | bool noyes(const char *, ...); 58 | 59 | /* from fetch_cb.c */ 60 | void fetch_file_progress_cb(const struct xbps_fetch_cb_data *, void *); 61 | 62 | /* from state_cb.c */ 63 | int state_cb(const struct xbps_state_cb_data *, void *); 64 | 65 | /* From util.c */ 66 | void print_package_line(const char *, unsigned int, bool); 67 | bool print_trans_colmode(struct transaction *, unsigned int); 68 | int get_maxcols(void); 69 | const char *ttype2str(xbps_dictionary_t); 70 | 71 | #endif /* !_XBPS_INSTALL_DEFS_H_ */ 72 | -------------------------------------------------------------------------------- /bin/xbps-install/question.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2008-2015 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "defs.h" 35 | 36 | #ifdef __clang__ 37 | #pragma clang diagnostic ignored "-Wformat-nonliteral" 38 | #endif 39 | 40 | static bool 41 | question(bool preset, const char *fmt, va_list ap) 42 | { 43 | int response; 44 | bool rv = false; 45 | 46 | vfprintf(stderr, fmt, ap); 47 | if (preset) 48 | fputs(" [Y/n] ", stderr); 49 | else 50 | fputs(" [y/N] ", stderr); 51 | 52 | response = fgetc(stdin); 53 | if (response == '\n') 54 | rv = preset; 55 | else if (response == 'y' || response == 'Y') 56 | rv = true; 57 | else if (response == 'n' || response == 'N') 58 | rv = false; 59 | 60 | /* read the rest of the line */ 61 | while (response != EOF && response != '\n') 62 | response = fgetc(stdin); 63 | 64 | return rv; 65 | } 66 | 67 | bool 68 | yesno(const char *fmt, ...) 69 | { 70 | va_list ap; 71 | bool res; 72 | 73 | va_start(ap, fmt); 74 | res = question(1, fmt, ap); 75 | va_end(ap); 76 | 77 | return res; 78 | } 79 | 80 | bool 81 | noyes(const char *fmt, ...) 82 | { 83 | va_list ap; 84 | bool res; 85 | 86 | va_start(ap, fmt); 87 | res = question(0, fmt, ap); 88 | va_end(ap); 89 | 90 | return res; 91 | } 92 | -------------------------------------------------------------------------------- /bin/xbps-pkgdb/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-pkgdb 5 | OBJS = main.o check.o check_pkg_files.o 6 | OBJS += check_pkg_alternatives.o check_pkg_rundeps.o 7 | OBJS += check_pkg_symlinks.o check_pkg_unneeded.o 8 | 9 | include $(TOPDIR)/mk/prog.mk 10 | -------------------------------------------------------------------------------- /bin/xbps-pkgdb/check_pkg_rundeps.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2011-2015 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include "defs.h" 36 | 37 | /* 38 | * Checks package integrity of an installed package. 39 | * The following task is accomplished in this file: 40 | * 41 | * o Check for missing run time dependencies. 42 | * 43 | * Returns 0 if test ran successfully, 1 otherwise and -1 on error. 44 | */ 45 | 46 | int 47 | check_pkg_rundeps(struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t pkg_propsd) 48 | { 49 | xbps_array_t array; 50 | const char *reqpkg = NULL; 51 | int rv = 0; 52 | 53 | array = xbps_dictionary_get(pkg_propsd, "run_depends"); 54 | for (unsigned int i = 0; i < xbps_array_count(array); i++) { 55 | xbps_array_get_cstring_nocopy(array, i, &reqpkg); 56 | if (xbps_pkg_is_ignored(xhp, reqpkg)) 57 | continue; 58 | if (xbps_pkg_is_installed(xhp, reqpkg) <= 0) { 59 | xbps_error_printf("%s: dependency not satisfied: %s\n", 60 | pkgname, reqpkg); 61 | rv = -1; 62 | } 63 | } 64 | return rv; 65 | } 66 | -------------------------------------------------------------------------------- /bin/xbps-pkgdb/check_pkg_symlinks.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2011-2015 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include "defs.h" 38 | 39 | /* 40 | * Checks package integrity of an installed package. 41 | * The following task is accomplished in this file: 42 | * 43 | * o Check for target file in symlinks, so that we can check that 44 | * they have not been modified. 45 | * 46 | * returns 0 if test ran successfully, 1 otherwise and -1 on error. 47 | */ 48 | 49 | int 50 | check_pkg_symlinks(struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t filesd) 51 | { 52 | xbps_array_t array; 53 | xbps_object_t obj; 54 | int rv = 0; 55 | 56 | array = xbps_dictionary_get(filesd, "links"); 57 | if (array == NULL) 58 | return 0; 59 | 60 | for (unsigned int i = 0; i < xbps_array_count(array); i++) { 61 | const char *file = NULL, *tgt = NULL; 62 | char path[PATH_MAX], *lnk = NULL; 63 | 64 | obj = xbps_array_get(array, i); 65 | if (!xbps_dictionary_get_cstring_nocopy(obj, "file", &file)) 66 | continue; 67 | 68 | /* skip noextract files */ 69 | if (xhp->noextract && xbps_patterns_match(xhp->noextract, file)) 70 | continue; 71 | 72 | if (!xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt)) { 73 | xbps_warn_printf("%s: `%s' symlink with " 74 | "empty target object!\n", pkgname, file); 75 | continue; 76 | } 77 | if (tgt[0] == '\0') { 78 | xbps_warn_printf("%s: `%s' symlink with " 79 | "empty target object!\n", pkgname, file); 80 | continue; 81 | } 82 | snprintf(path, sizeof(path), "%s/%s", xhp->rootdir, file); 83 | if ((lnk = xbps_symlink_target(xhp, path, tgt)) == NULL) { 84 | xbps_error_printf("%s: broken symlink %s (target: %s)\n", pkgname, file, tgt); 85 | rv = -1; 86 | continue; 87 | } 88 | if (strcmp(lnk, tgt)) { 89 | xbps_warn_printf("%s: modified symlink %s " 90 | "points to %s (shall be %s)\n", 91 | pkgname, file, lnk, tgt); 92 | rv = -1; 93 | } 94 | free(lnk); 95 | } 96 | return rv; 97 | } 98 | -------------------------------------------------------------------------------- /bin/xbps-pkgdb/check_pkg_unneeded.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include "defs.h" 37 | 38 | /* 39 | * Checks package integrity of an installed package. 40 | * The following task is accomplished in this file: 41 | * 42 | * o Check if pkg dictionary from pkgdb contains "unneeded" objects, 43 | * and remove them if that was true. 44 | */ 45 | int 46 | check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname, xbps_dictionary_t pkgd) 47 | { 48 | xbps_array_t replaces; 49 | const char *repo = NULL; 50 | char *buf; 51 | 52 | xbps_dictionary_remove(pkgd, "download"); 53 | xbps_dictionary_remove(pkgd, "remove-and-update"); 54 | xbps_dictionary_remove(pkgd, "transaction"); 55 | xbps_dictionary_remove(pkgd, "skip-obsoletes"); 56 | xbps_dictionary_remove(pkgd, "packaged-with"); 57 | if (xbps_dictionary_get_cstring_nocopy(pkgd, "repository-origin", &repo)) { 58 | xbps_dictionary_set_cstring(pkgd, "repository", repo); 59 | xbps_dictionary_remove(pkgd, "repository-origin"); 60 | } 61 | /* 62 | * Remove self replacement when applicable. 63 | */ 64 | if ((replaces = xbps_dictionary_get(pkgd, "replaces"))) { 65 | buf = xbps_xasprintf("%s>=0", pkgname); 66 | xbps_remove_string_from_array(replaces, buf); 67 | free(buf); 68 | if (!xbps_array_count(replaces)) 69 | xbps_dictionary_remove(pkgd, "replaces"); 70 | } 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /bin/xbps-pkgdb/defs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012-2013 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _XBPS_PKGDB_DEFS_H_ 27 | #define _XBPS_PKGDB_DEFS_H_ 28 | 29 | #include 30 | #include 31 | 32 | enum { 33 | CHECK_FILES = 1 << 0, 34 | CHECK_DEPENDENCIES = 1 << 1, 35 | CHECK_ALTERNATIVES = 1 << 2, 36 | CHECK_PKGDB = 1 << 3, 37 | }; 38 | 39 | /* from check.c */ 40 | int check_pkg(struct xbps_handle *, xbps_dictionary_t, const char *, unsigned); 41 | int check_all(struct xbps_handle *, unsigned); 42 | 43 | int check_pkg_unneeded( 44 | struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t pkgd); 45 | int check_pkg_files( 46 | struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t filesd); 47 | int check_pkg_symlinks( 48 | struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t filesd); 49 | int check_pkg_rundeps( 50 | struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t pkgd); 51 | int check_pkg_alternatives( 52 | struct xbps_handle *xhp, const char *pkgname, xbps_dictionary_t pkgd); 53 | 54 | int get_checks_to_run(unsigned *, char *); 55 | 56 | /* from convert.c */ 57 | void convert_pkgdb_format(struct xbps_handle *); 58 | 59 | #endif /* !_XBPS_PKGDB_DEFS_H_ */ 60 | -------------------------------------------------------------------------------- /bin/xbps-query/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-query 5 | OBJS = main.o list.o show-deps.o show-info-files.o 6 | OBJS += ownedby.o search.o ../xbps-install/util.o 7 | 8 | include $(TOPDIR)/mk/prog.mk 9 | -------------------------------------------------------------------------------- /bin/xbps-query/defs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009-2014 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _XBPS_QUERY_DEFS_H_ 27 | #define _XBPS_QUERY_DEFS_H_ 28 | 29 | #include 30 | 31 | #include "../xbps-install/defs.h" 32 | 33 | /* from show-deps.c */ 34 | int show_pkg_deps(struct xbps_handle *, const char *, bool, bool); 35 | int show_pkg_revdeps(struct xbps_handle *, const char *, bool); 36 | 37 | /* from show-info-files.c */ 38 | void show_pkg_info(xbps_dictionary_t); 39 | void show_pkg_info_one(xbps_dictionary_t, const char *); 40 | int show_pkg_info_from_metadir(struct xbps_handle *, const char *, 41 | const char *); 42 | int show_pkg_files(xbps_dictionary_t); 43 | int show_pkg_files_from_metadir(struct xbps_handle *, const char *); 44 | int repo_show_pkg_files(struct xbps_handle *, const char *); 45 | int cat_file(struct xbps_handle *, const char *, const char *); 46 | int repo_cat_file(struct xbps_handle *, const char *, const char *); 47 | int repo_show_pkg_info(struct xbps_handle *, const char *, const char *); 48 | int repo_show_pkg_namedesc(struct xbps_handle *, xbps_object_t, void *, 49 | bool *); 50 | 51 | /* from ownedby.c */ 52 | int ownedby(struct xbps_handle *, const char *, bool, bool); 53 | 54 | /* From list.c */ 55 | unsigned int find_longest_pkgver(struct xbps_handle *, xbps_object_t); 56 | 57 | int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); 58 | int list_manual_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); 59 | int list_hold_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); 60 | int list_repolock_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); 61 | int list_orphans(struct xbps_handle *); 62 | int list_pkgs_pkgdb(struct xbps_handle *); 63 | 64 | int repo_list(struct xbps_handle *); 65 | 66 | /* from search.c */ 67 | int search(struct xbps_handle *, bool, const char *, const char *, bool); 68 | 69 | 70 | #endif /* !_XBPS_QUERY_DEFS_H_ */ 71 | -------------------------------------------------------------------------------- /bin/xbps-query/show-deps.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009-2019 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include "defs.h" 35 | 36 | int 37 | show_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool repomode, bool full) 38 | { 39 | xbps_array_t rdeps; 40 | xbps_dictionary_t pkgd; 41 | 42 | if (repomode) { 43 | if (((pkgd = xbps_rpool_get_pkg(xhp, pkgname)) == NULL) && 44 | ((pkgd = xbps_rpool_get_virtualpkg(xhp, pkgname)) == NULL)) 45 | return errno; 46 | } else { 47 | if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) 48 | return errno; 49 | } 50 | if (full) { 51 | if (repomode) 52 | rdeps = xbps_rpool_get_pkg_fulldeptree(xhp, pkgname); 53 | else 54 | rdeps = xbps_pkgdb_get_pkg_fulldeptree(xhp, pkgname); 55 | 56 | if (rdeps == NULL) 57 | return errno; 58 | } else { 59 | rdeps = xbps_dictionary_get(pkgd, "run_depends"); 60 | } 61 | for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) { 62 | const char *pkgdep = NULL; 63 | xbps_array_get_cstring_nocopy(rdeps, i, &pkgdep); 64 | puts(pkgdep); 65 | } 66 | return 0; 67 | } 68 | 69 | int 70 | show_pkg_revdeps(struct xbps_handle *xhp, const char *pkg, bool repomode) 71 | { 72 | xbps_array_t revdeps; 73 | const char *pkgdep = NULL; 74 | 75 | if (repomode) 76 | revdeps = xbps_rpool_get_pkg_revdeps(xhp, pkg); 77 | else 78 | revdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkg); 79 | 80 | if (revdeps == NULL) 81 | return errno; 82 | 83 | for (unsigned int i = 0; i < xbps_array_count(revdeps); i++) { 84 | xbps_array_get_cstring_nocopy(revdeps, i, &pkgdep); 85 | puts(pkgdep); 86 | } 87 | xbps_object_release(revdeps); 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /bin/xbps-reconfigure/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-reconfigure 5 | OBJS = main.o find-deps.o 6 | 7 | include $(TOPDIR)/mk/prog.mk 8 | -------------------------------------------------------------------------------- /bin/xbps-reconfigure/defs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2022 classabbyamp. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _XBPS_RECONFIGURE_DEFS_H_ 27 | #define _XBPS_RECONFIGURE_DEFS_H_ 28 | 29 | #include 30 | 31 | /* from find-deps.c */ 32 | int find_pkg_deps(struct xbps_handle *, const char *, bool, xbps_array_t *); 33 | 34 | #endif /* !_XBPS_RECONFIGURE_DEFS_H_ */ 35 | -------------------------------------------------------------------------------- /bin/xbps-reconfigure/find-deps.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2022 classabbyamp. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include "defs.h" 30 | 31 | int 32 | find_pkg_deps(struct xbps_handle *xhp, const char *pkgname, bool full, xbps_array_t *rdeps) 33 | { 34 | xbps_dictionary_t pkgd; 35 | 36 | if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) { 37 | return errno; 38 | } 39 | 40 | if (full) { 41 | *rdeps = xbps_pkgdb_get_pkg_fulldeptree(xhp, pkgname); 42 | 43 | if (*rdeps == NULL) 44 | return errno; 45 | } else { 46 | *rdeps = xbps_dictionary_get(pkgd, "run_depends"); 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /bin/xbps-remove/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-remove 5 | OBJS = main.o clean-cache.o 6 | OBJS += ../xbps-install/question.o 7 | OBJS += ../xbps-install/util.o 8 | OBJS += ../xbps-install/transaction.o 9 | 10 | include $(TOPDIR)/mk/prog.mk 11 | -------------------------------------------------------------------------------- /bin/xbps-remove/defs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _XBPS_REMOVE_DEFS_H_ 27 | #define _XBPS_REMOVE_DEFS_H_ 28 | 29 | /* From clean-cache.c */ 30 | int clean_cachedir(struct xbps_handle *, bool uninstalled, bool drun); 31 | 32 | #endif /* !_XBPS_REMOVE_DEFS_H_ */ 33 | -------------------------------------------------------------------------------- /bin/xbps-rindex/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-rindex 5 | OBJS = main.o index-add.o index-clean.o remove-obsoletes.o repoflush.o sign.o 6 | 7 | include $(TOPDIR)/mk/prog.mk 8 | 9 | LDFLAGS += -lcrypto 10 | -------------------------------------------------------------------------------- /bin/xbps-rindex/defs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012-2015 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _XBPS_RINDEX_DEFS_H_ 27 | #define _XBPS_RINDEX_DEFS_H_ 28 | 29 | #include 30 | 31 | #define _XBPS_RINDEX "xbps-rindex" 32 | 33 | /* From index-add.c */ 34 | int index_add(struct xbps_handle *, int, int, char **, bool, const char *); 35 | 36 | /* From index-clean.c */ 37 | int index_clean(struct xbps_handle *, const char *, bool, const char *); 38 | 39 | /* From remove-obsoletes.c */ 40 | int remove_obsoletes(struct xbps_handle *, const char *); 41 | 42 | /* From sign.c */ 43 | int sign_repo(struct xbps_handle *, const char *, const char *, 44 | const char *, const char *); 45 | int sign_pkgs(struct xbps_handle *, int, int, char **, const char *, bool); 46 | 47 | /* From repoflush.c */ 48 | int repodata_flush(const char *repodir, const char *arch, 49 | xbps_dictionary_t index, xbps_dictionary_t stage, xbps_dictionary_t meta, 50 | const char *compression); 51 | 52 | #endif /* !_XBPS_RINDEX_DEFS_H_ */ 53 | -------------------------------------------------------------------------------- /bin/xbps-uchroot/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-uchroot 5 | 6 | include $(TOPDIR)/mk/prog.mk 7 | -------------------------------------------------------------------------------- /bin/xbps-uchroot/xbps-uchroot.1: -------------------------------------------------------------------------------- 1 | .Dd Feb 9, 2023 2 | .Dt XBPS-UCHROOT 1 3 | .Os 4 | .Sh NAME 5 | .Nm xbps-uchroot 6 | .Nd XBPS utility to chroot and bind mount with Linux namespaces 7 | .Sh SYNOPSIS 8 | .Nm 9 | .Op OPTIONS 10 | .Ar CHROOTDIR 11 | .Ar COMMAND 12 | .Op ARGS 13 | .Sh DESCRIPTION 14 | The 15 | .Nm 16 | utility allows users to chroot and automatically bind mount required 17 | pseudo-filesystems (/dev, /dev/shm, /proc and /sys) as well as 18 | user specified directories in the target 19 | .Ar CHROOTDIR 20 | to execute 21 | .Ar COMMAND . 22 | .Pp 23 | The 24 | .Nm 25 | utility uses by default Linux namespaces to isolate IPC, PIDs and mounts to 26 | the calling process. If running in a OpenVZ container, these namespace features 27 | are simply disabled. 28 | .Sh OPTIONS 29 | .Bl -tag -width -x 30 | .It Fl B Ar src:dest 31 | Bind mounts 32 | .Ar src 33 | into 34 | .Ar CHROOTDIR/dest 35 | in read-only mode. 36 | This option may be specified multiple times. 37 | Please note that both 38 | .Ar src 39 | and 40 | .Ar dest 41 | must be absolute paths and must exist. 42 | .It Fl b Ar src:dest 43 | Bind mounts 44 | .Ar src 45 | into 46 | .Ar CHROOTDIR/dest . 47 | This option may be specified multiple times. 48 | Please note that both 49 | .Ar src 50 | and 51 | .Ar dest 52 | must be absolute paths and must exist. 53 | .It Fl O 54 | Setups a temporary directory and then creates an overlay layer (via overlayfs) 55 | with the lowerdir set to CHROOTDIR. Useful to create a temporary tree that does not 56 | preserve changes in CHROOTDIR. 57 | .It Fl o Ar opts 58 | Arguments passed to the tmpfs mount, if the 59 | .Fl O 60 | and 61 | .Fl t 62 | options are specified. 63 | This expects the same arguments that are accepted as options in tmpfs, as explained in 64 | .Xr mount 1 . 65 | .It Fl t 66 | This makes the temporary directory to be mounted in tmpfs, so that everything is stored 67 | in RAM. Note that this is only useful if used with the 68 | .Fl O 69 | option (overlayfs). 70 | .It Fl - 71 | Stop interpreting following arguments as options. 72 | This option is useful if some of 73 | .Ar ARGS 74 | are options passed to 75 | .Ar COMMAND . 76 | .El 77 | .Sh SECURITY 78 | The 79 | .Nm 80 | executable must be setgid to function properly and shall only be executable by a specific 81 | group to avoid security issues (4750). 82 | .Sh NOTES 83 | The 84 | .Nm 85 | utility uses Linux specific features (namespaces) and it's not meant to be portable to 86 | other Operating Systems. The following kernel options must be enabled: 87 | .Pp 88 | .Bl -tag -width CONFIG_NAMESPACES -compact -offset indent 89 | .It Sy CONFIG_NAMESPACES 90 | .It Sy CONFIG_IPC_NS 91 | .It Sy CONFIG_PID_NS 92 | .It Sy CONFIG_UTS_NS 93 | .It Sy CONFIG_OVERLAY_FS 94 | .El 95 | .Sh SEE ALSO 96 | .Xr xbps-alternatives 1 , 97 | .Xr xbps-checkvers 1 , 98 | .Xr xbps-create 1 , 99 | .Xr xbps-dgraph 1 , 100 | .Xr xbps-digest 1 , 101 | .Xr xbps-fbulk 1 , 102 | .Xr xbps-fetch 1 , 103 | .Xr xbps-install 1 , 104 | .Xr xbps-pkgdb 1 , 105 | .Xr xbps-query 1 , 106 | .Xr xbps-reconfigure 1 , 107 | .Xr xbps-rindex 1 , 108 | .Xr xbps-uunshare 1 , 109 | .Xr xbps.d 5 110 | .Sh AUTHORS 111 | .An Juan Romero Pardines Aq Mt xtraeme@gmail.com 112 | .Sh BUGS 113 | Probably, but I try to make this not happen. Use it under your own 114 | responsibility and enjoy your life. 115 | .Pp 116 | Report bugs at 117 | .Lk https://github.com/void-linux/xbps/issues 118 | -------------------------------------------------------------------------------- /bin/xbps-uhelper/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-uhelper 5 | OBJS = main.o ../xbps-install/fetch_cb.o 6 | 7 | include $(TOPDIR)/mk/prog.mk 8 | -------------------------------------------------------------------------------- /bin/xbps-uunshare/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | BIN = xbps-uunshare 5 | 6 | include $(TOPDIR)/mk/prog.mk 7 | -------------------------------------------------------------------------------- /bin/xbps-uunshare/xbps-uunshare.1: -------------------------------------------------------------------------------- 1 | .Dd Feb 9, 2023 2 | .Dt XBPS-UUNSHARE 1 3 | .Os 4 | .Sh NAME 5 | .Nm xbps-uunshare 6 | .Nd XBPS utility to chroot and bind mount with Linux user namespaces 7 | .Sh SYNOPSIS 8 | .Nm 9 | .Op OPTIONS 10 | .Ar CHROOTDIR 11 | .Ar COMMAND 12 | .Op ARGS 13 | .Sh DESCRIPTION 14 | The 15 | .Nm 16 | utility allows users to chroot and bind mount required pseudo-filesystems 17 | (/dev, /proc and /sys) in the target 18 | .Ar CHROOTDIR 19 | to execute 20 | .Ar COMMAND . 21 | .Pp 22 | The 23 | .Nm 24 | utility uses by default Linux namespaces to isolate IPC, PIDs and mounts to 25 | the calling process. Thanks to 26 | .Xr user_namespaces 7 27 | the user does not need any privilege to create an isolated lightweight container. 28 | .Sh OPTIONS 29 | .Bl -tag -width -x 30 | .It Fl b Ar src:dest 31 | Bind mounts 32 | .Ar src 33 | into 34 | .Ar CHROOTDIR/dest . 35 | This option may be specified multiple times. 36 | Please note that both 37 | .Ar src 38 | and 39 | .Ar dest 40 | must be absolute paths and must exist. 41 | .It Fl - 42 | Stop interpreting following arguments as options. 43 | This option is useful if some of 44 | .Ar ARGS 45 | are options passed to 46 | .Ar COMMAND . 47 | .El 48 | .Sh NOTES 49 | The 50 | .Nm 51 | utility uses Linux specific features (namespaces) and it's not meant to be portable to 52 | other Operating Systems. The following kernel options must be enabled: 53 | .Pp 54 | .Bl -tag -width CONFIG_NAMESPACES -compact -offset indent 55 | .It Sy CONFIG_NAMESPACES 56 | .It Sy CONFIG_IPC_NS 57 | .It Sy CONFIG_USER_NS 58 | .It Sy CONFIG_UTS_NS 59 | .El 60 | .Sh SEE ALSO 61 | .Xr xbps-alternatives 1 , 62 | .Xr xbps-checkvers 1 , 63 | .Xr xbps-create 1 , 64 | .Xr xbps-dgraph 1 , 65 | .Xr xbps-digest 1 , 66 | .Xr xbps-fbulk 1 , 67 | .Xr xbps-fetch 1 , 68 | .Xr xbps-install 1 , 69 | .Xr xbps-pkgdb 1 , 70 | .Xr xbps-query 1 , 71 | .Xr xbps-reconfigure 1 , 72 | .Xr xbps-rindex 1 , 73 | .Xr xbps-uchroot 1 , 74 | .Xr xbps.d 5 75 | .Sh AUTHORS 76 | .An Juan Romero Pardines Aq Mt xtraeme@gmail.com 77 | .Sh BUGS 78 | Probably, but I try to make this not happen. Use it under your own 79 | responsibility and enjoy your life. 80 | .Pp 81 | Report bugs at 82 | .Lk https://github.com/void-linux/xbps/issues 83 | -------------------------------------------------------------------------------- /data/60:ae:0c:d6:f0:95:17:80:bc:93:46:7a:89:af:a3:2d.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | public-key 6 | LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUF2clN6QlpNdmd2T0NJM0FYYk9qYQoycktSa0pTVE0zYy9FalRJZ0NnRFhndW05M0JQQ3RZOE1jRlZvQ1U0T2lYSEdmVG1xMzlCVk5wTHZMSEw5S2sxCnAyNzhTQmhYVk90YkIyRVZtREtudmZJREVUbGRMR3plN3JaTlJKZHR1TjJtWi9UVnJVQjlTMHlRYytJdWY0aHYKMytEOTdWSWRUSkhBN0FTcjA0MjhwcEVHSkd3U1NoWTJYSm05RDVJMEV1R1JXYzE0TUVHN2RJS0ppWWlNMG5FNAp0WW8yL3ZINElGVEhkblZBM2dZaVp5RG5idUNBUi84RVNmVVRVMTNTTkNPZGJ1ZGYzRDVCY3krVWlNREpJM1llCjRNRktCclQ5WmhaK0dzWEJaWTQ4MmxxaVppNkNMNXB0YzlJUUZmOC9lS1phOGphdGtpVkZWZ3JLZU5Sak9UeE4KZldTdTJua3hHTlgrYmhYWXRoaUdXbUpFWThjQ0FQeUZOK0x2NVJldEsyNTZnZGNiMnNrbUVxZWZ2MnpQQyt3VgpXQmJkSDViRDRiWmpuME42Wmw4MXJ2NVJ6RHZudmYrdkQxNGFGVWJaOFFGcXU3NVBiTDR3Nm1ZTTRsZE0vZzBSCjZOWEU4QXo5Qnd4MnREZlllS3V1dHcxRXBQbTJZdkZ5VFViMWNveUF1VEdSeUFhcDFVVEh2ZzlsaFBJSm1oRlEKSjVrQ2cxcUQ3QTMxV2wwUmxuZTZoZ0dvMFpaTko1Y0pNL3YvelNUS0pjdUZnd283SDBoT0dpbDZEZm84OUI0agpHOTZBQ3lQUytEVktQRlhSWXdqL0FrYkhwYVEyZjFGTUFvU3BCcXVEcUhoM3VrazcxS1g2ajE5dDBpRjhEUUxyCnZ0RlNTZElqREEwMmx3ZVY5TmFRcFdzQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo= 7 | public-key-size 8 | 4096 9 | signature-by 10 | Void Linux 11 | 12 | 13 | -------------------------------------------------------------------------------- /data/Makefile: -------------------------------------------------------------------------------- 1 | -include ../config.mk 2 | 3 | PCFILE = libxbps.pc 4 | 5 | .PHONY: all 6 | all: 7 | sed -e "s|@@VERSION@@|${VERSION}|g" \ 8 | -e "s|@@PREFIX@@|${PREFIX}|g" \ 9 | -e "s|@@EPREFIX@@|${EPREFIX}|g" \ 10 | ${PCFILE}.in > ${PCFILE} 11 | 12 | .PHONY: install 13 | install: 14 | install -d $(DESTDIR)$(MANDIR)/man5 15 | install -m644 xbps.d.5 $(DESTDIR)$(MANDIR)/man5 16 | install -d $(DESTDIR)$(PKGCONFIGDIR) 17 | install -m644 $(PCFILE) $(DESTDIR)$(PKGCONFIGDIR) 18 | install -d $(DESTDIR)/$(DBDIR)/keys 19 | install -m644 *.plist $(DESTDIR)/$(DBDIR)/keys 20 | install -d $(DESTDIR)/$(SHAREDIR)/xbps.d 21 | install -m644 repod-main.conf $(DESTDIR)/$(SHAREDIR)/xbps.d/00-repository-main.conf 22 | install -m644 xbps.conf $(DESTDIR)/$(SHAREDIR)/xbps.d/xbps.conf 23 | install -d $(DESTDIR)/$(SHAREDIR)/zsh/site-functions 24 | install -m644 _xbps* $(DESTDIR)/$(SHAREDIR)/zsh/site-functions 25 | install -d $(DESTDIR)/$(SHAREDIR)/bash-completion/completions 26 | install -m644 xbps.bash $(DESTDIR)/$(SHAREDIR)/bash-completion/completions/xbps 27 | for file in xbps-checkvers xbps-create xbps-dgraph xbps-install \ 28 | xbps-pkgdb xbps-query xbps-reconfigure xbps-remove xbps-rindex; do \ 29 | ln -sf xbps $(DESTDIR)/$(SHAREDIR)/bash-completion/completions/$$file; \ 30 | done 31 | 32 | .PHONY: uninstall 33 | uninstall: 34 | -rm -f $(DESTDIR)$(PKGCONFIGDIR)/$(PCFILE) 35 | -rm -f $(DESTDIR)$(SHAREDIR)/xbps.d/00-repository-main.conf 36 | -rm -f $(DESTDIR)$(SHAREDIR)/xbps.d/xbps.conf 37 | 38 | 39 | .PHONY: clean 40 | clean: 41 | -rm -f $(PCFILE) 42 | -------------------------------------------------------------------------------- /data/_xbps_src: -------------------------------------------------------------------------------- 1 | #compdef xbps-src 2 | 3 | setopt localoptions extended_glob 4 | 5 | local ret=0 archs top 6 | 7 | archs=(aarch64-musl aarch64 armv5te-musl armv5te armv5tel-musl armv5tel armv6hf-musl armv6hf armv6l-musl armv6l armv7hf-musl armv7hf armv7l-musl armv7l i686-musl i686 mips-musl mipsel-musl mipselhf-musl mipshf-musl ppc-musl ppc ppc64-musl ppc64 ppc64le-musl ppc64le x86_64-musl) 8 | 9 | # path to masterdir and srcpkgs. 10 | top=$~_comp_command1:h 11 | 12 | _xbps_src_all_packages() { 13 | compadd "$@" -- $top/srcpkgs/*(:t) 14 | } 15 | 16 | _xbps_src_destdir_packages() { 17 | local -a dirs 18 | dirs=( $top/masterdir/destdir/*~[^-]#-linux-[^-]#(N/) ) 19 | compadd "$@" -- ${${dirs:t}%-*} 20 | } 21 | 22 | _xbps_src_build_packages() { 23 | local -a dirs 24 | dirs=( $top/masterdir/builddir/*~[^-]#-linux-[^-]#(N/) ) 25 | compadd "$@" -- ${${dirs:t}%-*} 26 | } 27 | 28 | _arguments -s : \ 29 | '-1[Fail if dependencies are missing]' \ 30 | '-A[Host architecture]:architecture:($archs)' \ 31 | '-a[Cross compile packages]:architecture:($archs)' \ 32 | '-b[Build broken, nocross, and excluded packages]' \ 33 | '-c[Configuration file]:config: ' \ 34 | '-C[Do not remove build directory/autodeps/destdir]' \ 35 | '-E[Exit immediately when binary package already exists]' \ 36 | '-f[Force building and registering binary packages]' \ 37 | '-G[Enable XBPS_USE_GIT_REVS]' \ 38 | '-g[Enable building -dbg packages]' \ 39 | '-H[Absolute path to hostdir]:hostdir:_files -/' \ 40 | '-h[Help]' \ 41 | '-I[Ignore required dependencies]' \ 42 | '-i[Make internal errors non-fatal]' \ 43 | '-j[Number of parallel build jobs]:number: ' \ 44 | '-K[Enable extended checks]' \ 45 | '-L[Disable ASCII colors]' \ 46 | '-m[Absolute path to masterdir]:masterdir:_files -/' \ 47 | '-N[Disable use of remote repositories]' \ 48 | '-p[Show additional variables]:variables: ' \ 49 | '-o[Set package build options]:options: ' \ 50 | '-Q[Enable running the check stage]' \ 51 | '-q[Suppress output of xbps-src]' \ 52 | '-r[Use alternative local repository]:repo:_files -/' \ 53 | '-s[Make some warnings errors]' \ 54 | '-t[Create a temporary masterdir]' \ 55 | '-v[Show verbose messages]' \ 56 | '-V[Print version]' \ 57 | '1:target:->target' \ 58 | '*::args:->args' && ret=0 59 | 60 | case $state in 61 | target) 62 | _values "target" binary-bootstrap bootstrap bootstrap-update \ 63 | build check chroot clean clean-repocache configure \ 64 | consistency-check extract fetch install \ 65 | list patch pkg purge-distfiles remove remove-autodeps \ 66 | show show-avail show-build-deps \ 67 | show-deps show-hostmakedepends show-makedepends \ 68 | show-files show-options show-shlib-provides \ 69 | show-shlib-requires show-var show-repo-updates \ 70 | show-sys-updates sort-dependencies update-bulk update-check \ 71 | update-sys update-hash-cache zap 72 | ret=0;; 73 | args) 74 | case $words[1] in 75 | build|check|configure|extract|fetch|install|patch|pkg|show|show-avail|show-build-deps|show-hostmakedepends|show-makedepends|show-options|update-check) 76 | _arguments ':package:_xbps_src_all_packages' && ret=0;; 77 | binary-bootstrap|bootstrap|bootstrap-update|chroot|clean-repocache|consistency-check|list|purge-distfiles|remove-autodeps|show-repo-updates|show-sys-updates|update-bulk|update-sys|update-hash-cache) 78 | # no further arguments 79 | ret=0;; 80 | clean) 81 | _arguments '::package:_xbps_src_build_packages' && ret=0;; 82 | remove|show-deps|show-files|show-shlib-provides|show-shlib-requires) 83 | _arguments ':package:_xbps_src_destdir_packages' && ret=0;; 84 | esac;; 85 | esac 86 | 87 | return $ret 88 | -------------------------------------------------------------------------------- /data/libxbps.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@@PREFIX@@ 2 | exec_prefix=@@EPREFIX@@ 3 | libdir=${exec_prefix}/lib 4 | includedir=${exec_prefix}/include 5 | 6 | Name: XBPS API Library 7 | Description: The X Binary Package System library 8 | Version: @@VERSION@@ 9 | Libs: -lxbps -L${libdir} 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /data/repod-main.conf: -------------------------------------------------------------------------------- 1 | repository=https://repo-default.voidlinux.org/current 2 | -------------------------------------------------------------------------------- /data/xbps.bash: -------------------------------------------------------------------------------- 1 | _xbps_parse_help() { 2 | local IFS line word 3 | 4 | $1 --help 2>&1 | while IFS=$'\n' read -r line; do 5 | [[ $line == *([ $'\t'])-* ]] || continue 6 | 7 | IFS=$' \t,=' 8 | for word in $line; do 9 | [[ $word == -* ]] || continue 10 | printf -- '%s\n' $word 11 | done 12 | done | sort | uniq 13 | } 14 | 15 | _xbps_all_packages() { 16 | xbps-query -Rs "$1*" | sed 's/^... \([^ ]*\)-.* .*/\1/' 17 | } 18 | 19 | _xbps_installed_packages() { 20 | xbps-query -l | sed 's/^.. \([^ ]*\)-.* .*/\1/' 21 | } 22 | 23 | _xbps_all_reply() { 24 | COMPREPLY=( $( compgen -W '$(_xbps_all_packages "$1")' -- "$1") ) 25 | } 26 | 27 | _xbps_installed_reply() { 28 | COMPREPLY=( $( compgen -W '$(_xbps_installed_packages)' -- "$1") ) 29 | } 30 | 31 | _xbps_complete() { 32 | local cur prev words cword 33 | 34 | _init_completion || return 35 | 36 | if [[ "$cur" == -* ]]; then 37 | COMPREPLY=( $( compgen -W '$( _xbps_parse_help "$1" )' -- "$cur") ) 38 | return 39 | fi 40 | 41 | local common='C|-config|r|-rootdir' 42 | local morecommon="$common|c|-cachedir" 43 | 44 | local modes='auto manual hold unhold' 45 | local props='architecture 46 | archive-compression-type 47 | automatic-install 48 | build-options 49 | conf_files 50 | conflicts 51 | filename-sha256 52 | filename-size 53 | homepage 54 | install-date 55 | install-msg 56 | install-script 57 | installed_size 58 | license 59 | maintainer 60 | metafile-sha256 61 | packaged-with 62 | pkgver 63 | preserve 64 | provides 65 | remove-msg 66 | remove-script 67 | replaces 68 | repository 69 | shlib-provides 70 | shlib-requires 71 | short_desc 72 | source-revisions 73 | state' 74 | 75 | case $1 in 76 | xbps-dgraph) 77 | if [[ $prev != -@(c|o|r) ]]; then 78 | _xbps_installed_reply $cur 79 | return 80 | fi 81 | ;; 82 | xbps-install) 83 | if [[ $prev != -@($morecommon) ]]; then 84 | _xbps_all_reply $cur 85 | return 86 | fi 87 | ;; 88 | xbps-pkgdb) 89 | if [[ $prev == -@(m|-mode) ]]; then 90 | COMPREPLY=( $( compgen -W "$modes" -- "$cur") ) 91 | return 92 | fi 93 | if [[ $prev != -@($common) ]]; then 94 | _xbps_installed_reply $cur 95 | return 96 | fi 97 | ;; 98 | xbps-query) 99 | if [[ $prev == -@(p|-property) ]]; then 100 | COMPREPLY=( $( compgen -W "$props" -- "$cur") ) 101 | return 102 | fi 103 | if [[ $prev != -@($morecommon|o|-ownedby) ]]; then 104 | local w 105 | for w in "${words[@]}"; do 106 | if [[ "$w" == -@(R|-repository) ]]; then 107 | _xbps_all_reply $cur 108 | return 109 | fi 110 | done 111 | _xbps_installed_reply $cur 112 | return 113 | fi 114 | ;; 115 | xbps-reconfigure) 116 | if [[ $prev != -@($common) ]]; then 117 | _xbps_installed_reply $cur 118 | return 119 | fi 120 | ;; 121 | xbps-remove) 122 | if [[ $prev != -@($morecommon) ]]; then 123 | _xbps_installed_reply $cur 124 | return 125 | fi 126 | ;; 127 | esac 128 | 129 | _filedir 130 | } 131 | 132 | complete -F _xbps_complete xbps-checkvers xbps-create xbps-dgraph xbps-install \ 133 | xbps-pkgdb xbps-query xbps-reconfigure xbps-remove xbps-rindex 134 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | -include ../config.mk 2 | 3 | # Makefile to build the libxbps API documentation. 4 | # 5 | DOXYF ?= xbps_api_doxyfile 6 | FORMAT ?= png 7 | FILES = xbps_transaction_dictionary.$(FORMAT) 8 | FILES += xbps_pkgdb_dictionary.$(FORMAT) 9 | FILES += xbps_pkg_props_dictionary.$(FORMAT) 10 | FILES += xbps_pkg_files_dictionary.$(FORMAT) 11 | FILES += xbps_binary_pkg_content.$(FORMAT) 12 | 13 | .PHONY: all 14 | all: $(FILES) doxyfiletrans doxygendocs 15 | 16 | $(FILES): %.$(FORMAT): %.dot 17 | dot -T$(FORMAT) $< -o images/$@ 18 | 19 | doxyfiletrans: $(DOXYF).in 20 | ifdef DISTVER 21 | sed -e "s|@@PROJECT_NUMBER@@|${DISTVER}|" $< > $(DOXYF) 22 | else 23 | sed -e "s|@@PROJECT_NUMBER@@|$$(date +%Y%m%d)|" $< > $(DOXYF) 24 | endif 25 | 26 | doxygendocs: $(FILES) doxyfiletrans 27 | doxygen $(DOXYF) 28 | 29 | .PHONY: clean 30 | clean: 31 | -rm -f images/*.$(FORMAT) 32 | -rm -rf ../api 33 | -rm -f $(DOXYF) 34 | 35 | .PHONY: install 36 | install: 37 | install -d $(DESTDIR)$(SHAREDIR)/doc/xbps 38 | cp -r ../api $(DESTDIR)$(SHAREDIR)/doc/xbps 39 | -------------------------------------------------------------------------------- /doc/images/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /doc/xbps-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/void-linux/xbps/d8c5319c4994ec6158a81085c56d8ddaa13f1491/doc/xbps-logo.png -------------------------------------------------------------------------------- /doc/xbps_binary_pkg_content.dot: -------------------------------------------------------------------------------- 1 | digraph xbps_binary_pkg_content { 2 | graph [ranksep="0"]; 3 | edge [color=white,arrowhead="none",fontname="DejaVuSansCondensed",fontsize="12"]; 4 | node [width="4.0",shape=box,fontname="DejaVuSansCondensed",fontsize="12"]; 5 | install -> remove; 6 | remove -> files_plist; 7 | files_plist -> props_plist; 8 | props_plist -> archive_entry; 9 | archive_entry -> archive_entry2; 10 | archive_entry2 -> archive_entry3; 11 | install [style=filled,label="INSTALL"]; 12 | remove [style=filled,label="REMOVE"]; 13 | files_plist [label="files.plist"]; 14 | props_plist [label="props.plist"]; 15 | archive_entry [style=filled,label="/etc"]; 16 | archive_entry2 [style=filled,label="/etc/foo.conf"]; 17 | archive_entry3 [style=filled,label="..."]; 18 | } 19 | -------------------------------------------------------------------------------- /doc/xbps_pkg_files_dictionary.dot: -------------------------------------------------------------------------------- 1 | digraph pkg_files_dictionary { 2 | graph [rankdir=LR,ranksep="0.7"]; 3 | edge [arrowhead="vee",arrowsize="0.2",fontname="DejaVuSansCondensed",fontsize="8"]; 4 | node [height=".1",shape=box,fontname="DejaVuSansCondensed",fontsize="8"]; 5 | files_plist -> main; 6 | files_plist [style=filled,fillcolor=darksalmon,label="files.plist"]; 7 | main [label="Package dictionary"]; 8 | main -> files [label=array]; 9 | files -> files_dict; 10 | files -> files_dict1; 11 | files_dict [style=filled,label="dictionary[0]"]; 12 | files_dict1 [style=filled,label="dictionary[N+1]"]; 13 | files_dict -> file [label=string]; 14 | files_dict -> file_sha256 [label=string]; 15 | files_dict -> file_mutable [label=bool]; 16 | file -> file_value; 17 | file_value [style=filled,fillcolor="yellowgreen",label="/bin/file"]; 18 | file_sha256 [label=sha256]; 19 | file_sha256 -> sha256_value; 20 | file_mutable [style=filled,label=mutable]; 21 | sha256_value [style=filled,fillcolor="yellowgreen",label="..."]; 22 | files_dict1 -> files_dict1_objs [style=filled,label="objects"]; 23 | files_dict1_objs [style=filled,label="..."]; 24 | main -> conf_files [label=array]; 25 | conf_files [style=filled]; 26 | conf_files -> conf_files_dict; 27 | conf_files -> conf_files_dict1; 28 | conf_files_dict [style=filled,label="dictionary[0]"]; 29 | conf_files_dict1 [style=filled,label="dictionary[N+1]"]; 30 | conf_files_dict -> cf_file [label=string]; 31 | conf_files_dict -> cf_sha256 [label=string]; 32 | conf_files_dict1 -> conf_files_dict1_objs [style=filled,label="objects"]; 33 | conf_files_dict1_objs [style=filled,label="..."]; 34 | cf_file [label=file]; 35 | cf_sha256 [label=sha256]; 36 | conf_files_dict [style=filled]; 37 | main -> links [label=array]; 38 | links -> links_dict; 39 | links -> links_dict1; 40 | links_dict [style=filled,label="dictionary[0]"]; 41 | links_dict1 [style=filled,label="dictionary[N+1]"]; 42 | links_dict -> link_file [label=string]; 43 | links_dict -> link_target [label=string]; 44 | link_file [label=file]; 45 | link_target [label=target]; 46 | links_dict1 -> links_dict1_objs [style=filled,label="objects"]; 47 | links_dict1_objs [style=filled,label="..."]; 48 | main -> dirs [label=array]; 49 | dirs -> dirs_dict; 50 | dirs -> dirs_dict1; 51 | dirs_dict [style=filled,label="dictionary[0]"]; 52 | dirs_dict1 [style=filled,label="dictionary[N+1]"]; 53 | dirs_dict -> dirs_file [label=string]; 54 | dirs_file [label=file]; 55 | dirs_dict1 -> dirs_dict1_objs [style=filled,label="objects"]; 56 | dirs_dict1_objs [style=filled,label="..."]; 57 | } 58 | -------------------------------------------------------------------------------- /doc/xbps_pkg_props_dictionary.dot: -------------------------------------------------------------------------------- 1 | digraph pkg_props_dictionary { 2 | graph [rankdir=LR,ranksep="0.7"]; 3 | edge [arrowhead="vee",arrowsize="0.2",fontname="DejaVuSansCondensed",fontsize="8"]; 4 | node [height=".1",shape=box,fontname="DejaVuSansCondensed",fontsize="8"]; 5 | props_plist -> main; 6 | props_plist [style=filled,fillcolor="darksalmon",label="props.plist"]; 7 | main [label="Package dictionary"]; 8 | main -> homepage [label="string"]; 9 | homepage -> homepage_value; 10 | homepage_value [style=filled,fillcolor="yellowgreen",label="https://code.google.com/p/xbps"]; 11 | main -> license [label="string"]; 12 | license -> license_value; 13 | license_value [style=filled,fillcolor="yellowgreen",label="BSD"]; 14 | main -> pkgver [label="string"]; 15 | pkgver -> pkgver_value; 16 | pkgver_value [style=filled,fillcolor="yellowgreen",label="xbps-0.5.2.2"]; 17 | main -> preserve [style=filled,label="bool"]; 18 | preserve [style=filled]; 19 | main -> run_depends [label="array"]; 20 | run_depends [style=filled]; 21 | run_depends -> rundep1_string [label="string"]; 22 | run_depends -> rundep2_string [label="string"]; 23 | rundep1_string [style=filled,fillcolor="yellowgreen",label="foo>=1.2"]; 24 | rundep2_string [style=filled,label="..."]; 25 | main -> architecture [label="string"]; 26 | architecture -> arch_value; 27 | arch_value [style=filled,fillcolor="yellowgreen",label="x86_64"]; 28 | main -> instsize [label="integer"]; 29 | instsize -> instsize_value; 30 | instsize_value [style=filled,fillcolor="yellowgreen",label="389120"]; 31 | instsize [label="installed_size"]; 32 | main -> short_desc [label="string"] 33 | short_desc -> shortdesc_val; 34 | shortdesc_val [style=filled,fillcolor="yellowgreen",label="The XBPS package system utilities"]; 35 | main -> long_desc [label="string"]; 36 | long_desc -> longdesc_val; 37 | longdesc_val [style=filled,fillcolor="yellowgreen",label="..."]; 38 | main -> maintainer [label="string"]; 39 | maintainer -> maintainer_val; 40 | maintainer_val [style=filled,fillcolor="yellowgreen",label="baobab@blobb.org"]; 41 | main -> replaces [label="array"]; 42 | replaces [style=filled]; 43 | replaces -> replace1_string [label="string"]; 44 | replaces -> replace2_string [label="string"]; 45 | replace1_string [style=filled,fillcolor="yellowgreen",label="blah<=2.0"]; 46 | replace2_string [style=filled,label="..."]; 47 | main -> conf_files [label="array"]; 48 | conf_files [style=filled]; 49 | conf_files -> cffile1 [style=filled,label="string"]; 50 | conf_files -> cffile2 [style=filled,label="string"]; 51 | cffile1 [style=filled,fillcolor="yellowgreen",label="/etc/foo.conf"]; 52 | cffile2 [style=filled,label="..."]; 53 | main -> conflicts [label="array"]; 54 | conflicts [style=filled]; 55 | conflicts -> conflict1 [style=filled,label="string"]; 56 | conflicts -> conflict2 [style=filled,label="string"]; 57 | conflict1 [style=filled,fillcolor="yellowgreen",label="foo<2.0"]; 58 | conflict2 [style=filled,label="..."]; 59 | main -> provides [label="array"]; 60 | provides [style=filled]; 61 | provides -> provides1 [style=filled,label="string"]; 62 | provides -> provides2 [style=filled,label="string"]; 63 | provides1 [style=filled,fillcolor="yellowgreen",label="boom-0"]; 64 | provides2 [style=filled,label="..."]; 65 | } 66 | -------------------------------------------------------------------------------- /doc/xbps_pkgdb_dictionary.dot: -------------------------------------------------------------------------------- 1 | digraph pkgdb_dictionary { 2 | graph [rankdir=LR,rank=same,ranksep=".10"]; 3 | edge [arrowhead="vee",arrowsize="0.2",fontname="DejaVuSansCondensed",fontsize="9"]; 4 | node [height=".1",shape=box,fontname="DejaVuSansCondensed",fontsize="9"]; 5 | pkgdb_plist -> main; 6 | pkgdb_plist [style=filled,fillcolor="darksalmon",label="pkgdb-0.21.plist"]; 7 | main [label="Main dictionary"]; 8 | main -> pkgdict [label="dictionary"]; 9 | main -> pkgdict2 [label="dictionary"]; 10 | pkgdict [style=filled,label="Package[0]"]; 11 | pkgdict2 [style=filled,label="Package[N+1]"]; 12 | pkgdict2 -> pkgdict2_objs [label="objects"]; 13 | pkgdict2_objs [style=filled,label="..."]; 14 | pkgdict -> pkgname [label="string"]; 15 | pkgdict -> version [label="string"]; 16 | pkgdict -> pkgver [label="string"]; 17 | pkgdict -> state [label="string"]; 18 | state -> state_inst [label="value"]; 19 | state -> state_hfuned [label="value"]; 20 | state -> state_unpack [label="value"]; 21 | state -> state_hfrmed [label="value"]; 22 | state_inst [style=filled,fillcolor="yellowgreen",label="installed"]; 23 | state_hfuned [style=filled,fillcolor="yellowgreen",label="half-unpacked"]; 24 | state_unpack [style=filled,fillcolor="yellowgreen",label="unpacked"]; 25 | state_hfrmed [style=filled,fillcolor="yellowgreen",label="half-removed"]; 26 | pkgdict -> automatic [label="bool"]; 27 | automatic [label="automatic-install"]; 28 | pkgdict -> short_desc [label="string"] 29 | pkgdict -> rundepends [label="array"]; 30 | rundepends [style=filled]; 31 | rundepends -> rundep1 [label="string"]; 32 | rundepends -> rundep2 [style=filled,label="string"]; 33 | rundep1 [label="blah>=2.0"]; 34 | rundep2 [style=filled,label="..."]; 35 | } 36 | -------------------------------------------------------------------------------- /doc/xbps_transaction_dictionary.dot: -------------------------------------------------------------------------------- 1 | digraph transaction_dictionary { 2 | graph [rankdir=LR,ranksep=".1"]; 3 | edge [arrowhead="vee",arrowsize="0.40",fontname="DejaVuSansCondensed",fontsize="8"]; 4 | node [shape=box,fontname="DejaVuSansCondensed",fontsize="8",height=".1",width=".1"]; 5 | main -> packages [label="array"]; 6 | main -> missing_deps [label="array"]; 7 | main -> conflicts [label="array"]; 8 | missing_deps -> mdep1 [label="string"]; 9 | missing_deps -> mdep2 [label="string"]; 10 | conflicts -> conflict1 [label="string"]; 11 | conflicts -> conflict2 [label="string"]; 12 | mdep1 [style=filled,label="blob>=3.0<4.1"]; 13 | mdep2 [style=filled,label="..."]; 14 | conflict1 [style=filled,label="blob<4.0.1"]; 15 | conflict2 [style=filled,label="..."]; 16 | main -> totalsize [label="integer"]; 17 | main -> totaldlsize [label="integer"]; 18 | main [style=filled,fillcolor="darksalmon",label="Main dictionary"]; 19 | totalsize [label="total-installed-size"]; 20 | totaldlsize [label="total-download-size"]; 21 | packages -> dictionary [label="dictionary"]; 22 | packages -> dictionary2 [label="dictionary"]; 23 | dictionary [style=filled,label="Package[0]"]; 24 | dictionary2 [style=filled,label="Package[N+1]"]; 25 | dictionary2 -> dict2_objs [label="objects"]; 26 | dict2_objs [style=filled,label="..."]; 27 | dictionary -> pkgname [label="string"]; 28 | dictionary -> version [label="string"]; 29 | dictionary -> pkgver [label="string"]; 30 | dictionary -> run_depends [label="array"]; 31 | run_depends [style=filled]; 32 | run_depends -> rundep1_string [label="string"]; 33 | run_depends -> rundep2_string [label="string"]; 34 | rundep1_string [label="foo>=1.2"]; 35 | rundep2_string [style=filled,label="..."]; 36 | dictionary -> architecture [label="string"]; 37 | dictionary -> filename [label="string"]; 38 | dictionary -> fnamesha256 [label="string"]; 39 | fnamesha256 [label="filename-sha256"]; 40 | dictionary -> fnamesize [label="integer"]; 41 | fnamesize [label="filename-size"]; 42 | dictionary -> instsize [label="integer"]; 43 | instsize [label="installed_size"]; 44 | dictionary -> repository [label="value"]; 45 | repository -> repoval [label="value"]; 46 | repoval [style=filled,fillcolor="yellowgreen",label="http://xbps.nopcode.org/repos/stable"]; 47 | dictionary -> archive_comptype [label="string"]; 48 | archive_comptype [label="archive-compression-type"]; 49 | archive_comptype -> comptype_gz [label="value"]; 50 | archive_comptype -> comptype_bz [label="value"]; 51 | archive_comptype -> comptype_xz [label="value"]; 52 | comptype_gz [style=filled,fillcolor="yellowgreen",label="gzip"]; 53 | comptype_bz [style=filled,fillcolor="yellowgreen",label="bzip2"]; 54 | comptype_xz [style=filled,fillcolor="yellowgreen",label="xz"]; 55 | dictionary -> short_desc [label="string"]; 56 | dictionary -> state [label="string"]; 57 | state -> state_notinst [label="value"]; 58 | state -> state_unpacked [label="value"]; 59 | state_notinst [style=filled,fillcolor="yellowgreen",label="not-installed"]; 60 | state_unpacked [style=filled,fillcolor="yellowgreen",label="unpacked"]; 61 | dictionary -> transaction [label="string"]; 62 | transaction [label="transaction"]; 63 | transaction -> tract_inst [label="value"]; 64 | transaction -> tract_up [label="value"]; 65 | transaction -> tract_cf [label="value"]; 66 | transaction -> tract_rm [label="value"]; 67 | tract_inst [style=filled,fillcolor="yellowgreen",label="install"]; 68 | tract_up [style=filled,fillcolor="yellowgreen",label="update"]; 69 | tract_cf [style=filled,fillcolor="yellowgreen",label="configure"]; 70 | tract_rm [style=filled,fillcolor="yellowgreen",label="remove"]; 71 | } 72 | -------------------------------------------------------------------------------- /include/Makefile: -------------------------------------------------------------------------------- 1 | -include ../config.mk 2 | 3 | INCS = xbps.h 4 | 5 | .PHONY: all 6 | all: 7 | sed -e "s|@@VERSION@@|${VERSION}|g" ${INCS}.in > ${INCS} 8 | 9 | .PHONY: install 10 | install: 11 | install -d $(DESTDIR)$(INCLUDEDIR)/xbps 12 | install -m 644 $(INCS) $(DESTDIR)$(INCLUDEDIR) 13 | for f in array bool data dictionary number object string; do \ 14 | install -m 644 xbps/xbps_$${f}.h $(DESTDIR)$(INCLUDEDIR)/xbps; \ 15 | done 16 | 17 | .PHONY: uninstall 18 | uninstall: 19 | -rm -f $(DESTDIR)$(INCLUDEDIR)/$(INCS) 20 | 21 | .PHONY: clean 22 | clean: 23 | -rm -f ${INCS} 24 | -------------------------------------------------------------------------------- /include/compat.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPAT_H 2 | #define COMPAT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #if HAVE_VISIBILITY 9 | #define HIDDEN __attribute__ ((visibility("hidden"))) 10 | #else 11 | #define HIDDEN 12 | #endif 13 | 14 | #ifndef HAVE_STRLCAT 15 | size_t HIDDEN strlcat(char *, const char *, size_t); 16 | #endif 17 | 18 | #ifndef HAVE_STRLCPY 19 | size_t HIDDEN strlcpy(char *, const char *, size_t); 20 | #endif 21 | 22 | #ifndef HAVE_STRCASESTR 23 | char HIDDEN *strcasestr(const char *, const char *); 24 | #endif 25 | 26 | #ifndef HAVE_VASPRINTF 27 | int HIDDEN vasprintf(char **, const char *, va_list); 28 | #endif 29 | 30 | #ifndef HAVE_HUMANIZE_NUMBER 31 | #define HN_DECIMAL 0x01 32 | #define HN_NOSPACE 0x02 33 | #define HN_B 0x04 34 | #define HN_DIVISOR_1000 0x08 35 | #define HN_GETSCALE 0x10 36 | #define HN_AUTOSCALE 0x20 37 | int HIDDEN humanize_number(char *, size_t, int64_t, const char *, int, int); 38 | #endif 39 | 40 | #endif /* COMPAT_H */ 41 | -------------------------------------------------------------------------------- /include/mainpage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @mainpage The X Binary Package System Library API 3 | * @section intro_sec Introduction 4 | * 5 | * XBPS is a new binary package system designed and implemented from 6 | * scratch, by Juan Romero Pardines. This document describes 7 | * the API used by the XBPS Library, that is the base to implement 8 | * a package manager frontend, such as is implemented in the xbps 9 | * command line interfaces. 10 | * 11 | * XBPS uses extensively NetBSD's proplib, a library that provides an 12 | * abstract interface for creating and manipulating property lists. 13 | * Property lists have object types for boolean values, opaque data, numbers, 14 | * and strings. Structure is provided by the array and dictionary collection 15 | * types. Property lists can be passed across protection boundaries by 16 | * translating them to an external representation. This external representation 17 | * is an XML document whose format is described by the following DTD: 18 | * 19 | * http://www.apple.com/DTDs/PropertyList-1.0.dtd 20 | * 21 | * NetBSD's proplib has been choosed because it's fast, extensible, and easy 22 | * to use. These are the three facts I mentioned: 23 | * 24 | * - Fast because proplib uses an ultra optimized 25 | * red-black tree implementation to store and find all its objects, 26 | * the same implementation has been used in commercial projects by 27 | * Apple Inc. 28 | * 29 | * - Extensible because you don't have to worry about ABI problems 30 | * with its objects, arrays and dictionaries can be extended without such 31 | * problems. 32 | * 33 | * - Easy to use (and learn) because it has a superb documentation 34 | * available in the form of manual pages. 35 | * 36 | * Not to mention that its arrays and dictionaries can be externalized to 37 | * files (known as plists) and are always written atomically. You 38 | * have the whole file or don't have it at all. 39 | */ 40 | -------------------------------------------------------------------------------- /include/xbps/xbps_bool.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_bool.h,v 1.4 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _XBPS_BOOL_H_ 33 | #define _XBPS_BOOL_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef struct _prop_bool *xbps_bool_t; 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | xbps_bool_t xbps_bool_create(bool); 45 | xbps_bool_t xbps_bool_copy(xbps_bool_t); 46 | 47 | bool xbps_bool_true(xbps_bool_t); 48 | 49 | bool xbps_bool_equals(xbps_bool_t, xbps_bool_t); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _XBPS_BOOL_H_ */ 56 | -------------------------------------------------------------------------------- /include/xbps/xbps_data.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_data.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _XBPS_DATA_H_ 33 | #define _XBPS_DATA_H_ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | typedef struct _prop_data *xbps_data_t; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | xbps_data_t xbps_data_create_data(const void *, size_t); 46 | xbps_data_t xbps_data_create_data_nocopy(const void *, size_t); 47 | 48 | xbps_data_t xbps_data_copy(xbps_data_t); 49 | 50 | size_t xbps_data_size(xbps_data_t); 51 | 52 | void * xbps_data_data(xbps_data_t); 53 | const void * xbps_data_data_nocopy(xbps_data_t); 54 | 55 | bool xbps_data_equals(xbps_data_t, xbps_data_t); 56 | bool xbps_data_equals_data(xbps_data_t, const void *, size_t); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* _XBPS_DATA_H_ */ 63 | -------------------------------------------------------------------------------- /include/xbps/xbps_number.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_number.h,v 1.6 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _XBPS_NUMBER_H_ 33 | #define _XBPS_NUMBER_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef struct _prop_number *xbps_number_t; 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | xbps_number_t xbps_number_create_integer(int64_t); 45 | xbps_number_t xbps_number_create_unsigned_integer(uint64_t); 46 | 47 | xbps_number_t xbps_number_copy(xbps_number_t); 48 | 49 | int xbps_number_size(xbps_number_t); 50 | bool xbps_number_unsigned(xbps_number_t); 51 | 52 | int64_t xbps_number_integer_value(xbps_number_t); 53 | uint64_t xbps_number_unsigned_integer_value(xbps_number_t); 54 | 55 | bool xbps_number_equals(xbps_number_t, xbps_number_t); 56 | bool xbps_number_equals_integer(xbps_number_t, int64_t); 57 | bool xbps_number_equals_unsigned_integer(xbps_number_t, uint64_t); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* _XBPS_NUMBER_H_ */ 64 | -------------------------------------------------------------------------------- /include/xbps/xbps_object.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_object.h,v 1.7 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _XBPS_OBJECT_H_ 33 | #define _XBPS_OBJECT_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef void *xbps_object_t; 39 | 40 | typedef enum { 41 | XBPS_TYPE_UNKNOWN = 0x00000000, 42 | XBPS_TYPE_BOOL = 0x626f6f6c, /* 'bool' */ 43 | XBPS_TYPE_NUMBER = 0x6e6d6272, /* 'nmbr' */ 44 | XBPS_TYPE_STRING = 0x73746e67, /* 'stng' */ 45 | XBPS_TYPE_DATA = 0x64617461, /* 'data' */ 46 | XBPS_TYPE_ARRAY = 0x61726179, /* 'aray' */ 47 | XBPS_TYPE_DICTIONARY = 0x64696374, /* 'dict' */ 48 | XBPS_TYPE_DICT_KEYSYM = 0x646b6579 /* 'dkey' */ 49 | } xbps_type_t; 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | void xbps_object_retain(xbps_object_t); 56 | void xbps_object_release(xbps_object_t); 57 | 58 | xbps_type_t xbps_object_type(xbps_object_t); 59 | 60 | bool xbps_object_equals(xbps_object_t, xbps_object_t); 61 | bool xbps_object_equals_with_error(xbps_object_t, xbps_object_t, bool *); 62 | 63 | typedef struct _prop_object_iterator *xbps_object_iterator_t; 64 | 65 | xbps_object_t xbps_object_iterator_next(xbps_object_iterator_t); 66 | void xbps_object_iterator_reset(xbps_object_iterator_t); 67 | void xbps_object_iterator_release(xbps_object_iterator_t); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* _XBPS_OBJECT_H_ */ 74 | -------------------------------------------------------------------------------- /include/xbps/xbps_string.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_string.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _XBPS_STRING_H_ 33 | #define _XBPS_STRING_H_ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | typedef struct _prop_string *xbps_string_t; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | xbps_string_t xbps_string_create(void); 46 | xbps_string_t xbps_string_create_cstring(const char *); 47 | xbps_string_t xbps_string_create_cstring_nocopy(const char *); 48 | 49 | xbps_string_t xbps_string_copy(xbps_string_t); 50 | xbps_string_t xbps_string_copy_mutable(xbps_string_t); 51 | 52 | size_t xbps_string_size(xbps_string_t); 53 | bool xbps_string_mutable(xbps_string_t); 54 | 55 | char * xbps_string_cstring(xbps_string_t); 56 | const char * xbps_string_cstring_nocopy(xbps_string_t); 57 | 58 | bool xbps_string_append(xbps_string_t, xbps_string_t); 59 | bool xbps_string_append_cstring(xbps_string_t, const char *); 60 | 61 | bool xbps_string_equals(xbps_string_t, xbps_string_t); 62 | bool xbps_string_equals_cstring(xbps_string_t, const char *); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* _XBPS_STRING_H_ */ 69 | -------------------------------------------------------------------------------- /lib/cb_util.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2011-2013 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "xbps_api_impl.h" 34 | 35 | #ifdef __clang__ 36 | #pragma clang diagnostic ignored "-Wformat-nonliteral" 37 | #endif 38 | 39 | void HIDDEN 40 | xbps_set_cb_fetch(struct xbps_handle *xhp, 41 | off_t file_size, 42 | off_t file_offset, 43 | off_t file_dloaded, 44 | const char *file_name, 45 | bool cb_start, 46 | bool cb_update, 47 | bool cb_end) 48 | { 49 | struct xbps_fetch_cb_data xfcd; 50 | 51 | if (xhp->fetch_cb == NULL) 52 | return; 53 | 54 | xfcd.xhp = xhp; 55 | xfcd.file_size = file_size; 56 | xfcd.file_offset = file_offset; 57 | xfcd.file_dloaded = file_dloaded; 58 | xfcd.file_name = file_name; 59 | xfcd.cb_start = cb_start; 60 | xfcd.cb_update = cb_update; 61 | xfcd.cb_end = cb_end; 62 | (*xhp->fetch_cb)(&xfcd, xhp->fetch_cb_data); 63 | } 64 | 65 | int HIDDEN 66 | xbps_set_cb_state(struct xbps_handle *xhp, 67 | xbps_state_t state, 68 | int err, 69 | const char *arg, 70 | const char *fmt, 71 | ...) 72 | { 73 | struct xbps_state_cb_data xscd; 74 | char *buf = NULL; 75 | va_list va; 76 | int retval; 77 | 78 | if (xhp->state_cb == NULL) 79 | return 0; 80 | 81 | xscd.xhp = xhp; 82 | xscd.state = state; 83 | xscd.err = err; 84 | xscd.arg = arg; 85 | if (fmt != NULL) { 86 | va_start(va, fmt); 87 | retval = vasprintf(&buf, fmt, va); 88 | va_end(va); 89 | if (retval <= 0) 90 | xscd.desc = NULL; 91 | else 92 | xscd.desc = buf; 93 | } 94 | retval = (*xhp->state_cb)(&xscd, xhp->state_cb_data); 95 | if (buf != NULL) 96 | free(buf); 97 | 98 | return retval; 99 | } 100 | -------------------------------------------------------------------------------- /lib/compat/strcasestr.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1990, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * This code is derived from software contributed to Berkeley by 8 | * Chris Torek. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #include "xbps_api_impl.h" 36 | #include 37 | #include 38 | #include 39 | 40 | /* 41 | * Find the first occurrence of find in s, ignore case. 42 | */ 43 | char HIDDEN * 44 | strcasestr(const char *s, const char *find) 45 | { 46 | char c, sc; 47 | size_t len; 48 | 49 | assert(s != NULL); 50 | assert(find != NULL); 51 | 52 | if ((c = *find++) != 0) { 53 | c = tolower((unsigned char)c); 54 | len = strlen(find); 55 | do { 56 | do { 57 | if ((sc = *s++) == 0) 58 | return (NULL); 59 | } while ((char)tolower((unsigned char)sc) != c); 60 | } while (strncasecmp(s, find, len) != 0); 61 | s--; 62 | } 63 | return __UNCONST(s); 64 | } 65 | -------------------------------------------------------------------------------- /lib/compat/strlcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #include "compat.h" 23 | 24 | /* 25 | * Appends src to string dst of size siz (unlike strncat, siz is the 26 | * full size of dst, not space left). At most siz-1 characters 27 | * will be copied. Always NUL terminates (unless siz <= strlen(dst)). 28 | * Returns strlen(src) + MIN(siz, strlen(initial dst)). 29 | * If retval >= siz, truncation occurred. 30 | */ 31 | size_t HIDDEN 32 | strlcat(char *dst, const char *src, size_t siz) 33 | { 34 | char *d = dst; 35 | const char *s = src; 36 | size_t n = siz; 37 | size_t dlen; 38 | 39 | /* Find the end of dst and adjust bytes left but don't go past end */ 40 | while (n-- != 0 && *d != '\0') 41 | d++; 42 | dlen = d - dst; 43 | n = siz - dlen; 44 | 45 | if (n == 0) 46 | return(dlen + strlen(s)); 47 | while (*s != '\0') { 48 | if (n != 1) { 49 | *d++ = *s; 50 | n--; 51 | } 52 | s++; 53 | } 54 | *d = '\0'; 55 | 56 | return(dlen + (s - src)); /* count does not include NUL */ 57 | } 58 | -------------------------------------------------------------------------------- /lib/compat/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #include "compat.h" 23 | 24 | /* 25 | * Copy src to string dst of size siz. At most siz-1 characters 26 | * will be copied. Always NUL terminates (unless siz == 0). 27 | * Returns strlen(src); if retval >= siz, truncation occurred. 28 | */ 29 | size_t HIDDEN 30 | strlcpy(char *dst, const char *src, size_t siz) 31 | { 32 | char *d = dst; 33 | const char *s = src; 34 | size_t n = siz; 35 | 36 | /* Copy as many bytes as will fit */ 37 | if (n != 0) { 38 | while (--n != 0) { 39 | if ((*d++ = *s++) == '\0') 40 | break; 41 | } 42 | } 43 | 44 | /* Not enough room in dst, add NUL and traverse rest of src */ 45 | if (n == 0) { 46 | if (siz != 0) 47 | *d = '\0'; /* NUL-terminate dst */ 48 | while (*s++) 49 | ; 50 | } 51 | 52 | return(s - src - 1); /* count does not include NUL */ 53 | } 54 | -------------------------------------------------------------------------------- /lib/compat/vasprintf.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: asprintf.c,v 1.2 2007/07/20 00:10:06 tnn Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2007 Joerg Sonnenberger . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | #include "compat.h" 36 | 37 | int HIDDEN 38 | vasprintf(char **ret, const char *fmt, va_list ap) 39 | { 40 | char *buf, *new_buf; 41 | size_t len; 42 | int retval; 43 | 44 | len = 128; 45 | buf = malloc(len); 46 | if (buf == NULL) { 47 | *ret = NULL; 48 | return -1; 49 | } 50 | 51 | retval = vsnprintf(buf, len, fmt, ap); 52 | if (retval < 0) { 53 | free(buf); 54 | *ret = NULL; 55 | return -1; 56 | } 57 | 58 | if (retval < (int)len) { 59 | new_buf = realloc(buf, retval + 1); 60 | if (new_buf == NULL) 61 | *ret = buf; 62 | else 63 | *ret = new_buf; 64 | return retval; 65 | } 66 | 67 | len = (size_t)retval + 1; 68 | free(buf); 69 | buf = malloc(len); 70 | if (buf == NULL) { 71 | *ret = NULL; 72 | return -1; 73 | } 74 | retval = vsnprintf(buf, len, fmt, ap); 75 | if (retval != (int)len - 1) { 76 | free(buf); 77 | *ret = NULL; 78 | return -1; 79 | } 80 | *ret = buf; 81 | return retval; 82 | } 83 | -------------------------------------------------------------------------------- /lib/external/mkpath.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1983, 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * The following is a modified function from NetBSD's src/bin/mkdir/mkdir.c 32 | */ 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include "xbps_api_impl.h" 40 | 41 | int 42 | xbps_mkpath(const char *path, mode_t mode) 43 | { 44 | struct stat sb; 45 | char *ppath, *slash; 46 | int done = 0; 47 | mode_t dir_mode; 48 | 49 | if ((ppath = strdup(path)) == NULL) 50 | return -1; 51 | 52 | slash = ppath; 53 | /* 54 | * The default file mode is a=rwx (0777) with selected permissions 55 | * removed in accordance with the file mode creation mask. For 56 | * intermediate path name components, the mode is the default modified 57 | * by u+wx so that the subdirectories can always be created. 58 | */ 59 | if (mode == 0) 60 | mode = (S_IRWXU | S_IRWXG | S_IRWXO) & ~umask(0); 61 | 62 | dir_mode = mode | S_IRUSR | S_IXUSR | S_IROTH | S_IXOTH; 63 | 64 | for (;;) { 65 | slash += strspn(slash, "/"); 66 | slash += strcspn(slash, "/"); 67 | 68 | done = (*slash == '\0'); 69 | *slash = '\0'; 70 | 71 | if (mkdir(ppath, done ? mode : dir_mode) == -1) { 72 | /* 73 | * Can't create; path exists or no perms. 74 | * stat() path to determine what's there now. 75 | */ 76 | int sverrno; 77 | 78 | sverrno = errno; 79 | if (stat(ppath, &sb) < 0) { 80 | /* Not there; use mkdir()s error */ 81 | errno = sverrno; 82 | free(ppath); 83 | return -1; 84 | } 85 | if (!S_ISDIR(sb.st_mode)) { 86 | /* Is there, but isn't a directory */ 87 | errno = ENOTDIR; 88 | free(ppath); 89 | return -1; 90 | } 91 | } 92 | if (done) 93 | break; 94 | 95 | *slash = '/'; 96 | } 97 | free(ppath); 98 | 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /lib/fetch/errlist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $NetBSD: errlist.sh,v 1.2 2008/10/06 12:58:29 joerg Exp $ 3 | 4 | printf "static struct fetcherr $1[] = {\n" 5 | while read code type msg; do 6 | [ "${code}" = "#" ] && continue 7 | printf "\t{ ${code}, FETCH_${type}, \"${msg}\" },\n" 8 | done < $3 9 | 10 | printf "\t{ -1, FETCH_UNKNOWN, \"Unknown $2 error\" }\n" 11 | printf "};\n" 12 | -------------------------------------------------------------------------------- /lib/fetch/ftp.errors: -------------------------------------------------------------------------------- 1 | # $NetBSD: ftp.errors,v 1.2 2008/10/06 12:58:29 joerg Exp $ 2 | # $FreeBSD: ftp.errors,v 1.6 2002/10/30 06:06:16 des Exp $ 3 | # 4 | # This list is taken from RFC 959. 5 | # It probably needs a going over. 6 | # 7 | 110 OK Restart marker reply 8 | 120 TEMP Service ready in a few minutes 9 | 125 OK Data connection already open; transfer starting 10 | 150 OK File status okay; about to open data connection 11 | 200 OK Command okay 12 | 202 PROTO Command not implemented, superfluous at this site 13 | 211 INFO System status, or system help reply 14 | 212 INFO Directory status 15 | 213 INFO File status 16 | 214 INFO Help message 17 | 215 INFO Set system type 18 | 220 OK Service ready for new user 19 | 221 OK Service closing control connection 20 | 225 OK Data connection open; no transfer in progress 21 | 226 OK Requested file action successful 22 | 227 OK Entering Passive Mode 23 | 229 OK Entering Extended Passive Mode 24 | 230 OK User logged in, proceed 25 | 250 OK Requested file action okay, completed 26 | 257 OK File/directory created 27 | 331 AUTH User name okay, need password 28 | 332 AUTH Need account for login 29 | 350 OK Requested file action pending further information 30 | 421 DOWN Service not available, closing control connection 31 | 425 NETWORK Can't open data connection 32 | 426 ABORT Connection closed; transfer aborted 33 | 450 UNAVAIL File unavailable (e.g., file busy) 34 | 451 SERVER Requested action aborted: local error in processing 35 | 452 FULL Insufficient storage space in system 36 | 500 PROTO Syntax error, command unrecognized 37 | 501 PROTO Syntax error in parameters or arguments 38 | 502 PROTO Command not implemented 39 | 503 PROTO Bad sequence of commands 40 | 504 PROTO Command not implemented for that parameter 41 | 530 AUTH Not logged in 42 | 532 AUTH Need account for storing files 43 | 535 PROTO Bug in MediaHawk Video Kernel FTP server 44 | 550 UNAVAIL File unavailable (e.g., file not found, no access) 45 | 551 PROTO Requested action aborted. Page type unknown 46 | 552 FULL Exceeded storage allocation 47 | 553 EXISTS File name not allowed 48 | 999 PROTO Protocol error 49 | -------------------------------------------------------------------------------- /lib/fetch/http.errors: -------------------------------------------------------------------------------- 1 | # $FreeBSD$ revision 241840 2 | # 3 | # This list is taken from RFC 2068. 4 | # 5 | 100 OK Continue 6 | 101 OK Switching Protocols 7 | 200 OK OK 8 | 201 OK Created 9 | 202 OK Accepted 10 | 203 INFO Non-Authoritative Information 11 | 204 OK No Content 12 | 205 OK Reset Content 13 | 206 OK Partial Content 14 | 300 MOVED Multiple Choices 15 | 301 MOVED Moved Permanently 16 | 302 MOVED Moved Temporarily 17 | 303 MOVED See Other 18 | 304 UNCHANGED Not Modified 19 | 305 INFO Use Proxy 20 | 307 MOVED Temporary Redirect 21 | 308 MOVED Permanent Redirect 22 | 400 PROTO Bad Request 23 | 401 AUTH Unauthorized 24 | 402 AUTH Payment Required 25 | 403 AUTH Forbidden 26 | 404 UNAVAIL Not Found 27 | 405 PROTO Method Not Allowed 28 | 406 PROTO Not Acceptable 29 | 407 AUTH Proxy Authentication Required 30 | 408 TIMEOUT Request Time-out 31 | 409 EXISTS Conflict 32 | 410 UNAVAIL Gone 33 | 411 PROTO Length Required 34 | 412 SERVER Precondition Failed 35 | 413 PROTO Request Entity Too Large 36 | 414 PROTO Request-URI Too Large 37 | 415 PROTO Unsupported Media Type 38 | 416 UNAVAIL Requested Range Not Satisfiable 39 | 417 SERVER Expectation Failed 40 | 500 SERVER Internal Server Error 41 | 501 PROTO Not Implemented 42 | 502 SERVER Bad Gateway 43 | 503 TEMP Service Unavailable 44 | 504 TIMEOUT Gateway Time-out 45 | 505 PROTO HTTP Version not supported 46 | 999 PROTO Protocol error 47 | -------------------------------------------------------------------------------- /lib/log.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2011-2015 Juan Romero Pardines. 3 | * Copyright (c) 2014 Enno Boland. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "xbps_api_impl.h" 32 | 33 | #ifdef __clang__ 34 | #pragma clang diagnostic ignored "-Wformat-nonliteral" 35 | #endif 36 | 37 | int xbps_debug_level = 0; 38 | 39 | /** 40 | * @file lib/log.c 41 | * @brief Logging functions 42 | * @defgroup log Logging functions 43 | * 44 | * Use these functions to log errors, warnings and debug messages. 45 | */ 46 | 47 | static void 48 | common_printf(FILE *f, const char *msg, const char *fmt, va_list ap) 49 | { 50 | if (msg != NULL) 51 | fprintf(f, "%s", msg); 52 | 53 | vfprintf(f, fmt, ap); 54 | } 55 | 56 | void 57 | xbps_dbg_printf_append(const char *fmt, ...) 58 | { 59 | va_list ap; 60 | 61 | if (xbps_debug_level == 0) 62 | return; 63 | 64 | va_start(ap, fmt); 65 | common_printf(stderr, NULL, fmt, ap); 66 | va_end(ap); 67 | } 68 | 69 | void 70 | xbps_dbg_printf(const char *fmt, ...) 71 | { 72 | va_list ap; 73 | 74 | if (xbps_debug_level == 0) 75 | return; 76 | 77 | va_start(ap, fmt); 78 | common_printf(stderr, "[DEBUG] ", fmt, ap); 79 | va_end(ap); 80 | } 81 | 82 | void 83 | xbps_error_printf(const char *fmt, ...) 84 | { 85 | va_list ap; 86 | 87 | va_start(ap, fmt); 88 | common_printf(stderr, "ERROR: ", fmt, ap); 89 | va_end(ap); 90 | } 91 | 92 | void 93 | xbps_warn_printf(const char *fmt, ...) 94 | { 95 | va_list ap; 96 | 97 | va_start(ap, fmt); 98 | common_printf(stderr, "WARNING: ", fmt, ap); 99 | va_end(ap); 100 | } 101 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/prop_bool.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_bool.h,v 1.4 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROP_BOOL_H_ 33 | #define _PROPLIB_PROP_BOOL_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef struct _prop_bool *prop_bool_t; 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | prop_bool_t prop_bool_create(bool); 45 | prop_bool_t prop_bool_copy(prop_bool_t); 46 | 47 | bool prop_bool_true(prop_bool_t); 48 | 49 | bool prop_bool_equals(prop_bool_t, prop_bool_t); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _PROPLIB_PROP_BOOL_H_ */ 56 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/prop_data.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_data.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROP_DATA_H_ 33 | #define _PROPLIB_PROP_DATA_H_ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | typedef struct _prop_data *prop_data_t; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | prop_data_t prop_data_create_data(const void *, size_t); 46 | prop_data_t prop_data_create_data_nocopy(const void *, size_t); 47 | 48 | prop_data_t prop_data_copy(prop_data_t); 49 | 50 | size_t prop_data_size(prop_data_t); 51 | 52 | void * prop_data_data(prop_data_t); 53 | const void * prop_data_data_nocopy(prop_data_t); 54 | 55 | bool prop_data_equals(prop_data_t, prop_data_t); 56 | bool prop_data_equals_data(prop_data_t, const void *, size_t); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* _PROPLIB_PROP_DATA_H_ */ 63 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/prop_ingest.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_ingest.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROP_INGEST_H_ 33 | #define _PROPLIB_PROP_INGEST_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef enum { 39 | PROP_INGEST_ERROR_NO_ERROR = 0, 40 | PROP_INGEST_ERROR_NO_KEY = 1, 41 | PROP_INGEST_ERROR_WRONG_TYPE = 2, 42 | PROP_INGEST_ERROR_HANDLER_FAILED = 3 43 | } prop_ingest_error_t; 44 | 45 | typedef enum { 46 | PROP_INGEST_FLAG_OPTIONAL = 0x01 47 | } prop_ingest_flag_t; 48 | 49 | typedef struct _prop_ingest_context *prop_ingest_context_t; 50 | 51 | typedef bool (*prop_ingest_handler_t)(prop_ingest_context_t, prop_object_t); 52 | 53 | typedef struct { 54 | const char *pite_key; 55 | prop_type_t pite_type; 56 | unsigned int pite_flags; 57 | prop_ingest_handler_t pite_handler; 58 | } prop_ingest_table_entry; 59 | 60 | #define PROP_INGEST(key_, type_, handler_) \ 61 | { .pite_key = key_ , \ 62 | .pite_type = type_ , \ 63 | .pite_flags = 0 , \ 64 | .pite_handler = handler_ } 65 | 66 | #define PROP_INGEST_OPTIONAL(key_, type_, handler_) \ 67 | { .pite_key = key_ , \ 68 | .pite_type = type_ , \ 69 | .pite_flags = PROP_INGEST_FLAG_OPTIONAL , \ 70 | .pite_handler = handler_ } 71 | 72 | #define PROP_INGEST_END \ 73 | { .pite_key = NULL } 74 | 75 | #ifdef __cplusplus 76 | extern "C" { 77 | #endif 78 | 79 | prop_ingest_context_t 80 | prop_ingest_context_alloc(void *); 81 | void prop_ingest_context_free(prop_ingest_context_t); 82 | 83 | prop_ingest_error_t 84 | prop_ingest_context_error(prop_ingest_context_t); 85 | prop_type_t prop_ingest_context_type(prop_ingest_context_t); 86 | const char * prop_ingest_context_key(prop_ingest_context_t); 87 | void * prop_ingest_context_private(prop_ingest_context_t); 88 | 89 | bool prop_dictionary_ingest(prop_dictionary_t, 90 | const prop_ingest_table_entry[], 91 | prop_ingest_context_t); 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* _PROPLIB_PROP_INGEST_H_ */ 97 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/prop_number.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_number.h,v 1.6 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROP_NUMBER_H_ 33 | #define _PROPLIB_PROP_NUMBER_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef struct _prop_number *prop_number_t; 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | prop_number_t prop_number_create_integer(int64_t); 45 | prop_number_t prop_number_create_unsigned_integer(uint64_t); 46 | 47 | prop_number_t prop_number_copy(prop_number_t); 48 | 49 | int prop_number_size(prop_number_t); 50 | bool prop_number_unsigned(prop_number_t); 51 | 52 | int64_t prop_number_integer_value(prop_number_t); 53 | uint64_t prop_number_unsigned_integer_value(prop_number_t); 54 | 55 | bool prop_number_equals(prop_number_t, prop_number_t); 56 | bool prop_number_equals_integer(prop_number_t, int64_t); 57 | bool prop_number_equals_unsigned_integer(prop_number_t, uint64_t); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* _PROPLIB_PROP_NUMBER_H_ */ 64 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/prop_object.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_object.h,v 1.7 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROP_OBJECT_H_ 33 | #define _PROPLIB_PROP_OBJECT_H_ 34 | 35 | #include 36 | #include 37 | 38 | typedef void *prop_object_t; 39 | 40 | typedef enum { 41 | PROP_TYPE_UNKNOWN = 0x00000000, 42 | PROP_TYPE_BOOL = 0x626f6f6c, /* 'bool' */ 43 | PROP_TYPE_NUMBER = 0x6e6d6272, /* 'nmbr' */ 44 | PROP_TYPE_STRING = 0x73746e67, /* 'stng' */ 45 | PROP_TYPE_DATA = 0x64617461, /* 'data' */ 46 | PROP_TYPE_ARRAY = 0x61726179, /* 'aray' */ 47 | PROP_TYPE_DICTIONARY = 0x64696374, /* 'dict' */ 48 | PROP_TYPE_DICT_KEYSYM = 0x646b6579 /* 'dkey' */ 49 | } prop_type_t; 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | void prop_object_retain(prop_object_t); 56 | void prop_object_release(prop_object_t); 57 | 58 | prop_type_t prop_object_type(prop_object_t); 59 | 60 | bool prop_object_equals(prop_object_t, prop_object_t); 61 | bool prop_object_equals_with_error(prop_object_t, prop_object_t, bool *); 62 | 63 | typedef struct _prop_object_iterator *prop_object_iterator_t; 64 | 65 | prop_object_t prop_object_iterator_next(prop_object_iterator_t); 66 | void prop_object_iterator_reset(prop_object_iterator_t); 67 | void prop_object_iterator_release(prop_object_iterator_t); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* _PROPLIB_PROP_OBJECT_H_ */ 74 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/prop_string.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_string.h,v 1.3 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROP_STRING_H_ 33 | #define _PROPLIB_PROP_STRING_H_ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | typedef struct _prop_string *prop_string_t; 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | prop_string_t prop_string_create(void); 46 | prop_string_t prop_string_create_cstring(const char *); 47 | prop_string_t prop_string_create_cstring_nocopy(const char *); 48 | 49 | prop_string_t prop_string_copy(prop_string_t); 50 | prop_string_t prop_string_copy_mutable(prop_string_t); 51 | 52 | size_t prop_string_size(prop_string_t); 53 | bool prop_string_mutable(prop_string_t); 54 | 55 | char * prop_string_cstring(prop_string_t); 56 | const char * prop_string_cstring_nocopy(prop_string_t); 57 | 58 | bool prop_string_append(prop_string_t, prop_string_t); 59 | bool prop_string_append_cstring(prop_string_t, const char *); 60 | 61 | bool prop_string_equals(prop_string_t, prop_string_t); 62 | bool prop_string_equals_cstring(prop_string_t, const char *); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* _PROPLIB_PROP_STRING_H_ */ 69 | -------------------------------------------------------------------------------- /lib/portableproplib/prop/proplib.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: proplib.h,v 1.6 2008/04/28 20:22:51 martin Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Jason R. Thorpe. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROPLIB_PROPLIB_H_ 33 | #define _PROPLIB_PROPLIB_H_ 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif /* _PROPLIB_PROPLIB_H_ */ 46 | -------------------------------------------------------------------------------- /lib/portableproplib/prop_rb_impl.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_rb_impl.h,v 1.8 2010/09/25 01:42:38 matt Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Matt Thomas . 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROP_RB_IMPL_H_ 33 | #define _PROP_RB_IMPL_H_ 34 | 35 | #include 36 | 37 | /* 38 | * Define local names for common rb_tree functions. 39 | */ 40 | #define _prop_rb_tree_init rb_tree_init 41 | #define _prop_rb_tree_insert_node rb_tree_insert_node 42 | #define _prop_rb_tree_find rb_tree_find_node 43 | #define _prop_rb_tree_remove_node rb_tree_remove_node 44 | #define _prop_rb_tree_iterate rb_tree_iterate 45 | 46 | #endif /* _PROP_RB_IMPL_H_*/ 47 | -------------------------------------------------------------------------------- /lib/portableproplib/prop_stack.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: prop_stack.h,v 1.2 2007/08/30 12:23:54 joerg Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2007 Joerg Sonnenberger . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef _PROP_STACK_H 33 | #define _PROP_STACK_H 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | struct _prop_stack_intern_elem { 40 | prop_object_t object; 41 | void *object_data[3]; 42 | }; 43 | 44 | struct _prop_stack_extern_elem { 45 | SLIST_ENTRY(_prop_stack_extern_elem) stack_link; 46 | prop_object_t object; 47 | void *object_data[3]; 48 | }; 49 | 50 | #define PROP_STACK_INTERN_ELEMS 16 51 | 52 | struct _prop_stack { 53 | struct _prop_stack_intern_elem intern_elems[PROP_STACK_INTERN_ELEMS]; 54 | size_t used_intern_elems; 55 | SLIST_HEAD(, _prop_stack_extern_elem) extern_elems; 56 | }; 57 | 58 | typedef struct _prop_stack *prop_stack_t; 59 | 60 | void _prop_stack_init(prop_stack_t); 61 | bool _prop_stack_push(prop_stack_t, prop_object_t, void *, void *, void *); 62 | bool _prop_stack_pop(prop_stack_t, prop_object_t *, void **, void **, void **); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /mk/prog.mk: -------------------------------------------------------------------------------- 1 | -include $(TOPDIR)/config.mk 2 | 3 | OBJS ?= main.o 4 | 5 | BINS = $(BIN) 6 | MANSECTION ?= 1 7 | MAN ?= $(BIN).$(MANSECTION) 8 | 9 | ifdef BUILD_STATIC 10 | BINS += $(BIN).static 11 | endif 12 | 13 | CFLAGS += -Wno-unused-command-line-argument 14 | 15 | .PHONY: all 16 | all: $(BINS) 17 | 18 | .PHONY: clean 19 | clean: 20 | -rm -f $(BIN) $(BIN).static 21 | -rm -f *.o 22 | 23 | .PHONY: install 24 | install: all 25 | install -d $(DESTDIR)$(SBINDIR) 26 | install -m 755 $(BIN) $(DESTDIR)$(SBINDIR) 27 | ifdef BUILD_STATIC 28 | install -m 755 $(BIN).static $(DESTDIR)$(SBINDIR) 29 | endif 30 | ifdef MAN 31 | install -d $(DESTDIR)$(MANDIR)/man$(MANSECTION) 32 | install -m 644 $(MAN) $(DESTDIR)$(MANDIR)/man$(MANSECTION) 33 | endif 34 | 35 | .PHONY: uninstall 36 | uninstall: 37 | -rm -f $(DESTDIR)$(SBINDIR)/$(BIN) 38 | ifdef BUILD_STATIC 39 | -rm -f $(DESTDIR)$(SBINDIR)/$(BIN).static 40 | endif 41 | ifdef MAN 42 | -rm -f $(DESTDIR)$(MANDIR)/man$(MANSECTION)/$(MAN) 43 | endif 44 | 45 | %.o: %.c 46 | @printf " [CC]\t\t$@\n" 47 | ${SILENT}$(CC) $(CPPFLAGS) $(PROG_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< 48 | 49 | $(BIN).static: $(OBJS) $(TOPDIR)/lib/libxbps.a 50 | @printf " [CCLD]\t\t$@\n" 51 | ${SILENT}$(CC) -static $(OBJS) $(CPPFLAGS) -L$(TOPDIR)/lib \ 52 | $(CFLAGS) $(LDFLAGS) $(PROG_LDFLAGS) $(STATIC_LIBS) -o $@ 53 | 54 | $(BIN): $(OBJS) $(TOPDIR)/lib/libxbps.so 55 | @printf " [CCLD]\t\t$@\n" 56 | ${SILENT}$(CC) $^ $(CPPFLAGS) -L$(TOPDIR)/lib \ 57 | $(CFLAGS) $(PROG_CFLAGS) $(LDFLAGS) $(PROG_LDFLAGS) \ 58 | -lxbps -o $@ 59 | 60 | -------------------------------------------------------------------------------- /mk/subdir.mk: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: 3 | @for dir in $(SUBDIRS); do \ 4 | $(MAKE) -C $$dir || exit 1; \ 5 | done 6 | 7 | .PHONY: install 8 | install: 9 | @for dir in $(SUBDIRS); do \ 10 | $(MAKE) -C $$dir install || exit 1; \ 11 | done 12 | 13 | .PHONY: uninstall 14 | uninstall: 15 | @for dir in $(SUBDIRS); do \ 16 | $(MAKE) -C $$dir uninstall || exit1; \ 17 | done 18 | 19 | .PHONY: clean 20 | clean: 21 | @for dir in $(SUBDIRS); do \ 22 | $(MAKE) -C $$dir clean || exit 1; \ 23 | done 24 | -------------------------------------------------------------------------------- /mk/test.mk: -------------------------------------------------------------------------------- 1 | -include $(TOPDIR)/config.mk 2 | 3 | OBJS ?= main.o 4 | 5 | .PHONY: all 6 | all: $(TEST) $(TESTSHELL) 7 | 8 | .PHONY: clean 9 | clean: 10 | -rm -f $(TEST) $(TESTSHELL) $(OBJS) 11 | 12 | .PHONY: install 13 | install: 14 | install -d $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 15 | ifdef TEST 16 | install -m755 $(TEST) $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 17 | endif 18 | ifdef TESTSHELL 19 | install -m755 $(TESTSHELL) $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 20 | endif 21 | ifdef EXTRA_FILES 22 | for f in $(EXTRA_FILES); do \ 23 | install -m644 $${f} $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR); \ 24 | done 25 | endif 26 | 27 | .PHONY: uninstall 28 | uninstall: 29 | -rm -f $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR)/$(TEST) 30 | -rm -f $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR)/$(TESTSHELL) 31 | 32 | %.o: %.c 33 | @printf " [CC]\t\t$@\n" 34 | ${SILENT}$(CC) $(CPPFLAGS) $(CFLAGS) -c $< 35 | 36 | $(TEST): $(OBJS) 37 | @printf " [CCLD]\t\t$@\n" 38 | ${SILENT}$(CC) $^ $(CPPFLAGS) -L$(TOPDIR)/lib $(CFLAGS) \ 39 | $(PROG_CFLAGS) $(LDFLAGS) $(PROG_LDFLAGS) -lxbps -latf-c -o $@ 40 | 41 | -------------------------------------------------------------------------------- /run-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for f in bin/*; do 4 | export PATH=$PWD/$f:$PATH 5 | done 6 | export PATH=$PATH:/usr/local/bin 7 | 8 | NPROCS=1 9 | if [ -r /proc/cpuinfo ]; then 10 | NPROCS=$(grep ^proc /proc/cpuinfo|wc -l) 11 | fi 12 | export XBPS_SYSLOG=false 13 | LIBRARY_PATH=$PWD/lib LD_LIBRARY_PATH=$PWD/lib ATF_SHELL=/bin/sh kyua --variable parallelism=$NPROCS test -r result.db -k tests/xbps/Kyuafile 14 | rv=$? 15 | kyua report --verbose -r result.db 16 | rm -f result.db 17 | exit $rv 18 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | -include ../config.mk 2 | 3 | SUBDIRS = xbps 4 | 5 | include ../mk/subdir.mk 6 | -------------------------------------------------------------------------------- /tests/xbps/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps") 4 | 5 | include('libxbps/Kyuafile') 6 | include('xbps-alternatives/Kyuafile') 7 | include('xbps-checkvers/Kyuafile') 8 | include('xbps-create/Kyuafile') 9 | include('xbps-fetch/Kyuafile') 10 | include('xbps-install/Kyuafile') 11 | include('xbps-query/Kyuafile') 12 | include('xbps-rindex/Kyuafile') 13 | include('xbps-uhelper/Kyuafile') 14 | include('xbps-remove/Kyuafile') 15 | include('xbps-digest/Kyuafile') 16 | -------------------------------------------------------------------------------- /tests/xbps/Makefile: -------------------------------------------------------------------------------- 1 | -include ../../config.mk 2 | 3 | SUBDIRS = common libxbps xbps-alternatives xbps-checkvers xbps-create xbps-fetch xbps-install xbps-query xbps-rindex xbps-uhelper xbps-remove xbps-digest 4 | 5 | include ../../mk/subdir.mk 6 | -------------------------------------------------------------------------------- /tests/xbps/common/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps 5 | 6 | all: 7 | 8 | install: 9 | install -d $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 10 | install -m644 ../Kyuafile $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 11 | 12 | uninstall: 13 | -rm -f $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR)/Kyuafile 14 | 15 | clean: 16 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | include('util/Kyuafile') 6 | include('util_path/Kyuafile') 7 | include('cmpver/Kyuafile') 8 | include('pkgpattern_match/Kyuafile') 9 | include('plist_match/Kyuafile') 10 | include('plist_match_virtual/Kyuafile') 11 | include('config/Kyuafile') 12 | include('find_pkg_orphans/Kyuafile') 13 | include('pkgdb/Kyuafile') 14 | include('shell/Kyuafile') 15 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/Makefile: -------------------------------------------------------------------------------- 1 | -include ../../../config.mk 2 | 3 | SUBDIRS = common 4 | 5 | SUBDIRS += cmpver 6 | SUBDIRS += pkgpattern_match 7 | SUBDIRS += plist_match 8 | SUBDIRS += plist_match_virtual 9 | SUBDIRS += util 10 | SUBDIRS += util_path 11 | SUBDIRS += find_pkg_orphans 12 | SUBDIRS += pkgdb 13 | SUBDIRS += config 14 | SUBDIRS += shell 15 | 16 | include ../../../mk/subdir.mk 17 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/Makefile.inc: -------------------------------------------------------------------------------- 1 | TESTSSUBDIR = xbps/libxbps 2 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/cmpver/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="cmpver_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/cmpver/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/cmpver 5 | TEST = cmpver_test 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/cmpver/main.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | *- 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | ATF_TC(cmpver_test); 31 | 32 | ATF_TC_HEAD(cmpver_test, tc) 33 | { 34 | atf_tc_set_md_var(tc, "descr", "Test xbps_cmpver conditions"); 35 | } 36 | 37 | ATF_TC_BODY(cmpver_test, tc) 38 | { 39 | ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0", "foo-1.0"), 0); 40 | ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0", "foo-1.0_1"), -1); 41 | ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0_1", "foo-1.0"), 1); 42 | ATF_REQUIRE_EQ(xbps_cmpver("foo-2.0rc2", "foo-2.0rc3"), -1); 43 | ATF_REQUIRE_EQ(xbps_cmpver("foo-2.0rc3", "foo-2.0rc2"), 1); 44 | ATF_REQUIRE_EQ(xbps_cmpver("foo-129", "foo-129_1"), -1); 45 | ATF_REQUIRE_EQ(xbps_cmpver("foo-blah-100dpi-21", "foo-blah-100dpi-21_0"), 0); 46 | ATF_REQUIRE_EQ(xbps_cmpver("foo-blah-100dpi-21", "foo-blah-100dpi-2.1"), 1); 47 | ATF_REQUIRE_EQ(xbps_cmpver("foo-1.0.1", "foo-1.0_1"), 1); 48 | } 49 | 50 | ATF_TP_ADD_TCS(tp) 51 | { 52 | ATF_TP_ADD_TC(tp, cmpver_test); 53 | return atf_no_error(); 54 | } 55 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/common/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | include ../Makefile.inc 5 | 6 | all: 7 | 8 | install: 9 | install -d $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 10 | install -m644 ../Kyuafile $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR) 11 | 12 | uninstall: 13 | -rm -f $(DESTDIR)$(TESTSDIR)/$(TESTSSUBDIR)/Kyuafile 14 | 15 | clean: 16 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/1.include.cf: -------------------------------------------------------------------------------- 1 | repository=1 2 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/2.include.cf: -------------------------------------------------------------------------------- 1 | repository=2 2 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="config_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/config 5 | TEST = config_test 6 | EXTRA_FILES = Kyuafile xbps.cf xbps_nomatch.cf 1.include.cf 2.include.cf 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/no-trailing-nl.cf: -------------------------------------------------------------------------------- 1 | repository=test -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/trim.cf: -------------------------------------------------------------------------------- 1 | repository= 1 2 | repository =2 -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/xbps.cf: -------------------------------------------------------------------------------- 1 | # relative path 2 | include=*.include.conf 3 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/xbps_absolute.cf: -------------------------------------------------------------------------------- 1 | # relative path 2 | include=/xbps2.d/1.include.conf 3 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/xbps_absolute_glob.cf: -------------------------------------------------------------------------------- 1 | # relative path 2 | include=/xbps2.d/*.include.conf 3 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/config/xbps_nomatch.cf: -------------------------------------------------------------------------------- 1 | # relative path 2 | include=*.this_file_does_not_exist.conf 3 | include=nodir/*.this_file_does_not_exist.conf 4 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/find_pkg_orphans/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="find_pkg_orphans_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/find_pkg_orphans/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/find_pkg_orphans 5 | TEST = find_pkg_orphans_test 6 | EXTRA_FILES = Kyuafile pkgdb-0.38.plist 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/pkgdb/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="pkgdb_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/pkgdb/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/pkgdb 5 | TEST = pkgdb_test 6 | EXTRA_FILES = Kyuafile pkgdb-0.38.plist 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/pkgdb/pkgdb-0.38.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | four 6 | 7 | automatic-install 8 | 9 | pkgver 10 | four-0.1_1 11 | run_depends 12 | 13 | mixed-0.1_1 14 | 15 | short_desc 16 | four descriptionm 17 | state 18 | installed 19 | 20 | mixed 21 | 22 | automatic-install 23 | 24 | pkgver 25 | mixed-0.1_1 26 | short_desc 27 | mixed description 28 | state 29 | installed 30 | 31 | one 32 | 33 | automatic-install 34 | 35 | pkgver 36 | one-0.1_1 37 | run_depends 38 | 39 | two>=0.2 40 | 41 | short_desc 42 | one descriptionm 43 | state 44 | installed 45 | 46 | three 47 | 48 | automatic-install 49 | 50 | pkgver 51 | three-0.1_1 52 | run_depends 53 | 54 | four-0.1_1 55 | 56 | short_desc 57 | three descriptionm 58 | state 59 | installed 60 | 61 | two 62 | 63 | automatic-install 64 | 65 | pkgver 66 | two-0.1_1 67 | run_depends 68 | 69 | three>=0.1 70 | mixed>=0 71 | 72 | short_desc 73 | two descriptionm 74 | state 75 | installed 76 | 77 | virtual-mixed 78 | 79 | automatic-install 80 | 81 | pkgver 82 | virtual-mixed-0.1_1 83 | provides 84 | 85 | mixed-0.1_1 86 | 87 | run_depends 88 | 89 | four-0.1_1 90 | three-0.1_1 91 | 92 | short_desc 93 | virtual-mixed description 94 | state 95 | installed 96 | 97 | reverts 98 | 99 | automatic-install 100 | 101 | pkgver 102 | reverts-0.2_1 103 | reverts 104 | 105 | 0.3_1 106 | 0.4_1 107 | 108 | short_desc 109 | two descriptionm 110 | state 111 | installed 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/pkgpattern_match/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="pkgpattern_match_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/pkgpattern_match/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/pkgpattern_match 5 | TEST = pkgpattern_match_test 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/pkgpattern_match/main.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | *- 25 | */ 26 | #include 27 | #include 28 | 29 | ATF_TC(pkgpattern_match_test); 30 | 31 | ATF_TC_HEAD(pkgpattern_match_test, tc) 32 | { 33 | atf_tc_set_md_var(tc, "descr", "Test xbps_pkgpattern_match"); 34 | } 35 | 36 | ATF_TC_BODY(pkgpattern_match_test, tc) 37 | { 38 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo>=0"), 1); 39 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo>=1.0"), 1); 40 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo>=1.0<1.0_1"), 1); 41 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo>1.0_1"), 0); 42 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo<1.0"), 0); 43 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo-1.0"), 1); 44 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo-[0-1].[0-9]*"), 1); 45 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.0", "foo-[1-2].[1-9]*"), 0); 46 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.01", "foo-1.[0-9]?"), 1); 47 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.01", "foo-1.[1-9]?"), 0); 48 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.01", "foo-1.[0-2][2-4]?"), 0); 49 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.02", "foo>=1.[0-2][2-4]?"), 1); 50 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.12", "foo>=1.[0-2][2-4]?"), 1); 51 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.22", "foo>=1.[0-2][2-4]?"), 1); 52 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.23", "foo>=1.[0-2][2-4]?"), 1); 53 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.24", "foo>=1.[0-2][2-4]?"), 1); 54 | ATF_REQUIRE_EQ(xbps_pkgpattern_match("foo-1.11", "foo-1.[0-2][2-4]?"), 0); 55 | } 56 | 57 | ATF_TP_ADD_TCS(tp) 58 | { 59 | ATF_TP_ADD_TC(tp, pkgpattern_match_test); 60 | return atf_no_error(); 61 | } 62 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/plist_match/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="plist_match_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/plist_match/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/plist_match 5 | TEST = plist_match_test 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/plist_match/main.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | *- 25 | */ 26 | #include 27 | #include 28 | 29 | static xbps_array_t 30 | array_init(void) 31 | { 32 | xbps_array_t a; 33 | 34 | a = xbps_array_create(); 35 | ATF_REQUIRE(a != NULL); 36 | xbps_array_add_cstring_nocopy(a, "foo-2.0_1"); 37 | xbps_array_add_cstring_nocopy(a, "blah-2.1_1"); 38 | 39 | return a; 40 | } 41 | 42 | ATF_TC(match_string_test); 43 | ATF_TC_HEAD(match_string_test, tc) 44 | { 45 | atf_tc_set_md_var(tc, "descr", "Test xbps_match_string_in_array"); 46 | } 47 | 48 | ATF_TC_BODY(match_string_test, tc) 49 | { 50 | xbps_array_t a = array_init(); 51 | ATF_REQUIRE_EQ(xbps_match_string_in_array(a, "foo-2.0_1"), true); 52 | ATF_REQUIRE_EQ(xbps_match_string_in_array(a, "foo-2.1_1"), false); 53 | } 54 | 55 | ATF_TC(match_pkgname_test); 56 | ATF_TC_HEAD(match_pkgname_test, tc) 57 | { 58 | atf_tc_set_md_var(tc, "descr", "Test xbps_match_pkgname_in_array"); 59 | } 60 | 61 | ATF_TC_BODY(match_pkgname_test, tc) 62 | { 63 | xbps_array_t a = array_init(); 64 | ATF_REQUIRE_EQ(xbps_match_pkgname_in_array(a, "foo"), true); 65 | ATF_REQUIRE_EQ(xbps_match_pkgname_in_array(a, "baz"), false); 66 | } 67 | 68 | ATF_TC(match_pkgpattern_test); 69 | ATF_TC_HEAD(match_pkgpattern_test, tc) 70 | { 71 | atf_tc_set_md_var(tc, "descr", "Test xbps_match_pkgpattern_in_array"); 72 | } 73 | 74 | ATF_TC_BODY(match_pkgpattern_test, tc) 75 | { 76 | xbps_array_t a = array_init(); 77 | ATF_REQUIRE_EQ(xbps_match_pkgpattern_in_array(a, "foo>=1.0"), true); 78 | ATF_REQUIRE_EQ(xbps_match_pkgpattern_in_array(a, "blah<1.0"), false); 79 | } 80 | 81 | ATF_TC(match_pkgdep_test); 82 | ATF_TC_HEAD(match_pkgdep_test, tc) 83 | { 84 | atf_tc_set_md_var(tc, "descr", "Test xbps_match_pkgdep_in_array"); 85 | } 86 | 87 | ATF_TC_BODY(match_pkgdep_test, tc) 88 | { 89 | xbps_array_t a = array_init(); 90 | ATF_REQUIRE_EQ(xbps_match_pkgdep_in_array(a, "foo-2.0_1"), true); 91 | } 92 | 93 | ATF_TP_ADD_TCS(tp) 94 | { 95 | ATF_TP_ADD_TC(tp, match_string_test); 96 | ATF_TP_ADD_TC(tp, match_pkgname_test); 97 | ATF_TP_ADD_TC(tp, match_pkgpattern_test); 98 | ATF_TP_ADD_TC(tp, match_pkgdep_test); 99 | 100 | return atf_no_error(); 101 | } 102 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/plist_match_virtual/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="plist_match_virtual_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/plist_match_virtual/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/plist_match_virtual 5 | TEST = plist_match_virtual_test 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/plist_match_virtual/main.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012-2015 Juan Romero Pardines. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | *- 25 | */ 26 | #include 27 | #include 28 | 29 | static xbps_array_t 30 | rundeps_init(void) 31 | { 32 | xbps_array_t a; 33 | 34 | a = xbps_array_create(); 35 | ATF_REQUIRE(a != NULL); 36 | 37 | xbps_array_add_cstring_nocopy(a, "cron-daemon>=0"); 38 | xbps_array_add_cstring_nocopy(a, "xbps>=0.14"); 39 | 40 | return a; 41 | } 42 | 43 | static xbps_array_t 44 | provides_init(void) 45 | { 46 | xbps_array_t a; 47 | 48 | a = xbps_array_create(); 49 | ATF_REQUIRE(a != NULL); 50 | 51 | xbps_array_add_cstring_nocopy(a, "cron-daemon-0_1"); 52 | xbps_array_add_cstring_nocopy(a, "xbps-9999_1"); 53 | 54 | return a; 55 | } 56 | 57 | static xbps_dictionary_t 58 | pkgdict_init(void) 59 | { 60 | xbps_array_t a; 61 | xbps_dictionary_t d; 62 | 63 | d = xbps_dictionary_create(); 64 | ATF_REQUIRE(d != NULL); 65 | 66 | a = provides_init(); 67 | ATF_REQUIRE_EQ(xbps_dictionary_set(d, "provides", a), true); 68 | 69 | return d; 70 | } 71 | 72 | ATF_TC(match_virtual_pkg_dict_test); 73 | ATF_TC_HEAD(match_virtual_pkg_dict_test, tc) 74 | { 75 | atf_tc_set_md_var(tc, "descr", "Test xbps_match_virtual_pkg_in_dict"); 76 | } 77 | 78 | ATF_TC_BODY(match_virtual_pkg_dict_test, tc) 79 | { 80 | xbps_dictionary_t d; 81 | 82 | d = pkgdict_init(); 83 | ATF_REQUIRE_EQ(xbps_match_virtual_pkg_in_dict(d, "cron-daemon"), true); 84 | ATF_REQUIRE_EQ(xbps_match_virtual_pkg_in_dict(d, "cron-daemon>=0"), true); 85 | ATF_REQUIRE_EQ(xbps_match_virtual_pkg_in_dict(d, "cron-daemon>2"), false); 86 | } 87 | 88 | ATF_TC(match_any_virtualpkg_rundeps_test); 89 | ATF_TC_HEAD(match_any_virtualpkg_rundeps_test, tc) 90 | { 91 | atf_tc_set_md_var(tc, "descr", "Test xbps_match_any_virtualpkg_in_rundeps"); 92 | } 93 | 94 | ATF_TC_BODY(match_any_virtualpkg_rundeps_test, tc) 95 | { 96 | xbps_array_t provides, rundeps; 97 | 98 | provides = provides_init(); 99 | rundeps = rundeps_init(); 100 | 101 | ATF_REQUIRE_EQ( 102 | xbps_match_any_virtualpkg_in_rundeps(rundeps, provides), true); 103 | } 104 | 105 | ATF_TP_ADD_TCS(tp) 106 | { 107 | ATF_TP_ADD_TC(tp, match_virtual_pkg_dict_test); 108 | ATF_TP_ADD_TC(tp, match_any_virtualpkg_rundeps_test); 109 | 110 | return atf_no_error(); 111 | } 112 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="issue6_test"} 6 | atf_test_program{name="issue18_test"} 7 | atf_test_program{name="issue20_test"} 8 | atf_test_program{name="issue31_test"} 9 | atf_test_program{name="conf_files_test"} 10 | atf_test_program{name="remove_test"} 11 | atf_test_program{name="replace_test"} 12 | atf_test_program{name="installmode_test"} 13 | atf_test_program{name="obsoletefiles_test"} 14 | atf_test_program{name="scripts_test"} 15 | atf_test_program{name="incorrect_deps_test"} 16 | atf_test_program{name="vpkg_test"} 17 | atf_test_program{name="install_test"} 18 | atf_test_program{name="configure_test"} 19 | atf_test_program{name="preserve_files_test"} 20 | atf_test_program{name="update_shlibs_test"} 21 | atf_test_program{name="update_hold_test"} 22 | atf_test_program{name="update_repolock_test"} 23 | atf_test_program{name="update_itself_test"} 24 | atf_test_program{name="cyclic_deps_test"} 25 | atf_test_program{name="conflicts_test"} 26 | atf_test_program{name="hold_test"} 27 | atf_test_program{name="ignore_test"} 28 | atf_test_program{name="preserve_test"} 29 | atf_test_program{name="orphans_test"} 30 | atf_test_program{name="noextract_files_test"} 31 | atf_test_program{name="transaction_check_revdeps_test"} 32 | atf_test_program{name="repo_test"} 33 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/shell 5 | TESTSHELL = conf_files_test issue6_test issue18_test issue20_test remove_test 6 | TESTSHELL+= replace_test installmode_test obsoletefiles_test 7 | TESTSHELL+= issue31_test scripts_test incorrect_deps_test 8 | TESTSHELL+= vpkg_test install_test preserve_files_test configure_test 9 | TESTSHELL+= update_shlibs_test update_hold_test update_repolock_test 10 | TESTSHELL+= cyclic_deps_test conflicts_test update_itself_test 11 | TESTSHELL+= hold_test ignore_test preserve_test repo_test 12 | TESTSHELL+= noextract_files_test orphans_test transaction_check_revdeps_test 13 | EXTRA_FILES = Kyuafile 14 | 15 | include $(TOPDIR)/mk/test.mk 16 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/configure_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env atf-sh 2 | 3 | atf_test_case filemode 4 | 5 | filemode_head() { 6 | atf_set "descr" "Tests for pkg configuration: sane umask for file mode creation" 7 | } 8 | 9 | filemode_body() { 10 | umask 077 11 | mkdir -p repo pkg_A 12 | cat >>pkg_A/INSTALL<=7.11" ../pkg_A 15 | atf_check_equal $? 0 16 | xbps-create -A noarch -n B-1.0_1 -s "B pkg" --dependencies "libGL>=7.11" ../pkg_B 17 | atf_check_equal $? 0 18 | xbps-create -A noarch -n C-1.0_1 -s "C pkg" --dependencies "B>=0" ../pkg_C 19 | atf_check_equal $? 0 20 | 21 | xbps-rindex -d -a $PWD/*.xbps 22 | atf_check_equal $? 0 23 | cd .. 24 | 25 | xbps-install -r root --repository=$PWD/some_repo -dy C 26 | atf_check_equal $? 0 27 | 28 | xbps-query -r root --fulldeptree -x C 29 | atf_check_equal $? 0 30 | } 31 | 32 | atf_test_case cyclic_dep_vpkg2 33 | 34 | cyclic_dep_vpkg2_head() { 35 | atf_set "descr" "Tests for cyclic deps: unresolved circular dependencies" 36 | } 37 | 38 | cyclic_dep_vpkg2_body() { 39 | mkdir some_repo 40 | mkdir -p pkg_A/usr/bin pkg_B/usr/bin pkg_C/usr/bin pkg_D/usr/bin 41 | cd some_repo 42 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" --provides "libGL-7.11_1" --dependencies "xserver-abi-video<20" ../pkg_A 43 | atf_check_equal $? 0 44 | xbps-create -A noarch -n B-1.0_1 -s "B pkg" --dependencies "libGL>=7.11" --provides "xserver-abi-video-19_1" ../pkg_B 45 | atf_check_equal $? 0 46 | xbps-create -A noarch -n C-1.0_1 -s "C pkg" --dependencies "libGL>=7.11" ../pkg_C 47 | atf_check_equal $? 0 48 | 49 | xbps-rindex -d -a $PWD/*.xbps 50 | atf_check_equal $? 0 51 | cd .. 52 | 53 | xbps-install -r root --repository=$PWD/some_repo -dy C 54 | atf_check_equal $? 40 55 | } 56 | 57 | atf_test_case cyclic_dep_full 58 | 59 | cyclic_dep_full_head() { 60 | atf_set "descr" "Tests for cyclic deps: verify fulldeptree" 61 | } 62 | 63 | cyclic_dep_full_body() { 64 | mkdir some_repo 65 | mkdir -p pkg_A/usr/bin pkg_B/usr/bin 66 | cd some_repo 67 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" --dependencies "B>=0" ../pkg_A 68 | atf_check_equal $? 0 69 | xbps-create -A noarch -n B-1.0_1 -s "B pkg" --dependencies "A>=0" ../pkg_B 70 | atf_check_equal $? 0 71 | 72 | xbps-rindex -d -a $PWD/*.xbps 73 | atf_check_equal $? 0 74 | cd .. 75 | 76 | xbps-install -r root --repository=$PWD/some_repo -dy B 77 | atf_check_equal $? 0 78 | xbps-query -r root --fulldeptree -dx B 79 | atf_check_equal $? 0 80 | xbps-remove -r root -Ryvd B 81 | atf_check_equal $? 0 82 | } 83 | 84 | atf_init_test_cases() { 85 | atf_add_test_case cyclic_dep_vpkg 86 | atf_add_test_case cyclic_dep_vpkg2 87 | atf_add_test_case cyclic_dep_full 88 | } 89 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/issue18_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | 3 | # xbps issue #18. 4 | # How to reproduce it: 5 | # Generate pkg A-0.1_1 and B-0.1_1. 6 | # Install both pkgs. 7 | # Generate pkg A-0.2_1: conflicts with B<0.1_2. 8 | # Generate pkg B-0.1_2. 9 | # Update all packages. 10 | 11 | atf_test_case issue18 12 | 13 | issue18_head() { 14 | atf_set "descr" "xbps issue #18 (https://github.com/xtraeme/xbps/issues/18)" 15 | } 16 | 17 | issue18_body() { 18 | mkdir pkg_A pkg_B 19 | xbps-create -A noarch -n A-0.1_1 -s "pkg A" pkg_A 20 | atf_check_equal $? 0 21 | xbps-create -A noarch -n B-0.1_1 -s "pkg B" pkg_B 22 | atf_check_equal $? 0 23 | xbps-rindex -d -a $PWD/*.xbps 24 | atf_check_equal $? 0 25 | xbps-install -C null.conf -r rootdir --repository=$PWD -y A B 26 | atf_check_equal $? 0 27 | 28 | xbps-create -A noarch -n A-0.2_1 -s "pkg A" --conflicts "B<0.1_2" pkg_A 29 | atf_check_equal $? 0 30 | xbps-create -A noarch -n B-0.1_2 -s "pkg B" pkg_B 31 | atf_check_equal $? 0 32 | xbps-rindex -d -a $PWD/*.xbps 33 | atf_check_equal $? 0 34 | xbps-install -C null.conf -r rootdir --repository=$PWD -yu 35 | atf_check_equal $? 0 36 | } 37 | 38 | atf_init_test_cases() { 39 | atf_add_test_case issue18 40 | } 41 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/issue20_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | 3 | # xbps issue #20. 4 | # How to reproduce it: 5 | # Create pkg a-0.1_1 containing 1 file and 1 symlink: 6 | # 7 | # /foo 8 | # /blah -> foo 9 | # 10 | # Create pkg a-0.2_1 containing 1 file and 1 symlink (inverted): 11 | # 12 | # /foo -> blah 13 | # /blah 14 | # 15 | # Upgrade pkg a to 0.2. 16 | 17 | atf_test_case issue20 18 | 19 | issue20_head() { 20 | atf_set "descr" "xbps issue #20 (https://github.com/xtraeme/xbps/issues/18)" 21 | } 22 | 23 | issue20_body() { 24 | mkdir repo 25 | cd repo 26 | mkdir pkg_a 27 | touch pkg_a/foo 28 | ln -s foo pkg_a/blah 29 | xbps-create -A noarch -n a-0.1_1 -s "pkg a" pkg_a 30 | atf_check_equal $? 0 31 | rm -rf pkg_a 32 | xbps-rindex -d -a $PWD/*.xbps 33 | atf_check_equal $? 0 34 | xbps-install -C null.conf -r rootdir --repository=$PWD -yvd a 35 | atf_check_equal $? 0 36 | 37 | mkdir pkg_a 38 | touch pkg_a/blah 39 | ln -s blah pkg_a/foo 40 | xbps-create -A noarch -n a-0.2_1 -s "pkg a" pkg_a 41 | atf_check_equal $? 0 42 | rm -rf pkg_a 43 | xbps-rindex -d -a $PWD/*.xbps 44 | atf_check_equal $? 0 45 | xbps-install -C null.conf -r rootdir --repository=$PWD -yuvd 46 | atf_check_equal $? 0 47 | tgt=$(readlink rootdir/foo) 48 | rval=1 49 | if [ -f rootdir/blah -a "$tgt" = "blah" ]; then 50 | rval=0 51 | fi 52 | atf_check_equal $rval 0 53 | } 54 | 55 | atf_init_test_cases() { 56 | atf_add_test_case issue20 57 | } 58 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/issue31_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | 3 | # xbps issue #31. 4 | # How to reproduce it: 5 | # Generate pkg A-0.1_1: 6 | # /dir/dir/foo 7 | # Install pkg A. 8 | # Generate pkg A-0.2_1: 9 | # /dir/foo 10 | # Update pkg A to 0.2_1 11 | 12 | atf_test_case issue31 13 | 14 | issue31_head() { 15 | atf_set "descr" "xbps issue #31 (https://github.com/xtraeme/xbps/issues/31)" 16 | } 17 | 18 | issue31_body() { 19 | mkdir -p pkg_A/usr/share/licenses/chromium/license.html 20 | echo random > pkg_A/usr/share/licenses/chromium/license.html/eula.html 21 | xbps-create -A noarch -n A-0.1_1 -s "pkg A" pkg_A 22 | atf_check_equal $? 0 23 | xbps-rindex -d -a $PWD/*.xbps 24 | atf_check_equal $? 0 25 | 26 | xbps-install -r root -C null.conf --repository=$PWD -y A 27 | atf_check_equal $? 0 28 | 29 | touch root/usr/share/licenses/chromium/license.html/fail 30 | 31 | mkdir -p pkg_B/usr/share/licenses/chromium 32 | echo "morerandom" > pkg_B/usr/share/licenses/chromium/license.html 33 | xbps-create -A noarch -n A-0.2_1 -s "pkg A" pkg_B 34 | atf_check_equal $? 0 35 | xbps-rindex -d -a A-0.2_1.noarch.xbps 36 | atf_check_equal $? 0 37 | 38 | xbps-install -r root -C null.conf --repository=$PWD -yuvd A 39 | # ENOTEMPTY 40 | atf_check_equal $? 39 41 | 42 | rm root/usr/share/licenses/chromium/license.html/fail 43 | xbps-install -r root -C null.conf --repository=$PWD -yuvd A 44 | atf_check_equal $? 0 45 | } 46 | 47 | atf_init_test_cases() { 48 | atf_add_test_case issue31 49 | } 50 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/issue6_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | 3 | # xbps issue #6. 4 | # How to reproduce it: 5 | # - Create pkg a-0.1_1 (empty). 6 | # - Create two empty dirs on target rootdir. 7 | # /usr/lib/firefox/dictionaries 8 | # /usr/lib/firefox/hyphenation 9 | # - Create pkg a-0.2_1 containing 2 symlinks overwriting existing dirs. 10 | # /usr/lib/firefox/dictionaries -> /usr/share/hunspell 11 | # /usr/lib/firefox/hyphenation -> /usr/share/hyphen 12 | # - Upgrade pkg a to 0.2. 13 | 14 | atf_test_case issue6 15 | 16 | issue6_head() { 17 | atf_set "descr" "xbps issue #6 (https://github.com/xtraeme/xbps/issues/6)" 18 | } 19 | 20 | issue6_body() { 21 | mkdir repo 22 | cd repo 23 | xbps-create -A noarch -n a-0.1_1 -s "pkg a" . 24 | atf_check_equal $? 0 25 | xbps-rindex -d -a $PWD/*.xbps 26 | atf_check_equal $? 0 27 | xbps-install -C null.conf -r rootdir --repository=$PWD -yvd a 28 | atf_check_equal $? 0 29 | mkdir -p rootdir/usr/lib/firefox/dictionaries 30 | mkdir -p rootdir/usr/lib/firefox/hyphenation 31 | mkdir -p pkg_a/usr/lib/firefox 32 | ln -s /usr/share/hunspell pkg_a/usr/lib/firefox/dictionaries 33 | ln -s /usr/share/hyphen pkg_a/usr/lib/firefox/hyphenation 34 | xbps-create -A noarch -n a-0.2_1 -s "pkg a" pkg_a 35 | atf_check_equal $? 0 36 | rm -rf pkg_a 37 | xbps-rindex -d -a $PWD/*.xbps 38 | atf_check_equal $? 0 39 | xbps-install -C null.conf -r rootdir --repository=$PWD -yuvd 40 | atf_check_equal $? 0 41 | tgt1=$(readlink rootdir/usr/lib/firefox/dictionaries) 42 | tgt2=$(readlink rootdir/usr/lib/firefox/hyphenation) 43 | rval=1 44 | if [ "$tgt1" = "/usr/share/hunspell" -a "$tgt2" = "/usr/share/hyphen" ]; then 45 | rval=0 46 | fi 47 | atf_check_equal $rval 0 48 | } 49 | 50 | atf_init_test_cases() { 51 | atf_add_test_case issue6 52 | } 53 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/orphans_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env atf-sh 2 | 3 | atf_test_case tc1 4 | 5 | tc1_head() { 6 | atf_set "descr" "Tests for pkg orphans: https://github.com/void-linux/xbps/issues/234" 7 | } 8 | 9 | tc1_body() { 10 | mkdir -p repo pkg_A 11 | cd repo 12 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A 13 | atf_check_equal $? 0 14 | xbps-create -A noarch -n B-1.0_1 -s "B pkg" --dependencies "A>=0" ../pkg_A 15 | atf_check_equal $? 0 16 | xbps-create -A noarch -n C-1.0_1 -s "C pkg" --dependencies "B>=0" ../pkg_A 17 | atf_check_equal $? 0 18 | xbps-create -A noarch -n D-1.0_1 -s "D pkg" --dependencies "C>=0" ../pkg_A 19 | atf_check_equal $? 0 20 | xbps-rindex -d -a $PWD/*.xbps 21 | atf_check_equal $? 0 22 | cd .. 23 | xbps-install -r root --repo=repo -yd D 24 | atf_check_equal $? 0 25 | out="$(xbps-query -r root -m)" 26 | atf_check_equal $? 0 27 | atf_check_equal "$out" "D-1.0_1" 28 | xbps-remove -r root -Ryd D 29 | atf_check_equal $? 0 30 | out="$(xbps-query -r root -l|wc -l)" 31 | atf_check_equal $? 0 32 | atf_check_equal "$out" "0" 33 | 34 | xbps-install -r root --repo=repo -yd A 35 | atf_check_equal $? 0 36 | out="$(xbps-query -r root -m)" 37 | atf_check_equal $? 0 38 | atf_check_equal "$out" "A-1.0_1" 39 | xbps-install -r root --repo=repo -yd D 40 | atf_check_equal $? 0 41 | xbps-remove -r root -Ryd D 42 | atf_check_equal $? 0 43 | out="$(xbps-query -r root -m)" 44 | atf_check_equal $? 0 45 | atf_check_equal "$out" "A-1.0_1" 46 | 47 | xbps-install -r root --repo=repo -yd D 48 | atf_check_equal $? 0 49 | xbps-pkgdb -r root -m auto A 50 | atf_check_equal $? 0 51 | xbps-remove -r root -Ryd D 52 | atf_check_equal $? 0 53 | out="$(xbps-query -r root -l|wc -l)" 54 | atf_check_equal $? 0 55 | atf_check_equal "$out" "0" 56 | 57 | } 58 | 59 | atf_init_test_cases() { 60 | atf_add_test_case tc1 61 | } 62 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/preserve_files_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env atf-sh 2 | 3 | atf_test_case tc1 4 | 5 | tc1_head() { 6 | atf_set "descr" "Tests for pkg install/upgrade with preserved files: preserve on-disk files with globs" 7 | } 8 | 9 | tc1_body() { 10 | mkdir some_repo 11 | mkdir -p pkg_A/usr/bin 12 | echo "blahblah" > pkg_A/usr/bin/blah 13 | echo "foofoo" > pkg_A/usr/bin/foo 14 | cd some_repo 15 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A 16 | atf_check_equal $? 0 17 | xbps-rindex -d -a $PWD/*.xbps 18 | atf_check_equal $? 0 19 | cd .. 20 | 21 | mkdir -p root/usr/bin 22 | mkdir -p root/xbps.d 23 | echo "modified blahblah" > root/usr/bin/blah 24 | echo "modified foofoo" > root/usr/bin/foo 25 | 26 | echo "preserve=/usr/bin/*" > root/xbps.d/foo.conf 27 | 28 | xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A 29 | atf_check_equal $? 0 30 | 31 | rv=1 32 | if [ "$(cat root/usr/bin/blah)" = "modified blahblah" -a "$(cat root/usr/bin/foo)" = "modified foofoo" ]; then 33 | rv=0 34 | fi 35 | atf_check_equal $rv 0 36 | } 37 | 38 | atf_test_case tc2 39 | 40 | tc2_head() { 41 | atf_set "descr" "Tests for pkg install/upgrade with preserved files: preserve on-disk files without globs" 42 | } 43 | 44 | tc2_body() { 45 | mkdir some_repo 46 | mkdir -p pkg_A/usr/bin 47 | echo "blahblah" > pkg_A/usr/bin/blah 48 | echo "foofoo" > pkg_A/usr/bin/foo 49 | cd some_repo 50 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A 51 | atf_check_equal $? 0 52 | xbps-rindex -d -a $PWD/*.xbps 53 | atf_check_equal $? 0 54 | cd .. 55 | 56 | mkdir -p root/usr/bin 57 | mkdir -p root/xbps.d 58 | echo "modified blahblah" > root/usr/bin/blah 59 | echo "modified foofoo" > root/usr/bin/foo 60 | 61 | printf "preserve=/usr/bin/blah\npreserve=/usr/bin/foo\n" > root/xbps.d/foo.conf 62 | 63 | echo "foo.conf" >&2 64 | cat foo.conf >&2 65 | 66 | xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A 67 | atf_check_equal $? 0 68 | 69 | rv=1 70 | if [ "$(cat root/usr/bin/blah)" = "modified blahblah" -a "$(cat root/usr/bin/foo)" = "modified foofoo" ]; then 71 | rv=0 72 | fi 73 | 74 | echo "root/usr/bin/blah" >&2 75 | cat root/usr/bin/blah >&2 76 | echo "root/usr/bin/foo" >&2 77 | cat root/usr/bin/foo >&2 78 | 79 | atf_check_equal $rv 0 80 | } 81 | 82 | atf_init_test_cases() { 83 | atf_add_test_case tc1 84 | atf_add_test_case tc2 85 | } 86 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/repo_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env atf-sh 2 | 3 | atf_test_case repo_close 4 | 5 | repo_close_head() { 6 | atf_set "descr" "Tests for pkg repos: truncate repo size to 0" 7 | } 8 | 9 | repo_close_body() { 10 | mkdir -p repo pkg_A 11 | cd repo 12 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A 13 | atf_check_equal $? 0 14 | xbps-rindex -d -a $PWD/*.xbps 15 | atf_check_equal $? 0 16 | cd .. 17 | xbps-install -C empty.conf -r root --repository=repo -yn A 18 | atf_check_equal $? 0 19 | truncate --size 0 repo/*-repodata 20 | xbps-install -C empty.conf -r root --repository=repo -yn A 21 | # ENOENT because invalid repodata 22 | atf_check_equal $? 2 23 | } 24 | 25 | atf_init_test_cases() { 26 | atf_add_test_case repo_close 27 | } 28 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/shell/transaction_check_revdeps_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env atf-sh 2 | 3 | atf_test_case issue_245 4 | 5 | issue_245_head() { 6 | atf_set "descr" "Tests update of package with removed and uptodate revdeps" 7 | } 8 | 9 | issue_245_body() { 10 | mkdir some_repo 11 | mkdir destdir 12 | 13 | cd some_repo 14 | xbps-create -A noarch -n libX-1_1 -s "libX pkg" ../destdir 15 | atf_check_equal $? 0 16 | xbps-create -A noarch -n cmdA-1_1 -s "cmdA pkg" --dependencies "libX>=1_1" ../destdir 17 | atf_check_equal $? 0 18 | xbps-create -A noarch -n cmdB-1_1 -s "cmdB pkg" --dependencies "libX>=1_1" ../destdir 19 | atf_check_equal $? 0 20 | xbps-rindex -d -a $PWD/*.xbps 21 | atf_check_equal $? 0 22 | cd .. 23 | 24 | xbps-install -r root --repository=$PWD/some_repo -yd cmdA cmdB 25 | atf_check_equal $? 0 26 | 27 | cd some_repo 28 | xbps-create -A noarch -n libX-1_2 -s "libX pkg" --replaces "cmdA>=1_1" ../destdir 29 | atf_check_equal $? 0 30 | xbps-rindex -d -a $PWD/*.xbps 31 | atf_check_equal $? 0 32 | cd .. 33 | 34 | # was failing here with 35 | xbps-install -r root --repository=$PWD/some_repo -uyd 36 | atf_check_equal $? 0 37 | 38 | xbps-query -r root cmdA 39 | atf_check_equal $? 2 40 | 41 | xbps-query -r root libX-1_2 42 | atf_check_equal $? 0 43 | } 44 | 45 | atf_init_test_cases() { 46 | atf_add_test_case issue_245 47 | } 48 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/util/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="util_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/util/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/util 5 | TEST = util_test 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/util_path/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("libxbps") 4 | 5 | atf_test_program{name="util_path_test"} 6 | -------------------------------------------------------------------------------- /tests/xbps/libxbps/util_path/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSSUBDIR = xbps/libxbps/util 5 | TEST = util_path_test 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-alternatives/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-alternatives") 4 | atf_test_program{name="main_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-alternatives/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = main_test 5 | TESTSSUBDIR = xbps/xbps-alternatives 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-checkvers/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-checkvers") 4 | atf_test_program{name="checkvers_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-checkvers/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = checkvers_test 5 | TESTSSUBDIR = xbps/xbps-checkvers 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-create/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-create") 4 | atf_test_program{name="basic_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-create/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = basic_test 5 | TESTSSUBDIR = xbps/xbps-create 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-digest/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-digest") 4 | atf_test_program{name="basic_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-digest/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = basic_test 5 | TESTSSUBDIR = xbps/xbps-digest 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-digest/basic_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-digest(1) works as expected. 3 | 4 | atf_test_case empty_string 5 | 6 | empty_string_head() { 7 | atf_set "descr" "xbps-digest(1): check empty string hash" 8 | } 9 | 10 | empty_string_body() { 11 | result="$(printf "" | xbps-digest)" 12 | expected=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 13 | rv=0 14 | if [ "$result" != "$expected" ]; then 15 | echo "result: $result" 16 | echo "expected: $expected" 17 | rv=1 18 | fi 19 | atf_check_equal $rv 0 20 | } 21 | 22 | atf_test_case small_file 23 | 24 | small_file_head() { 25 | atf_set "descr" "xbps-digest(1): check small file hash" 26 | } 27 | 28 | small_file_body() { 29 | printf "abc\nbca" > file 30 | result="$(xbps-digest file)" 31 | expected="36749ea1445c9fcb405767cbf67ebb4679dd4f7560a3b5fa977bc288fe15f999" 32 | rv=0 33 | if [ "$result" != "$expected" ]; then 34 | echo "result: $result" 35 | echo "expected: $expected" 36 | rv=1 37 | fi 38 | atf_check_equal $rv 0 39 | } 40 | 41 | atf_init_test_cases() { 42 | atf_add_test_case empty_string 43 | atf_add_test_case small_file 44 | } 45 | -------------------------------------------------------------------------------- /tests/xbps/xbps-fetch/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-fetch") 4 | atf_test_program{name="fetch_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-fetch/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = fetch_test 5 | TESTSSUBDIR = xbps/xbps-fetch 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-fetch/fetch_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-fetch works as expected. 3 | 4 | atf_test_case success 5 | 6 | success_head() { 7 | atf_set "descr" "xbps-fetch: test successful remote fetch" 8 | } 9 | 10 | success_body() { 11 | mkdir some_repo 12 | touch some_repo/pkg_A 13 | xbps-fetch file://$PWD/some_repo/pkg_A 14 | atf_check_equal $? 0 15 | } 16 | 17 | atf_test_case pkgnotfound 18 | 19 | pkgnotfound_head() { 20 | atf_set "descr" "xbps-fetch: test remote package not found" 21 | } 22 | 23 | pkgnotfound_body() { 24 | xbps-fetch file://$PWD/nonexistant 25 | atf_check_equal $? 1 26 | } 27 | 28 | atf_test_case identical 29 | 30 | identical_head() { 31 | atf_set "descr" "xbps-fetch: test fetching identical file from remote" 32 | } 33 | 34 | identical_body() { 35 | mkdir some_repo 36 | echo 'content' > some_repo/pkg_A 37 | echo 'content' > pkg_A 38 | output=$(xbps-fetch file://$PWD/some_repo/pkg_A 2>&1) 39 | atf_check_equal $? 0 40 | atf_check_equal "$output" "WARNING: xbps-fetch: file://$PWD/some_repo/pkg_A: file is identical with remote." 41 | } 42 | 43 | atf_test_case multiple_success 44 | 45 | multiple_success_head() { 46 | atf_set "descr" "xbps-fetch: test fetching multiple remote files" 47 | } 48 | 49 | multiple_success_body() { 50 | mkdir some_repo 51 | touch some_repo/pkg_A some_repo/pkg_B 52 | xbps-fetch file://$PWD/some_repo/pkg_A file://$PWD/some_repo/pkg_B 53 | atf_check_equal $? 0 54 | test -f pkg_A 55 | atf_check_equal $? 0 56 | test -f pkg_B 57 | atf_check_equal $? 0 58 | } 59 | 60 | atf_test_case multiple_notfound 61 | 62 | multiple_notfound_head() { 63 | atf_set "descr" "xbps-fetch: test fetching multiple remote files, with one not found" 64 | } 65 | 66 | multiple_notfound_body() { 67 | mkdir some_repo 68 | touch some_repo/pkg_A 69 | xbps-fetch file://$PWD/some_repo/nonexistant file://$PWD/some_repo/pkg_A 70 | atf_check_equal $? 1 71 | test -f pkg_A 72 | atf_check_equal $? 0 73 | test -f nonexistant 74 | atf_check_equal $? 1 75 | } 76 | 77 | atf_init_test_cases() { 78 | atf_add_test_case success 79 | atf_add_test_case pkgnotfound 80 | atf_add_test_case identical 81 | atf_add_test_case multiple_success 82 | atf_add_test_case multiple_notfound 83 | } 84 | -------------------------------------------------------------------------------- /tests/xbps/xbps-install/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-install") 4 | atf_test_program{name="behaviour_tests"} 5 | atf_test_program{name="revert_tests"} 6 | -------------------------------------------------------------------------------- /tests/xbps/xbps-install/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = behaviour_tests revert_tests 5 | TESTSSUBDIR = xbps/xbps-install 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-install/revert_tests.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | 3 | atf_test_case revert_package 4 | 5 | revert_package_head() { 6 | atf_set "descr" "xbps-install(1): do a full workflow of reverting a package version" 7 | } 8 | 9 | revert_package_body() { 10 | mkdir -p some_repo pkg_A 11 | touch pkg_A/file00 12 | # create package and install it 13 | cd some_repo 14 | echo first V1.0 > ../pkg_A/file00 15 | xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A 16 | atf_check_equal $? 0 17 | xbps-rindex -d -a $PWD/*.xbps 18 | atf_check_equal $? 0 19 | cd .. 20 | xbps-install -r root -C empty.conf --repository=$PWD/some_repo -y A 21 | atf_check_equal $? 0 22 | 23 | # make an update to the package 24 | cd some_repo 25 | echo V1.1 > ../pkg_A/file00 26 | xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A 27 | atf_check_equal $? 0 28 | xbps-rindex -d -a $PWD/*.xbps 29 | atf_check_equal $? 0 30 | cd .. 31 | xbps-install -r root -C empty.conf --repository=$PWD/some_repo -y -u 32 | atf_check_equal $? 0 33 | 34 | # whoops, we made a mistake, rollback to 1.0_1 35 | cd some_repo 36 | echo second V1.0 > ../pkg_A/file00 37 | xbps-create -A noarch -n A-1.0_1 -r "1.1_1" -s "A pkg" ../pkg_A 38 | atf_check_equal $? 0 39 | xbps-rindex -d -a $PWD/*.xbps 40 | atf_check_equal $? 0 41 | cd .. 42 | xbps-install -d -r root -C empty.conf --repository=$PWD/some_repo -y -u 43 | atf_check_equal $? 0 44 | 45 | atf_check_equal "`cat root/file00`" "second V1.0" 46 | } 47 | 48 | atf_init_test_cases() { 49 | atf_add_test_case revert_package 50 | } 51 | -------------------------------------------------------------------------------- /tests/xbps/xbps-query/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-query") 4 | atf_test_program{name="ignore_repos_test"} 5 | atf_test_program{name="list_test"} 6 | atf_test_program{name="remote_test"} 7 | atf_test_program{name="query_test"} 8 | -------------------------------------------------------------------------------- /tests/xbps/xbps-query/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = ignore_repos_test list_test remote_test query_test 5 | TESTSSUBDIR = xbps/xbps-query 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-query/ignore_repos_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-query(1) -i works as expected 3 | 4 | atf_test_case ignore_system 5 | 6 | ignore_system_head() { 7 | atf_set "descr" "xbps-query(1) -i: ignore repos defined in the system directory (sharedir/xbps.d)" 8 | } 9 | 10 | ignore_system_body() { 11 | mkdir -p repo pkg_A/bin 12 | touch pkg_A/bin/file 13 | ln -s repo repo1 14 | cd repo 15 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 16 | atf_check_equal $? 0 17 | xbps-rindex -d -a $PWD/*.xbps 18 | atf_check_equal $? 0 19 | rm -f *.xbps 20 | cd .. 21 | systemdir=$(xbps-uhelper getsystemdir) 22 | mkdir -p root/${systemdir} 23 | echo "repository=$PWD/repo1" > root/${systemdir}/myrepo.conf 24 | out="$(xbps-query -C empty.conf --repository=$PWD/repo -i -L|wc -l)" 25 | atf_check_equal "$out" 1 26 | } 27 | 28 | atf_test_case ignore_conf 29 | 30 | ignore_conf_head() { 31 | atf_set "descr" "xbps-query(1) -i: ignore repos defined in the configuration directory (xbps.d)" 32 | } 33 | 34 | ignore_conf_body() { 35 | mkdir -p repo pkg_A/bin 36 | touch pkg_A/bin/file 37 | ln -s repo repo1 38 | cd repo 39 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 40 | atf_check_equal $? 0 41 | xbps-rindex -d -a $PWD/*.xbps 42 | atf_check_equal $? 0 43 | rm -f *.xbps 44 | cd .. 45 | mkdir -p root/xbps.d 46 | echo "repository=$PWD/repo1" > root/xbps.d/myrepo.conf 47 | out="$(xbps-query -r root -C xbps.d --repository=$PWD/repo -i -L|wc -l)" 48 | atf_check_equal "$out" 1 49 | } 50 | 51 | atf_init_test_cases() { 52 | atf_add_test_case ignore_conf 53 | atf_add_test_case ignore_system 54 | } 55 | -------------------------------------------------------------------------------- /tests/xbps/xbps-query/list_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-query(1) list modes work as expected 3 | 4 | atf_test_case list_repos 5 | 6 | list_repos_head() { 7 | atf_set "descr" "xbps-query(1) -L" 8 | } 9 | 10 | list_repos_body() { 11 | mkdir -p some_repo pkg_A/bin 12 | touch pkg_A/bin/file 13 | cd some_repo 14 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 15 | atf_check_equal $? 0 16 | xbps-create -A noarch -n baz-1.0_1 -s "baz pkg" ../pkg_A 17 | atf_check_equal $? 0 18 | xbps-rindex -d -a $PWD/*.xbps 19 | atf_check_equal $? 0 20 | rm -f *.xbps 21 | cd .. 22 | output="$(xbps-query -C empty.conf -i --repository=some_repo --repository=vanished_repo -L | tr -d '\n')" 23 | atf_check_equal "$output" " 2 ${PWD}/some_repo (RSA unsigned) -1 vanished_repo (RSA maybe-signed)" 24 | 25 | output="$(xbps-query -C empty.conf -i --repository=https://localhost/wtf -L | tr -d '\n')" 26 | atf_check_equal "$output" " -1 https://localhost/wtf (RSA maybe-signed)" 27 | } 28 | 29 | atf_init_test_cases() { 30 | atf_add_test_case list_repos 31 | } 32 | -------------------------------------------------------------------------------- /tests/xbps/xbps-query/query_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | 3 | cat_file_head() { 4 | atf_set "descr" "xbps-query(1) --cat: cat pkgdb file" 5 | } 6 | 7 | cat_file_body() { 8 | mkdir -p repo pkg_A/bin 9 | echo "hello world!" > pkg_A/bin/file 10 | cd repo 11 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 12 | atf_check_equal $? 0 13 | xbps-rindex -d -a *.xbps 14 | atf_check_equal $? 0 15 | cd .. 16 | mkdir root 17 | xbps-install -r root --repository=repo -dvy foo 18 | atf_check_equal $? 0 19 | res=$(xbps-query -r root -dv -C empty.conf --cat /bin/file foo) 20 | atf_check_equal $? 0 21 | atf_check_equal "$res" "hello world!" 22 | } 23 | 24 | repo_cat_file_head() { 25 | atf_set "descr" "xbps-query(1) -R --cat: cat repo file" 26 | } 27 | 28 | repo_cat_file_body() { 29 | mkdir -p repo pkg_A/bin 30 | echo "hello world!" > pkg_A/bin/file 31 | cd repo 32 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 33 | atf_check_equal $? 0 34 | xbps-rindex -d -a *.xbps 35 | atf_check_equal $? 0 36 | cd .. 37 | res=$(xbps-query -r root -dv --repository=repo -C empty.conf --cat /bin/file foo) 38 | atf_check_equal $? 0 39 | atf_check_equal "$res" "hello world!" 40 | } 41 | 42 | atf_init_test_cases() { 43 | atf_add_test_case cat_file 44 | atf_add_test_case repo_cat_file 45 | } 46 | -------------------------------------------------------------------------------- /tests/xbps/xbps-query/remote_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-query(1) remote modes work as expected 3 | 4 | # 1st test: test that -Rf does not segfault when binpkg is not available 5 | atf_test_case remote_files 6 | 7 | remote_files_head() { 8 | atf_set "descr" "xbps-query(1) -Rf: binpkg files test" 9 | } 10 | 11 | remote_files_body() { 12 | mkdir -p some_repo pkg_A/bin 13 | touch pkg_A/bin/file 14 | cd some_repo 15 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 16 | atf_check_equal $? 0 17 | xbps-rindex -d -a $PWD/*.xbps 18 | atf_check_equal $? 0 19 | rm -f *.xbps 20 | cd .. 21 | xbps-query -C empty.conf --repository=some_repo -f foo-1.0_1 22 | # ENOENT is ok because binpkg does not exist 23 | atf_check_equal $? 2 24 | } 25 | 26 | atf_init_test_cases() { 27 | atf_add_test_case remote_files 28 | } 29 | -------------------------------------------------------------------------------- /tests/xbps/xbps-remove/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-remove") 4 | atf_test_program{name="basic_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-remove/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = basic_test 5 | TESTSSUBDIR = xbps/xbps-remove 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-rindex/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-rindex") 4 | atf_test_program{name="add_test"} 5 | atf_test_program{name="clean_test"} 6 | atf_test_program{name="remove_test"} 7 | -------------------------------------------------------------------------------- /tests/xbps/xbps-rindex/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = add_test clean_test remove_test 5 | TESTSSUBDIR = xbps/xbps-rindex 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-rindex/clean_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-rindex(1) -c (clean mode) works as expected. 3 | 4 | # 1st test: make sure that nothing is removed if there are no changes. 5 | atf_test_case noremove 6 | 7 | noremove_head() { 8 | atf_set "descr" "xbps-rindex(1) -c: dont removing anything test" 9 | } 10 | 11 | noremove_body() { 12 | mkdir -p some_repo pkg_A 13 | cd some_repo 14 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A 15 | atf_check_equal $? 0 16 | xbps-rindex -d -a $PWD/*.xbps 17 | atf_check_equal $? 0 18 | cd .. 19 | xbps-rindex -c some_repo 20 | atf_check_equal $? 0 21 | result=$(xbps-query -r root -C empty.conf --repository=some_repo -s foo|wc -l) 22 | atf_check_equal ${result} 1 23 | } 24 | 25 | # xbps issue #19. 26 | # How to reproduce it: 27 | # Generate pkg foo-1.0_1. 28 | # Add it to the index of a local repo. 29 | # Remove the pkg file from the repo. 30 | # Run xbps-rindex -c on the repo. 31 | 32 | atf_test_case issue19 33 | 34 | issue19_head() { 35 | atf_set "descr" "xbps issue #19 (https://github.com/xtraeme/xbps/issues/19)" 36 | } 37 | 38 | issue19_body() { 39 | mkdir -p some_repo 40 | cd some_repo 41 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" . 42 | atf_check_equal $? 0 43 | xbps-rindex -d -a $PWD/*.xbps 44 | atf_check_equal $? 0 45 | cd .. 46 | rm some_repo/*.xbps 47 | xbps-rindex -c some_repo 48 | atf_check_equal $? 0 49 | result=$(xbps-query -r root -C empty.conf --repository=some_repo -s foo) 50 | test -z "${result}" 51 | atf_check_equal $? 0 52 | } 53 | 54 | atf_test_case remove_from_stage 55 | 56 | remove_from_stage_head() { 57 | atf_set "descr" "xbps-rindex(1) -r: don't removing if there's staging test" 58 | } 59 | 60 | remove_from_stage_body() { 61 | mkdir -p some_repo pkg_A pkg_B 62 | cd some_repo 63 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" --shlib-provides "foo.so.1" ../pkg_A 64 | atf_check_equal $? 0 65 | xbps-create -A noarch -n bar-1.0_1 -s "foo pkg" --shlib-requires "foo.so.1" ../pkg_B 66 | atf_check_equal $? 0 67 | xbps-rindex -d -a $PWD/*.xbps 68 | atf_check_equal $? 0 69 | xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" --shlib-provides "foo.so.2" ../pkg_A 70 | atf_check_equal $? 0 71 | xbps-rindex -d -a $PWD/*.xbps 72 | atf_check -o inline:" 2 $PWD (Staged) (RSA unsigned)\n" -- \ 73 | xbps-query -r ../root -i --repository=$PWD -L 74 | atf_check_equal $? 0 75 | rm foo-1.1_1* 76 | xbps-rindex -c . 77 | atf_check -o inline:" 1 $PWD (RSA unsigned)\n" -- \ 78 | xbps-query -r ../root -i --repository=$PWD -L 79 | cd .. 80 | } 81 | 82 | atf_init_test_cases() { 83 | atf_add_test_case noremove 84 | atf_add_test_case issue19 85 | atf_add_test_case remove_from_stage 86 | } 87 | -------------------------------------------------------------------------------- /tests/xbps/xbps-rindex/remove_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-rindex(1) -c (clean mode) works as expected. 3 | 4 | # 1st test: make sure that nothing is removed if there are no changes. 5 | atf_test_case noremove_stage 6 | 7 | noremove_stage_head() { 8 | atf_set "descr" "xbps-rindex(1) -r: don't removing if there's staging test" 9 | } 10 | 11 | noremove_stage_body() { 12 | mkdir -p some_repo pkg_A pkg_B 13 | cd some_repo 14 | xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" --shlib-provides "foo.so.1" ../pkg_A 15 | atf_check_equal $? 0 16 | xbps-create -A noarch -n bar-1.0_1 -s "foo pkg" --shlib-requires "foo.so.1" ../pkg_B 17 | atf_check_equal $? 0 18 | xbps-rindex -d -a $PWD/*.xbps 19 | atf_check_equal $? 0 20 | xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" --shlib-provides "foo.so.2" ../pkg_A 21 | atf_check_equal $? 0 22 | xbps-rindex -d -a $PWD/*.xbps 23 | atf_check_equal $? 0 24 | atf_check -o inline:" 2 $PWD (Staged) (RSA unsigned)\n" -- \ 25 | xbps-query -r ../root -i --repository=$PWD -L 26 | xbps-rindex -r some_repo 27 | atf_check_equal $? 0 28 | [ -f foo-1.0_1* ] 29 | atf_check_equal $? 0 30 | [ -f foo-1.1_1* ] 31 | atf_check_equal $? 0 32 | [ -f bar-1.0_1* ] 33 | atf_check_equal $? 0 34 | } 35 | 36 | atf_init_test_cases() { 37 | atf_add_test_case noremove_stage 38 | } 39 | -------------------------------------------------------------------------------- /tests/xbps/xbps-uhelper/Kyuafile: -------------------------------------------------------------------------------- 1 | syntax("kyuafile", 1) 2 | 3 | test_suite("xbps-uhelper") 4 | atf_test_program{name="arch_test"} 5 | -------------------------------------------------------------------------------- /tests/xbps/xbps-uhelper/Makefile: -------------------------------------------------------------------------------- 1 | TOPDIR = ../../.. 2 | -include $(TOPDIR)/config.mk 3 | 4 | TESTSHELL = arch_test 5 | TESTSSUBDIR = xbps/xbps-uhelper 6 | EXTRA_FILES = Kyuafile 7 | 8 | include $(TOPDIR)/mk/test.mk 9 | -------------------------------------------------------------------------------- /tests/xbps/xbps-uhelper/arch_test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env atf-sh 2 | # Test that xbps-uhelper arch works as expected. 3 | 4 | atf_test_case native 5 | 6 | native_head() { 7 | atf_set "descr" "xbps-uhelper arch: native test" 8 | } 9 | 10 | native_body() { 11 | atf_check_equal $(xbps-uhelper -r $PWD arch) $(uname -m) 12 | } 13 | 14 | atf_test_case env 15 | 16 | env_head() { 17 | atf_set "descr" "xbps-uhelper arch: envvar override test" 18 | } 19 | env_body() { 20 | export XBPS_ARCH=foo 21 | atf_check_equal $(xbps-uhelper -r $PWD arch) foo 22 | } 23 | 24 | atf_test_case conf 25 | 26 | conf_head() { 27 | atf_set "descr" "xbps-uhelper arch: configuration override test" 28 | } 29 | conf_body() { 30 | mkdir -p xbps.d 31 | echo "architecture=x86_64-musl" > xbps.d/arch.conf 32 | atf_check_equal $(xbps-uhelper -C $PWD/xbps.d arch) x86_64-musl 33 | } 34 | 35 | atf_init_test_cases() { 36 | atf_add_test_case native 37 | atf_add_test_case env 38 | atf_add_test_case conf 39 | } 40 | --------------------------------------------------------------------------------