Running local search when searching

swupd-search is a script that searches locally for the best bundle that
matches a search-term.

This commit runs the swupd-search script when users use the "swupd search"
command instead of calling the previous search code.

The previous search functionality will still be available for now using
the "search-legacy" command.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
Castulo Martinez
2019-03-01 15:01:19 -08:00
committed by Otavio Pontes
parent 8798c4c154
commit 23dbbbafa8
6 changed files with 24 additions and 23 deletions
+2 -1
View File
@@ -43,7 +43,8 @@ static struct subcmd commands[] = {
{ "update", "Update to latest OS version", update_main },
{ "verify", "Verify content for OS version", verify_main },
{ "check-update", "Check if a new OS version is available", check_update_main },
{ "search", "Search Clear Linux for a binary or library", search_main },
{ "search", "Searches for the best bundle to install a binary or library.", binary_loader_main },
{ "search-legacy", "Legacy command to search Clear Linux for a binary or library", search_main },
{ "info", "Show the version and the update URLs", info_main },
{ "clean", "Clean cached files", clean_main },
{ "mirror", "Configure mirror url for swupd content", mirror_main },
@@ -69,7 +69,7 @@ global_teardown() {
@test "SRH012: Search for bundles over HTTPS with a valid client certificate" {
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-file"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-file"
assert_status_is 0
}
@@ -79,7 +79,7 @@ global_teardown() {
# remove client certificate
sudo rm "$CLIENT_CERT"
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-file --debug"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-file --debug"
assert_status_is "$SWUPD_CURL_INIT_FAILED"
expected_output=$(cat <<-EOM
@@ -94,7 +94,7 @@ global_teardown() {
# make client certificate invalid
sudo sh -c "echo foo > $CLIENT_CERT"
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-file --debug"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-file --debug"
assert_status_is "$SWUPD_CURL_INIT_FAILED"
expected_output=$(cat <<-EOM
@@ -35,7 +35,7 @@ global_teardown() {
# manifests, so we need to account for those messages in
# this first test
run sudo sh -c "$SWUPD search $SWUPD_OPTS fake-file"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS fake-file"
assert_status_is "$SWUPD_NO"
expected_output=$(cat <<-EOM
@@ -52,7 +52,7 @@ global_teardown() {
@test "SRH010: Try searching for a file that does not exist using the full path" {
run sudo sh -c "$SWUPD search $SWUPD_OPTS /usr/lib64/test-lib100"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS /usr/lib64/test-lib100"
assert_status_is "$SWUPD_NO"
expected_output=$(cat <<-EOM
@@ -66,7 +66,7 @@ global_teardown() {
@test "SRH011: Try searching for a library that does not exist" {
run sudo sh -c "$SWUPD search $SWUPD_OPTS -l libtest-nohit"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS -l libtest-nohit"
assert_status_is "$SWUPD_NO"
expected_output=$(cat <<-EOM
@@ -36,7 +36,7 @@ global_teardown() {
# really search for anything but the MoM and all manifests
# in it should be downloaded to the local system
run sudo sh -c "$SWUPD search $SWUPD_OPTS --init"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS --init"
assert_status_is "$SWUPD_OK"
expected_output=$(cat <<-EOM
@@ -55,7 +55,7 @@ global_teardown() {
# it should find the bundle since the tracking file has the
# same name as the bundle
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-bundle1"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-bundle1"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -70,7 +70,7 @@ global_teardown() {
@test "SRH002: Search for a file" {
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-file2"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-file2"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -85,7 +85,7 @@ global_teardown() {
@test "SRH003: Search for a file that is in multiple bundles" {
run sudo sh -c "$SWUPD search $SWUPD_OPTS common"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS common"
assert_status_is 0
# search finds the files in different order, sometimes, test-bundle1
@@ -108,7 +108,7 @@ global_teardown() {
@test "SRH004: Search for a file that is in multiple bundles in different locations" {
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-file3"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-file3"
assert_status_is 0
# search finds the files in different order, sometimes, test-bundle1
@@ -134,7 +134,7 @@ global_teardown() {
# test-file3 is in two bundles but in different path, since we
# are specifying a path, search should only find one
run sudo sh -c "$SWUPD search $SWUPD_OPTS /bar/test-file3"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS /bar/test-file3"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -149,7 +149,7 @@ global_teardown() {
@test "SRH006: Search for a binary" {
run sudo sh -c "$SWUPD search --binary $SWUPD_OPTS test-bin"
run sudo sh -c "$SWUPD search-legacy --binary $SWUPD_OPTS test-bin"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -164,7 +164,7 @@ global_teardown() {
@test "SRH007: Search for a library (lib32)" {
run sudo sh -c "$SWUPD search --library $SWUPD_OPTS test-lib32"
run sudo sh -c "$SWUPD search-legacy --library $SWUPD_OPTS test-lib32"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -179,7 +179,7 @@ global_teardown() {
@test "SRH008: Search for a library (lib 64)" {
run sudo sh -c "$SWUPD search --library $SWUPD_OPTS test-lib64"
run sudo sh -c "$SWUPD search-legacy --library $SWUPD_OPTS test-lib64"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -41,7 +41,7 @@ global_teardown() {
# for those messages. If the bundle is experimental it should
# swhow that
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-bundle1"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-bundle1"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -63,7 +63,7 @@ global_teardown() {
# same name as the bundle. If the bundle is experimental it
# should swhow that
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-bundle2"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-bundle2"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -80,7 +80,7 @@ global_teardown() {
# If the bundle is experimental it should swhow that
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-file1"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-file1"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -97,7 +97,7 @@ global_teardown() {
# If the bundle is experimental it should swhow that
run sudo sh -c "$SWUPD search --binary $SWUPD_OPTS test-bin"
run sudo sh -c "$SWUPD search-legacy --binary $SWUPD_OPTS test-bin"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -114,7 +114,7 @@ global_teardown() {
# If the bundle is experimental it should swhow that
run sudo sh -c "$SWUPD search --library $SWUPD_OPTS test-lib32"
run sudo sh -c "$SWUPD search-legacy --library $SWUPD_OPTS test-lib32"
assert_status_is 0
expected_output=$(cat <<-EOM
@@ -28,7 +28,7 @@ test_setup() {
# fill up all the space in the disk
sudo dd if=/dev/zero of="$TEST_NAME"/testfs/dummy >& /dev/null || print "Using all space left in disk"
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-bundle2"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-bundle2"
assert_status_is "$SWUPD_COULDNT_LOAD_MOM"
expected_output=$(cat <<-EOM
@@ -57,7 +57,7 @@ test_setup() {
sudo mv "$big_manifest" "$WEBDIR"/10/Manifest.test-bundle1
sudo mv "$big_manifest".tar "$WEBDIR"/10/Manifest.test-bundle1.tar
run sudo sh -c "$SWUPD search $SWUPD_OPTS test-bundle2"
run sudo sh -c "$SWUPD search-legacy $SWUPD_OPTS test-bundle2"
assert_status_is "$SWUPD_RECURSE_MANIFEST"
expected_output=$(cat <<-EOM