enhancement: expose srpmproc library

This commit is contained in:
Mustafa Gezen 2021-08-19 12:09:53 +02:00
parent f71605a7d5
commit 7d84156a4b
Signed by: mustafa
GPG Key ID: DCDF010D946438C1
23 changed files with 31 additions and 32 deletions

5
.gitignore vendored
View File

@ -14,7 +14,6 @@
# Dependency directories (remove the comment below to include it) # Dependency directories (remove the comment below to include it)
# vendor/ # vendor/
testdata testdata
srpmproc /srpmproc
.idea .idea
dist/ /dist/
dist/

View File

@ -23,7 +23,7 @@ package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/rocky-linux/srpmproc/internal/data" "github.com/rocky-linux/srpmproc/pkg/data"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"io/ioutil" "io/ioutil"
"log" "log"

View File

@ -22,6 +22,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/rocky-linux/srpmproc/pkg/srpmproc"
"log" "log"
"os" "os"
"os/user" "os/user"
@ -32,13 +33,12 @@ import (
"github.com/go-git/go-billy/v5/memfs" "github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/osfs" "github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/plumbing/transport/ssh" "github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rocky-linux/srpmproc/internal/blob" "github.com/rocky-linux/srpmproc/pkg/blob"
"github.com/rocky-linux/srpmproc/internal/blob/file" "github.com/rocky-linux/srpmproc/pkg/blob/file"
"github.com/rocky-linux/srpmproc/internal/blob/gcs" "github.com/rocky-linux/srpmproc/pkg/blob/gcs"
"github.com/rocky-linux/srpmproc/internal/blob/s3" "github.com/rocky-linux/srpmproc/pkg/blob/s3"
"github.com/rocky-linux/srpmproc/internal/data" "github.com/rocky-linux/srpmproc/pkg/data"
"github.com/rocky-linux/srpmproc/internal"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -96,14 +96,14 @@ func mn(_ *cobra.Command, _ []string) {
sourceRpmLocation := "" sourceRpmLocation := ""
if strings.HasPrefix(sourceRpm, "file://") { if strings.HasPrefix(sourceRpm, "file://") {
sourceRpmLocation = strings.TrimPrefix(sourceRpm, "file://") sourceRpmLocation = strings.TrimPrefix(sourceRpm, "file://")
importer = &internal.SrpmMode{} importer = &srpmproc.SrpmMode{}
} else { } else {
if moduleMode { if moduleMode {
sourceRpmLocation = fmt.Sprintf("%s/%s", modulePrefix, sourceRpm) sourceRpmLocation = fmt.Sprintf("%s/%s", modulePrefix, sourceRpm)
} else { } else {
sourceRpmLocation = fmt.Sprintf("%s/%s", rpmPrefix, sourceRpm) sourceRpmLocation = fmt.Sprintf("%s/%s", rpmPrefix, sourceRpm)
} }
importer = &internal.GitMode{} importer = &srpmproc.GitMode{}
} }
lastKeyLocation := sshKeyLocation lastKeyLocation := sshKeyLocation
@ -145,7 +145,7 @@ func mn(_ *cobra.Command, _ []string) {
manualCs = strings.Split(manualCommits, ",") manualCs = strings.Split(manualCommits, ",")
} }
internal.ProcessRPM(&data.ProcessData{ srpmproc.ProcessRPM(&data.ProcessData{
Importer: importer, Importer: importer,
RpmLocation: sourceRpmLocation, RpmLocation: sourceRpmLocation,
UpstreamPrefix: upstreamPrefix, UpstreamPrefix: upstreamPrefix,

View File

@ -23,7 +23,7 @@ package data
import ( import (
"github.com/go-git/go-billy/v5" "github.com/go-git/go-billy/v5"
"github.com/go-git/go-git/v5/plumbing/transport/ssh" "github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rocky-linux/srpmproc/internal/blob" "github.com/rocky-linux/srpmproc/pkg/blob"
) )
type ProcessData struct { type ProcessData struct {

View File

@ -28,8 +28,8 @@ import (
"path/filepath" "path/filepath"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
// returns right if not empty, else left // returns right if not empty, else left

View File

@ -25,8 +25,8 @@ import (
"fmt" "fmt"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
func del(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, _ *git.Worktree, pushTree *git.Worktree) error { func del(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, _ *git.Worktree, pushTree *git.Worktree) error {

View File

@ -28,8 +28,8 @@ import (
"strings" "strings"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
func checkAddPrefix(file string) string { func checkAddPrefix(file string) string {

View File

@ -33,8 +33,8 @@ import (
"time" "time"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error { func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {

View File

@ -28,8 +28,8 @@ import (
"github.com/bluekeyes/go-gitdiff/gitdiff" "github.com/bluekeyes/go-gitdiff/gitdiff"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error { func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {

View File

@ -27,8 +27,8 @@ import (
"os" "os"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error { func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {

View File

@ -33,8 +33,8 @@ import (
"time" "time"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
) )
const ( const (

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
package internal package srpmproc
import ( import (
"fmt" "fmt"
@ -36,7 +36,7 @@ import (
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data" "github.com/rocky-linux/srpmproc/pkg/data"
) )
type remoteTarget struct { type remoteTarget struct {

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
package internal package srpmproc
import ( import (
"github.com/cavaliercoder/go-rpm" "github.com/cavaliercoder/go-rpm"

View File

@ -18,4 +18,4 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
package internal package srpmproc

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
package internal package srpmproc
import ( import (
"fmt" "fmt"
@ -33,10 +33,10 @@ import (
"github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/internal/directives"
"github.com/rocky-linux/srpmproc/modulemd" "github.com/rocky-linux/srpmproc/modulemd"
srpmprocpb "github.com/rocky-linux/srpmproc/pb" srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
"github.com/rocky-linux/srpmproc/pkg/directives"
"google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/encoding/prototext"
) )

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
package internal package srpmproc
import ( import (
"encoding/hex" "encoding/hex"
@ -38,7 +38,7 @@ import (
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data" "github.com/rocky-linux/srpmproc/pkg/data"
) )
var tagImportRegex *regexp.Regexp var tagImportRegex *regexp.Regexp

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
package internal package srpmproc
import ( import (
"bytes" "bytes"
@ -37,7 +37,7 @@ import (
"github.com/go-git/go-billy/v5/memfs" "github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data" "github.com/rocky-linux/srpmproc/pkg/data"
) )
type SrpmMode struct{} type SrpmMode struct{}