├── swupd ├── testdata │ ├── testbundle │ │ ├── test1 │ │ ├── test2 │ │ └── usr │ │ │ └── lib │ │ │ └── testdir │ │ │ └── test3 │ ├── invalid_manifests │ │ ├── manifest.empty │ │ ├── manifest.missingFiles │ │ ├── manifest.missingContentsize │ │ ├── manifest.missingTimestamp │ │ ├── manifest.missingPrevious │ │ ├── manifest.missingVersion │ │ ├── manifest.missingFilecount │ │ ├── manifest.missingFormat │ │ ├── manifest.wrongFormat │ │ └── manifest.duplicateVersion │ ├── test-bundle-includes │ ├── groups.ini.no-os-core │ ├── groups.ini │ └── server.ini ├── fullchroot_test.go ├── fullchroot.go ├── external_test.go ├── filesystem_test.go ├── config_test.go ├── external.go ├── heuristics.go ├── cmd │ └── create-fullfiles │ │ └── main.go └── archive.go ├── vendor ├── github.com │ ├── spf13 │ │ ├── pflag │ │ │ ├── .gitignore │ │ │ ├── .golangci.yaml │ │ │ ├── .editorconfig │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── int.go │ │ │ ├── string.go │ │ │ ├── int64.go │ │ │ └── int8.go │ │ └── cobra │ │ │ ├── .mailmap │ │ │ ├── MAINTAINERS │ │ │ ├── .gitignore │ │ │ ├── command_notwin.go │ │ │ ├── Makefile │ │ │ ├── command_win.go │ │ │ ├── .golangci.yml │ │ │ ├── CONTRIBUTING.md │ │ │ ├── active_help.go │ │ │ └── CONDUCT.md │ ├── BurntSushi │ │ └── toml │ │ │ ├── .gitignore │ │ │ ├── doc.go │ │ │ ├── deprecated.go │ │ │ ├── COPYING │ │ │ ├── internal │ │ │ └── tz.go │ │ │ └── type_toml.go │ ├── go-ini │ │ └── ini │ │ │ ├── .gitignore │ │ │ ├── .editorconfig │ │ │ ├── Makefile │ │ │ ├── codecov.yml │ │ │ ├── .golangci.yml │ │ │ ├── helper.go │ │ │ ├── deprecated.go │ │ │ ├── error.go │ │ │ ├── README.md │ │ │ └── data_source.go │ ├── pkg │ │ └── errors │ │ │ ├── .travis.yml │ │ │ ├── .gitignore │ │ │ ├── appveyor.yml │ │ │ ├── Makefile │ │ │ ├── LICENSE │ │ │ ├── go113.go │ │ │ └── README.md │ ├── mattn │ │ └── go-runewidth │ │ │ ├── runewidth_appengine.go │ │ │ ├── runewidth_js.go │ │ │ ├── runewidth_windows.go │ │ │ ├── README.md │ │ │ ├── LICENSE │ │ │ └── runewidth_posix.go │ ├── olekukonko │ │ └── tablewriter │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE.md │ │ │ ├── csv.go │ │ │ ├── util.go │ │ │ ├── wrap.go │ │ │ └── table_with_color.go │ ├── inconshreveable │ │ └── mousetrap │ │ │ ├── trap_others.go │ │ │ ├── README.md │ │ │ └── trap_windows.go │ └── rivo │ │ └── uniseg │ │ ├── LICENSE.txt │ │ ├── width.go │ │ ├── word.go │ │ └── sentence.go └── modules.txt ├── bat └── tests │ ├── state-conversion │ ├── configs │ │ ├── 1.0_mixer.state │ │ └── 1.1_mixer.state │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── update-mixver-offline │ ├── .run.bats.swp │ ├── description.txt │ ├── run.bats │ └── Makefile │ ├── content-chroot │ ├── description.txt │ └── Makefile │ ├── clr-installer-config │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── build-validate │ ├── description.txt │ └── Makefile │ ├── build-all-delta-packs │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── build-delta-manifests │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── clean-rebuild │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── manual-upstream-format-bump-flow │ ├── description.txt │ └── Makefile │ ├── manual-format-bump-flow │ ├── description.txt │ └── Makefile │ ├── export-flag │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── bundle-commands │ ├── description.txt │ └── Makefile │ ├── customize-os-release │ ├── description.txt │ ├── files │ │ ├── my-os-release │ │ └── my-builder.conf │ ├── Makefile │ └── run.bats │ ├── no-state-variables-in-full │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── create-mix-with-upstream-bundles │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── build-multiple-delta-packs │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── no-delta-packs-over-format-bump │ ├── description.txt │ └── Makefile │ ├── contentsize-check │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── no-delta-manifests-over-format-bump │ ├── description.txt │ └── Makefile │ ├── config-conversion │ ├── description.txt │ ├── Makefile │ ├── configs │ │ ├── legacy_builder.conf │ │ ├── nover_builder.conf │ │ ├── 1.0_builder.conf │ │ ├── 1.1_builder.conf │ │ └── 1.2_builder.conf │ └── run.bats │ ├── update-mix-add-remove-bundles │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── create-mix-with-custom-content │ ├── description.txt │ ├── Makefile │ └── run.bats │ ├── test-format-bump │ ├── description.txt │ └── Makefile │ ├── create-mix-with-blended-content │ ├── description.txt │ ├── Makefile │ └── run.bats │ └── upstream-format-bump │ ├── description.txt │ ├── Makefile │ └── run.bats ├── Dockerfile ├── how-to-make-a-release ├── SECURITY.md ├── action.yml ├── .gitignore ├── entrypoint.sh ├── Makefile.bats ├── go.mod ├── mixer ├── main.go └── cmd │ ├── rpms.go │ └── config.go ├── swupd-inspector ├── clean.go ├── cat.go └── log.go ├── mixer-completion ├── main.go └── cmd │ └── completion.go ├── README.md ├── docs ├── mixer.add-rpms.1.rst ├── mixer.add-rpms.1 ├── mixer.config.1.rst ├── mixer.init.1.rst ├── mixer.repo.1.rst ├── mixer.versions.1.rst ├── mixer.config.1 └── mixer.init.1 ├── helpers └── helpers_test.go ├── config └── state_convert.go ├── go.sum └── Makefile /swupd/testdata/testbundle/test1: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /swupd/testdata/testbundle/test2: -------------------------------------------------------------------------------- 1 | test2 2 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | 3 | -------------------------------------------------------------------------------- /swupd/testdata/testbundle/usr/lib/testdir/test3: -------------------------------------------------------------------------------- 1 | testtest 2 | -------------------------------------------------------------------------------- /swupd/testdata/test-bundle-includes: -------------------------------------------------------------------------------- 1 | test-bundle1 2 | test-bundle2 3 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | /toml.test 2 | /toml-test 3 | -------------------------------------------------------------------------------- /bat/tests/state-conversion/configs/1.0_mixer.state: -------------------------------------------------------------------------------- 1 | #VERSION 1.0 2 | 3 | [Mix] 4 | FORMAT = "27" 5 | -------------------------------------------------------------------------------- /swupd/testdata/groups.ini.no-os-core: -------------------------------------------------------------------------------- 1 | [test-bundle] 2 | group=test-bundle 3 | 4 | [test-bundle2] 5 | group=test-bundle2 6 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.golangci.yaml: -------------------------------------------------------------------------------- 1 | linters: 2 | disable-all: true 3 | enable: 4 | - nolintlint 5 | -------------------------------------------------------------------------------- /bat/tests/state-conversion/configs/1.1_mixer.state: -------------------------------------------------------------------------------- 1 | #VERSION 1.1 2 | 3 | [Mix] 4 | FORMAT = "27" 5 | PREVIOUS_MIX_VERSION = "0" 6 | -------------------------------------------------------------------------------- /bat/tests/update-mixver-offline/.run.bats.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clearlinux/mixer-tools/master/bat/tests/update-mixver-offline/.run.bats.swp -------------------------------------------------------------------------------- /swupd/testdata/groups.ini: -------------------------------------------------------------------------------- 1 | [os-core] 2 | group=os-core 3 | 4 | [test-bundle] 5 | group=test-bundle 6 | 7 | [Test-bundle2] 8 | group=Test-bundle2 9 | -------------------------------------------------------------------------------- /bat/tests/content-chroot/description.txt: -------------------------------------------------------------------------------- 1 | content-chroot 2 | ==================== 3 | This test creates a mix that uses a content bundle chroot to generate a manifest. 4 | -------------------------------------------------------------------------------- /bat/tests/clr-installer-config/description.txt: -------------------------------------------------------------------------------- 1 | clr-install-config 2 | ============ 3 | This test case tests the usage of clr-install config file during 'mixer build image'. 4 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/.gitignore: -------------------------------------------------------------------------------- 1 | testdata/conf_out.ini 2 | ini.sublime-project 3 | ini.sublime-workspace 4 | testdata/conf_reflect.ini 5 | .idea 6 | /.vscode 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/clearlinux/mixer-ci:latest 2 | ENV LC_ALL="en_US.UTF-8" 3 | WORKDIR /home/clr/mixer-tools 4 | COPY --chown=clr:clr . . 5 | ENTRYPOINT ["/home/clr/mixer-tools/entrypoint.sh"] 6 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingFiles: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | version: 19440 3 | previous: 19430 4 | filecount: 12927 5 | timestamp: 1512419456 6 | contentsize: 1145939028 7 | includes: os-core 8 | -------------------------------------------------------------------------------- /bat/tests/build-validate/description.txt: -------------------------------------------------------------------------------- 1 | build-validate 2 | ================ 3 | This test confirms that the 'build validate' command can properly identify 4 | manifest errors and print pacakge statistics. 5 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/errors 3 | go: 4 | - 1.11.x 5 | - 1.12.x 6 | - 1.13.x 7 | - tip 8 | 9 | script: 10 | - make check 11 | -------------------------------------------------------------------------------- /bat/tests/build-all-delta-packs/description.txt: -------------------------------------------------------------------------------- 1 | build-all-delta-packs 2 | ===================== 3 | This test case tests the 'mixer build delta-packs' command when generating 4 | content with 'mixer build all'. 5 | -------------------------------------------------------------------------------- /bat/tests/build-delta-manifests/description.txt: -------------------------------------------------------------------------------- 1 | build-delta-manifests 2 | ===================== 3 | This test case tests the 'mixer build delta-manifests command when generating 4 | content with 'mixer build all'. 5 | -------------------------------------------------------------------------------- /bat/tests/clean-rebuild/description.txt: -------------------------------------------------------------------------------- 1 | clean-rebuild 2 | ================ 3 | This test rebuilds version 20 and confirms that the current/previous versions are correctly 4 | maintained when a build is cleaned. 5 | -------------------------------------------------------------------------------- /bat/tests/manual-upstream-format-bump-flow/description.txt: -------------------------------------------------------------------------------- 1 | manual-upstream-format-bump-flow 2 | ======================= 3 | This test uses the manual format bump process to cross an upstream format 4 | bump boundary. 5 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.mailmap: -------------------------------------------------------------------------------- 1 | Steve Francia 2 | Bjørn Erik Pedersen 3 | Fabiano Franz 4 | -------------------------------------------------------------------------------- /bat/tests/manual-format-bump-flow/description.txt: -------------------------------------------------------------------------------- 1 | manual-format-bump-flow 2 | ======================= 3 | This test creates a format bump using a manual process (not auto-format-bump) 4 | and checks that all output is correct. 5 | -------------------------------------------------------------------------------- /bat/tests/export-flag/description.txt: -------------------------------------------------------------------------------- 1 | export-flag 2 | ==================== 3 | This test simulates the usage of un-export() keyword in a bundle definition file and validates the manifests for correct 4 | setting of the export flag 'x'. 5 | -------------------------------------------------------------------------------- /bat/tests/update-mixver-offline/description.txt: -------------------------------------------------------------------------------- 1 | update-mixver-offline 2 | =================================== 3 | This test case creates a basic mix and attempts to update the 4 | mixversion only, which should not reach out over the network 5 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/MAINTAINERS: -------------------------------------------------------------------------------- 1 | maintainers: 2 | - spf13 3 | - johnSchnake 4 | - jpmcb 5 | - marckhouzam 6 | inactive: 7 | - anthonyfok 8 | - bep 9 | - bogem 10 | - broady 11 | - eparis 12 | - jharshman 13 | - wfernandes 14 | -------------------------------------------------------------------------------- /bat/tests/bundle-commands/description.txt: -------------------------------------------------------------------------------- 1 | bundle-commands 2 | =============== 3 | This test case tests the 'mixer bundle' commands for adding and removing bundles 4 | from your mix, and for manipulating upstream and local bundle definition files. 5 | -------------------------------------------------------------------------------- /how-to-make-a-release: -------------------------------------------------------------------------------- 1 | 1) Update vendor and test (should be a separate PR) 2 | 1a) Update version in Makefile 3 | 1b) go get -u ./... && go mod tidy && go mod vendor 4 | 2) Tag new release version and push tag to github and use github ui to draft a new release 5 | -------------------------------------------------------------------------------- /swupd/testdata/server.ini: -------------------------------------------------------------------------------- 1 | [Server] 2 | emptydir=/var/lib/update/emptytest/ 3 | imagebase=/var/lib/update/imagetest/ 4 | outputdir=/var/lib/update/wwwtest/ 5 | 6 | [Debuginfo] 7 | banned=true 8 | lib=/usr/lib/debugtest/ 9 | src=/usr/src/debugtest/ 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_appengine.go: -------------------------------------------------------------------------------- 1 | //go:build appengine 2 | // +build appengine 3 | 4 | package runewidth 5 | 6 | // IsEastAsian return true if the current locale is CJK 7 | func IsEastAsian() bool { 8 | return false 9 | } 10 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting Security Concerns 2 | 3 | If you have discovered potential security vulnerability, please visit https://www.intel.com/content/www/us/en/security-center/default.html for best practices on reporting security issues and to report your concern. 4 | -------------------------------------------------------------------------------- /bat/tests/customize-os-release/description.txt: -------------------------------------------------------------------------------- 1 | customize-os-release 2 | ================= 3 | This test simulates os-release customization for mixer build. It initiates a 4 | mix, replaces the default config with modified config with customized os-release file path. 5 | -------------------------------------------------------------------------------- /bat/tests/no-state-variables-in-full/description.txt: -------------------------------------------------------------------------------- 1 | no-state-variables-in-full 2 | ========================== 3 | This test case creates a simple mix and checks that no state paths 4 | exist in the full chroot, which should be removed during the build 5 | bundles phase 6 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.go] 12 | indent_style = tab 13 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-upstream-bundles/description.txt: -------------------------------------------------------------------------------- 1 | create-mix-with-upstream-bundles 2 | ================================ 3 | This test case creates a mix with an unchanged upstream bundle. The default 4 | config is updated to support building a mix with just os-core. 5 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*_test.go] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /bat/tests/build-multiple-delta-packs/description.txt: -------------------------------------------------------------------------------- 1 | build-multiple-delta-packs 2 | ===================== 3 | This test case tests and runs 'mixer build delta-packs' command multiple times for different 4 | versions with some delta files missing when generating content with 'mixer build all'. -------------------------------------------------------------------------------- /bat/tests/no-delta-packs-over-format-bump/description.txt: -------------------------------------------------------------------------------- 1 | no-delta-packs-over-format-bump 2 | =============================== 3 | This test creates a format bump using a manual process (not auto-format-bump) 4 | and attempts to create delta packs over that bump. No delta packs should be 5 | created. 6 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_js.go: -------------------------------------------------------------------------------- 1 | //go:build js && !appengine 2 | // +build js,!appengine 3 | 4 | package runewidth 5 | 6 | func IsEastAsian() bool { 7 | // TODO: Implement this for the web. Detect east asian in a compatible way, and return true. 8 | return false 9 | } 10 | -------------------------------------------------------------------------------- /bat/tests/contentsize-check/description.txt: -------------------------------------------------------------------------------- 1 | contentsize-check 2 | ================ 3 | This test calculates the content size of the files in the chroot for each bundle 4 | and compares them against the contentsize field in the corresponding manifest. 5 | The directory size is omitted for the content size calculation. 6 | -------------------------------------------------------------------------------- /bat/tests/no-delta-manifests-over-format-bump/description.txt: -------------------------------------------------------------------------------- 1 | no-delta-manifests-over-format-bump 2 | =================================== 3 | This test creates a format bump using a manual process (not auto-format-bump) 4 | and attempts to create delta manifests over that bump. No delta manifests 5 | should be created. 6 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/description.txt: -------------------------------------------------------------------------------- 1 | config-conversion 2 | ================= 3 | This test simulates conversion between config file versions. It initiates a 4 | mix, replaces the default config with an older version and try to perform 5 | the conversion. It also checks if the format value is properly transferred 6 | to mixer.state 7 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build test bench vet coverage 2 | 3 | build: vet bench 4 | 5 | test: 6 | go test -v -cover -race 7 | 8 | bench: 9 | go test -v -cover -test.bench=. -test.benchmem 10 | 11 | vet: 12 | go vet 13 | 14 | coverage: 15 | go test -coverprofile=c.out && go tool cover -html=c.out && rm c.out 16 | -------------------------------------------------------------------------------- /bat/tests/update-mix-add-remove-bundles/description.txt: -------------------------------------------------------------------------------- 1 | update-mix-add-remove-bundles 2 | ============================= 3 | This test creates an initial version 10, a version 20 with upstream bundles 4 | added, and a version 30 with one of those bundles removed. All bundles have been 5 | stripped down for efficiency, and all content comes from upstream. 6 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-custom-content/description.txt: -------------------------------------------------------------------------------- 1 | create-mix-with-custom-content 2 | ============================== 3 | This test creates a mix version 10 with a unique bundle that does not exist 4 | upstream and contains a package that is not in upstream. All upstream bundles 5 | have been stripped down for efficiency and are thus edited local copies. 6 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | range: "60...95" 3 | status: 4 | project: 5 | default: 6 | threshold: 1% 7 | informational: true 8 | patch: 9 | defualt: 10 | only_pulls: true 11 | informational: true 12 | 13 | comment: 14 | layout: 'diff' 15 | 16 | github_checks: false 17 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'mixer-tools CI Docker image' 2 | description: 'Build and run tests in mixer-tools CI Docker image' 3 | inputs: 4 | runfunc: 5 | description: 'Function to run' 6 | required: true 7 | runs: 8 | using: 'docker' 9 | image: 'Dockerfile' 10 | env: 11 | GOCACHE: /tmp/gocache # change default cache to avoid permission issues 12 | -------------------------------------------------------------------------------- /bat/tests/state-conversion/description.txt: -------------------------------------------------------------------------------- 1 | state-conversion 2 | ================= 3 | This test simulates conversion between state file versions. It replaces the 4 | default state file with an older version and checks for successful conversions. 5 | This test also verifies that the PREVIOUS_MIX_VERSION is properly initialized by 6 | the LAST_VER file during conversions. 7 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, build with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | 16 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | arch: 3 | - ppc64le 4 | - amd64 5 | go: 6 | - 1.3 7 | - 1.4 8 | - 1.5 9 | - 1.6 10 | - 1.7 11 | - 1.8 12 | - 1.9 13 | - "1.10" 14 | - tip 15 | jobs: 16 | exclude : 17 | - arch : ppc64le 18 | go : 19 | - 1.3 20 | - arch : ppc64le 21 | go : 22 | - 1.4 23 | -------------------------------------------------------------------------------- /bat/tests/test-format-bump/description.txt: -------------------------------------------------------------------------------- 1 | test-format-bump 2 | ================ 3 | This test simulates a format bump change by creating an initial version 10, 4 | a version 20 with a new bundle and package inside of-it, version 30 with 5 | that package deleted from the bundle, version 40 with the format bumped +1, 6 | then 50 and 60 updates built with new (locally cloned) swupd server code. 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .clear-version 2 | .mix-version 3 | .mixer-repopath 4 | .repos/ 5 | .yum-clear.conf 6 | .yum-mix.conf 7 | build/ 8 | bundles 9 | repos/ 10 | results/ 11 | Makefile.in 12 | configure 13 | aclocal.m4 14 | autom4te.cache/ 15 | config.log 16 | config.status 17 | install-sh 18 | missing 19 | mixer-tools-*.tar.xz 20 | swupd-server.log.* 21 | coverage.out 22 | testdata-*/ 23 | !testdata-*.in/ 24 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: go 4 | 5 | go: 6 | - 1.9.x 7 | - 1.10.x 8 | - 1.11.x 9 | - tip 10 | 11 | matrix: 12 | allow_failures: 13 | - go: tip 14 | 15 | install: 16 | - go get golang.org/x/lint/golint 17 | - export PATH=$GOPATH/bin:$PATH 18 | - go install ./... 19 | 20 | script: 21 | - verify/all.sh -v 22 | - go test ./... 23 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | // Package toml implements decoding and encoding of TOML files. 2 | // 3 | // This package supports TOML v1.0.0, as specified at https://toml.io 4 | // 5 | // The github.com/BurntSushi/toml/cmd/tomlv package implements a TOML validator, 6 | // and can be used to verify if TOML document is valid. It can also be used to 7 | // print the type of each key. 8 | package toml 9 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-blended-content/description.txt: -------------------------------------------------------------------------------- 1 | create-mix-with-blended-content 2 | =============================== 3 | This test creates a mix version 10 with two blended bundles: an upstream bundle 4 | with a unique package that does not exist upstream added, and a custom bundle 5 | with a package from upstream added. All upstream bundles have been stripped down 6 | for efficiency and are thus edited local copies. 7 | -------------------------------------------------------------------------------- /bat/tests/update-mixver-offline/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Update mixver while offline" { 11 | mixer-init-stripped-down 25770 10 12 | export https_proxy=0.0.0.0 13 | export http_proxy=0.0.0.0 14 | mixer versions update --mix-version 50 15 | } 16 | 17 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 18 | -------------------------------------------------------------------------------- /bat/tests/customize-os-release/files/my-os-release: -------------------------------------------------------------------------------- 1 | NAME="Clear Linux OS" 2 | VERSION=1 3 | ID=clear-linux-os-downstream 4 | ID_LIKE=clear-linux-os-downstream 5 | VERSION_ID=1 6 | PRETTY_NAME="Clear Linux OS (DownStream)" 7 | ANSI_COLOR="1;35" 8 | HOME_URL="https://clearlinux.org" 9 | SUPPORT_URL="https://clearlinux.org" 10 | BUG_REPORT_URL="mailto:dev@lists.clearlinux.org" 11 | PRIVACY_POLICY_URL="http://www.intel.com/privacy" 12 | BUILD_ID=1 13 | 14 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -l 2 | cd /home/clr/mixer-tools 3 | 4 | run_precheck() { 5 | make && sudo -E make install 6 | export CI_ONLY=1 7 | export GOLANGCI_LINT_CACHE=/tmp/.golangci-lint 8 | make lint && make check 9 | } 10 | 11 | run_battest() { 12 | make && sudo -E make install 13 | cd bat/tests/$TEST_DIR && make 14 | } 15 | 16 | if t=$(type -t "$INPUT_RUNFUNC"); then 17 | if [ "$t" = "function" ]; then 18 | $INPUT_RUNFUNC 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /bat/tests/upstream-format-bump/description.txt: -------------------------------------------------------------------------------- 1 | upstream-format-bump 2 | ==================== 3 | This test attempts to create a mix that crosses an upstream format boundary. It 4 | should stop once versions update is called and notices that a bump is needed, 5 | and build upstream-bump should automatically create the two required bump 6 | builds, leaving mixer.state showing the new format, and upstreamversion 7 | showing the original version the user tried to create. 8 | -------------------------------------------------------------------------------- /bat/tests/bundle-commands/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/clean-rebuild/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/contentsize-check/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/test-format-bump/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/build-all-delta-packs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/build-delta-manifests/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/update-mixver-offline/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/upstream-format-bump/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/build-multiple-delta-packs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/manual-format-bump-flow/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/no-state-variables-in-full/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/build-validate/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles ./update-backup 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/content-chroot/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles ./custom-content 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-blended-content/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-upstream-bundles/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/export-flag/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles ./custom-content 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/manual-upstream-format-bump-flow/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/no-delta-packs-over-format-bump/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/update-mix-add-remove-bundles/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/no-delta-manifests-over-format-bump/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-custom-content/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles ./custom-yum 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./builder.conf.bkp ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles current.conf 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/state-conversion/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state.bkp ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles current.state 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/customize-os-release/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./builder.conf.bkp ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles builder-orig.conf 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /bat/tests/build-all-delta-packs/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "build delta-packs after build all" { 11 | current_ver=$(get-current-version) 12 | mixer-init-stripped-down "$current_ver" 10 13 | sudo -E mixer build all --increment 14 | mixer-build-all 15 | sudo -E mixer build delta-packs --previous-versions=1 16 | 17 | test $(< mixversion) -eq 20 18 | test -e update/www/20/pack-os-core-from-10.tar 19 | } 20 | 21 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 22 | -------------------------------------------------------------------------------- /bat/tests/build-delta-manifests/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "build delta-manifests after build all" { 11 | current_ver=$(get-current-version) 12 | mixer-init-stripped-down "$current_ver" 10 13 | sudo -E mixer build all --increment 14 | mixer-build-all 15 | sudo -E mixer build delta-manifests --previous-versions=1 16 | 17 | test $(< mixversion) -eq 20 18 | test -e update/www/20/Manifest-os-core-delta-from-10 19 | } 20 | 21 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 22 | -------------------------------------------------------------------------------- /bat/tests/clr-installer-config/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: check clean 2 | 3 | check: 4 | bats ./run.bats 5 | 6 | CLEANDIRS = ./update ./test-chroot ./logs ./.repos ./bundles ./update ./mix-bundles ./clr-bundles ./local-yum ./results ./repodata ./local-rpms ./upstream-bundles ./local-bundles ./clr-installer* 7 | CLEANFILES = ./*.log ./run.bats.trs ./yum.conf.in ./builder.conf ./mixer.state ./.{c,m}* *.pem .yum-mix.conf mixversion upstreamurl upstreamversion mixbundles release-image-config.yaml release.img release.iso pre-install-clr-installer.yaml release-image-config.log 8 | clean: 9 | sudo rm -rf $(CLEANDIRS) $(CLEANFILES) 10 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_others.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | // +build !windows 3 | 4 | package mousetrap 5 | 6 | // StartedByExplorer returns true if the program was invoked by the user 7 | // double-clicking on the executable from explorer.exe 8 | // 9 | // It is conservative and returns false if any of the internal calls fail. 10 | // It does not guarantee that the program was run from a terminal. It only can tell you 11 | // whether it was launched from explorer.exe 12 | // 13 | // On non-Windows platforms, it always returns false. 14 | func StartedByExplorer() bool { 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /Makefile.bats: -------------------------------------------------------------------------------- 1 | SUBMAKEFILES := $(shell find bat/tests/ -name Makefile) 2 | DIRS2RUNMAKECHECK := $(addprefix checkdir-,${SUBMAKEFILES}) 3 | DIRS2RUNMAKECLEAN := $(addprefix clean-,${SUBMAKEFILES}) 4 | 5 | batcheck: ${DIRS2RUNMAKECHECK} 6 | 7 | ${DIRS2RUNMAKECHECK}: checkdir-%: 8 | $(MAKE) -C $(dir $(subst checkdir-,,$@)) check 9 | 10 | batclean: $(DIRS2RUNMAKECLEAN) clean-dnf 11 | 12 | ${DIRS2RUNMAKECLEAN}: clean-%: 13 | $(MAKE) -C $(dir $(subst clean-,,$@)) clean 14 | 15 | clean-dnf: 16 | rm -rf bat/dnf 17 | 18 | .PHONY: batcheck 19 | .PHONY: batclean 20 | .PHONY: ${DIRS2RUNMAKECHECK} 21 | .PHONY: ${DIRS2RUNMAKECLEAN} 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/.golangci.yml: -------------------------------------------------------------------------------- 1 | linters-settings: 2 | staticcheck: 3 | checks: [ 4 | "all", 5 | "-SA1019" # There are valid use cases of strings.Title 6 | ] 7 | nakedret: 8 | max-func-lines: 0 # Disallow any unnamed return statement 9 | 10 | linters: 11 | enable: 12 | - deadcode 13 | - errcheck 14 | - gosimple 15 | - govet 16 | - ineffassign 17 | - staticcheck 18 | - structcheck 19 | - typecheck 20 | - unused 21 | - varcheck 22 | - nakedret 23 | - gofmt 24 | - rowserrcheck 25 | - unconvert 26 | - goimports 27 | - unparam 28 | -------------------------------------------------------------------------------- /bat/tests/no-state-variables-in-full/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Test that state paths do not exist in the full chroot" { 11 | upstreamver=$(get-last-format-boundary) 12 | mixer-init-stripped-down $upstreamver 10 13 | 14 | #Create initial version in the old format 15 | mixer-build-bundles > $LOGDIR/build_bundles.log 16 | 17 | toRemove="/etc/dnf /var/lib/cache/yum /var/cache/yum /var/cache/dnf /var/lib/dnf /var/lib/rpm" 18 | for f in $toRemove; do 19 | test ! -d update/image/10/full/$f 20 | done 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows && !appengine 2 | // +build windows,!appengine 3 | 4 | package runewidth 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | var ( 11 | kernel32 = syscall.NewLazyDLL("kernel32") 12 | procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP") 13 | ) 14 | 15 | // IsEastAsian return true if the current locale is CJK 16 | func IsEastAsian() bool { 17 | r1, _, _ := procGetConsoleOutputCP.Call() 18 | if r1 == 0 { 19 | return false 20 | } 21 | 22 | switch int(r1) { 23 | case 932, 51932, 936, 949, 950: 24 | return true 25 | } 26 | 27 | return false 28 | } 29 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/clearlinux/mixer-tools 2 | 3 | go 1.21 4 | 5 | require ( 6 | github.com/BurntSushi/toml v1.5.0 7 | github.com/go-ini/ini v1.67.0 8 | github.com/olekukonko/tablewriter v0.0.5 9 | github.com/pkg/errors v0.9.1 10 | github.com/spf13/cobra v1.9.1 11 | ) 12 | 13 | require ( 14 | github.com/davecgh/go-spew v1.1.1 // indirect 15 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 16 | github.com/mattn/go-runewidth v0.0.16 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/rivo/uniseg v0.4.7 // indirect 19 | github.com/spf13/pflag v1.0.6 // indirect 20 | github.com/stretchr/testify v1.2.2 // indirect 21 | ) 22 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | # Vim files https://github.com/github/gitignore/blob/master/Global/Vim.gitignore 23 | # swap 24 | [._]*.s[a-w][a-z] 25 | [._]s[a-w][a-z] 26 | # session 27 | Session.vim 28 | # temporary 29 | .netrwhist 30 | *~ 31 | # auto-generated tag files 32 | tags 33 | 34 | *.exe 35 | cobra.test 36 | bin 37 | 38 | .idea/ 39 | *.iml 40 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/configs/legacy_builder.conf: -------------------------------------------------------------------------------- 1 | [Builder] 2 | SERVER_STATE_DIR=/home/clr/mix/update 3 | BUNDLE_DIR=/home/clr/mix/mix-bundles 4 | YUM_CONF=/home/clr/mix/.yum-mix.conf 5 | CERT=/home/clr/mix/Swupd_Root.pem 6 | VERSIONS_PATH=/home/clr/mix 7 | 8 | [swupd] 9 | BUNDLE=os-core-update 10 | CONTENTURL= 11 | VERSIONURL= 12 | FORMAT=1 13 | 14 | [Server] 15 | debuginfo_banned=true 16 | debuginfo_lib=/usr/lib/debug 17 | debuginfo_src=/usr/src/debug 18 | 19 | [Mixer] 20 | LOCAL_BUNDLE_DIR=/home/clr/mix/local-bundles 21 | LOCAL_REPO_DIR=/home/clr/mix/local-yum 22 | LOCAL_RPM_DIR=/home/clr/mix/local-rpms 23 | DOCKER_IMAGE_PATH=clearlinux/mixer 24 | -------------------------------------------------------------------------------- /swupd/fullchroot_test.go: -------------------------------------------------------------------------------- 1 | package swupd 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | "testing" 8 | ) 9 | 10 | func TestSyncToFull(t *testing.T) { 11 | d, err := ioutil.TempDir("", "") 12 | if err != nil { 13 | t.Fatal("couldn't create test directory") 14 | } 15 | 16 | if err = os.MkdirAll(filepath.Join(d, "10/testbundle/test"), 0755); err != nil { 17 | t.Fatal("couldn't create bundle test directory") 18 | } 19 | 20 | if err = syncToFull(10, "testbundle", d); err != nil { 21 | t.Errorf("syncToFull failed with valid input: %s", err) 22 | } 23 | 24 | if _, err = os.Stat(filepath.Join(d, "10/full/test")); err != nil { 25 | t.Errorf("syncToFull failed to sync test file to full chroot: %s", err) 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-upstream-bundles/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Create mix 10 with real clear bundle" { 11 | mixer $MIXARGS init --clear-version $CLRVER --mix-version 10 12 | 13 | rm -f $BATS_TEST_DIRNAME/mixbundles # Wipe out default bundles 14 | mixer $MIXARGS bundle add os-core # Add real os-core from upstream 15 | sed -i 's/os-core-update/os-core/' $BATS_TEST_DIRNAME/builder.conf # Patch default builder.conf 16 | 17 | mixer-build-bundles > $LOGDIR/build_bundles.log 18 | mixer-build-update > $LOGDIR/build_update.log 19 | } 20 | 21 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 22 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/configs/nover_builder.conf: -------------------------------------------------------------------------------- 1 | [Builder] 2 | CERT = "/home/clr/mix/Swupd_Root.pem" 3 | SERVER_STATE_DIR = "/home/clr/mix/update" 4 | VERSIONS_PATH = "/home/clr/mix" 5 | YUM_CONF = "/home/clr/mix/.yum-mix.conf" 6 | 7 | [Swupd] 8 | BUNDLE = "os-core-update" 9 | CONTENTURL = "" 10 | VERSIONURL = "" 11 | FORMAT = "1" 12 | 13 | [Server] 14 | DEBUG_INFO_BANNED = "true" 15 | DEBUG_INFO_LIB = "/usr/lib/debug" 16 | DEBUG_INFO_SRC = "/usr/src/debug" 17 | 18 | [Mixer] 19 | LOCAL_BUNDLE_DIR = "/home/clr/mix/local-bundles" 20 | LOCAL_REPO_DIR = "/home/clr/mix/local-yum" 21 | LOCAL_RPM_DIR = "/home/clr/mix/local-rpms" 22 | DOCKER_IMAGE_PATH = "clearlinux/mixer" 23 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/configs/1.0_builder.conf: -------------------------------------------------------------------------------- 1 | #VERSION 1.0 2 | 3 | [Builder] 4 | CERT = "/home/clr/mix/Swupd_Root.pem" 5 | SERVER_STATE_DIR = "/home/clr/mix/update" 6 | VERSIONS_PATH = "/home/clr/mix" 7 | YUM_CONF = "/home/clr/mix/.yum-mix.conf" 8 | 9 | [Swupd] 10 | BUNDLE = "os-core-update" 11 | CONTENTURL = "" 12 | VERSIONURL = "" 13 | 14 | [Server] 15 | DEBUG_INFO_BANNED = "true" 16 | DEBUG_INFO_LIB = "/usr/lib/debug" 17 | DEBUG_INFO_SRC = "/usr/src/debug" 18 | 19 | [Mixer] 20 | LOCAL_BUNDLE_DIR = "/home/clr/mix/local-bundles" 21 | LOCAL_REPO_DIR = "/home/clr/mix/local-yum" 22 | LOCAL_RPM_DIR = "/home/clr/mix/local-rpms" 23 | DOCKER_IMAGE_PATH = "clearlinux/mixer" 24 | -------------------------------------------------------------------------------- /mixer/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/clearlinux/mixer-tools/mixer/cmd" 19 | ) 20 | 21 | func main() { 22 | cmd.Execute() 23 | } 24 | -------------------------------------------------------------------------------- /bat/tests/build-multiple-delta-packs/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "build delta-packs after build all for different versions" { 11 | current_ver=$(get-current-version) 12 | mixer-init-stripped-down "$current_ver" 10 13 | mixer-build-all 14 | sudo mixer versions update 15 | mixer-build-all 16 | mixer-build-delta-packs 10 17 | sudo rm -rf ./update/image/10/full/usr/lib/os-release 18 | sudo mixer versions update 19 | mixer-build-all 20 | mixer-build-delta-packs 10 21 | test $(ls ./update/www/30/delta/ | wc -l) -eq 1 22 | test $(ls ./update/www/10/delta/ | wc -l) -eq 0 23 | test $(ls ./update/www/20/delta/ | wc -l) -eq 1 24 | } 25 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 26 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_notwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2023 The Cobra Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows 16 | // +build !windows 17 | 18 | package cobra 19 | 20 | var preExecHookFn func(*Command) 21 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /swupd-inspector/clean.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "log" 6 | "os" 7 | "path/filepath" 8 | ) 9 | 10 | func runClean(cacheDir string) { 11 | fis, err := ioutil.ReadDir(cacheDir) 12 | if err != nil { 13 | log.Fatalf("ERROR: %s", err) 14 | } 15 | 16 | for _, fi := range fis { 17 | if !fi.IsDir() { 18 | log.Printf("Skipping unknown file %s/%s", cacheDir, fi.Name()) 19 | continue 20 | } 21 | stateDir := filepath.Join(cacheDir, fi.Name()) 22 | _, err = os.Stat(filepath.Join(stateDir, "content")) 23 | if err != nil { 24 | log.Printf("Skipping unrecognized directory %s", stateDir) 25 | continue 26 | } 27 | log.Printf("Deleting directory %s", stateDir) 28 | err = os.RemoveAll(stateDir) 29 | if err != nil { 30 | log.Fatalf("ERROR: %s", err) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/configs/1.1_builder.conf: -------------------------------------------------------------------------------- 1 | #VERSION 1.1 2 | 3 | [Builder] 4 | CERT = "/home/clr/mix/Swupd_Root.pem" 5 | SERVER_STATE_DIR = "/home/clr/mix/update" 6 | VERSIONS_PATH = "/home/clr/mix" 7 | YUM_CONF = "/home/clr/mix/.yum-mix.conf" 8 | 9 | [Swupd] 10 | BUNDLE = "os-core-update" 11 | CONTENTURL = "" 12 | VERSIONURL = "" 13 | 14 | [Server] 15 | DEBUG_INFO_BANNED = "true" 16 | DEBUG_INFO_LIB = "/usr/lib/debug" 17 | DEBUG_INFO_SRC = "/usr/src/debug" 18 | 19 | [Mixer] 20 | LOCAL_BUNDLE_DIR = "/home/clr/mix/local-bundles" 21 | LOCAL_REPO_DIR = "/home/clr/mix/local-yum" 22 | LOCAL_RPM_DIR = "/home/clr/mix/local-rpms" 23 | DOCKER_IMAGE_PATH = "clearlinux/mixer" 24 | OS_RELEASE_PATH = "" 25 | LOG = "" 26 | -------------------------------------------------------------------------------- /bat/tests/customize-os-release/files/my-builder.conf: -------------------------------------------------------------------------------- 1 | #VERSION 1.1 2 | 3 | [Builder] 4 | CERT = "/home/clr/mix/Swupd_Root.pem" 5 | SERVER_STATE_DIR = "/home/clr/mix/update" 6 | VERSIONS_PATH = "/home/clr/mix" 7 | YUM_CONF = "/home/clr/mix/.yum-mix.conf" 8 | 9 | [Swupd] 10 | BUNDLE = "os-core-update" 11 | CONTENTURL = "" 12 | VERSIONURL = "" 13 | 14 | [Server] 15 | DEBUG_INFO_BANNED = "true" 16 | DEBUG_INFO_LIB = "/usr/lib/debug" 17 | DEBUG_INFO_SRC = "/usr/src/debug" 18 | 19 | [Mixer] 20 | LOCAL_BUNDLE_DIR = "/home/clr/mix/local-bundles" 21 | LOCAL_REPO_DIR = "/home/clr/mix/local-yum" 22 | LOCAL_RPM_DIR = "/home/clr/mix/local-rpms" 23 | DOCKER_IMAGE_PATH = "clearlinux/mixer" 24 | OS_RELEASE_PATH = "/home/clr/mix/files/my-os-release" 25 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/helper.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | func inSlice(str string, s []string) bool { 18 | for _, v := range s { 19 | if str == v { 20 | return true 21 | } 22 | } 23 | return false 24 | } 25 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/configs/1.2_builder.conf: -------------------------------------------------------------------------------- 1 | #VERSION 1.2 2 | 3 | [Builder] 4 | CERT = "/home/clr/mix/Swupd_Root.pem" 5 | SERVER_STATE_DIR = "/home/clr/mix/update" 6 | VERSIONS_PATH = "/home/clr/mix" 7 | YUM_CONF = "/home/clr/mix/.yum-mix.conf" 8 | 9 | [Swupd] 10 | BUNDLE = "os-core-update" 11 | CONTENTURL = "" 12 | VERSIONURL = "" 13 | COMPRESSION = ["external-xz"] 14 | UPSTREAM_BUNDLES_URL = "https://github.com/clearlinux/clr-bundles/archive/" 15 | 16 | [Server] 17 | DEBUG_INFO_BANNED = "true" 18 | DEBUG_INFO_LIB = "/usr/lib/debug" 19 | DEBUG_INFO_SRC = "/usr/src/debug" 20 | 21 | [Mixer] 22 | LOCAL_BUNDLE_DIR = "/home/clr/mix/local-bundles" 23 | LOCAL_REPO_DIR = "/home/clr/mix/local-yum" 24 | LOCAL_RPM_DIR = "/home/clr/mix/local-rpms" 25 | OS_RELEASE_PATH = "" 26 | LOG = "" 27 | -------------------------------------------------------------------------------- /mixer-completion/main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "os" 19 | 20 | "github.com/clearlinux/mixer-tools/mixer-completion/cmd" 21 | ) 22 | 23 | func main() { 24 | if err := cmd.CompletionCmd.Execute(); err != nil { 25 | os.Exit(1) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/deprecated.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | var ( 18 | // Deprecated: Use "DefaultSection" instead. 19 | DEFAULT_SECTION = DefaultSection 20 | // Deprecated: AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. 21 | AllCapsUnderscore = SnackCase 22 | ) 23 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingContentsize: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | version: 19440 3 | previous: 19430 4 | filecount: 8 5 | timestamp: 1512419456 6 | includes: os-core 7 | 8 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 9 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 11 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 12 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 13 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 14 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 15 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 16 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingTimestamp: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | version: 19440 3 | previous: 19430 4 | filecount: 8 5 | contentsize: 1145939028 6 | includes: os-core 7 | 8 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 9 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 11 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 12 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 13 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 14 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 15 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 16 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingPrevious: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | version: 19440 3 | filecount: 8 4 | timestamp: 1512419456 5 | contentsize: 1145939028 6 | includes: os-core 7 | 8 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 9 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 11 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 12 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 13 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 14 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 15 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 16 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingVersion: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | previous: 19430 3 | filecount: 8 4 | timestamp: 1512419456 5 | contentsize: 1145939028 6 | includes: os-core 7 | 8 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 9 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 11 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 12 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 13 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 14 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 15 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 16 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingFilecount: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | version: 19440 3 | previous: 19430 4 | timestamp: 1512419456 5 | contentsize: 1145939028 6 | includes: os-core 7 | 8 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 9 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 11 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 12 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 13 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 14 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 15 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 16 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.missingFormat: -------------------------------------------------------------------------------- 1 | version: 19440 2 | previous: 19430 3 | filecount: 8 4 | timestamp: 1512419456 5 | contentsize: 1145939028 6 | includes: os-core 7 | 8 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 9 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 11 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 12 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 13 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 14 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 15 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 16 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.wrongFormat: -------------------------------------------------------------------------------- 1 | MANIFEST xxxxxxxxxx 2 | version: 19440 3 | previous: 19430 4 | filecount: 8 5 | timestamp: 1512419456 6 | contentsize: 1145939028 7 | includes: os-core 8 | 9 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 10 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 11 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 12 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 13 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 14 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 15 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 16 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/README.md: -------------------------------------------------------------------------------- 1 | go-runewidth 2 | ============ 3 | 4 | [![Build Status](https://github.com/mattn/go-runewidth/workflows/test/badge.svg?branch=master)](https://github.com/mattn/go-runewidth/actions?query=workflow%3Atest) 5 | [![Codecov](https://codecov.io/gh/mattn/go-runewidth/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-runewidth) 6 | [![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) 8 | 9 | Provides functions to get fixed width of the character or string. 10 | 11 | Usage 12 | ----- 13 | 14 | ```go 15 | runewidth.StringWidth("つのだ☆HIRO") == 12 16 | ``` 17 | 18 | 19 | Author 20 | ------ 21 | 22 | Yasuhiro Matsumoto 23 | 24 | License 25 | ------- 26 | 27 | under the MIT License: http://mattn.mit-license.org/2013 28 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/deprecated.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | import ( 4 | "encoding" 5 | "io" 6 | ) 7 | 8 | // TextMarshaler is an alias for encoding.TextMarshaler. 9 | // 10 | // Deprecated: use encoding.TextMarshaler 11 | type TextMarshaler encoding.TextMarshaler 12 | 13 | // TextUnmarshaler is an alias for encoding.TextUnmarshaler. 14 | // 15 | // Deprecated: use encoding.TextUnmarshaler 16 | type TextUnmarshaler encoding.TextUnmarshaler 17 | 18 | // DecodeReader is an alias for NewDecoder(r).Decode(v). 19 | // 20 | // Deprecated: use NewDecoder(reader).Decode(&value). 21 | func DecodeReader(r io.Reader, v any) (MetaData, error) { return NewDecoder(r).Decode(v) } 22 | 23 | // PrimitiveDecode is an alias for MetaData.PrimitiveDecode(). 24 | // 25 | // Deprecated: use MetaData.PrimitiveDecode. 26 | func PrimitiveDecode(primValue Primitive, v any) error { 27 | md := MetaData{decoded: make(map[string]struct{})} 28 | return md.unify(primValue.undecoded, rvalue(v)) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/README.md: -------------------------------------------------------------------------------- 1 | # mousetrap 2 | 3 | mousetrap is a tiny library that answers a single question. 4 | 5 | On a Windows machine, was the process invoked by someone double clicking on 6 | the executable file while browsing in explorer? 7 | 8 | ### Motivation 9 | 10 | Windows developers unfamiliar with command line tools will often "double-click" 11 | the executable for a tool. Because most CLI tools print the help and then exit 12 | when invoked without arguments, this is often very frustrating for those users. 13 | 14 | mousetrap provides a way to detect these invocations so that you can provide 15 | more helpful behavior and instructions on how to run the CLI tool. To see what 16 | this looks like, both from an organizational and a technical perspective, see 17 | https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/ 18 | 19 | ### The interface 20 | 21 | The library exposes a single interface: 22 | 23 | func StartedByExplorer() (bool) 24 | -------------------------------------------------------------------------------- /swupd/testdata/invalid_manifests/manifest.duplicateVersion: -------------------------------------------------------------------------------- 1 | MANIFEST 21 2 | version: 19440 3 | version: 19440 4 | previous: 19430 5 | filecount: 8 6 | timestamp: 1512419456 7 | contentsize: 1145939028 8 | includes: os-core 9 | 10 | F... 9bcc1718757db298fb656ae6e2ee143dde746f49fbf6805db7683cb574c36728 18940 /usr/bin/FileCheck 11 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal 12 | F... 33ccead640727d66c62be03e089a3ca3f4ef7c374a3eeab79764f9509075b0d8 18940 /usr/bin/aclocal-1.15 13 | F... b26f85ffaf3595ecd9a8b1e0c894f1b9e6e3ed0e8c3f28bcde3d66e63bfedd4d 18940 /usr/bin/addr2line 14 | F... a49e68b3e2230855586e9ffd1b2962a2282411a488b80e3bd65851f068394c0a 18940 /usr/bin/ar 15 | F... d5d363d7b1b30ebd39dbae6b3bb4b29817a97dc3471a8795e1428e937033e7b3 18940 /usr/bin/as 16 | F... 63266f59318fb6f3dd15d996ebe48adcf9d9de30883aa958632db45e1499fa57 18940 /usr/bin/autoconf 17 | F... 864f78102661c05b61cafcb59785349fd2fb7a956ec00a77198fe5bc2432de76 18940 /usr/bin/autogen 18 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-blended-content/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Create stripped down mix 10 with blended bundles" { 11 | mixer-init-stripped-down $CLRVER 10 12 | localize_builder_conf 13 | 14 | download-rpm json-c 15 | mixer-add-rpms 16 | 17 | # Put custom content in upstream bundle 18 | create-empty-local-bundle "os-core-update" 19 | add-package-to-local-bundle "bsdiff" "os-core-update" 20 | add-package-to-local-bundle "json-c" "os-core-update" 21 | mixer-bundle-add "os-core-update" 22 | 23 | # Put upstream content in custom bundle 24 | create-empty-local-bundle "testbundle" 25 | add-package-to-local-bundle "json-c" "testbundle" 26 | add-package-to-local-bundle "bsdiff" "testbundle" 27 | mixer-bundle-add "testbundle" 28 | 29 | mixer-build-bundles > $LOGDIR/build_bundles.log 30 | mixer-build-update > $LOGDIR/build_update.log 31 | } 32 | 33 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 34 | -------------------------------------------------------------------------------- /bat/tests/customize-os-release/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Customize os-release file" { 11 | 12 | mixer init > /dev/null 13 | 14 | #Use modified config which has customized os-release file 15 | cp files/my-builder.conf builder.conf 16 | sed -i "s:/home/clr/mix:$PWD:g" builder.conf 17 | 18 | #Mixer build bundle 19 | mixer-build-bundles > $LOGDIR/build_bundles.log 20 | 21 | #Compare the diff between customized os-release file and output of mixer build 22 | #bundle. The only difference should be VERSION_ID and BUILD_ID 23 | run bash -c "diff files/my-os-release update/image/10/full/usr/lib/os-release | wc -l " 24 | [ "$output" -eq 8 ] 25 | 26 | run bash -c "diff files/my-os-release update/image/10/full/usr/lib/os-release" 27 | [[ ${lines[1]} =~ "VERSION_ID" ]] 28 | [[ ${lines[3]} =~ "VERSION_ID" ]] 29 | [[ ${lines[5]} =~ "BUILD_ID" ]] 30 | [[ ${lines[7]} =~ "BUILD_ID" ]] 31 | } 32 | 33 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 34 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/BurntSushi/toml v1.5.0 2 | ## explicit; go 1.18 3 | github.com/BurntSushi/toml 4 | github.com/BurntSushi/toml/internal 5 | # github.com/davecgh/go-spew v1.1.1 6 | ## explicit 7 | # github.com/go-ini/ini v1.67.0 8 | ## explicit 9 | github.com/go-ini/ini 10 | # github.com/inconshreveable/mousetrap v1.1.0 11 | ## explicit; go 1.18 12 | github.com/inconshreveable/mousetrap 13 | # github.com/mattn/go-runewidth v0.0.16 14 | ## explicit; go 1.9 15 | github.com/mattn/go-runewidth 16 | # github.com/olekukonko/tablewriter v0.0.5 17 | ## explicit; go 1.12 18 | github.com/olekukonko/tablewriter 19 | # github.com/pkg/errors v0.9.1 20 | ## explicit 21 | github.com/pkg/errors 22 | # github.com/pmezard/go-difflib v1.0.0 23 | ## explicit 24 | # github.com/rivo/uniseg v0.4.7 25 | ## explicit; go 1.18 26 | github.com/rivo/uniseg 27 | # github.com/spf13/cobra v1.9.1 28 | ## explicit; go 1.15 29 | github.com/spf13/cobra 30 | # github.com/spf13/pflag v1.0.6 31 | ## explicit; go 1.12 32 | github.com/spf13/pflag 33 | # github.com/stretchr/testify v1.2.2 34 | ## explicit 35 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/Makefile: -------------------------------------------------------------------------------- 1 | BIN="./bin" 2 | SRC=$(shell find . -name "*.go") 3 | 4 | ifeq (, $(shell which golangci-lint)) 5 | $(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh") 6 | endif 7 | 8 | .PHONY: fmt lint test install_deps clean 9 | 10 | default: all 11 | 12 | all: fmt test 13 | 14 | fmt: 15 | $(info ******************** checking formatting ********************) 16 | @test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1) 17 | 18 | lint: 19 | $(info ******************** running lint tools ********************) 20 | golangci-lint run -v 21 | 22 | test: install_deps 23 | $(info ******************** running tests ********************) 24 | go test -v ./... 25 | 26 | richtest: install_deps 27 | $(info ******************** running tests with kyoh86/richgo ********************) 28 | richgo test -v ./... 29 | 30 | install_deps: 31 | $(info ******************** downloading dependencies ********************) 32 | go get -v ./... 33 | 34 | clean: 35 | rm -rf $(BIN) 36 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/Makefile: -------------------------------------------------------------------------------- 1 | PKGS := github.com/pkg/errors 2 | SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) 3 | GO := go 4 | 5 | check: test vet gofmt misspell unconvert staticcheck ineffassign unparam 6 | 7 | test: 8 | $(GO) test $(PKGS) 9 | 10 | vet: | test 11 | $(GO) vet $(PKGS) 12 | 13 | staticcheck: 14 | $(GO) get honnef.co/go/tools/cmd/staticcheck 15 | staticcheck -checks all $(PKGS) 16 | 17 | misspell: 18 | $(GO) get github.com/client9/misspell/cmd/misspell 19 | misspell \ 20 | -locale GB \ 21 | -error \ 22 | *.md *.go 23 | 24 | unconvert: 25 | $(GO) get github.com/mdempsky/unconvert 26 | unconvert -v $(PKGS) 27 | 28 | ineffassign: 29 | $(GO) get github.com/gordonklaus/ineffassign 30 | find $(SRCDIRS) -name '*.go' | xargs ineffassign 31 | 32 | pedantic: check errcheck 33 | 34 | unparam: 35 | $(GO) get mvdan.cc/unparam 36 | unparam ./... 37 | 38 | errcheck: 39 | $(GO) get github.com/kisielk/errcheck 40 | errcheck $(PKGS) 41 | 42 | gofmt: 43 | @echo Checking code is gofmted 44 | @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## DISCONTINUATION OF PROJECT. 2 | 3 | This project will no longer be maintained by Intel. 4 | 5 | Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project. 6 | 7 | Contact: webadmin@linux.intel.com 8 | [![Go Report Card](https://goreportcard.com/badge/github.com/clearlinux/mixer-tools)](https://goreportcard.com/report/github.com/clearlinux/mixer-tools) 9 | [![mixer-tools CI](https://github.com/clearlinux/mixer-tools/workflows/mixer-tools%20CI/badge.svg)](https://github.com/clearlinux/mixer-tools/actions?query=workflow%3A%22mixer-tools+CI%22) 10 | 11 | This project contains tooling for using the software update mixer. 12 | 13 | Please follow the guide at https://www.clearlinux.org/clear-linux-documentation/guides/clear/mixer.html to learn more about how to use the mixer tool. 14 | -------------------------------------------------------------------------------- /docs/mixer.add-rpms.1.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | mixer.add-rpms 3 | ============== 4 | 5 | --------------------- 6 | Add local RPMs to mix 7 | --------------------- 8 | 9 | :Copyright: \(C) 2018 Intel Corporation, CC-BY-SA-3.0 10 | :Manual section: 1 11 | 12 | 13 | SYNOPSIS 14 | ======== 15 | 16 | ``mixer add-rpms [flags]`` 17 | 18 | 19 | DESCRIPTION 20 | =========== 21 | 22 | Adds RPMs from the `LOCAL_RPM_DIR` (configured in the `builder.conf`) to the 23 | local RPM repository to be used in creating a mix. 24 | 25 | 26 | OPTIONS 27 | ======= 28 | 29 | In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for 30 | more details), the following options are recognized. 31 | 32 | - ``-c, --config {path}`` 33 | 34 | Optionally tell ``mixer`` to use the configuration file at `path`. Uses the 35 | default `builder.conf` in the mixer workspace if this option is not provided. 36 | 37 | - ``-h, --help`` 38 | 39 | Display ``add-rpm`` help information and exit. 40 | 41 | 42 | EXIT STATUS 43 | =========== 44 | 45 | On success, 0 is returned. A non-zero return code indicates a failure. 46 | 47 | SEE ALSO 48 | -------- 49 | 50 | * ``mixer``\(1) 51 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 by Oleku Konko 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/rivo/uniseg/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Oliver Kuederle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 TOML authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /bat/tests/clr-installer-config/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Build image using default clr-installer config" { 11 | mixer $MIXARGS init --clear-version $CLRVER --mix-version 10 12 | mixer $MIXARGS bundle add editors 13 | 14 | # `build image` should fail because the prerequisite commands are not executed. 15 | # This is intentional in order to reduce test execution time. 16 | # The goal is to unit test the creation of clr-installer config file with relevant bundles. 17 | run sudo mixer $MIXARGS build image 18 | [[ "$status" -ne 0 ]] 19 | [[ "$output" =~ "release-image-config.yaml not found" ]] 20 | [[ "$output" =~ "Updating image bundle list based on mixbundles" ]] 21 | } 22 | 23 | @test "Update clr-installer config file with mix bundle list" { 24 | run cat release-image-config.yaml 25 | [[ "$status" -eq 0 ]] 26 | [[ "$output" =~ "os-core" ]] 27 | [[ "$output" =~ "os-core-update" ]] 28 | [[ "$output" =~ "kernel-native" ]] 29 | [[ "$output" =~ "bootloader" ]] 30 | [[ "$output" =~ "editors" ]] 31 | } 32 | 33 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 34 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bat/tests/update-mix-add-remove-bundles/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Create initial stripped down mix 10" { 11 | mixer-init-stripped-down $CLRVER 10 12 | mixer-build-bundles > $LOGDIR/build_bundles_10.log 13 | mixer-build-update > $LOGDIR/build_update_10.log 14 | } 15 | 16 | @test "Create version 20 with more stripped down upstream bundles" { 17 | mixer-mixversion-update 20 18 | 19 | create-empty-local-bundle "editors" 20 | add-package-to-local-bundle "joe" "editors" 21 | mixer-bundle-add "editors" 22 | 23 | create-empty-local-bundle "os-core-update" 24 | add-package-to-local-bundle "bsdiff" "os-core-update" 25 | mixer-bundle-add "os-core-update" 26 | 27 | mixer-build-bundles > $LOGDIR/build_bundles_20.log 28 | mixer-build-update > $LOGDIR/build_update_20.log 29 | } 30 | 31 | @test "Create version 30 with an upstream bundle deleted" { 32 | mixer-mixversion-update 30 33 | mixer-bundle-remove "editors" 34 | mixer-build-bundles > $LOGDIR/build_bundles_30.log 35 | mixer-build-update > $LOGDIR/build_update_30.log 36 | } 37 | 38 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 39 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_win.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2023 The Cobra Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | // +build windows 17 | 18 | package cobra 19 | 20 | import ( 21 | "fmt" 22 | "os" 23 | "time" 24 | 25 | "github.com/inconshreveable/mousetrap" 26 | ) 27 | 28 | var preExecHookFn = preExecHook 29 | 30 | func preExecHook(c *Command) { 31 | if MousetrapHelpText != "" && mousetrap.StartedByExplorer() { 32 | c.Print(MousetrapHelpText) 33 | if MousetrapDisplayDuration > 0 { 34 | time.Sleep(MousetrapDisplayDuration) 35 | } else { 36 | c.Println("Press return to continue...") 37 | fmt.Scanln() 38 | } 39 | os.Exit(1) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bat/tests/contentsize-check/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | 9 | current_ver=$(get-current-version) 10 | mixer-init-stripped-down "$current_ver" 10 11 | mixer-build-all 12 | } 13 | 14 | @test "Compare calculated contentsize with actual" { 15 | manifestPrefix=update/www/10/Manifest. 16 | manifests=$(sed -n 's/^[M,I]\..*\t//p' "${manifestPrefix}"MoM) 17 | 18 | while read -r manifest; do 19 | chroot=update/image/10/full/ 20 | 21 | # Only files and links are included in the contentsize. Directories 22 | # can be installed with variable sizes, so they are omitted from the 23 | # contentsize calculation. 24 | files=$(sed -n 's/^[F,L].*\t//p' "${manifestPrefix}${manifest}") 25 | 26 | # Add the content sizes of the files and links 27 | total=0 28 | while read -r f; do 29 | if [ -z "$f" ]; then 30 | continue 31 | fi 32 | size=$(stat -c "%s" "${chroot}${f}") 33 | total=$((total + size)) 34 | done <<< "$files" 35 | 36 | manifestSize=$(sed -n 's/^contentsize:\t//p' "${manifestPrefix}${manifest}") 37 | 38 | # Compare the calculated contentsize against the manifest's contentsize 39 | test "$total" -eq "$manifestSize" 40 | done <<< "$manifests" 41 | } 42 | 43 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 44 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows.go: -------------------------------------------------------------------------------- 1 | package mousetrap 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) { 9 | snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0) 10 | if err != nil { 11 | return nil, err 12 | } 13 | defer syscall.CloseHandle(snapshot) 14 | var procEntry syscall.ProcessEntry32 15 | procEntry.Size = uint32(unsafe.Sizeof(procEntry)) 16 | if err = syscall.Process32First(snapshot, &procEntry); err != nil { 17 | return nil, err 18 | } 19 | for { 20 | if procEntry.ProcessID == uint32(pid) { 21 | return &procEntry, nil 22 | } 23 | err = syscall.Process32Next(snapshot, &procEntry) 24 | if err != nil { 25 | return nil, err 26 | } 27 | } 28 | } 29 | 30 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 31 | // on the executable from explorer.exe 32 | // 33 | // It is conservative and returns false if any of the internal calls fail. 34 | // It does not guarantee that the program was run from a terminal. It only can tell you 35 | // whether it was launched from explorer.exe 36 | func StartedByExplorer() bool { 37 | pe, err := getProcessEntry(syscall.Getppid()) 38 | if err != nil { 39 | return false 40 | } 41 | return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:]) 42 | } 43 | -------------------------------------------------------------------------------- /bat/tests/export-flag/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Create mix 10 with un-export flag" { 11 | 12 | mixer-init-stripped-down "$CLRVER" 10 13 | 14 | # Create local bundle definition with a package and un-export file path 15 | create-empty-local-bundle "bundle1" 16 | add-package-to-local-bundle "bsdiff" "bundle1" 17 | mixer-bundle-add "bundle1" 18 | 19 | mixer-build-bundles > "$LOGDIR"/build_bundles.log 20 | mixer-build-update > "$LOGDIR"/build_update.log 21 | 22 | # Verify that manifest contains the export flags for the bsdiff files 23 | grep -P "F..x\t[A-Za-z0-9]*\t10\t/usr/bin/bsdiff" update/www/10/Manifest.bundle1 # should have export flag 24 | grep -P "F..x\t[A-Za-z0-9]*\t10\t/usr/bin/bspatch" update/www/10/Manifest.bundle1 # should have export flag 25 | 26 | mixer versions update 27 | echo "un-export(/usr/bin/bsdiff)" >> "$LOCAL_BUNDLE_DIR"/bundle1 28 | mixer-build-bundles > "$LOGDIR"/build_bundles.log 29 | mixer-build-update > "$LOGDIR"/build_update.log 30 | grep -P "F..\.\t[A-Za-z0-9]*\t20\t/usr/bin/bsdiff" update/www/20/Manifest.bundle1 # should not have export flag 31 | grep -P "F..x\t[A-Za-z0-9]*\t10\t/usr/bin/bspatch" update/www/20/Manifest.bundle1 # should have export flag 32 | 33 | } 34 | 35 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 36 | -------------------------------------------------------------------------------- /bat/tests/clean-rebuild/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Verify mixer builds clean the workspace" { 11 | mixer-init-stripped-down 25740 10 12 | mixer-build-all 13 | mixer-mixversion-update 20 14 | mixer-build-all 15 | 16 | # Rebuild v20 17 | run sudo mixer build bundles 18 | [[ $status -eq 0 ]] 19 | 20 | # Check v20 output directory cleaned 21 | [[ ! -d "$BATS_TEST_DIRNAME"/update/www/20 ]] 22 | 23 | run sudo mixer build update 24 | [[ $status -eq 0 ]] 25 | 26 | mom="$BATS_TEST_DIRNAME"/update/www/20/Manifest.MoM 27 | 28 | test $(sed -n 's/^version:\t//p' "$mom") -eq 20 29 | test $(sed -n 's/^previous:\t//p' "$mom") -eq 10 30 | test $(< "$BATS_TEST_DIRNAME"/update/image/LAST_VER) -eq 20 31 | 32 | # Check that PREVIOUS_MIX_VERSION in mixer.state is correct 33 | test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 10 34 | 35 | # Erase PREVIOUS_MIX_VERSION. This will cause it to default to 36 | # LAST_VER which will lead to an incorrectly generated manifest. 37 | sed -i "/PREVIOUS_MIX_VERSION/d" mixer.state 38 | 39 | run sudo mixer build all 40 | [[ $status -eq 0 ]] 41 | 42 | # Verify that previous is incorrect 43 | test $(sed -n 's/^previous:\t//p' "$mom") -ne 10 44 | } 45 | 46 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 47 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /helpers/helpers_test.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/clearlinux/mixer-tools/log" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | func TestRunCommandOutputSuccess(t *testing.T) { 11 | const msg = "Hello, world!" 12 | const fail = "This is not working!" 13 | // Prints both in stdout and stderr. 14 | out, err := RunCommandOutput(log.Mixer, "bash", "-c", fmt.Sprintf("echo -n %q; echo -n %q >&2", msg, fail)) 15 | if err != nil { 16 | t.Fatal(err) 17 | } 18 | // Output contains only stdout. 19 | if out.String() != msg { 20 | t.Fatalf("unexpected output %q instead of %q", out.String(), msg) 21 | } 22 | } 23 | 24 | func TestRunCommandOutputFailure(t *testing.T) { 25 | // Prints both in stdout and stderr. Calling false forces failure. 26 | out, err := RunCommandOutput(log.Mixer, "bash", "-c", "export OK=OK; export FAIL=FAIL; echo -n $OK$OK; echo -n $FAIL$FAIL >&2; false") 27 | if err == nil { 28 | t.Fatal("unexpected success when running command") 29 | } 30 | // Error should contain both errcode and stderr. Note that the strings we are 31 | // looking at are not part of the command, to avoid matching those. Output contains the stdout string. 32 | if !strings.Contains(out.String(), "OKOK") { 33 | t.Errorf("error doesn't contain the stdout of the program") 34 | } 35 | if !strings.Contains(err.Error(), "FAILFAIL") { 36 | t.Errorf("error doesn't contain the stderr of the program") 37 | } 38 | if t.Failed() { 39 | fmt.Println(err) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /swupd/fullchroot.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package swupd 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | "os/exec" 21 | "path/filepath" 22 | ) 23 | 24 | func syncToFull(version uint32, bundle string, imageBase string) error { 25 | fullPath := filepath.Join(imageBase, fmt.Sprint(version), "full") 26 | // MkdirAll returns nil when the path exists, so we continue to do the 27 | // full chroot creation over the existing one 28 | if err := os.MkdirAll(fullPath, 0777); err != nil { 29 | return err 30 | } 31 | 32 | // append trailing slash to get contents only 33 | bundlePath := filepath.Join(imageBase, fmt.Sprint(version), bundle) + "/" 34 | if _, err := os.Stat(bundlePath); err == nil { 35 | cmd := exec.Command("rsync", "-aAX", "--ignore-existing", bundlePath, fullPath) 36 | if err := cmd.Run(); err != nil { 37 | return fmt.Errorf("rsync error: %v", err) 38 | } 39 | } 40 | 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/csv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Oleku Konko All rights reserved. 2 | // Use of this source code is governed by a MIT 3 | // license that can be found in the LICENSE file. 4 | 5 | // This module is a Table Writer API for the Go Programming Language. 6 | // The protocols were written in pure Go and works on windows and unix systems 7 | 8 | package tablewriter 9 | 10 | import ( 11 | "encoding/csv" 12 | "io" 13 | "os" 14 | ) 15 | 16 | // Start A new table by importing from a CSV file 17 | // Takes io.Writer and csv File name 18 | func NewCSV(writer io.Writer, fileName string, hasHeader bool) (*Table, error) { 19 | file, err := os.Open(fileName) 20 | if err != nil { 21 | return &Table{}, err 22 | } 23 | defer file.Close() 24 | csvReader := csv.NewReader(file) 25 | t, err := NewCSVReader(writer, csvReader, hasHeader) 26 | return t, err 27 | } 28 | 29 | // Start a New Table Writer with csv.Reader 30 | // This enables customisation such as reader.Comma = ';' 31 | // See http://golang.org/src/pkg/encoding/csv/reader.go?s=3213:3671#L94 32 | func NewCSVReader(writer io.Writer, csvReader *csv.Reader, hasHeader bool) (*Table, error) { 33 | t := NewWriter(writer) 34 | if hasHeader { 35 | // Read the first row 36 | headers, err := csvReader.Read() 37 | if err != nil { 38 | return &Table{}, err 39 | } 40 | t.SetHeader(headers) 41 | } 42 | for { 43 | record, err := csvReader.Read() 44 | if err == io.EOF { 45 | break 46 | } else if err != nil { 47 | return &Table{}, err 48 | } 49 | t.Append(record) 50 | } 51 | return t, nil 52 | } 53 | -------------------------------------------------------------------------------- /bat/tests/config-conversion/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Convert to latest config" { 11 | mixer init > /dev/null 12 | 13 | #Backup current config 14 | cp builder.conf current.conf 15 | 16 | for f in "configs"/* 17 | do 18 | cp $f builder.conf 19 | sed -i "s:/home/clr/mix:$PWD:g" builder.conf 20 | 21 | mixer config validate > /dev/null 22 | 23 | diff builder.conf current.conf 24 | done 25 | 26 | } 27 | 28 | @test "Convert custom path" { 29 | cp configs/1.0_builder.conf configs/custom_builder.conf 30 | sed -i "s:/home/clr/mix:$PWD:g" configs/custom_builder.conf 31 | 32 | mixer init --config configs/custom_builder.conf > /dev/null 33 | } 34 | 35 | @test "Test format transfer" { 36 | mixer init > /dev/null 37 | 38 | cp configs/nover_builder.conf builder.conf 39 | 40 | rm mixer.state 41 | 42 | mixer config validate > /dev/null 43 | 44 | #check if format was transfered from builder.conf to mixer.state 45 | test $(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 1 46 | } 47 | 48 | @test "Test format keep" { 49 | mixer init > /dev/null 50 | 51 | #Save initial format 52 | format=$(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) 53 | 54 | cp configs/nover_builder.conf builder.conf 55 | 56 | mixer config validate > /dev/null 57 | 58 | #check if format has been preserved 59 | test $(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq $format 60 | } 61 | 62 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 63 | -------------------------------------------------------------------------------- /swupd/external_test.go: -------------------------------------------------------------------------------- 1 | package swupd 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "os/exec" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | func TestExternalWriter(t *testing.T) { 12 | tr, err := exec.LookPath("tr") 13 | if err != nil { 14 | if err == exec.ErrNotFound { 15 | t.Skip("couldn't find tr program used for test") 16 | } 17 | t.Fatal(err) 18 | } 19 | 20 | var output bytes.Buffer 21 | w, err := NewExternalWriter(&output, tr, "e", "a") 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | 26 | input := "Hello, world!" 27 | expected := strings.Replace(input, "e", "a", -1) 28 | 29 | _, err = w.Write([]byte(input)) 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | err = w.Close() 34 | if err != nil { 35 | t.Fatal(err) 36 | } 37 | 38 | if output.String() != expected { 39 | t.Fatalf("got %q, but want %q", output.String(), expected) 40 | } 41 | } 42 | 43 | func TestExternalReader(t *testing.T) { 44 | tr, err := exec.LookPath("tr") 45 | if err != nil { 46 | if err == exec.ErrNotFound { 47 | t.Skip("couldn't find tr program used for test") 48 | } 49 | t.Fatal(err) 50 | } 51 | 52 | input := "Hello, world!" 53 | expected := strings.Replace(input, "e", "a", -1) 54 | 55 | r, err := NewExternalReader(strings.NewReader(input), tr, "e", "a") 56 | if err != nil { 57 | t.Fatal(err) 58 | } 59 | 60 | output, err := ioutil.ReadAll(r) 61 | if err != nil { 62 | t.Fatal(err) 63 | } 64 | 65 | if string(output) != expected { 66 | t.Fatalf("got %q, but want %q", string(output), expected) 67 | } 68 | 69 | err = r.Close() 70 | if err != nil { 71 | t.Fatal(err) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/go113.go: -------------------------------------------------------------------------------- 1 | // +build go1.13 2 | 3 | package errors 4 | 5 | import ( 6 | stderrors "errors" 7 | ) 8 | 9 | // Is reports whether any error in err's chain matches target. 10 | // 11 | // The chain consists of err itself followed by the sequence of errors obtained by 12 | // repeatedly calling Unwrap. 13 | // 14 | // An error is considered to match a target if it is equal to that target or if 15 | // it implements a method Is(error) bool such that Is(target) returns true. 16 | func Is(err, target error) bool { return stderrors.Is(err, target) } 17 | 18 | // As finds the first error in err's chain that matches target, and if so, sets 19 | // target to that error value and returns true. 20 | // 21 | // The chain consists of err itself followed by the sequence of errors obtained by 22 | // repeatedly calling Unwrap. 23 | // 24 | // An error matches target if the error's concrete value is assignable to the value 25 | // pointed to by target, or if the error has a method As(interface{}) bool such that 26 | // As(target) returns true. In the latter case, the As method is responsible for 27 | // setting target. 28 | // 29 | // As will panic if target is not a non-nil pointer to either a type that implements 30 | // error, or to any interface type. As returns false if err is nil. 31 | func As(err error, target interface{}) bool { return stderrors.As(err, target) } 32 | 33 | // Unwrap returns the result of calling the Unwrap method on err, if err's 34 | // type contains an Unwrap method returning error. 35 | // Otherwise, Unwrap returns nil. 36 | func Unwrap(err error) error { 37 | return stderrors.Unwrap(err) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.golangci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2013-2023 The Cobra Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | run: 16 | deadline: 5m 17 | 18 | linters: 19 | disable-all: true 20 | enable: 21 | #- bodyclose 22 | # - deadcode ! deprecated since v1.49.0; replaced by 'unused' 23 | #- depguard 24 | #- dogsled 25 | #- dupl 26 | - errcheck 27 | #- exhaustive 28 | #- funlen 29 | #- gochecknoinits 30 | - goconst 31 | - gocritic 32 | #- gocyclo 33 | - gofmt 34 | - goimports 35 | #- gomnd 36 | #- goprintffuncname 37 | - gosec 38 | - gosimple 39 | - govet 40 | - ineffassign 41 | #- lll 42 | - misspell 43 | #- nakedret 44 | #- noctx 45 | - nolintlint 46 | #- rowserrcheck 47 | #- scopelint 48 | - staticcheck 49 | #- structcheck ! deprecated since v1.49.0; replaced by 'unused' 50 | - stylecheck 51 | #- typecheck 52 | - unconvert 53 | #- unparam 54 | - unused 55 | # - varcheck ! deprecated since v1.49.0; replaced by 'unused' 56 | #- whitespace 57 | fast: false 58 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Alex Ogier. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 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 FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/internal/tz.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import "time" 4 | 5 | // Timezones used for local datetime, date, and time TOML types. 6 | // 7 | // The exact way times and dates without a timezone should be interpreted is not 8 | // well-defined in the TOML specification and left to the implementation. These 9 | // defaults to current local timezone offset of the computer, but this can be 10 | // changed by changing these variables before decoding. 11 | // 12 | // TODO: 13 | // Ideally we'd like to offer people the ability to configure the used timezone 14 | // by setting Decoder.Timezone and Encoder.Timezone; however, this is a bit 15 | // tricky: the reason we use three different variables for this is to support 16 | // round-tripping – without these specific TZ names we wouldn't know which 17 | // format to use. 18 | // 19 | // There isn't a good way to encode this right now though, and passing this sort 20 | // of information also ties in to various related issues such as string format 21 | // encoding, encoding of comments, etc. 22 | // 23 | // So, for the time being, just put this in internal until we can write a good 24 | // comprehensive API for doing all of this. 25 | // 26 | // The reason they're exported is because they're referred from in e.g. 27 | // internal/tag. 28 | // 29 | // Note that this behaviour is valid according to the TOML spec as the exact 30 | // behaviour is left up to implementations. 31 | var ( 32 | localOffset = func() int { _, o := time.Now().Zone(); return o }() 33 | LocalDatetime = time.FixedZone("datetime-local", localOffset) 34 | LocalDate = time.FixedZone("date-local", localOffset) 35 | LocalTime = time.FixedZone("time-local", localOffset) 36 | ) 37 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "fmt" 19 | ) 20 | 21 | // ErrDelimiterNotFound indicates the error type of no delimiter is found which there should be one. 22 | type ErrDelimiterNotFound struct { 23 | Line string 24 | } 25 | 26 | // IsErrDelimiterNotFound returns true if the given error is an instance of ErrDelimiterNotFound. 27 | func IsErrDelimiterNotFound(err error) bool { 28 | _, ok := err.(ErrDelimiterNotFound) 29 | return ok 30 | } 31 | 32 | func (err ErrDelimiterNotFound) Error() string { 33 | return fmt.Sprintf("key-value delimiter not found: %s", err.Line) 34 | } 35 | 36 | // ErrEmptyKeyName indicates the error type of no key name is found which there should be one. 37 | type ErrEmptyKeyName struct { 38 | Line string 39 | } 40 | 41 | // IsErrEmptyKeyName returns true if the given error is an instance of ErrEmptyKeyName. 42 | func IsErrEmptyKeyName(err error) bool { 43 | _, ok := err.(ErrEmptyKeyName) 44 | return ok 45 | } 46 | 47 | func (err ErrEmptyKeyName) Error() string { 48 | return fmt.Sprintf("empty key name: %s", err.Line) 49 | } 50 | -------------------------------------------------------------------------------- /swupd/filesystem_test.go: -------------------------------------------------------------------------------- 1 | package swupd 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func TestCreateFileFromPath(t *testing.T) { 9 | resetHash() 10 | path := "testdata/manifest.good" 11 | expected := File{ 12 | Name: path, 13 | Type: TypeFile, 14 | } 15 | 16 | var fh Hashval 17 | var err error 18 | fh, err = Hashcalc(expected.Name) 19 | if err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | expected.Hash = fh 24 | 25 | m := Manifest{} 26 | var fi os.FileInfo 27 | if fi, err = os.Lstat(path); err != nil { 28 | t.Fatal(err) 29 | } 30 | 31 | err = m.createFileRecord("", path, "", fi) 32 | if err != nil { 33 | t.Error(err) 34 | } 35 | 36 | newFile := m.Files[0] 37 | if newFile.Name != expected.Name || 38 | newFile.Type != expected.Type || 39 | !HashEquals(newFile.Hash, expected.Hash) { 40 | t.Error("created File did not match expected") 41 | } 42 | } 43 | 44 | func TestAddFilesFromChroot(t *testing.T) { 45 | rootPath := "testdata/testbundle" 46 | m := Manifest{} 47 | if err := m.addFilesFromChroot(rootPath, ""); err != nil { 48 | t.Error(err) 49 | } 50 | 51 | if len(m.Files) != 6 { 52 | t.Error("incorrect number of files added from chroot") 53 | } 54 | } 55 | 56 | func TestAddFilesFromChrootNotExist(t *testing.T) { 57 | rootPath := "testdata/nowhere" 58 | m := Manifest{} 59 | if err := m.addFilesFromChroot(rootPath, ""); err == nil { 60 | t.Errorf("addFilesFromChroot did not fail on missing root") 61 | } 62 | } 63 | 64 | func TestExists(t *testing.T) { 65 | if !exists("testdata/manifest.good") { 66 | t.Error("exists() did not return true for existing file") 67 | } 68 | 69 | if exists("testdata/nowhere") { 70 | t.Error("exists() returned true for non-existent file") 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /bat/tests/state-conversion/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | 9 | mixer-init-stripped-down $CLRVER 10 10 | cp mixer.state current.state 11 | } 12 | 13 | function copy_test_state() { 14 | cp $1 mixer.state 15 | 16 | # Update test state file to current format 17 | format=$(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' current.state) 18 | sed -i "s/\(FORMAT\).*/\1 = \"$format\"/" mixer.state 19 | } 20 | 21 | @test "Convert all state versions to latest with version update" { 22 | # Verify that all state version conversions work 23 | for f in "configs"/* 24 | do 25 | copy_test_state $f 26 | 27 | mixer versions --offline 28 | 29 | diff mixer.state current.state 30 | 31 | mixer-init-stripped-down $CLRVER 10 32 | done 33 | } 34 | 35 | @test "Convert to latest state with build all" { 36 | # When LAST_VER exists, PREVIOUS_MIX_VERSION is set to LAST_VER during 37 | # conversions. Otherwise, PREVIOUS_MIX_VERSION is set to 0. 38 | 39 | copy_test_state configs/1.0_mixer.state 40 | 41 | # Verify that state is converted when LAST_VER doesn't exist 42 | sudo mixer build all 43 | diff mixer.state current.state 44 | 45 | # Increment versions and update expected PREVIOUS_MIX_VERSION value 46 | mixer versions update --mix-version 20 47 | copy_test_state configs/1.0_mixer.state 48 | sed -i 's/\(PREVIOUS_MIX_VERSION\).*/\1 = "10"/' current.state 49 | 50 | # Verify that state is converted and initialized to LAST_VER. At the 51 | # time of the PREVIOUS_MIX_VERSION initialization, LAST_VER should 52 | # still be 10. 53 | sudo mixer build all 54 | diff mixer.state current.state 55 | } 56 | 57 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 58 | -------------------------------------------------------------------------------- /mixer/cmd/rpms.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "github.com/clearlinux/mixer-tools/builder" 19 | "github.com/clearlinux/mixer-tools/helpers" 20 | 21 | "github.com/spf13/cobra" 22 | ) 23 | 24 | var addRPMCmd = &cobra.Command{ 25 | Use: "add-rpms", 26 | Short: "Add RPMs to local dnf repository", 27 | Long: `Add RPMS from the configured LOCAL_RPM_DIR to local dnf repository`, 28 | Run: runAddRPM, 29 | } 30 | 31 | var rpmCmds = []*cobra.Command{ 32 | addRPMCmd, 33 | } 34 | 35 | func init() { 36 | for _, cmd := range rpmCmds { 37 | RootCmd.AddCommand(cmd) 38 | } 39 | 40 | externalDeps[addRPMCmd] = []string{ 41 | "createrepo_c", 42 | } 43 | } 44 | 45 | func runAddRPM(_ *cobra.Command, _ []string) { 46 | b, err := builder.NewFromConfig(configFile) 47 | if err != nil { 48 | fail(err) 49 | } 50 | if b.Config.Mixer.LocalRPMDir == "" { 51 | failf("LOCAL_RPM_DIR not set in configuration") 52 | } 53 | rpms, err := helpers.ListVisibleFiles(b.Config.Mixer.LocalRPMDir) 54 | if err != nil { 55 | failf("cannot read LOCAL_RPM_DIR: %s", err) 56 | } 57 | err = b.AddRPMList(rpms) 58 | if err != nil { 59 | fail(err) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /config/state_convert.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | import ( 18 | "bufio" 19 | "github.com/clearlinux/mixer-tools/log" 20 | "os" 21 | ) 22 | 23 | // CurrentStateVersion is the current revision for the state file structure 24 | const CurrentStateVersion = "1.1" 25 | 26 | func (state *MixState) parseVersionAndConvert() error { 27 | f, err := os.Open(state.filename) 28 | if err != nil { 29 | return err 30 | } 31 | defer func() { 32 | _ = f.Close() 33 | }() 34 | 35 | // Read state version 36 | reader := bufio.NewReader(f) 37 | found, err := state.parseVersion(reader) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | // Already on latest version 43 | if found && state.version == CurrentStateVersion { 44 | return nil 45 | } 46 | 47 | log.Info(log.Mixer, "Converting state to version %s", CurrentStateVersion) 48 | 49 | return state.convertCurrent() 50 | } 51 | 52 | func (state *MixState) convertCurrent() error { 53 | // Version only exists in new state, so parse mixer.state as TOML 54 | if err := state.parse(); err != nil { 55 | return err 56 | } 57 | 58 | // Set state to the current version 59 | state.version = CurrentStateVersion 60 | 61 | return state.Save() 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_posix.go: -------------------------------------------------------------------------------- 1 | //go:build !windows && !js && !appengine 2 | // +build !windows,!js,!appengine 3 | 4 | package runewidth 5 | 6 | import ( 7 | "os" 8 | "regexp" 9 | "strings" 10 | ) 11 | 12 | var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`) 13 | 14 | var mblenTable = map[string]int{ 15 | "utf-8": 6, 16 | "utf8": 6, 17 | "jis": 8, 18 | "eucjp": 3, 19 | "euckr": 2, 20 | "euccn": 2, 21 | "sjis": 2, 22 | "cp932": 2, 23 | "cp51932": 2, 24 | "cp936": 2, 25 | "cp949": 2, 26 | "cp950": 2, 27 | "big5": 2, 28 | "gbk": 2, 29 | "gb2312": 2, 30 | } 31 | 32 | func isEastAsian(locale string) bool { 33 | charset := strings.ToLower(locale) 34 | r := reLoc.FindStringSubmatch(locale) 35 | if len(r) == 2 { 36 | charset = strings.ToLower(r[1]) 37 | } 38 | 39 | if strings.HasSuffix(charset, "@cjk_narrow") { 40 | return false 41 | } 42 | 43 | for pos, b := range []byte(charset) { 44 | if b == '@' { 45 | charset = charset[:pos] 46 | break 47 | } 48 | } 49 | max := 1 50 | if m, ok := mblenTable[charset]; ok { 51 | max = m 52 | } 53 | if max > 1 && (charset[0] != 'u' || 54 | strings.HasPrefix(locale, "ja") || 55 | strings.HasPrefix(locale, "ko") || 56 | strings.HasPrefix(locale, "zh")) { 57 | return true 58 | } 59 | return false 60 | } 61 | 62 | // IsEastAsian return true if the current locale is CJK 63 | func IsEastAsian() bool { 64 | locale := os.Getenv("LC_ALL") 65 | if locale == "" { 66 | locale = os.Getenv("LC_CTYPE") 67 | } 68 | if locale == "" { 69 | locale = os.Getenv("LANG") 70 | } 71 | 72 | // ignore C locale 73 | if locale == "POSIX" || locale == "C" { 74 | return false 75 | } 76 | if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') { 77 | return false 78 | } 79 | 80 | return isEastAsian(locale) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/README.md: -------------------------------------------------------------------------------- 1 | # INI 2 | 3 | [![GitHub Workflow Status](https://img.shields.io/github/checks-status/go-ini/ini/main?logo=github&style=for-the-badge)](https://github.com/go-ini/ini/actions?query=branch%3Amain) 4 | [![codecov](https://img.shields.io/codecov/c/github/go-ini/ini/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/go-ini/ini) 5 | [![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/go-ini/ini?tab=doc) 6 | [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/go-ini/ini) 7 | 8 | ![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200) 9 | 10 | Package ini provides INI file read and write functionality in Go. 11 | 12 | ## Features 13 | 14 | - Load from multiple data sources(file, `[]byte`, `io.Reader` and `io.ReadCloser`) with overwrites. 15 | - Read with recursion values. 16 | - Read with parent-child sections. 17 | - Read with auto-increment key names. 18 | - Read with multiple-line values. 19 | - Read with tons of helper methods. 20 | - Read and convert values to Go types. 21 | - Read and **WRITE** comments of sections and keys. 22 | - Manipulate sections, keys and comments with ease. 23 | - Keep sections and keys in order as you parse and save. 24 | 25 | ## Installation 26 | 27 | The minimum requirement of Go is **1.13**. 28 | 29 | ```sh 30 | $ go get gopkg.in/ini.v1 31 | ``` 32 | 33 | Please add `-u` flag to update in the future. 34 | 35 | ## Getting Help 36 | 37 | - [Getting Started](https://ini.unknwon.io/docs/intro/getting_started) 38 | - [API Documentation](https://gowalker.org/gopkg.in/ini.v1) 39 | - 中国大陆镜像:https://ini.unknwon.cn 40 | 41 | ## License 42 | 43 | This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text. 44 | -------------------------------------------------------------------------------- /vendor/github.com/rivo/uniseg/width.go: -------------------------------------------------------------------------------- 1 | package uniseg 2 | 3 | // EastAsianAmbiguousWidth specifies the monospace width for East Asian 4 | // characters classified as Ambiguous. The default is 1 but some rare fonts 5 | // render them with a width of 2. 6 | var EastAsianAmbiguousWidth = 1 7 | 8 | // runeWidth returns the monospace width for the given rune. The provided 9 | // grapheme property is a value mapped by the [graphemeCodePoints] table. 10 | // 11 | // Every rune has a width of 1, except for runes with the following properties 12 | // (evaluated in this order): 13 | // 14 | // - Control, CR, LF, Extend, ZWJ: Width of 0 15 | // - \u2e3a, TWO-EM DASH: Width of 3 16 | // - \u2e3b, THREE-EM DASH: Width of 4 17 | // - East-Asian width Fullwidth and Wide: Width of 2 (Ambiguous and Neutral 18 | // have a width of 1) 19 | // - Regional Indicator: Width of 2 20 | // - Extended Pictographic: Width of 2, unless Emoji Presentation is "No". 21 | func runeWidth(r rune, graphemeProperty int) int { 22 | switch graphemeProperty { 23 | case prControl, prCR, prLF, prExtend, prZWJ: 24 | return 0 25 | case prRegionalIndicator: 26 | return 2 27 | case prExtendedPictographic: 28 | if property(emojiPresentation, r) == prEmojiPresentation { 29 | return 2 30 | } 31 | return 1 32 | } 33 | 34 | switch r { 35 | case 0x2e3a: 36 | return 3 37 | case 0x2e3b: 38 | return 4 39 | } 40 | 41 | switch propertyEastAsianWidth(r) { 42 | case prW, prF: 43 | return 2 44 | case prA: 45 | return EastAsianAmbiguousWidth 46 | } 47 | 48 | return 1 49 | } 50 | 51 | // StringWidth returns the monospace width for the given string, that is, the 52 | // number of same-size cells to be occupied by the string. 53 | func StringWidth(s string) (width int) { 54 | state := -1 55 | for len(s) > 0 { 56 | var w int 57 | _, s, w, state = FirstGraphemeClusterInString(s, state) 58 | width += w 59 | } 60 | return 61 | } 62 | -------------------------------------------------------------------------------- /docs/mixer.add-rpms.1: -------------------------------------------------------------------------------- 1 | .\" Man page generated from reStructuredText. 2 | . 3 | .TH MIXER.ADD-RPMS 1 "" "" "" 4 | .SH NAME 5 | mixer.add-rpms \- Add local RPMs to mix 6 | . 7 | .nr rst2man-indent-level 0 8 | . 9 | .de1 rstReportMargin 10 | \\$1 \\n[an-margin] 11 | level \\n[rst2man-indent-level] 12 | level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] 13 | - 14 | \\n[rst2man-indent0] 15 | \\n[rst2man-indent1] 16 | \\n[rst2man-indent2] 17 | .. 18 | .de1 INDENT 19 | .\" .rstReportMargin pre: 20 | . RS \\$1 21 | . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] 22 | . nr rst2man-indent-level +1 23 | .\" .rstReportMargin post: 24 | .. 25 | .de UNINDENT 26 | . RE 27 | .\" indent \\n[an-margin] 28 | .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] 29 | .nr rst2man-indent-level -1 30 | .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] 31 | .in \\n[rst2man-indent\\n[rst2man-indent-level]]u 32 | .. 33 | .SH SYNOPSIS 34 | .sp 35 | \fBmixer add\-rpms [flags]\fP 36 | .SH DESCRIPTION 37 | .sp 38 | Adds RPMs from the \fILOCAL_RPM_DIR\fP (configured in the \fIbuilder.conf\fP) to the 39 | local RPM repository to be used in creating a mix. 40 | .SH OPTIONS 41 | .sp 42 | In addition to the globally recognized \fBmixer\fP flags (see \fBmixer\fP(1) for 43 | more details), the following options are recognized. 44 | .INDENT 0.0 45 | .IP \(bu 2 46 | \fB\-c, \-\-config {path}\fP 47 | .sp 48 | Optionally tell \fBmixer\fP to use the configuration file at \fIpath\fP\&. Uses the 49 | default \fIbuilder.conf\fP in the mixer workspace if this option is not provided. 50 | .IP \(bu 2 51 | \fB\-h, \-\-help\fP 52 | .sp 53 | Display \fBadd\-rpm\fP help information and exit. 54 | .UNINDENT 55 | .SH EXIT STATUS 56 | .sp 57 | On success, 0 is returned. A non\-zero return code indicates a failure. 58 | .SS SEE ALSO 59 | .INDENT 0.0 60 | .IP \(bu 2 61 | \fBmixer\fP(1) 62 | .UNINDENT 63 | .SH COPYRIGHT 64 | (C) 2018 Intel Corporation, CC-BY-SA-3.0 65 | .\" Generated by docutils manpage writer. 66 | . 67 | -------------------------------------------------------------------------------- /swupd-inspector/cat.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "log" 7 | "os" 8 | "path/filepath" 9 | "strings" 10 | 11 | "github.com/clearlinux/mixer-tools/internal/client" 12 | "github.com/clearlinux/mixer-tools/swupd" 13 | ) 14 | 15 | // TODO: Support reading text files. 16 | 17 | func runCat(cacheDir, url, arg string) { 18 | base, version := parseURL(url) 19 | stateDir := filepath.Join(cacheDir, convertContentBaseToDirname(base)) 20 | state, err := client.NewState(stateDir, base) 21 | if err != nil { 22 | log.Fatalf("ERROR: %s", err) 23 | } 24 | 25 | mom, err := state.GetMoM(version) 26 | if err != nil { 27 | log.Fatalf("ERROR: %s", err) 28 | } 29 | 30 | switch { 31 | case arg == "Manifest.MoM", arg == "Manifest.full": 32 | path, err := state.GetFile(version, arg) 33 | if err != nil { 34 | log.Fatalf("ERROR: %s", err) 35 | } 36 | err = copyFileToStdout(path) 37 | if err != nil { 38 | log.Fatalf("ERROR: %s", err) 39 | } 40 | 41 | case strings.HasPrefix(arg, "Manifest."): 42 | // Look at MoM first to find the version of the bundle. 43 | name := arg[9:] 44 | var found *swupd.File 45 | for _, f := range mom.Files { 46 | if f.Name == name { 47 | found = f 48 | break 49 | } 50 | } 51 | if found == nil { 52 | log.Fatalf("ERROR: Manifest.MoM for version %s doesn't have a bundle named %s", version, name) 53 | } 54 | path, err := state.GetFile(fmt.Sprint(found.Version), arg) 55 | if err != nil { 56 | log.Fatalf("ERROR: %s", err) 57 | } 58 | err = copyFileToStdout(path) 59 | if err != nil { 60 | log.Fatalf("ERROR: %s", err) 61 | } 62 | 63 | default: 64 | log.Fatalf("Second argument to 'cat' must be a Manifest name") 65 | } 66 | } 67 | 68 | func copyFileToStdout(src string) error { 69 | srcF, err := os.Open(src) 70 | if err != nil { 71 | return err 72 | } 73 | defer func() { 74 | _ = srcF.Close() 75 | }() 76 | _, err = io.Copy(os.Stdout, srcF) 77 | return err 78 | } 79 | -------------------------------------------------------------------------------- /docs/mixer.config.1.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | mixer.config 3 | ============ 4 | 5 | ------------------------------------------ 6 | Perform configuration manipulation actions 7 | ------------------------------------------ 8 | 9 | :Copyright: \(C) 2018 Intel Corporation, CC-BY-SA-3.0 10 | :Manual section: 1 11 | 12 | 13 | SYNOPSIS 14 | ======== 15 | 16 | ``mixer config [command]`` 17 | 18 | 19 | DESCRIPTION 20 | =========== 21 | 22 | Perform various configuration manipulation actions on the mixer configuration 23 | files. 24 | 25 | 26 | OPTIONS 27 | ======= 28 | 29 | In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for 30 | more details), the following options are recognized. 31 | 32 | - ``-h, --help`` 33 | 34 | Display ``config`` help information and exit. 35 | 36 | 37 | SUBCOMMANDS 38 | =========== 39 | 40 | ``convert`` 41 | 42 | Convert an old config file to the new TOML format. The command will generate 43 | a backup file of the old config and will replace it with the converted one. 44 | Environment variables will not be expanded and the values will not be 45 | validated. In addition to the global options ``mixer config convert`` takes 46 | the following options. 47 | 48 | - ``-c, --config {path}`` 49 | 50 | The `path` to the configuration file to convert. 51 | 52 | - ``-h, --help`` 53 | 54 | Display ``config convert`` help and exit. 55 | 56 | ``validate`` 57 | 58 | Parse a builder config file and display its properties. Properties 59 | containing environment variables will be expanded. In addition to the 60 | global options ``mixer config validate`` takes the following options. 61 | 62 | - ``-c, --config {path}`` 63 | 64 | The `path` to the configuration file to validate. 65 | 66 | - ``-h, --help`` 67 | 68 | Display ``config validate`` help and exit. 69 | 70 | 71 | EXIT STATUS 72 | =========== 73 | 74 | On success, 0 is returned. A non-zero return code indicates a failure. 75 | 76 | SEE ALSO 77 | -------- 78 | 79 | * ``mixer``\(1) 80 | -------------------------------------------------------------------------------- /bat/tests/create-mix-with-custom-content/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Create stripped down mix 10 with custom content in custom bundle" { 11 | mixer-init-stripped-down $CLRVER 10 12 | localize_builder_conf 13 | 14 | download-rpm json-c 15 | mixer-add-rpms 16 | create-empty-local-bundle "testbundle" 17 | add-package-to-local-bundle "json-c" "testbundle" 18 | mixer-bundle-add "testbundle" 19 | 20 | mixer-build-bundles > $LOGDIR/build_bundles.log 21 | mixer-build-update > $LOGDIR/build_update.log 22 | } 23 | 24 | @test "Create stripped down mix 10 with custom rpm from custom repo" { 25 | mixer-init-stripped-down $CLRVER 10 26 | localize_builder_conf 27 | 28 | # create a custom repo directory which has a sub directory 29 | mkdir -p $BATS_TEST_DIRNAME/custom-yum/sub-dir 30 | 31 | # download the helloworld rpm, rename it to a non-autospec convention and place it within the repo sub directory 32 | curl --retry 4 --retry-delay 10 --fail --silent --show-error --location --remote-name https://download.clearlinux.org/releases/35110/clear/x86_64/os/Packages/helloworld-4-167.x86_64.rpm 33 | mv helloworld-4-167.x86_64.rpm $BATS_TEST_DIRNAME/custom-yum/sub-dir/foo.rpm 34 | 35 | # create the repo 36 | createrepo_c $BATS_TEST_DIRNAME/custom-yum/ 37 | 38 | # add the custom repo to mixer with the baseurl not including the sub directory 39 | mixer repo add custom file://$BATS_TEST_DIRNAME/custom-yum 40 | 41 | # create and add a bundle for the downloaded package to the mix 42 | cat > local-bundles/foobar < $LOGDIR/build_bundles.log 54 | 55 | # check if the corresponding bin file for the package is created 56 | test -e $BATS_TEST_DIRNAME/update/image/10/full/usr/bin/helloworld 57 | } 58 | 59 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 60 | -------------------------------------------------------------------------------- /docs/mixer.init.1.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | mixer.init 3 | ========== 4 | 5 | ------------------------------ 6 | Initialize mixer and workspace 7 | ------------------------------ 8 | 9 | :Copyright: \(C) 2018 Intel Corporation, CC-BY-SA-3.0 10 | :Manual section: 1 11 | 12 | 13 | SYNOPSIS 14 | ======== 15 | 16 | ``mixer init [flags]`` 17 | 18 | 19 | DESCRIPTION 20 | =========== 21 | 22 | Initialize the mixer configuration and mixer workspace by writing default 23 | configuration files if necessary and building the proper directory structure. 24 | 25 | OPTIONS 26 | ======= 27 | 28 | In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for 29 | more details), the following options are recognized. 30 | 31 | - ``--all-local`` 32 | 33 | Initialize mix with all local bundles automatically included. 34 | 35 | - ``--all-upstream`` 36 | 37 | Initialize the mix with all upstream bundles automatically included. 38 | 39 | - ``--clear-version {version}`` 40 | 41 | Upstream version used to compose the mix. It must be either an integer or 'latest' (default "latest") 42 | 43 | - ``--config {path}`` 44 | 45 | Supply a specific configuration file at `path` to use for mixing. 46 | 47 | - ``--format {format}`` 48 | 49 | Supply the format version for the mix. 50 | 51 | - ``--git`` 52 | 53 | Track mixer's internal work directory with git. 54 | 55 | - ``-h, --help`` 56 | 57 | Display ``init`` help information and exit. 58 | 59 | - ``--local-rpms`` 60 | 61 | Create and configure local RPM directories. 62 | 63 | - ``--mix-version {version}`` 64 | 65 | Supply the mix version to build (default is 10) 66 | 67 | - ``--no-default-bundles`` 68 | 69 | Skip adding default bundles to the mix 70 | 71 | - ``--upstream-url {url}`` 72 | 73 | Supply an upstream URL to use for mixing (default is 74 | "https://download.clearlinux.org") 75 | 76 | - ``--upstream-version {version}`` 77 | 78 | Alias to `--clear-version` (default is "latest") 79 | 80 | 81 | EXIT STATUS 82 | =========== 83 | 84 | On success, 0 is returned. A non-zero return code indicates a failure. 85 | 86 | SEE ALSO 87 | -------- 88 | 89 | * ``mixer``\(1) 90 | -------------------------------------------------------------------------------- /docs/mixer.repo.1.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | mixer.repo 3 | ========== 4 | 5 | --------------------------------------------------------------- 6 | Perform various configuration actions on mixer RPM repositories 7 | --------------------------------------------------------------- 8 | 9 | :Copyright: \(C) 2018 Intel Corporation, CC-BY-SA-3.0 10 | :Manual section: 1 11 | 12 | 13 | SYNOPSIS 14 | ======== 15 | 16 | ``mixer repo [command]`` 17 | 18 | 19 | DESCRIPTION 20 | =========== 21 | 22 | Perform various configuration actions on mixer RPM repositories. These RPM 23 | repositories are used as content sources for mixer to build updates from. 24 | 25 | 26 | OPTIONS 27 | ======= 28 | 29 | In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for 30 | more details), the following options are recognized. 31 | 32 | - ``-c, --config {path}`` 33 | 34 | The `path` to the configuration file to use. 35 | 36 | - ``-h, --help`` 37 | 38 | Display subcommand help information and exit. 39 | 40 | 41 | SUBCOMMANDS 42 | =========== 43 | 44 | ``add {name} {url}`` 45 | 46 | Add the repo named `name` at the `url` url. In addition to the global 47 | options ``mixer repo add`` takes the following options. 48 | 49 | - ``--priority`` 50 | 51 | Repo priority between 1 and 99, where 1 is highest. This flag defaults to 1. 52 | 53 | ``init`` 54 | 55 | Initialize the DNF configuration file with the default `Clear` repository 56 | enabled. 57 | 58 | ``list`` 59 | 60 | List all RPM repositories configured in the DNF configuration file used by 61 | mixer. 62 | 63 | ``remove {name}`` 64 | 65 | Remove the repo `name` from the DNF configuration file used by mixer. 66 | 67 | ``set-priority {name} {priority}`` 68 | 69 | Sets the priority for repo `name` to the provided `priority`. 70 | 71 | ``set-url {name} {url}`` 72 | 73 | Sets the URL for repo `name` to the provided `url`. If `name` does not exist 74 | the repo will be added to the configuration. 75 | 76 | 77 | EXIT STATUS 78 | =========== 79 | 80 | On success, 0 is returned. A non-zero return code indicates a failure. 81 | 82 | SEE ALSO 83 | -------- 84 | 85 | * ``mixer``\(1) 86 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/type_toml.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // tomlType represents any Go type that corresponds to a TOML type. 4 | // While the first draft of the TOML spec has a simplistic type system that 5 | // probably doesn't need this level of sophistication, we seem to be militating 6 | // toward adding real composite types. 7 | type tomlType interface { 8 | typeString() string 9 | } 10 | 11 | // typeEqual accepts any two types and returns true if they are equal. 12 | func typeEqual(t1, t2 tomlType) bool { 13 | if t1 == nil || t2 == nil { 14 | return false 15 | } 16 | return t1.typeString() == t2.typeString() 17 | } 18 | 19 | func typeIsTable(t tomlType) bool { 20 | return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) 21 | } 22 | 23 | type tomlBaseType string 24 | 25 | func (btype tomlBaseType) typeString() string { return string(btype) } 26 | func (btype tomlBaseType) String() string { return btype.typeString() } 27 | 28 | var ( 29 | tomlInteger tomlBaseType = "Integer" 30 | tomlFloat tomlBaseType = "Float" 31 | tomlDatetime tomlBaseType = "Datetime" 32 | tomlString tomlBaseType = "String" 33 | tomlBool tomlBaseType = "Bool" 34 | tomlArray tomlBaseType = "Array" 35 | tomlHash tomlBaseType = "Hash" 36 | tomlArrayHash tomlBaseType = "ArrayHash" 37 | ) 38 | 39 | // typeOfPrimitive returns a tomlType of any primitive value in TOML. 40 | // Primitive values are: Integer, Float, Datetime, String and Bool. 41 | // 42 | // Passing a lexer item other than the following will cause a BUG message 43 | // to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. 44 | func (p *parser) typeOfPrimitive(lexItem item) tomlType { 45 | switch lexItem.typ { 46 | case itemInteger: 47 | return tomlInteger 48 | case itemFloat: 49 | return tomlFloat 50 | case itemDatetime: 51 | return tomlDatetime 52 | case itemString, itemStringEsc: 53 | return tomlString 54 | case itemMultilineString: 55 | return tomlString 56 | case itemRawString: 57 | return tomlString 58 | case itemRawMultilineString: 59 | return tomlString 60 | case itemBool: 61 | return tomlBool 62 | } 63 | p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) 64 | panic("unreachable") 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/go-ini/ini/data_source.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Unknwon 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | // License for the specific language governing permissions and limitations 13 | // under the License. 14 | 15 | package ini 16 | 17 | import ( 18 | "bytes" 19 | "fmt" 20 | "io" 21 | "io/ioutil" 22 | "os" 23 | ) 24 | 25 | var ( 26 | _ dataSource = (*sourceFile)(nil) 27 | _ dataSource = (*sourceData)(nil) 28 | _ dataSource = (*sourceReadCloser)(nil) 29 | ) 30 | 31 | // dataSource is an interface that returns object which can be read and closed. 32 | type dataSource interface { 33 | ReadCloser() (io.ReadCloser, error) 34 | } 35 | 36 | // sourceFile represents an object that contains content on the local file system. 37 | type sourceFile struct { 38 | name string 39 | } 40 | 41 | func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { 42 | return os.Open(s.name) 43 | } 44 | 45 | // sourceData represents an object that contains content in memory. 46 | type sourceData struct { 47 | data []byte 48 | } 49 | 50 | func (s *sourceData) ReadCloser() (io.ReadCloser, error) { 51 | return ioutil.NopCloser(bytes.NewReader(s.data)), nil 52 | } 53 | 54 | // sourceReadCloser represents an input stream with Close method. 55 | type sourceReadCloser struct { 56 | reader io.ReadCloser 57 | } 58 | 59 | func (s *sourceReadCloser) ReadCloser() (io.ReadCloser, error) { 60 | return s.reader, nil 61 | } 62 | 63 | func parseDataSource(source interface{}) (dataSource, error) { 64 | switch s := source.(type) { 65 | case string: 66 | return sourceFile{s}, nil 67 | case []byte: 68 | return &sourceData{s}, nil 69 | case io.ReadCloser: 70 | return &sourceReadCloser{s}, nil 71 | case io.Reader: 72 | return &sourceReadCloser{ioutil.NopCloser(s)}, nil 73 | default: 74 | return nil, fmt.Errorf("error parsing data source: unknown type %q", s) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /swupd/config_test.go: -------------------------------------------------------------------------------- 1 | package swupd 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestReadServerINI(t *testing.T) { 9 | if c, _ := readServerINI("nowhere", "noINI"); !reflect.DeepEqual(c, defaultConfig) { 10 | // should just leave the defaults in place 11 | t.Error("generated config was the not the expected default config") 12 | } 13 | 14 | var c config 15 | c, _ = readServerINI("/var/lib/update", "testdata/server.ini") 16 | if reflect.DeepEqual(c, defaultConfig) { 17 | t.Error("generated config was the same as the default config") 18 | } 19 | 20 | if c.emptyDir != "/var/lib/update/emptytest/" || 21 | c.imageBase != "/var/lib/update/imagetest/" || 22 | c.outputDir != "/var/lib/update/wwwtest/" || 23 | c.debuginfo.banned != true || 24 | c.debuginfo.lib != "/usr/lib/debugtest/" || 25 | c.debuginfo.src != "/usr/src/debugtest/" { 26 | t.Errorf("%v\n%v\n%v\n%v\n%v\n", 27 | c.imageBase, c.outputDir, c.debuginfo.banned, c.debuginfo.lib, c.debuginfo.src) 28 | } 29 | } 30 | 31 | func TestReadGroupsINI(t *testing.T) { 32 | var err error 33 | if _, err = readGroupsINI("nowhere"); err == nil { 34 | t.Error("readGroupsINI did not raise an error on a non-existent file") 35 | } 36 | 37 | if _, err = readGroupsINI("testdata/groups.ini.no-os-core"); err == nil { 38 | t.Error("readGroupsINI did not raise an error for groups.ini file with no os-core listed") 39 | } 40 | 41 | var groups []string 42 | if groups, err = readGroupsINI("testdata/groups.ini"); err != nil { 43 | t.Error(err) 44 | } 45 | 46 | expected := []string{"os-core", "test-bundle", "Test-bundle2"} 47 | if !reflect.DeepEqual(groups, expected) { 48 | t.Errorf("groups %v did not match expected %v", groups, expected) 49 | } 50 | } 51 | 52 | func TestReadIncludesFile(t *testing.T) { 53 | var err error 54 | if _, err = readIncludesFile("nowhere"); err != nil { 55 | // this just means there are no includes 56 | // there should be no error 57 | t.Error(err) 58 | } 59 | 60 | var includes []string 61 | if includes, err = readIncludesFile("testdata/test-bundle-includes"); err != nil { 62 | t.Error(err) 63 | } 64 | 65 | expected := []string{"test-bundle1", "test-bundle2"} 66 | if !reflect.DeepEqual(includes, expected) { 67 | t.Errorf("includes %v did not match expected %v", includes, expected) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Cobra 2 | 3 | Thank you so much for contributing to Cobra. We appreciate your time and help. 4 | Here are some guidelines to help you get started. 5 | 6 | ## Code of Conduct 7 | 8 | Be kind and respectful to the members of the community. Take time to educate 9 | others who are seeking help. Harassment of any kind will not be tolerated. 10 | 11 | ## Questions 12 | 13 | If you have questions regarding Cobra, feel free to ask it in the community 14 | [#cobra Slack channel][cobra-slack] 15 | 16 | ## Filing a bug or feature 17 | 18 | 1. Before filing an issue, please check the existing issues to see if a 19 | similar one was already opened. If there is one already opened, feel free 20 | to comment on it. 21 | 1. If you believe you've found a bug, please provide detailed steps of 22 | reproduction, the version of Cobra and anything else you believe will be 23 | useful to help troubleshoot it (e.g. OS environment, environment variables, 24 | etc...). Also state the current behavior vs. the expected behavior. 25 | 1. If you'd like to see a feature or an enhancement please open an issue with 26 | a clear title and description of what the feature is and why it would be 27 | beneficial to the project and its users. 28 | 29 | ## Submitting changes 30 | 31 | 1. CLA: Upon submitting a Pull Request (PR), contributors will be prompted to 32 | sign a CLA. Please sign the CLA :slightly_smiling_face: 33 | 1. Tests: If you are submitting code, please ensure you have adequate tests 34 | for the feature. Tests can be run via `go test ./...` or `make test`. 35 | 1. Since this is golang project, ensure the new code is properly formatted to 36 | ensure code consistency. Run `make all`. 37 | 38 | ### Quick steps to contribute 39 | 40 | 1. Fork the project. 41 | 1. Download your fork to your PC (`git clone https://github.com/your_username/cobra && cd cobra`) 42 | 1. Create your feature branch (`git checkout -b my-new-feature`) 43 | 1. Make changes and run tests (`make test`) 44 | 1. Add them to staging (`git add .`) 45 | 1. Commit your changes (`git commit -m 'Add some feature'`) 46 | 1. Push to the branch (`git push origin my-new-feature`) 47 | 1. Create new pull request 48 | 49 | 50 | [cobra-slack]: https://gophers.slack.com/archives/CD3LP1199 51 | -------------------------------------------------------------------------------- /docs/mixer.versions.1.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | mixer.versions 3 | ============== 4 | 5 | -------------------------------- 6 | Manage mix and upstream versions 7 | -------------------------------- 8 | 9 | :Copyright: \(C) 2018 Intel Corporation, CC-BY-SA-3.0 10 | :Manual section: 1 11 | 12 | 13 | SYNOPSIS 14 | ======== 15 | 16 | ``mixer versions`` 17 | 18 | ``mixer versions [command]`` 19 | 20 | 21 | DESCRIPTION 22 | =========== 23 | 24 | Manage mix and upstream versions. By itself the command will print the current 25 | version of mix and upstream, and also report on the latest version of upstream 26 | available. This command also allows the user to increment the mix version and 27 | optionally the upstream version. 28 | 29 | 30 | OPTIONS 31 | ======= 32 | 33 | In addition to the globally recognized ``mixer`` flags (see ``mixer``\(1) for 34 | more details), the following options are recognized. 35 | 36 | - ``-h, --help`` 37 | 38 | Display subcommand help information and exit. 39 | 40 | 41 | SUBCOMMANDS 42 | =========== 43 | 44 | ``update`` 45 | 46 | Increment the mix version to generate a new release. By default the mix 47 | version is incremented by 10, following Clear Linux conventions to leave 48 | room for intermediate versions if necessary. The increment can be configured 49 | with the `--increment` flag. The ``update`` command also allows the user to 50 | update the upstream version. 51 | 52 | In addition to the global options ``mixer versions update`` takes the 53 | following options. 54 | 55 | - ``--clear-version {version}`` 56 | 57 | Alias to `--upstream-version` 58 | 59 | - ``-c, --config {path}`` 60 | 61 | Supply the `path` to the configuration file to use. 62 | 63 | - ``--increment {number}`` 64 | 65 | Amount to increment the current mix version (default is 10). 66 | 67 | - ``--mix-version {version}`` 68 | 69 | Set a specific mix `version`. 70 | 71 | - ``--upstream-version {version}`` 72 | 73 | Set a specific next upstream version (either version number or the default 74 | "latest" string). 75 | 76 | - ``--skip-format-check`` 77 | 78 | Skip check for compatible upstream format when changing upstream version. 79 | 80 | This command will not update to an upstream version of a different format 81 | ("format bumps"). At the moment this needs to be handled manually. 82 | 83 | 84 | EXIT STATUS 85 | =========== 86 | 87 | On success, 0 is returned. A non-zero return code indicates a failure. 88 | 89 | SEE ALSO 90 | -------- 91 | 92 | * ``mixer``\(1) 93 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Oleku Konko All rights reserved. 2 | // Use of this source code is governed by a MIT 3 | // license that can be found in the LICENSE file. 4 | 5 | // This module is a Table Writer API for the Go Programming Language. 6 | // The protocols were written in pure Go and works on windows and unix systems 7 | 8 | package tablewriter 9 | 10 | import ( 11 | "math" 12 | "regexp" 13 | "strings" 14 | 15 | "github.com/mattn/go-runewidth" 16 | ) 17 | 18 | var ansi = regexp.MustCompile("\033\\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]") 19 | 20 | func DisplayWidth(str string) int { 21 | return runewidth.StringWidth(ansi.ReplaceAllLiteralString(str, "")) 22 | } 23 | 24 | // Simple Condition for string 25 | // Returns value based on condition 26 | func ConditionString(cond bool, valid, inValid string) string { 27 | if cond { 28 | return valid 29 | } 30 | return inValid 31 | } 32 | 33 | func isNumOrSpace(r rune) bool { 34 | return ('0' <= r && r <= '9') || r == ' ' 35 | } 36 | 37 | // Format Table Header 38 | // Replace _ , . and spaces 39 | func Title(name string) string { 40 | origLen := len(name) 41 | rs := []rune(name) 42 | for i, r := range rs { 43 | switch r { 44 | case '_': 45 | rs[i] = ' ' 46 | case '.': 47 | // ignore floating number 0.0 48 | if (i != 0 && !isNumOrSpace(rs[i-1])) || (i != len(rs)-1 && !isNumOrSpace(rs[i+1])) { 49 | rs[i] = ' ' 50 | } 51 | } 52 | } 53 | name = string(rs) 54 | name = strings.TrimSpace(name) 55 | if len(name) == 0 && origLen > 0 { 56 | // Keep at least one character. This is important to preserve 57 | // empty lines in multi-line headers/footers. 58 | name = " " 59 | } 60 | return strings.ToUpper(name) 61 | } 62 | 63 | // Pad String 64 | // Attempts to place string in the center 65 | func Pad(s, pad string, width int) string { 66 | gap := width - DisplayWidth(s) 67 | if gap > 0 { 68 | gapLeft := int(math.Ceil(float64(gap / 2))) 69 | gapRight := gap - gapLeft 70 | return strings.Repeat(string(pad), gapLeft) + s + strings.Repeat(string(pad), gapRight) 71 | } 72 | return s 73 | } 74 | 75 | // Pad String Right position 76 | // This would place string at the left side of the screen 77 | func PadRight(s, pad string, width int) string { 78 | gap := width - DisplayWidth(s) 79 | if gap > 0 { 80 | return s + strings.Repeat(string(pad), gap) 81 | } 82 | return s 83 | } 84 | 85 | // Pad String Left position 86 | // This would place string at the right side of the screen 87 | func PadLeft(s, pad string, width int) string { 88 | gap := width - DisplayWidth(s) 89 | if gap > 0 { 90 | return strings.Repeat(string(pad), gap) + s 91 | } 92 | return s 93 | } 94 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= 2 | github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= 3 | github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= 7 | github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= 8 | github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= 9 | github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 10 | github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= 11 | github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= 12 | github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 13 | github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= 14 | github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= 15 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 16 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 17 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 18 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 19 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 20 | github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= 21 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 22 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 23 | github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= 24 | github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= 25 | github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= 26 | github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 27 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 28 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 29 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 30 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 31 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.bats 2 | 3 | .NOTPARALLEL: 4 | 5 | VERSION=6.4.1 6 | GO_PACKAGE_PREFIX := github.com/clearlinux/mixer-tools 7 | GOPATH ?= ${HOME}/go 8 | gopath = $(shell go env GOPATH) 9 | 10 | .PHONY: build install clean check man 11 | 12 | .DEFAULT_GOAL := build 13 | 14 | build: man 15 | go install -mod=vendor -ldflags="-X ${GO_PACKAGE_PREFIX}/builder.Version=${VERSION}" ${GO_PACKAGE_PREFIX}/mixer 16 | go install -mod=vendor ${GO_PACKAGE_PREFIX}/swupd-extract 17 | go install -mod=vendor ${GO_PACKAGE_PREFIX}/swupd-inspector 18 | go install -mod=vendor ${GO_PACKAGE_PREFIX}/mixer-completion 19 | 20 | install: build 21 | test -d $(DESTDIR)/usr/bin || install -D -d -m 00755 $(DESTDIR)/usr/bin; 22 | install -m 00755 $(GOPATH)/bin/mixer $(DESTDIR)/usr/bin/. 23 | install -m 00755 $(GOPATH)/bin/swupd-extract $(DESTDIR)/usr/bin/. 24 | install -m 00755 $(GOPATH)/bin/swupd-inspector $(DESTDIR)/usr/bin/. 25 | $(GOPATH)/bin/mixer-completion bash --path $(DESTDIR)/usr/share/bash-completion/completions/mixer 26 | $(GOPATH)/bin/mixer-completion zsh --path $(DESTDIR)/usr/share/zsh/site-functions/_mixer 27 | test -d $(DESTDIR)/usr/share/man/man1 || install -D -d -m 00755 $(DESTDIR)/usr/share/man/man1 28 | install -m 00644 $(MANPAGES) $(DESTDIR)/usr/share/man/man1/ 29 | 30 | check: 31 | go test -cover ${GO_PACKAGE_PREFIX}/... 32 | 33 | .PHONY: checkcoverage 34 | checkcoverage: 35 | go test -cover ${GO_PACKAGE_PREFIX}/... -coverprofile=coverage.out 36 | go tool cover -html=coverage.out 37 | 38 | .PHONY: lint 39 | lint: 40 | @if [ ! -z "${CI_ONLY}" ]; then \ 41 | echo "Installing linters..."; \ 42 | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(gopath)/bin v1.55.2; \ 43 | fi 44 | @$(gopath)/bin/golangci-lint run --deadline=10m --tests --disable-all \ 45 | --enable=misspell \ 46 | --enable=vet \ 47 | --enable=ineffassign \ 48 | --enable=gofmt \ 49 | $${CYCLO_MAX:+--enable=gocyclo --cyclo-over=$${CYCLO_MAX}} \ 50 | --enable=revive \ 51 | --enable=unused \ 52 | --enable=vetshadow \ 53 | --enable=errcheck \ 54 | ./... 55 | 56 | clean: 57 | go clean -i -x ${GO_PACKAGE_PREFIX}/... 58 | rm -f mixer-tools-*.tar.gz 59 | 60 | release: 61 | @if [ ! -d .git ]; then \ 62 | echo "Release needs to be used from a git repository"; \ 63 | exit 1; \ 64 | fi 65 | git archive --format=tar.gz --verbose -o mixer-tools-${VERSION}.tar.gz HEAD --prefix=mixer-tools-${VERSION}/ 66 | 67 | MANPAGES = \ 68 | docs/mixer.1 \ 69 | docs/mixer.add-rpms.1 \ 70 | docs/mixer.build.1 \ 71 | docs/mixer.bundle.1 \ 72 | docs/mixer.config.1 \ 73 | docs/mixer.init.1 \ 74 | docs/mixer.repo.1 \ 75 | docs/mixer.versions.1 \ 76 | 77 | man: $(MANPAGES) 78 | 79 | $(MANPAGES): %: %.rst 80 | mkdir -p "$$(dirname $@)" 81 | rst2man "$<" > "$@.tmp" && mv -f "$@.tmp" "$@" 82 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/active_help.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2023 The Cobra Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cobra 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | ) 21 | 22 | const ( 23 | activeHelpMarker = "_activeHelp_ " 24 | // The below values should not be changed: programs will be using them explicitly 25 | // in their user documentation, and users will be using them explicitly. 26 | activeHelpEnvVarSuffix = "ACTIVE_HELP" 27 | activeHelpGlobalEnvVar = configEnvVarGlobalPrefix + "_" + activeHelpEnvVarSuffix 28 | activeHelpGlobalDisable = "0" 29 | ) 30 | 31 | // AppendActiveHelp adds the specified string to the specified array to be used as ActiveHelp. 32 | // Such strings will be processed by the completion script and will be shown as ActiveHelp 33 | // to the user. 34 | // The array parameter should be the array that will contain the completions. 35 | // This function can be called multiple times before and/or after completions are added to 36 | // the array. Each time this function is called with the same array, the new 37 | // ActiveHelp line will be shown below the previous ones when completion is triggered. 38 | func AppendActiveHelp(compArray []Completion, activeHelpStr string) []Completion { 39 | return append(compArray, fmt.Sprintf("%s%s", activeHelpMarker, activeHelpStr)) 40 | } 41 | 42 | // GetActiveHelpConfig returns the value of the ActiveHelp environment variable 43 | // _ACTIVE_HELP where is the name of the root command in upper 44 | // case, with all non-ASCII-alphanumeric characters replaced by `_`. 45 | // It will always return "0" if the global environment variable COBRA_ACTIVE_HELP 46 | // is set to "0". 47 | func GetActiveHelpConfig(cmd *Command) string { 48 | activeHelpCfg := os.Getenv(activeHelpGlobalEnvVar) 49 | if activeHelpCfg != activeHelpGlobalDisable { 50 | activeHelpCfg = os.Getenv(activeHelpEnvVar(cmd.Root().Name())) 51 | } 52 | return activeHelpCfg 53 | } 54 | 55 | // activeHelpEnvVar returns the name of the program-specific ActiveHelp environment 56 | // variable. It has the format _ACTIVE_HELP where is the name of the 57 | // root command in upper case, with all non-ASCII-alphanumeric characters replaced by `_`. 58 | func activeHelpEnvVar(name string) string { 59 | return configEnvVar(name, activeHelpEnvVarSuffix) 60 | } 61 | -------------------------------------------------------------------------------- /bat/tests/upstream-format-bump/run.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | # shared test functions 4 | load ../../lib/mixerlib 5 | 6 | setup() { 7 | global_setup 8 | } 9 | 10 | @test "Perform format bump builds to cross upstream format bump" { 11 | # The kernel-container bundle is deleted in the format bump from 27 to 28 12 | # and is used to test upstream bundle deletion. Version 29690 is in format 13 | # 27 and version 29800 is in format 28. 14 | mixer-init-stripped-down 29690 10 15 | format=$(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) 16 | 17 | # Add bundle deleted by upstream 18 | mixer-bundle-add kernel-container 19 | 20 | # Create local bundle to be deleted 21 | create-empty-local-bundle "local-deleted" 22 | sed -i "s/\(# \[STATUS\]:\).*/\1 Deprecated/" local-bundles/local-deleted 23 | mixer-bundle-add "local-deleted" 24 | 25 | # Create initial version in the old format 26 | mixer-build-bundles > $LOGDIR/build_bundles.log 27 | 28 | mixer-build-update > $LOGDIR/build_update.log 29 | 30 | run mixer-versions-update 20 29800 31 | # Updating versions should have output this as part of the error 32 | [[ "$output" =~ "mixer build upstream-format" ]] 33 | 34 | mixer-build-upstream-format-bump $((format+1)) 35 | 36 | #check if +10 previous version is set to +0 37 | awk '$1 == "previous:" { exit $2 != 10}' update/www/20/Manifest.MoM 38 | 39 | # #check if +20 previous version is set to +0 40 | awk '$1 == "previous:" { exit $2 != 10}' update/www/30/Manifest.MoM 41 | 42 | #check if +10 format is set to formatN+1 43 | awk -v f=$format '$1 == "MANIFEST" {exit $2 != f}' update/www/20/Manifest.MoM 44 | 45 | format=$((format+1)) 46 | #check if +20 format is set to formatN 47 | awk -v f=$format '$1 == "MANIFEST" {exit $2 != f}' update/www/30/Manifest.MoM 48 | 49 | #check LAST_VER and PREVIOUS_MIX_VERSION match 50 | test $(< update/image/LAST_VER) -eq 30 51 | test $(sed -n 's/[ ]*PREVIOUS_MIX_VERSION[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq 30 52 | 53 | # check deleted upstream/local bundles delete tracking file in +10 54 | grep -P "20\tkernel-container" update/www/20/Manifest.MoM 55 | grep -P "20\tlocal-deleted" update/www/20/Manifest.MoM 56 | grep -P "00000000000\t20\t/usr/share/clear/bundles/kernel-container" update/www/20/Manifest.kernel-container 57 | grep -P "00000000000\t20\t/usr/share/clear/bundles/local-deleted" update/www/20/Manifest.local-deleted 58 | 59 | # check deleted upstream/local bundle manifest deletions in +20 60 | grep -v "kernel-container" update/www/30/Manifest.MoM 61 | grep -v "local-deleted" update/www/30/Manifest.MoM 62 | test ! -f update/www/30/Manifest.kernel-container 63 | test ! -f update/www/30/Manifest.local-deleted 64 | 65 | # check deleted bundles no longer tracked by mix 66 | grep -v "kernel-container" mixbundles 67 | grep -v "local-deleted" mixbundles 68 | 69 | } 70 | # vi: ft=sh ts=8 sw=2 sts=2 et tw=80 71 | -------------------------------------------------------------------------------- /swupd/external.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package swupd 16 | 17 | import ( 18 | "io" 19 | "os/exec" 20 | ) 21 | 22 | // ExternalWriter filters a Writer with an external program. Every 23 | // time Write is called, it will write to the program, and then the 24 | // result written to the underlying Writer. 25 | type ExternalWriter struct { 26 | cmd *exec.Cmd 27 | input io.WriteCloser 28 | } 29 | 30 | // NewExternalWriter creates an ExternalWriter with the passed 31 | // underlying Writer and the program to execute as filter. 32 | func NewExternalWriter(w io.Writer, program string, args ...string) (*ExternalWriter, error) { 33 | cmd := exec.Command(program, args...) 34 | input, err := cmd.StdinPipe() 35 | if err != nil { 36 | return nil, err 37 | } 38 | cmd.Stdout = w 39 | err = cmd.Start() 40 | if err != nil { 41 | _ = input.Close() 42 | return nil, err 43 | } 44 | return &ExternalWriter{cmd, input}, nil 45 | } 46 | 47 | func (ew *ExternalWriter) Write(p []byte) (int, error) { 48 | return ew.input.Write(p) 49 | } 50 | 51 | // Close properly finish the execution of an ExternalWriter. 52 | func (ew *ExternalWriter) Close() error { 53 | err := ew.input.Close() 54 | if err != nil { 55 | return err 56 | } 57 | return ew.cmd.Wait() 58 | } 59 | 60 | // ExternalReader filters a Reader with an external program. Every 61 | // time a Read is called, it will read from the output of the program, 62 | // that reads from the underlying reader. 63 | type ExternalReader struct { 64 | cmd *exec.Cmd 65 | output io.ReadCloser 66 | } 67 | 68 | // NewExternalReader creates an ExternalReader with the passed underlying 69 | // Reader and the program to execute as filter. 70 | func NewExternalReader(r io.Reader, program string, args ...string) (*ExternalReader, error) { 71 | cmd := exec.Command(program, args...) 72 | cmd.Stdin = r 73 | output, err := cmd.StdoutPipe() 74 | if err != nil { 75 | return nil, err 76 | } 77 | err = cmd.Start() 78 | if err != nil { 79 | _ = output.Close() 80 | return nil, err 81 | } 82 | return &ExternalReader{cmd, output}, nil 83 | } 84 | 85 | func (er *ExternalReader) Read(p []byte) (int, error) { 86 | return er.output.Read(p) 87 | } 88 | 89 | // Close properly finish the execution of an ExternalReader. 90 | func (er *ExternalReader) Close() error { 91 | return er.cmd.Wait() 92 | } 93 | -------------------------------------------------------------------------------- /mixer-completion/cmd/completion.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "errors" 19 | "os" 20 | "path/filepath" 21 | 22 | mixerCmd "github.com/clearlinux/mixer-tools/mixer/cmd" 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | type completionCmdFlags struct { 27 | path string 28 | } 29 | 30 | var completionFlags completionCmdFlags 31 | 32 | // CompletionCmd represents the base command for mixer-completion 33 | var CompletionCmd = &cobra.Command{ 34 | Use: "mixer-completion", 35 | Short: "Generate autocomplete files for mixer", 36 | Long: `Generates autocomplete files for mixer. If no arguments are passed, or if 37 | 'bash' is passed, a bash completion file is written to 38 | /usr/share/bash-completion/completions/mixer. If 'zsh' is passed, a zsh 39 | completion file is written to /usr/share/zsh/site-functions/_mixer. These 40 | locations can be overridden by passing '--path', with a full path to the chosen 41 | destination file. 42 | 43 | These files allow you to type, for example: 44 | mixer bun[TAB] -> mixer bundle a[TAB] -> mixer bundle add 45 | 46 | Note that this command must be run as root if using the default file locations.`, 47 | Args: cobra.OnlyValidArgs, 48 | ValidArgs: []string{"bash", "zsh"}, 49 | RunE: func(cmd *cobra.Command, args []string) error { 50 | if len(args) > 1 { 51 | return errors.New("mixer-completion takes at most one argument") 52 | } 53 | 54 | var shell string 55 | if len(args) > 0 { 56 | shell = args[0] 57 | } else { 58 | shell = "bash" 59 | } 60 | 61 | var path = completionFlags.path 62 | var err error 63 | switch shell { 64 | case "bash": 65 | if path == "" { 66 | path = "/usr/share/bash-completion/completions/mixer" 67 | } 68 | if err = os.MkdirAll(filepath.Dir(path), 0755); err != nil { 69 | return err 70 | } 71 | err = mixerCmd.RootCmd.GenBashCompletionFile(path) 72 | case "zsh": 73 | if path == "" { 74 | path = "/usr/share/zsh/site-functions/_mixer" 75 | } 76 | if err = os.MkdirAll(filepath.Dir(path), 0755); err != nil { 77 | return err 78 | } 79 | err = mixerCmd.RootCmd.GenZshCompletionFile(path) 80 | } 81 | 82 | return err 83 | }, 84 | } 85 | 86 | func init() { 87 | CompletionCmd.Flags().StringVar(&completionFlags.path, "path", "", "Completion file destination path override") 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/README.md: -------------------------------------------------------------------------------- 1 | # errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) 2 | 3 | Package errors provides simple error handling primitives. 4 | 5 | `go get github.com/pkg/errors` 6 | 7 | The traditional error handling idiom in Go is roughly akin to 8 | ```go 9 | if err != nil { 10 | return err 11 | } 12 | ``` 13 | which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. 14 | 15 | ## Adding context to an error 16 | 17 | The errors.Wrap function returns a new error that adds context to the original error. For example 18 | ```go 19 | _, err := ioutil.ReadAll(r) 20 | if err != nil { 21 | return errors.Wrap(err, "read failed") 22 | } 23 | ``` 24 | ## Retrieving the cause of an error 25 | 26 | Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. 27 | ```go 28 | type causer interface { 29 | Cause() error 30 | } 31 | ``` 32 | `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: 33 | ```go 34 | switch err := errors.Cause(err).(type) { 35 | case *MyError: 36 | // handle specifically 37 | default: 38 | // unknown error 39 | } 40 | ``` 41 | 42 | [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). 43 | 44 | ## Roadmap 45 | 46 | With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: 47 | 48 | - 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) 49 | - 1.0. Final release. 50 | 51 | ## Contributing 52 | 53 | Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. 54 | 55 | Before sending a PR, please discuss your change by raising an issue. 56 | 57 | ## License 58 | 59 | BSD-2-Clause 60 | -------------------------------------------------------------------------------- /swupd/heuristics.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package swupd 16 | 17 | import "strings" 18 | 19 | func (f *File) setModifierFromPathname() { 20 | temp := strings.TrimPrefix(f.Name, "/VA") 21 | if temp != f.Name { 22 | f.Modifier = Apx4 23 | f.Name = temp 24 | return 25 | } 26 | temp = strings.TrimPrefix(f.Name, "/V4") 27 | if temp != f.Name { 28 | f.Modifier = Avx512_2 29 | f.Name = temp 30 | return 31 | } 32 | temp = strings.TrimPrefix(f.Name, "/V3") 33 | if temp != f.Name { 34 | f.Modifier = Avx2_1 35 | f.Name = temp 36 | return 37 | } 38 | } 39 | 40 | func (f *File) setPrefixFromModifier() { 41 | f.Name = modifierPrefixes[f.Modifier] + f.Name 42 | } 43 | 44 | func (f *File) setFullModifier(bits uint64) { 45 | switch f.Modifier { 46 | case Sse0: 47 | switch bits { 48 | case 0: 49 | f.Modifier = Sse0 50 | case 1: 51 | f.Modifier = Sse1 52 | case 2: 53 | f.Modifier = Sse2 54 | case 3: 55 | f.Modifier = Sse3 56 | case 4: 57 | f.Modifier = Sse4 58 | case 5: 59 | f.Modifier = Sse5 60 | case 6: 61 | f.Modifier = Sse6 62 | case 7: 63 | f.Modifier = Sse7 64 | } 65 | case Avx2_1: 66 | switch bits { 67 | case 1: 68 | f.Modifier = Avx2_1 69 | case 3: 70 | f.Modifier = Avx2_3 71 | case 5: 72 | f.Modifier = Avx2_5 73 | case 7: 74 | f.Modifier = Avx2_7 75 | } 76 | case Avx512_2: 77 | switch bits { 78 | case 2: 79 | f.Modifier = Avx512_2 80 | case 3: 81 | f.Modifier = Avx512_3 82 | case 6: 83 | f.Modifier = Avx512_6 84 | case 7: 85 | f.Modifier = Avx512_7 86 | } 87 | case Apx4: 88 | switch bits { 89 | case 4: 90 | f.Modifier = Apx4 91 | case 5: 92 | f.Modifier = Apx5 93 | case 6: 94 | f.Modifier = Apx6 95 | case 7: 96 | f.Modifier = Apx7 97 | } 98 | } 99 | } 100 | 101 | func (f *File) setGhostedFromPathname() { 102 | bootPaths := []string{ 103 | "/boot/", 104 | "/usr/lib/modules/", 105 | "/usr/lib/kernel/", 106 | } 107 | for _, path := range bootPaths { 108 | if strings.HasPrefix(f.Name, path) { 109 | if f.Status == StatusDeleted { 110 | f.Status = StatusGhosted 111 | } 112 | return 113 | } 114 | } 115 | } 116 | 117 | func (m *Manifest) applyHeuristics() { 118 | for _, f := range m.Files { 119 | f.setGhostedFromPathname() 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /docs/mixer.config.1: -------------------------------------------------------------------------------- 1 | .\" Man page generated from reStructuredText. 2 | . 3 | .TH MIXER.CONFIG 1 "" "" "" 4 | .SH NAME 5 | mixer.config \- Perform configuration manipulation actions 6 | . 7 | .nr rst2man-indent-level 0 8 | . 9 | .de1 rstReportMargin 10 | \\$1 \\n[an-margin] 11 | level \\n[rst2man-indent-level] 12 | level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] 13 | - 14 | \\n[rst2man-indent0] 15 | \\n[rst2man-indent1] 16 | \\n[rst2man-indent2] 17 | .. 18 | .de1 INDENT 19 | .\" .rstReportMargin pre: 20 | . RS \\$1 21 | . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] 22 | . nr rst2man-indent-level +1 23 | .\" .rstReportMargin post: 24 | .. 25 | .de UNINDENT 26 | . RE 27 | .\" indent \\n[an-margin] 28 | .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] 29 | .nr rst2man-indent-level -1 30 | .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] 31 | .in \\n[rst2man-indent\\n[rst2man-indent-level]]u 32 | .. 33 | .SH SYNOPSIS 34 | .sp 35 | \fBmixer config [command]\fP 36 | .SH DESCRIPTION 37 | .sp 38 | Perform various configuration manipulation actions on the mixer configuration 39 | files. 40 | .SH OPTIONS 41 | .sp 42 | In addition to the globally recognized \fBmixer\fP flags (see \fBmixer\fP(1) for 43 | more details), the following options are recognized. 44 | .INDENT 0.0 45 | .IP \(bu 2 46 | \fB\-h, \-\-help\fP 47 | .sp 48 | Display \fBconfig\fP help information and exit. 49 | .UNINDENT 50 | .SH SUBCOMMANDS 51 | .sp 52 | \fBconvert\fP 53 | .INDENT 0.0 54 | .INDENT 3.5 55 | Convert an old config file to the new TOML format. The command will generate 56 | a backup file of the old config and will replace it with the converted one. 57 | Environment variables will not be expanded and the values will not be 58 | validated. In addition to the global options \fBmixer config convert\fP takes 59 | the following options. 60 | .INDENT 0.0 61 | .IP \(bu 2 62 | \fB\-c, \-\-config {path}\fP 63 | .sp 64 | The \fIpath\fP to the configuration file to convert. 65 | .IP \(bu 2 66 | \fB\-h, \-\-help\fP 67 | .sp 68 | Display \fBconfig convert\fP help and exit. 69 | .UNINDENT 70 | .UNINDENT 71 | .UNINDENT 72 | .sp 73 | \fBvalidate\fP 74 | .INDENT 0.0 75 | .INDENT 3.5 76 | Parse a builder config file and display its properties. Properties 77 | containing environment variables will be expanded. In addition to the 78 | global options \fBmixer config validate\fP takes the following options. 79 | .INDENT 0.0 80 | .IP \(bu 2 81 | \fB\-c, \-\-config {path}\fP 82 | .sp 83 | The \fIpath\fP to the configuration file to validate. 84 | .IP \(bu 2 85 | \fB\-h, \-\-help\fP 86 | .sp 87 | Display \fBconfig validate\fP help and exit. 88 | .UNINDENT 89 | .UNINDENT 90 | .UNINDENT 91 | .SH EXIT STATUS 92 | .sp 93 | On success, 0 is returned. A non\-zero return code indicates a failure. 94 | .SS SEE ALSO 95 | .INDENT 0.0 96 | .IP \(bu 2 97 | \fBmixer\fP(1) 98 | .UNINDENT 99 | .SH COPYRIGHT 100 | (C) 2018 Intel Corporation, CC-BY-SA-3.0 101 | .\" Generated by docutils manpage writer. 102 | . 103 | -------------------------------------------------------------------------------- /vendor/github.com/rivo/uniseg/word.go: -------------------------------------------------------------------------------- 1 | package uniseg 2 | 3 | import "unicode/utf8" 4 | 5 | // FirstWord returns the first word found in the given byte slice according to 6 | // the rules of [Unicode Standard Annex #29, Word Boundaries]. This function can 7 | // be called continuously to extract all words from a byte slice, as illustrated 8 | // in the example below. 9 | // 10 | // If you don't know the current state, for example when calling the function 11 | // for the first time, you must pass -1. For consecutive calls, pass the state 12 | // and rest slice returned by the previous call. 13 | // 14 | // The "rest" slice is the sub-slice of the original byte slice "b" starting 15 | // after the last byte of the identified word. If the length of the "rest" slice 16 | // is 0, the entire byte slice "b" has been processed. The "word" byte slice is 17 | // the sub-slice of the input slice containing the identified word. 18 | // 19 | // Given an empty byte slice "b", the function returns nil values. 20 | // 21 | // [Unicode Standard Annex #29, Word Boundaries]: http://unicode.org/reports/tr29/#Word_Boundaries 22 | func FirstWord(b []byte, state int) (word, rest []byte, newState int) { 23 | // An empty byte slice returns nothing. 24 | if len(b) == 0 { 25 | return 26 | } 27 | 28 | // Extract the first rune. 29 | r, length := utf8.DecodeRune(b) 30 | if len(b) <= length { // If we're already past the end, there is nothing else to parse. 31 | return b, nil, wbAny 32 | } 33 | 34 | // If we don't know the state, determine it now. 35 | if state < 0 { 36 | state, _ = transitionWordBreakState(state, r, b[length:], "") 37 | } 38 | 39 | // Transition until we find a boundary. 40 | var boundary bool 41 | for { 42 | r, l := utf8.DecodeRune(b[length:]) 43 | state, boundary = transitionWordBreakState(state, r, b[length+l:], "") 44 | 45 | if boundary { 46 | return b[:length], b[length:], state 47 | } 48 | 49 | length += l 50 | if len(b) <= length { 51 | return b, nil, wbAny 52 | } 53 | } 54 | } 55 | 56 | // FirstWordInString is like [FirstWord] but its input and outputs are strings. 57 | func FirstWordInString(str string, state int) (word, rest string, newState int) { 58 | // An empty byte slice returns nothing. 59 | if len(str) == 0 { 60 | return 61 | } 62 | 63 | // Extract the first rune. 64 | r, length := utf8.DecodeRuneInString(str) 65 | if len(str) <= length { // If we're already past the end, there is nothing else to parse. 66 | return str, "", wbAny 67 | } 68 | 69 | // If we don't know the state, determine it now. 70 | if state < 0 { 71 | state, _ = transitionWordBreakState(state, r, nil, str[length:]) 72 | } 73 | 74 | // Transition until we find a boundary. 75 | var boundary bool 76 | for { 77 | r, l := utf8.DecodeRuneInString(str[length:]) 78 | state, boundary = transitionWordBreakState(state, r, nil, str[length+l:]) 79 | 80 | if boundary { 81 | return str[:length], str[length:], state 82 | } 83 | 84 | length += l 85 | if len(str) <= length { 86 | return str, "", wbAny 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/rivo/uniseg/sentence.go: -------------------------------------------------------------------------------- 1 | package uniseg 2 | 3 | import "unicode/utf8" 4 | 5 | // FirstSentence returns the first sentence found in the given byte slice 6 | // according to the rules of [Unicode Standard Annex #29, Sentence Boundaries]. 7 | // This function can be called continuously to extract all sentences from a byte 8 | // slice, as illustrated in the example below. 9 | // 10 | // If you don't know the current state, for example when calling the function 11 | // for the first time, you must pass -1. For consecutive calls, pass the state 12 | // and rest slice returned by the previous call. 13 | // 14 | // The "rest" slice is the sub-slice of the original byte slice "b" starting 15 | // after the last byte of the identified sentence. If the length of the "rest" 16 | // slice is 0, the entire byte slice "b" has been processed. The "sentence" byte 17 | // slice is the sub-slice of the input slice containing the identified sentence. 18 | // 19 | // Given an empty byte slice "b", the function returns nil values. 20 | // 21 | // [Unicode Standard Annex #29, Sentence Boundaries]: http://unicode.org/reports/tr29/#Sentence_Boundaries 22 | func FirstSentence(b []byte, state int) (sentence, rest []byte, newState int) { 23 | // An empty byte slice returns nothing. 24 | if len(b) == 0 { 25 | return 26 | } 27 | 28 | // Extract the first rune. 29 | r, length := utf8.DecodeRune(b) 30 | if len(b) <= length { // If we're already past the end, there is nothing else to parse. 31 | return b, nil, sbAny 32 | } 33 | 34 | // If we don't know the state, determine it now. 35 | if state < 0 { 36 | state, _ = transitionSentenceBreakState(state, r, b[length:], "") 37 | } 38 | 39 | // Transition until we find a boundary. 40 | var boundary bool 41 | for { 42 | r, l := utf8.DecodeRune(b[length:]) 43 | state, boundary = transitionSentenceBreakState(state, r, b[length+l:], "") 44 | 45 | if boundary { 46 | return b[:length], b[length:], state 47 | } 48 | 49 | length += l 50 | if len(b) <= length { 51 | return b, nil, sbAny 52 | } 53 | } 54 | } 55 | 56 | // FirstSentenceInString is like [FirstSentence] but its input and outputs are 57 | // strings. 58 | func FirstSentenceInString(str string, state int) (sentence, rest string, newState int) { 59 | // An empty byte slice returns nothing. 60 | if len(str) == 0 { 61 | return 62 | } 63 | 64 | // Extract the first rune. 65 | r, length := utf8.DecodeRuneInString(str) 66 | if len(str) <= length { // If we're already past the end, there is nothing else to parse. 67 | return str, "", sbAny 68 | } 69 | 70 | // If we don't know the state, determine it now. 71 | if state < 0 { 72 | state, _ = transitionSentenceBreakState(state, r, nil, str[length:]) 73 | } 74 | 75 | // Transition until we find a boundary. 76 | var boundary bool 77 | for { 78 | r, l := utf8.DecodeRuneInString(str[length:]) 79 | state, boundary = transitionSentenceBreakState(state, r, nil, str[length+l:]) 80 | 81 | if boundary { 82 | return str[:length], str[length:], state 83 | } 84 | 85 | length += l 86 | if len(str) <= length { 87 | return str, "", sbAny 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /swupd-inspector/log.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "path/filepath" 7 | 8 | "github.com/clearlinux/mixer-tools/internal/client" 9 | "github.com/clearlinux/mixer-tools/swupd" 10 | ) 11 | 12 | // TODO: Consider a --unique flag that would not print consecutive versions that have the same hash. 13 | 14 | func runLog(cacheDir, url, filename string) { 15 | base, version := parseURL(url) 16 | stateDir := filepath.Join(cacheDir, convertContentBaseToDirname(base)) 17 | state, err := client.NewState(stateDir, base) 18 | if err != nil { 19 | log.Fatalf("ERROR: %s", err) 20 | } 21 | 22 | if filename == "" || filename[0] != '/' { 23 | // TODO: Support Manifest.* files too, but showing the diff of the files? 24 | log.Fatalf("Second argument to 'log' must be an absolute path") 25 | } 26 | 27 | var lastVersion uint32 28 | lastBundle := "" 29 | 30 | for version != "0" { 31 | mom, err := state.GetMoM(version) 32 | if err != nil { 33 | // TODO: check for the "aborted" file in the version directory? 34 | log.Fatalf("ERROR: %s", err) 35 | } 36 | 37 | var found *swupd.File 38 | 39 | visit := func(bundle, file *swupd.File) bool { 40 | if file.Name == filename && file.Present() { 41 | found = file 42 | lastBundle = bundle.Name 43 | return true 44 | } 45 | return false 46 | } 47 | 48 | // Look first in the bundle that had the file before, since it is more likely to 49 | // have the file again. This reduces the amount of manifest files downloaded. 50 | if lastBundle != "" { 51 | var bundleF *swupd.File 52 | for _, b := range mom.Files { 53 | if b.Name == lastBundle { 54 | bundleF = b 55 | } 56 | } 57 | 58 | if bundleF != nil { 59 | err = visitFilesInBundle(state, bundleF, visit) 60 | if err != nil { 61 | log.Fatalf("ERROR: %s", err) 62 | } 63 | } 64 | } 65 | 66 | if found == nil { 67 | err = visitAllFiles(state, mom, visit) 68 | if err != nil { 69 | log.Fatalf("ERROR: %s", err) 70 | } 71 | } 72 | 73 | if found == nil { 74 | break 75 | } 76 | if lastVersion != found.Version { 77 | fmt.Printf("%s/%d/files/%s.tar\n", base, found.Version, found.Hash) 78 | lastVersion = found.Version 79 | } 80 | 81 | // Look at the immediate previous OS version, unless we already know the file is 82 | // from an earlier version, so we can skip to it. 83 | v := mom.Header.Previous 84 | if v > found.Version { 85 | v = found.Version 86 | } 87 | version = fmt.Sprint(v) 88 | } 89 | 90 | if lastBundle == "" { 91 | log.Fatalf("ERROR: file %s not found in version %s", filename, version) 92 | } 93 | 94 | } 95 | 96 | func visitFilesInBundle(state *client.State, bundleFile *swupd.File, visitFunc func(bundle, file *swupd.File) bool) error { 97 | bundle, err := state.GetBundleManifest(fmt.Sprint(bundleFile.Version), bundleFile.Name, "") 98 | if err != nil { 99 | return err 100 | } 101 | for _, f := range bundle.Files { 102 | if visitFunc(bundleFile, f) { 103 | break 104 | } 105 | } 106 | return nil 107 | } 108 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "strconv" 4 | 5 | // -- int Value 6 | type intValue int 7 | 8 | func newIntValue(val int, p *int) *intValue { 9 | *p = val 10 | return (*intValue)(p) 11 | } 12 | 13 | func (i *intValue) Set(s string) error { 14 | v, err := strconv.ParseInt(s, 0, 64) 15 | *i = intValue(v) 16 | return err 17 | } 18 | 19 | func (i *intValue) Type() string { 20 | return "int" 21 | } 22 | 23 | func (i *intValue) String() string { return strconv.Itoa(int(*i)) } 24 | 25 | func intConv(sval string) (interface{}, error) { 26 | return strconv.Atoi(sval) 27 | } 28 | 29 | // GetInt return the int value of a flag with the given name 30 | func (f *FlagSet) GetInt(name string) (int, error) { 31 | val, err := f.getFlagType(name, "int", intConv) 32 | if err != nil { 33 | return 0, err 34 | } 35 | return val.(int), nil 36 | } 37 | 38 | // IntVar defines an int flag with specified name, default value, and usage string. 39 | // The argument p points to an int variable in which to store the value of the flag. 40 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { 41 | f.VarP(newIntValue(value, p), name, "", usage) 42 | } 43 | 44 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 45 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { 46 | f.VarP(newIntValue(value, p), name, shorthand, usage) 47 | } 48 | 49 | // IntVar defines an int flag with specified name, default value, and usage string. 50 | // The argument p points to an int variable in which to store the value of the flag. 51 | func IntVar(p *int, name string, value int, usage string) { 52 | CommandLine.VarP(newIntValue(value, p), name, "", usage) 53 | } 54 | 55 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 56 | func IntVarP(p *int, name, shorthand string, value int, usage string) { 57 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) 58 | } 59 | 60 | // Int defines an int flag with specified name, default value, and usage string. 61 | // The return value is the address of an int variable that stores the value of the flag. 62 | func (f *FlagSet) Int(name string, value int, usage string) *int { 63 | p := new(int) 64 | f.IntVarP(p, name, "", value, usage) 65 | return p 66 | } 67 | 68 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 69 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { 70 | p := new(int) 71 | f.IntVarP(p, name, shorthand, value, usage) 72 | return p 73 | } 74 | 75 | // Int defines an int flag with specified name, default value, and usage string. 76 | // The return value is the address of an int variable that stores the value of the flag. 77 | func Int(name string, value int, usage string) *int { 78 | return CommandLine.IntP(name, "", value, usage) 79 | } 80 | 81 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 82 | func IntP(name, shorthand string, value int, usage string) *int { 83 | return CommandLine.IntP(name, shorthand, value, usage) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/wrap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Oleku Konko All rights reserved. 2 | // Use of this source code is governed by a MIT 3 | // license that can be found in the LICENSE file. 4 | 5 | // This module is a Table Writer API for the Go Programming Language. 6 | // The protocols were written in pure Go and works on windows and unix systems 7 | 8 | package tablewriter 9 | 10 | import ( 11 | "math" 12 | "strings" 13 | 14 | "github.com/mattn/go-runewidth" 15 | ) 16 | 17 | var ( 18 | nl = "\n" 19 | sp = " " 20 | ) 21 | 22 | const defaultPenalty = 1e5 23 | 24 | // Wrap wraps s into a paragraph of lines of length lim, with minimal 25 | // raggedness. 26 | func WrapString(s string, lim int) ([]string, int) { 27 | words := strings.Split(strings.Replace(s, nl, sp, -1), sp) 28 | var lines []string 29 | max := 0 30 | for _, v := range words { 31 | max = runewidth.StringWidth(v) 32 | if max > lim { 33 | lim = max 34 | } 35 | } 36 | for _, line := range WrapWords(words, 1, lim, defaultPenalty) { 37 | lines = append(lines, strings.Join(line, sp)) 38 | } 39 | return lines, lim 40 | } 41 | 42 | // WrapWords is the low-level line-breaking algorithm, useful if you need more 43 | // control over the details of the text wrapping process. For most uses, 44 | // WrapString will be sufficient and more convenient. 45 | // 46 | // WrapWords splits a list of words into lines with minimal "raggedness", 47 | // treating each rune as one unit, accounting for spc units between adjacent 48 | // words on each line, and attempting to limit lines to lim units. Raggedness 49 | // is the total error over all lines, where error is the square of the 50 | // difference of the length of the line and lim. Too-long lines (which only 51 | // happen when a single word is longer than lim units) have pen penalty units 52 | // added to the error. 53 | func WrapWords(words []string, spc, lim, pen int) [][]string { 54 | n := len(words) 55 | 56 | length := make([][]int, n) 57 | for i := 0; i < n; i++ { 58 | length[i] = make([]int, n) 59 | length[i][i] = runewidth.StringWidth(words[i]) 60 | for j := i + 1; j < n; j++ { 61 | length[i][j] = length[i][j-1] + spc + runewidth.StringWidth(words[j]) 62 | } 63 | } 64 | nbrk := make([]int, n) 65 | cost := make([]int, n) 66 | for i := range cost { 67 | cost[i] = math.MaxInt32 68 | } 69 | for i := n - 1; i >= 0; i-- { 70 | if length[i][n-1] <= lim { 71 | cost[i] = 0 72 | nbrk[i] = n 73 | } else { 74 | for j := i + 1; j < n; j++ { 75 | d := lim - length[i][j-1] 76 | c := d*d + cost[j] 77 | if length[i][j-1] > lim { 78 | c += pen // too-long lines get a worse penalty 79 | } 80 | if c < cost[i] { 81 | cost[i] = c 82 | nbrk[i] = j 83 | } 84 | } 85 | } 86 | } 87 | var lines [][]string 88 | i := 0 89 | for i < n { 90 | lines = append(lines, words[i:nbrk[i]]) 91 | i = nbrk[i] 92 | } 93 | return lines 94 | } 95 | 96 | // getLines decomposes a multiline string into a slice of strings. 97 | func getLines(s string) []string { 98 | return strings.Split(s, nl) 99 | } 100 | -------------------------------------------------------------------------------- /docs/mixer.init.1: -------------------------------------------------------------------------------- 1 | .\" Man page generated from reStructuredText. 2 | . 3 | .TH MIXER.INIT 1 "" "" "" 4 | .SH NAME 5 | mixer.init \- Initialize mixer and workspace 6 | . 7 | .nr rst2man-indent-level 0 8 | . 9 | .de1 rstReportMargin 10 | \\$1 \\n[an-margin] 11 | level \\n[rst2man-indent-level] 12 | level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] 13 | - 14 | \\n[rst2man-indent0] 15 | \\n[rst2man-indent1] 16 | \\n[rst2man-indent2] 17 | .. 18 | .de1 INDENT 19 | .\" .rstReportMargin pre: 20 | . RS \\$1 21 | . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] 22 | . nr rst2man-indent-level +1 23 | .\" .rstReportMargin post: 24 | .. 25 | .de UNINDENT 26 | . RE 27 | .\" indent \\n[an-margin] 28 | .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] 29 | .nr rst2man-indent-level -1 30 | .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] 31 | .in \\n[rst2man-indent\\n[rst2man-indent-level]]u 32 | .. 33 | .SH SYNOPSIS 34 | .sp 35 | \fBmixer init [flags]\fP 36 | .SH DESCRIPTION 37 | .sp 38 | Initialize the mixer configuration and mixer workspace by writing default 39 | configuration files if necessary and building the proper directory structure. 40 | .SH OPTIONS 41 | .sp 42 | In addition to the globally recognized \fBmixer\fP flags (see \fBmixer\fP(1) for 43 | more details), the following options are recognized. 44 | .INDENT 0.0 45 | .IP \(bu 2 46 | \fB\-\-all\-local\fP 47 | .sp 48 | Initialize mix with all local bundles automatically included. 49 | .IP \(bu 2 50 | \fB\-\-all\-upstream\fP 51 | .sp 52 | Initialize the mix with all upstream bundles automatically included. 53 | .IP \(bu 2 54 | \fB\-\-clear\-version {version}\fP 55 | .sp 56 | Upstream version used to compose the mix. It must be either an integer or \(aqlatest\(aq (default "latest") 57 | .IP \(bu 2 58 | \fB\-\-config {path}\fP 59 | .sp 60 | Supply a specific configuration file at \fIpath\fP to use for mixing. 61 | .IP \(bu 2 62 | \fB\-\-format {format}\fP 63 | .sp 64 | Supply the format version for the mix. 65 | .IP \(bu 2 66 | \fB\-\-git\fP 67 | .sp 68 | Track mixer\(aqs internal work directory with git. 69 | .IP \(bu 2 70 | \fB\-h, \-\-help\fP 71 | .sp 72 | Display \fBinit\fP help information and exit. 73 | .IP \(bu 2 74 | \fB\-\-local\-rpms\fP 75 | .sp 76 | Create and configure local RPM directories. 77 | .IP \(bu 2 78 | \fB\-\-mix\-version {version}\fP 79 | .sp 80 | Supply the mix version to build (default is 10) 81 | .IP \(bu 2 82 | \fB\-\-no\-default\-bundles\fP 83 | .sp 84 | Skip adding default bundles to the mix 85 | .IP \(bu 2 86 | \fB\-\-upstream\-url {url}\fP 87 | .sp 88 | Supply an upstream URL to use for mixing (default is 89 | "\fI\%https://download.clearlinux.org\fP") 90 | .IP \(bu 2 91 | \fB\-\-upstream\-version {version}\fP 92 | .sp 93 | Alias to \fI\-\-clear\-version\fP (default is "latest") 94 | .UNINDENT 95 | .SH EXIT STATUS 96 | .sp 97 | On success, 0 is returned. A non\-zero return code indicates a failure. 98 | .SS SEE ALSO 99 | .INDENT 0.0 100 | .IP \(bu 2 101 | \fBmixer\fP(1) 102 | .UNINDENT 103 | .SH COPYRIGHT 104 | (C) 2018 Intel Corporation, CC-BY-SA-3.0 105 | .\" Generated by docutils manpage writer. 106 | . 107 | -------------------------------------------------------------------------------- /swupd/cmd/create-fullfiles/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Creates the fullfiles for a specific version given a state 4 | // directory. Used to test the logic in the library functions. 5 | 6 | import ( 7 | "flag" 8 | "fmt" 9 | "io/ioutil" 10 | "os" 11 | "path/filepath" 12 | "runtime/pprof" 13 | 14 | "github.com/clearlinux/mixer-tools/log" 15 | "github.com/clearlinux/mixer-tools/swupd" 16 | ) 17 | 18 | func usage() { 19 | log.Info(log.Mixer, `Usage: create-fullfiles [FLAGS] STATEDIR VERSION 20 | Flags: 21 | `) 22 | flag.PrintDefaults() 23 | os.Exit(2) 24 | } 25 | 26 | func main() { 27 | cpuProfile := flag.String("cpuprofile", "", "write CPU profile to a file") 28 | outputDir := flag.String("o", "", "output directory, creates temporary if not specified") 29 | logFile := flag.String("log", "", "write logs to a file") 30 | logLevel := flag.Int("log-level", 4, "set the log level between 1-5") 31 | flag.Usage = usage 32 | 33 | flag.Parse() 34 | if flag.NArg() != 2 { 35 | usage() 36 | } 37 | 38 | if *cpuProfile != "" { 39 | f, err := os.Create(*cpuProfile) 40 | if err != nil { 41 | log.Error(log.Mixer, "couldn't create file for CPU profile: %s", err) 42 | os.Exit(1) 43 | } 44 | _ = pprof.StartCPUProfile(f) 45 | defer pprof.StopCPUProfile() 46 | } 47 | 48 | if *logFile != "" { 49 | // Configure logger 50 | _, err := log.SetOutputFilename(*logFile) 51 | if err != nil { 52 | fmt.Printf("WARNING: couldn't create file for log: %s", err) 53 | } else { 54 | log.SetLogLevel(*logLevel) 55 | } 56 | defer log.CloseLogHandler() 57 | } 58 | 59 | stateDir := flag.Arg(0) 60 | version := flag.Arg(1) 61 | 62 | chrootDir := filepath.Join(stateDir, "image", version, "full") 63 | if _, err := os.Stat(chrootDir); err != nil { 64 | log.Error(log.Mixer, "couldn't access the full chroot: %s", err) 65 | os.Exit(1) 66 | } 67 | 68 | manifestFile := filepath.Join(stateDir, "www", version, "Manifest.full") 69 | if _, err := os.Stat(manifestFile); err != nil { 70 | log.Error(log.Mixer, "couldn't access the full manifest: %s", err) 71 | os.Exit(1) 72 | } 73 | 74 | m, err := swupd.ParseManifestFile(manifestFile) 75 | if err != nil { 76 | log.Error(log.Mixer, "couldn't read full manifest %s: %s", manifestFile, err) 77 | os.Exit(1) 78 | } 79 | 80 | if *outputDir == "" { 81 | tempDir, terr := ioutil.TempDir(".", "fullfiles-") 82 | if terr != nil { 83 | log.Error(log.Mixer, "couldn't create output directory: %s", terr) 84 | os.Exit(1) 85 | } 86 | *outputDir = tempDir 87 | } else { 88 | if _, err = os.Stat(*outputDir); err == nil { 89 | log.Error(log.Mixer, "output dir already exists, exiting to not overwrite files") 90 | os.Exit(1) 91 | } 92 | err = os.MkdirAll(*outputDir, 0755) 93 | if err != nil { 94 | log.Error(log.Mixer, "couldn't create output directory: %s", err) 95 | os.Exit(1) 96 | } 97 | } 98 | 99 | log.Info(log.Mixer, "Output directory: %s", *outputDir) 100 | _, err = swupd.CreateFullfiles(m, chrootDir, *outputDir, 0, []string{"external-xz"}) 101 | if err != nil { 102 | log.Error(log.Mixer, err.Error()) 103 | os.Exit(1) 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Cobra User Contract 2 | 3 | ### Versioning 4 | Cobra will follow a steady release cadence. Non breaking changes will be released as minor versions quarterly. Patch bug releases are at the discretion of the maintainers. Users can expect security patch fixes to be released within relatively short order of a CVE becoming known. For more information on security patch fixes see the CVE section below. Releases will follow [Semantic Versioning](https://semver.org/). Users tracking the Master branch should expect unpredictable breaking changes as the project continues to move forward. For stability, it is highly recommended to use a release. 5 | 6 | ### Backward Compatibility 7 | We will maintain two major releases in a moving window. The N-1 release will only receive bug fixes and security updates and will be dropped once N+1 is released. 8 | 9 | ### Deprecation 10 | Deprecation of Go versions or dependent packages will only occur in major releases. To reduce the change of this taking users by surprise, any large deprecation will be preceded by an announcement in the [#cobra slack channel](https://gophers.slack.com/archives/CD3LP1199) and an Issue on Github. 11 | 12 | ### CVE 13 | Maintainers will make every effort to release security patches in the case of a medium to high severity CVE directly impacting the library. The speed in which these patches reach a release is up to the discretion of the maintainers. A low severity CVE may be a lower priority than a high severity one. 14 | 15 | ### Communication 16 | Cobra maintainers will use GitHub issues and the [#cobra slack channel](https://gophers.slack.com/archives/CD3LP1199) as the primary means of communication with the community. This is to foster open communication with all users and contributors. 17 | 18 | ### Breaking Changes 19 | Breaking changes are generally allowed in the master branch, as this is the branch used to develop the next release of Cobra. 20 | 21 | There may be times, however, when master is closed for breaking changes. This is likely to happen as we near the release of a new version. 22 | 23 | Breaking changes are not allowed in release branches, as these represent minor versions that have already been released. These version have consumers who expect the APIs, behaviors, etc, to remain stable during the lifetime of the patch stream for the minor release. 24 | 25 | Examples of breaking changes include: 26 | - Removing or renaming exported constant, variable, type, or function. 27 | - Updating the version of critical libraries such as `spf13/pflag`, `spf13/viper` etc... 28 | - Some version updates may be acceptable for picking up bug fixes, but maintainers must exercise caution when reviewing. 29 | 30 | There may, at times, need to be exceptions where breaking changes are allowed in release branches. These are at the discretion of the project's maintainers, and must be carefully considered before merging. 31 | 32 | ### CI Testing 33 | Maintainers will ensure the Cobra test suite utilizes the current supported versions of Golang. 34 | 35 | ### Disclaimer 36 | Changes to this document and the contents therein are at the discretion of the maintainers. 37 | None of the contents of this document are legally binding in any way to the maintainers or the users. 38 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/string.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | // -- string Value 4 | type stringValue string 5 | 6 | func newStringValue(val string, p *string) *stringValue { 7 | *p = val 8 | return (*stringValue)(p) 9 | } 10 | 11 | func (s *stringValue) Set(val string) error { 12 | *s = stringValue(val) 13 | return nil 14 | } 15 | func (s *stringValue) Type() string { 16 | return "string" 17 | } 18 | 19 | func (s *stringValue) String() string { return string(*s) } 20 | 21 | func stringConv(sval string) (interface{}, error) { 22 | return sval, nil 23 | } 24 | 25 | // GetString return the string value of a flag with the given name 26 | func (f *FlagSet) GetString(name string) (string, error) { 27 | val, err := f.getFlagType(name, "string", stringConv) 28 | if err != nil { 29 | return "", err 30 | } 31 | return val.(string), nil 32 | } 33 | 34 | // StringVar defines a string flag with specified name, default value, and usage string. 35 | // The argument p points to a string variable in which to store the value of the flag. 36 | func (f *FlagSet) StringVar(p *string, name string, value string, usage string) { 37 | f.VarP(newStringValue(value, p), name, "", usage) 38 | } 39 | 40 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 41 | func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) { 42 | f.VarP(newStringValue(value, p), name, shorthand, usage) 43 | } 44 | 45 | // StringVar defines a string flag with specified name, default value, and usage string. 46 | // The argument p points to a string variable in which to store the value of the flag. 47 | func StringVar(p *string, name string, value string, usage string) { 48 | CommandLine.VarP(newStringValue(value, p), name, "", usage) 49 | } 50 | 51 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 52 | func StringVarP(p *string, name, shorthand string, value string, usage string) { 53 | CommandLine.VarP(newStringValue(value, p), name, shorthand, usage) 54 | } 55 | 56 | // String defines a string flag with specified name, default value, and usage string. 57 | // The return value is the address of a string variable that stores the value of the flag. 58 | func (f *FlagSet) String(name string, value string, usage string) *string { 59 | p := new(string) 60 | f.StringVarP(p, name, "", value, usage) 61 | return p 62 | } 63 | 64 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 65 | func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string { 66 | p := new(string) 67 | f.StringVarP(p, name, shorthand, value, usage) 68 | return p 69 | } 70 | 71 | // String defines a string flag with specified name, default value, and usage string. 72 | // The return value is the address of a string variable that stores the value of the flag. 73 | func String(name string, value string, usage string) *string { 74 | return CommandLine.StringP(name, "", value, usage) 75 | } 76 | 77 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 78 | func StringP(name, shorthand string, value string, usage string) *string { 79 | return CommandLine.StringP(name, shorthand, value, usage) 80 | } 81 | -------------------------------------------------------------------------------- /mixer/cmd/config.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "github.com/clearlinux/mixer-tools/config" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | // Top level config command ('mixer config') 23 | var configCmd = &cobra.Command{ 24 | Use: "config", 25 | Short: "Perform config related actions", 26 | } 27 | 28 | var configValidateCmd = &cobra.Command{ 29 | Use: "validate", 30 | Short: "Parse a config file and print its properties", 31 | Long: `Parse a builder config file and display its properties. Properties containing 32 | environment variables will be expanded`, 33 | Run: func(cmd *cobra.Command, args []string) { 34 | var mc config.MixConfig 35 | if err := mc.LoadConfig(configFile); err != nil { 36 | fail(err) 37 | } 38 | 39 | if err := mc.Print(); err != nil { 40 | fail(err) 41 | } 42 | 43 | }, 44 | } 45 | 46 | var configConvertCmd = &cobra.Command{ 47 | Use: "convert", 48 | Short: "Converts an old config file to the new TOML format", 49 | Long: `Convert an old config file to the new TOML format. The command will generate 50 | a backup file of the old config and will replace it with the converted one. Environment 51 | variables will not be expanded and the values will not be validated`, 52 | Run: func(cmd *cobra.Command, args []string) { 53 | var mc config.MixConfig 54 | if err := mc.Convert(configFile); err != nil { 55 | fail(err) 56 | } 57 | 58 | var ms config.MixState 59 | if err := ms.Load(mc); err != nil { 60 | fail(err) 61 | } 62 | 63 | }, 64 | } 65 | 66 | var configSetCmd = &cobra.Command{ 67 | Use: "set ", 68 | Short: "Set a property in the config file to a given value", 69 | Long: `This command will parse the provided property in the format 'Section.Property', 70 | assign the provided value and update the config file. The command will only validate 71 | the existence of the provided property, but will not validate the value provided.`, 72 | Args: cobra.ExactArgs(2), 73 | Run: func(cmd *cobra.Command, args []string) { 74 | var mc config.MixConfig 75 | if err := mc.LoadConfig(configFile); err != nil { 76 | fail(err) 77 | } 78 | 79 | if err := mc.SetProperty(args[0], args[1]); err != nil { 80 | fail(err) 81 | } 82 | 83 | }, 84 | } 85 | 86 | // List of all config commands 87 | var configCmds = []*cobra.Command{ 88 | configValidateCmd, 89 | configConvertCmd, 90 | configSetCmd, 91 | } 92 | 93 | func init() { 94 | for _, cmd := range configCmds { 95 | configCmd.AddCommand(cmd) 96 | } 97 | 98 | RootCmd.AddCommand(configCmd) 99 | } 100 | -------------------------------------------------------------------------------- /swupd/archive.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package swupd 16 | 17 | import ( 18 | "archive/tar" 19 | "bytes" 20 | "compress/bzip2" 21 | "compress/gzip" 22 | "fmt" 23 | "io" 24 | ) 25 | 26 | // CompressedTarReader is a tar.Reader that also wraps the uncompression Reader. 27 | type CompressedTarReader struct { 28 | *tar.Reader 29 | CompressionCloser io.Closer 30 | } 31 | 32 | // Close a CompressedTarReader. Unlike regular tar.Reader, the compression algorithm might need Close 33 | // to be called to dispose resources (like external process execution). 34 | func (ctr *CompressedTarReader) Close() error { 35 | if ctr.CompressionCloser != nil { 36 | return ctr.CompressionCloser.Close() 37 | } 38 | return nil 39 | } 40 | 41 | // Compression algorithms have "magic" bytes in the beginning of the file to identify them. 42 | var ( 43 | gzipMagic = []byte{0x1F, 0x8B} 44 | xzMagic = []byte{0xFD, '7', 'z', 'X', 'Z', 0x00} 45 | bzip2Magic = []byte{'B', 'Z', 'h'} 46 | // https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L385 47 | zstdMagic = []byte{0x28, 0xB5, 0x2F, 0xFD} 48 | ) 49 | 50 | // NewCompressedTarReader creates a struct compatible with tar.Reader reading from uncompressed or 51 | // compressed input. Compressed input type is guessed based on the magic on the input. 52 | func NewCompressedTarReader(rs io.ReadSeeker) (*CompressedTarReader, error) { 53 | var h [6]byte 54 | _, err := rs.Read(h[:]) 55 | if err != nil { 56 | return nil, err 57 | } 58 | _, err = rs.Seek(0, io.SeekStart) 59 | if err != nil { 60 | return nil, err 61 | } 62 | result := &CompressedTarReader{} 63 | switch { 64 | case bytes.HasPrefix(h[:], gzipMagic): 65 | gr, err := gzip.NewReader(rs) 66 | if err != nil { 67 | return nil, fmt.Errorf("couldn't decompress using gzip: %s", err) 68 | } 69 | result.CompressionCloser = gr 70 | result.Reader = tar.NewReader(gr) 71 | case bytes.HasPrefix(h[:], xzMagic): 72 | xr, err := NewExternalReader(rs, "unxz") 73 | if err != nil { 74 | return nil, fmt.Errorf("couldn't decompress using xz: %s", err) 75 | } 76 | result.CompressionCloser = xr 77 | result.Reader = tar.NewReader(xr) 78 | case bytes.HasPrefix(h[:], bzip2Magic): 79 | br := bzip2.NewReader(rs) 80 | result.Reader = tar.NewReader(br) 81 | case bytes.HasPrefix(h[:], zstdMagic): 82 | zr, err := NewExternalReader(rs, "zstd", "-d") 83 | if err != nil { 84 | return nil, fmt.Errorf("couldn't decompress using zstd: %s", err) 85 | } 86 | result.CompressionCloser = zr 87 | result.Reader = tar.NewReader(zr) 88 | default: 89 | // Assume uncompressed tar and let it complain if not valid. 90 | result.Reader = tar.NewReader(rs) 91 | } 92 | return result, nil 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/table_with_color.go: -------------------------------------------------------------------------------- 1 | package tablewriter 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | const ESC = "\033" 10 | const SEP = ";" 11 | 12 | const ( 13 | BgBlackColor int = iota + 40 14 | BgRedColor 15 | BgGreenColor 16 | BgYellowColor 17 | BgBlueColor 18 | BgMagentaColor 19 | BgCyanColor 20 | BgWhiteColor 21 | ) 22 | 23 | const ( 24 | FgBlackColor int = iota + 30 25 | FgRedColor 26 | FgGreenColor 27 | FgYellowColor 28 | FgBlueColor 29 | FgMagentaColor 30 | FgCyanColor 31 | FgWhiteColor 32 | ) 33 | 34 | const ( 35 | BgHiBlackColor int = iota + 100 36 | BgHiRedColor 37 | BgHiGreenColor 38 | BgHiYellowColor 39 | BgHiBlueColor 40 | BgHiMagentaColor 41 | BgHiCyanColor 42 | BgHiWhiteColor 43 | ) 44 | 45 | const ( 46 | FgHiBlackColor int = iota + 90 47 | FgHiRedColor 48 | FgHiGreenColor 49 | FgHiYellowColor 50 | FgHiBlueColor 51 | FgHiMagentaColor 52 | FgHiCyanColor 53 | FgHiWhiteColor 54 | ) 55 | 56 | const ( 57 | Normal = 0 58 | Bold = 1 59 | UnderlineSingle = 4 60 | Italic 61 | ) 62 | 63 | type Colors []int 64 | 65 | func startFormat(seq string) string { 66 | return fmt.Sprintf("%s[%sm", ESC, seq) 67 | } 68 | 69 | func stopFormat() string { 70 | return fmt.Sprintf("%s[%dm", ESC, Normal) 71 | } 72 | 73 | // Making the SGR (Select Graphic Rendition) sequence. 74 | func makeSequence(codes []int) string { 75 | codesInString := []string{} 76 | for _, code := range codes { 77 | codesInString = append(codesInString, strconv.Itoa(code)) 78 | } 79 | return strings.Join(codesInString, SEP) 80 | } 81 | 82 | // Adding ANSI escape sequences before and after string 83 | func format(s string, codes interface{}) string { 84 | var seq string 85 | 86 | switch v := codes.(type) { 87 | 88 | case string: 89 | seq = v 90 | case []int: 91 | seq = makeSequence(v) 92 | case Colors: 93 | seq = makeSequence(v) 94 | default: 95 | return s 96 | } 97 | 98 | if len(seq) == 0 { 99 | return s 100 | } 101 | return startFormat(seq) + s + stopFormat() 102 | } 103 | 104 | // Adding header colors (ANSI codes) 105 | func (t *Table) SetHeaderColor(colors ...Colors) { 106 | if t.colSize != len(colors) { 107 | panic("Number of header colors must be equal to number of headers.") 108 | } 109 | for i := 0; i < len(colors); i++ { 110 | t.headerParams = append(t.headerParams, makeSequence(colors[i])) 111 | } 112 | } 113 | 114 | // Adding column colors (ANSI codes) 115 | func (t *Table) SetColumnColor(colors ...Colors) { 116 | if t.colSize != len(colors) { 117 | panic("Number of column colors must be equal to number of headers.") 118 | } 119 | for i := 0; i < len(colors); i++ { 120 | t.columnsParams = append(t.columnsParams, makeSequence(colors[i])) 121 | } 122 | } 123 | 124 | // Adding column colors (ANSI codes) 125 | func (t *Table) SetFooterColor(colors ...Colors) { 126 | if len(t.footers) != len(colors) { 127 | panic("Number of footer colors must be equal to number of footer.") 128 | } 129 | for i := 0; i < len(colors); i++ { 130 | t.footerParams = append(t.footerParams, makeSequence(colors[i])) 131 | } 132 | } 133 | 134 | func Color(colors ...int) []int { 135 | return colors 136 | } 137 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int64.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "strconv" 4 | 5 | // -- int64 Value 6 | type int64Value int64 7 | 8 | func newInt64Value(val int64, p *int64) *int64Value { 9 | *p = val 10 | return (*int64Value)(p) 11 | } 12 | 13 | func (i *int64Value) Set(s string) error { 14 | v, err := strconv.ParseInt(s, 0, 64) 15 | *i = int64Value(v) 16 | return err 17 | } 18 | 19 | func (i *int64Value) Type() string { 20 | return "int64" 21 | } 22 | 23 | func (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) } 24 | 25 | func int64Conv(sval string) (interface{}, error) { 26 | return strconv.ParseInt(sval, 0, 64) 27 | } 28 | 29 | // GetInt64 return the int64 value of a flag with the given name 30 | func (f *FlagSet) GetInt64(name string) (int64, error) { 31 | val, err := f.getFlagType(name, "int64", int64Conv) 32 | if err != nil { 33 | return 0, err 34 | } 35 | return val.(int64), nil 36 | } 37 | 38 | // Int64Var defines an int64 flag with specified name, default value, and usage string. 39 | // The argument p points to an int64 variable in which to store the value of the flag. 40 | func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) { 41 | f.VarP(newInt64Value(value, p), name, "", usage) 42 | } 43 | 44 | // Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. 45 | func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) { 46 | f.VarP(newInt64Value(value, p), name, shorthand, usage) 47 | } 48 | 49 | // Int64Var defines an int64 flag with specified name, default value, and usage string. 50 | // The argument p points to an int64 variable in which to store the value of the flag. 51 | func Int64Var(p *int64, name string, value int64, usage string) { 52 | CommandLine.VarP(newInt64Value(value, p), name, "", usage) 53 | } 54 | 55 | // Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. 56 | func Int64VarP(p *int64, name, shorthand string, value int64, usage string) { 57 | CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage) 58 | } 59 | 60 | // Int64 defines an int64 flag with specified name, default value, and usage string. 61 | // The return value is the address of an int64 variable that stores the value of the flag. 62 | func (f *FlagSet) Int64(name string, value int64, usage string) *int64 { 63 | p := new(int64) 64 | f.Int64VarP(p, name, "", value, usage) 65 | return p 66 | } 67 | 68 | // Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. 69 | func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 { 70 | p := new(int64) 71 | f.Int64VarP(p, name, shorthand, value, usage) 72 | return p 73 | } 74 | 75 | // Int64 defines an int64 flag with specified name, default value, and usage string. 76 | // The return value is the address of an int64 variable that stores the value of the flag. 77 | func Int64(name string, value int64, usage string) *int64 { 78 | return CommandLine.Int64P(name, "", value, usage) 79 | } 80 | 81 | // Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. 82 | func Int64P(name, shorthand string, value int64, usage string) *int64 { 83 | return CommandLine.Int64P(name, shorthand, value, usage) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int8.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "strconv" 4 | 5 | // -- int8 Value 6 | type int8Value int8 7 | 8 | func newInt8Value(val int8, p *int8) *int8Value { 9 | *p = val 10 | return (*int8Value)(p) 11 | } 12 | 13 | func (i *int8Value) Set(s string) error { 14 | v, err := strconv.ParseInt(s, 0, 8) 15 | *i = int8Value(v) 16 | return err 17 | } 18 | 19 | func (i *int8Value) Type() string { 20 | return "int8" 21 | } 22 | 23 | func (i *int8Value) String() string { return strconv.FormatInt(int64(*i), 10) } 24 | 25 | func int8Conv(sval string) (interface{}, error) { 26 | v, err := strconv.ParseInt(sval, 0, 8) 27 | if err != nil { 28 | return 0, err 29 | } 30 | return int8(v), nil 31 | } 32 | 33 | // GetInt8 return the int8 value of a flag with the given name 34 | func (f *FlagSet) GetInt8(name string) (int8, error) { 35 | val, err := f.getFlagType(name, "int8", int8Conv) 36 | if err != nil { 37 | return 0, err 38 | } 39 | return val.(int8), nil 40 | } 41 | 42 | // Int8Var defines an int8 flag with specified name, default value, and usage string. 43 | // The argument p points to an int8 variable in which to store the value of the flag. 44 | func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) { 45 | f.VarP(newInt8Value(value, p), name, "", usage) 46 | } 47 | 48 | // Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. 49 | func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) { 50 | f.VarP(newInt8Value(value, p), name, shorthand, usage) 51 | } 52 | 53 | // Int8Var defines an int8 flag with specified name, default value, and usage string. 54 | // The argument p points to an int8 variable in which to store the value of the flag. 55 | func Int8Var(p *int8, name string, value int8, usage string) { 56 | CommandLine.VarP(newInt8Value(value, p), name, "", usage) 57 | } 58 | 59 | // Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. 60 | func Int8VarP(p *int8, name, shorthand string, value int8, usage string) { 61 | CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage) 62 | } 63 | 64 | // Int8 defines an int8 flag with specified name, default value, and usage string. 65 | // The return value is the address of an int8 variable that stores the value of the flag. 66 | func (f *FlagSet) Int8(name string, value int8, usage string) *int8 { 67 | p := new(int8) 68 | f.Int8VarP(p, name, "", value, usage) 69 | return p 70 | } 71 | 72 | // Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. 73 | func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 { 74 | p := new(int8) 75 | f.Int8VarP(p, name, shorthand, value, usage) 76 | return p 77 | } 78 | 79 | // Int8 defines an int8 flag with specified name, default value, and usage string. 80 | // The return value is the address of an int8 variable that stores the value of the flag. 81 | func Int8(name string, value int8, usage string) *int8 { 82 | return CommandLine.Int8P(name, "", value, usage) 83 | } 84 | 85 | // Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. 86 | func Int8P(name, shorthand string, value int8, usage string) *int8 { 87 | return CommandLine.Int8P(name, shorthand, value, usage) 88 | } 89 | --------------------------------------------------------------------------------